abchahal/llm-evaluation-promptfoo-suite
GitHub: abchahal/llm-evaluation-promptfoo-suite
一个基于Promptfoo和TypeScript的自动化LLM安全评估框架,专注于测试模型在安全性和质量方面的鲁棒性。
Stars: 1 | Forks: 1
# 基于 Promptfoo 的 LLM 评估测试套件
## 项目概述
本项目是一个基于 Promptfoo 和 TypeScript 构建的自动化 **LLM 评估与安全测试框架**。它用于验证 LLM 在以下方面的表现:
- 功能正确性
- 安全鲁棒性(覆盖 OWASP LLM Top 10)
- 提示注入攻击防护
- 毒性内容处理
- 自定义风险评分逻辑
该框架专为**使用 LLM 系统的 QA 工程师和 SDETs 设计**,旨在确保 AI 响应安全、可靠且可用于生产环境。
## 测试模型
- Gemini 1.5 Flash(通过 Google AI Studio)
- Ollama LLaMA3(本地测试支持)
## 技术栈
- Promptfoo(LLM 评估框架)
- TypeScript(自定义断言 & 风险引擎)
- Node.js
- 基于正则表达式的验证
- 基于 YAML 的测试配置
## 测试覆盖范围详述
| 类别 | 描述 |
|------------|-------------------------------------------|
| 功能测试 | 有效的 AcmeCorp 产品/服务查询 |
| 安全测试 | 提示注入、越狱尝试、角色混淆 |
| 数据泄露测试 | API 密钥、密码、敏感数据暴露 |
| 毒性处理 | 攻击性或侮辱性输入的处理 |
| 偏离主题处理 | 非领域查询(笑话、不相关话题) |
| 自定义断言 | 风险评分引擎(0-100 严重性模型) |
## 项目结构
```
promptfooPractice/
│
├── security-test.yaml # Main test suite
├── customAssertion/
│ └── riskScorer.ts # Custom risk scoring engine
├── results/ # Evaluation outputs (optional)
└── README.md
---
## 关键特性
- OWASP LLM Top 10 inspired security coverage
- Risk scoring system (0–100 severity model)
- Custom TypeScript assertion engine
- Prompt injection & jailbreak detection
- Structured evaluation reports via Promptfoo
- CLI-based execution for CI/CD integration
---
## 关键发现
- The model generally handles off-topic queries well
- Moderate resistance to basic prompt injection
- Weakness observed in:
- Indirect prompt injection cases
- Obfuscated input patterns
- Some responses may still attempt partial role confusion handling
---
## 🚀 如何运行这个项目
### 1. 安装依赖项
```bash
npm install
2. Install Promptfoo (if not already installed)
npm install -g promptfoo
3. Run the evaluation tests
promptfoo eval -c security-test.yaml
4. View results in browser UI
promptfoo view
5. Export evaluation results (optional)
promptfoo eval -c security-test.yaml --output results.json
6. Run with verbose logs (debug mode)
promptfoo eval -c security-test.yaml --verbose
```
标签:AI安全, Chat Copilot, GNU通用公共许可证, LLM评估, MITM代理, Node.js, Ollama, OWASP LLM Top 10, Promptfoo, TypeScript, YAML配置, 人工智能测试, 大型语言模型, 安全扫描, 安全插件, 安全测试, 密钥泄露防护, 攻击性安全, 数据泄露测试, 时序注入, 机器学习安全, 毒性检查, 测试框架, 结构化输出验证, 自动化攻击, 自定义断言, 质量保证, 越狱检测, 零日漏洞检测, 风险模型, 风险评分