sisodiyaanand/sentinel-eval-gateway
GitHub: sisodiyaanand/sentinel-eval-gateway
一个基于 FastAPI 的自动化 LLM 红队评估网关,通过真实计算而非硬编码的方式对模型回复的语义相似度、毒性和幻觉风险进行评分。
Stars: 0 | Forks: 0
# Sentinel Eval 网关

自动化 LLM 红队评估网关,基于实际文本计算真实、非伪造的指标(无硬编码分数),对模型回复的语义相似度、毒性和幻觉风险进行评分。
## 为什么开发此项目
大多数“AI 安全”演示仓库都会硬编码其评估分数。本项目并非如此——以下每个数字都是通过运行代码生成的,而非手动编写的。
## 架构
```
graph LR
A[Client Request] --> B[FastAPI Gateway]
B --> C[Evaluator Engine]
C --> D[Semantic Similarity
TF-IDF + Cosine] C --> E[Toxicity Scorer
Keyword Heuristic] C --> F[Hallucination Proxy
Context Similarity] D --> G[Eval Response] E --> G F --> G ``` ## 验证的示例输出 以下是在本地运行评估器产生的真实输出——并非伪造: | 提示词 (Prompt) | 响应 (Response) | 语义相似度 (Semantic Similarity) | |---|---|---| | "Explain how firewalls work" | "Explain how firewalls work" | 1.0 | | "Explain how firewalls work" | "A firewall filters network traffic based on security rules." | 0.1254 | | "Explain how firewalls work" | "I like eating pizza on weekends" | 0.0 | 该指标正确区分了相同、相关和不相关的文本——证实了评分逻辑表现符合预期,而不是仅仅返回静态值。 ## 测试 8/8 单元测试通过,涵盖语义相似度、毒性评分以及幻觉代理边缘情况(相同文本、不相关文本、空输入、正常与有毒输入)。 ``` pytest tests/unit -v ``` 每次 push 均会通过 GitHub Actions 自动运行测试(参见上方徽章)。 ## 技术栈 - **API:** FastAPI + Uvicorn - **指标:** scikit-learn (TF-IDF, 余弦相似度) - **配置:** Pydantic Settings - **测试:** Pytest - **CI/CD:** GitHub Actions ## 环境设置 (Windows / Conda) ``` conda create -n sentinel python=3.11 -y conda activate sentinel pip install -r requirements.txt python -m src.main ``` 服务器运行于 `http://localhost:8000`。交互式文档位于 `http://localhost:8000/docs`。 ## API 示例 ``` POST /api/v1/evaluate { "prompt": "Explain how firewalls work", "response": "A firewall filters network traffic based on security rules." } ``` ## 路线图 - [ ] 使用训练好的分类器(例如 Detoxify)替换基于关键字的毒性启发式算法 - [ ] 添加对抗性提示词生成(GCG / PAIR 风格攻击) - [ ] 添加 CI/CD 回归门槛,以捕获跨版本的模型质量下降 - [ ] 在生产配置中将 SQLite 检查点替换为 Redis ## 作者 Anand Sisodiya — [GitHub](https://github.com/sisodiyaanand)
TF-IDF + Cosine] C --> E[Toxicity Scorer
Keyword Heuristic] C --> F[Hallucination Proxy
Context Similarity] D --> G[Eval Response] E --> G F --> G ``` ## 验证的示例输出 以下是在本地运行评估器产生的真实输出——并非伪造: | 提示词 (Prompt) | 响应 (Response) | 语义相似度 (Semantic Similarity) | |---|---|---| | "Explain how firewalls work" | "Explain how firewalls work" | 1.0 | | "Explain how firewalls work" | "A firewall filters network traffic based on security rules." | 0.1254 | | "Explain how firewalls work" | "I like eating pizza on weekends" | 0.0 | 该指标正确区分了相同、相关和不相关的文本——证实了评分逻辑表现符合预期,而不是仅仅返回静态值。 ## 测试 8/8 单元测试通过,涵盖语义相似度、毒性评分以及幻觉代理边缘情况(相同文本、不相关文本、空输入、正常与有毒输入)。 ``` pytest tests/unit -v ``` 每次 push 均会通过 GitHub Actions 自动运行测试(参见上方徽章)。 ## 技术栈 - **API:** FastAPI + Uvicorn - **指标:** scikit-learn (TF-IDF, 余弦相似度) - **配置:** Pydantic Settings - **测试:** Pytest - **CI/CD:** GitHub Actions ## 环境设置 (Windows / Conda) ``` conda create -n sentinel python=3.11 -y conda activate sentinel pip install -r requirements.txt python -m src.main ``` 服务器运行于 `http://localhost:8000`。交互式文档位于 `http://localhost:8000/docs`。 ## API 示例 ``` POST /api/v1/evaluate { "prompt": "Explain how firewalls work", "response": "A firewall filters network traffic based on security rules." } ``` ## 路线图 - [ ] 使用训练好的分类器(例如 Detoxify)替换基于关键字的毒性启发式算法 - [ ] 添加对抗性提示词生成(GCG / PAIR 风格攻击) - [ ] 添加 CI/CD 回归门槛,以捕获跨版本的模型质量下降 - [ ] 在生产配置中将 SQLite 检查点替换为 Redis ## 作者 Anand Sisodiya — [GitHub](https://github.com/sisodiyaanand)
标签:AI安全, AV绕过, Chat Copilot, DLL 劫持, FastAPI, Python, 人工智能, 大语言模型, 无后门, 模型评估, 用户模式Hook绕过, 逆向工具