Punkrose/Prism
GitHub: Punkrose/Prism
PRISM 是一个零依赖的 LLM 分析平台,提供 prompt 逆向工程、模型指纹识别和标准化基准测试三大核心能力。
Stars: 0 | Forks: 0
# 🔷 PRISM




**AI 驱动的 prompt 逆向工程、模型指纹识别和 LLM 基准测试平台。**
PRISM 通过分析 LLM 输出,推断生成这些输出的 prompt,识别生成响应的模型,并在标准化任务上对 LLM 性能进行基准测试——所有这些都无需任何外部依赖。
## ✨ 功能
### 🔍 Prompt 逆向工程
- 检测 prompt 类型(创意、分析、代码、对话、指令遵循、事实)
- 提取格式限制(代码块、列表、标题、JSON 等)
- 识别拒绝模式和置信度水平
- 分析响应结构(段落、句子长度、代码存在情况)
- 计算复杂度得分
### 🪪 模型指纹识别
- 识别生成特定输出的 LLM
- 与内置模型特征库匹配(GPT-4o、Claude 3.5、Gemini Pro、Llama 3、DeepSeek、Mistral)
- 分析风格标记:正式度、模糊限制语、代码质量、重复率
- 根据置信度得分对候选模型进行排名
### 📊 LLM 基准测试
- 运行标准化任务(摘要、代码、推理、创意、事实)
- 基于启发式方法针对每个任务的多个标准进行评分
- 多模型比较并生成排行榜
- 格式化的基准测试报告
## 📦 安装
```
git clone https://github.com/Punkrose/Prism.git
cd Prism
npm install # No dependencies to install — just sets up the project
```
## 🚀 快速开始
### CLI 用法
```
# 从响应逆向工程 prompt
node bin/prism.js reverse "Here is a function that reverses a string..."
# 指纹识别输出是由哪个 model 生成的
node bin/prism.js fingerprint "Certainly! I'd be happy to help. Here's a detailed explanation..."
# 使用模拟的 provider 运行 benchmarks
node bin/prism.js bench --tasks 5
# 显示项目信息
node bin/prism.js info
# 从文件运行
node bin/prism.js reverse ./response.txt
```
### API 用法
```
const { PromptReverseEngineer, ModelFingerprinter, LLMBenchmark } = require('./src');
// ── Prompt Reverse Engineering ──
const engineer = new PromptReverseEngineer({ detail: 'full' });
const analysis = engineer.analyze('Your LLM response text here...');
console.log(analysis.promptType); // 'code'
console.log(analysis.complexity); // { score: 65, level: 'moderate' }
console.log(analysis.constraints); // ['code-blocks', 'bullet-lists']
console.log(analysis.inference); // Human-readable summary
// ── Model Fingerprinting ──
const fingerprinter = new ModelFingerprinter();
const result = fingerprinter.fingerprint('Certainly! Here\'s a helpful response...');
console.log(result.detected); // 'claude-3.5'
console.log(result.confidence); // 0.72
console.log(result.ranked); // [{ id, score, markers, styleMatch }, ...]
// ── Benchmarking ──
const benchmark = new LLMBenchmark();
const results = await benchmark.run(async (prompt) => {
// Call your LLM API here
return await myLLM.generate(prompt);
});
console.log(benchmark.report(results));
```
## 🔧 工作原理
### Prompt 逆向工程
`PromptReverseEngineer` 分析文本响应以推断可能的 prompt 结构:
1. **Tokenization** — 将响应拆分为带类型的 token(单词、数字、标点符号、代码)
2. **模式检测** — 识别结构标记(代码块、列表、标题、JSON)
3. **分类** — 使用加权信号评分将 prompt 分类到 6 个类别中
4. **拒绝检测** — 匹配 20 多种已知的拒绝模式并进行置信度评分
5. **复杂度评分** — 结合长度、词汇多样性、结构复杂度和句子长度
### 模型指纹识别
`ModelFingerprinter` 识别可能的源模型:
1. **标记提取** — 搜索已知的特定模型短语和模式
2. **风格分析** — 计算指标:平均句子长度、正式度 (0-1)、模糊限制语 (0-1)、代码质量 (0-1)、重复率 (0-1)
3. **特征匹配** — 将提取的标记和风格指标与内置模型特征库进行比较
4. **排名** — 根据标记匹配和风格相似度按 50/50 的权重组合对每个模型进行评分
### LLM 基准测试
`LLMBenchmark` 评估 LLM 的性能:
1. **任务执行** — 通过 provider 函数运行标准化 prompt
2. **启发式评分** — 使用模式匹配和结构分析,根据特定于任务的标准对每个响应进行评分
3. **比较** — 生成跨多个模型的排名排行榜
4. **报告** — 生成包含得分、延迟和排名的易于阅读的基准测试报告
## 🪪 默认模型特征库
| 模型 | ID | 关键标记 | 正式度 | 模糊限制语 |
|-------|-----|-------------|-----------|---------|
| GPT-4o | `gpt-4o` | "As an AI", "cutoff" | 0.70 | 0.30 |
| Claude 3.5 | `claude-3.5` | "Certainly", "I'd be happy" | 0.80 | 0.40 |
| Gemini Pro | `gemini-pro` | "Great question", "Here are" | 0.60 | 0.50 |
| Llama 3 | `llama-3` | "As a language model" | 0.50 | 0.20 |
| DeepSeek | `deepseek` | "Let me think", "First, Second, Third," | 0.60 | 0.35 |
| Mistral | `mistral` | "In summary", "The answer is" | 0.55 | 0.25 |
## 📋 默认基准测试任务
| 任务 | Prompt | 标准 |
|------|--------|----------|
| 摘要 | 总结一段回文段落 | 简洁性、准确性 |
| 代码 | 在不使用 `.reverse()` 的情况下反转字符串 | 正确性、效率、可读性 |
| 推理 | 关于玫瑰和花的逻辑谜题 | 逻辑性、清晰度 |
| 创意 | 写一首关于 AI 的俳句 | 创造力、结构 |
| 事实 | 热力学三大定律 | 准确性、完整性 |
## 🧪 测试
```
# 运行所有测试
npm test
# 运行 demo
npm run demo
```
## 📁 项目结构
```
prism/
├── bin/
│ └── prism.js # CLI entry point
├── src/
│ ├── index.js # Main exports
│ ├── utils.js # Shared utilities
│ ├── reverse.js # Prompt reverse engineering
│ ├── fingerprint.js # Model fingerprinting
│ └── benchmark.js # LLM benchmarking
├── test/
│ ├── reverse.test.js # Reverse engineering tests
│ ├── fingerprint.test.js # Fingerprinting tests
│ └── benchmark.test.js # Benchmarking tests
├── examples/
│ └── demo.js # Full demo script
├── package.json
├── LICENSE
└── README.md
```
## 📜 许可证
MIT 许可证 — 版权所有 (c) 2026 Punkrose
详情请参阅 [LICENSE](./LICENSE)。
标签:DLL 劫持, GNU通用公共许可证, LLM基准测试, MITM代理, Node.js, 人工智能, 大语言模型, 提示词逆向, 文档结构分析, 模型指纹识别, 用户模式Hook绕过, 自定义脚本