ruoxi_sun 4f274c2c32 add fingerprint model library & fp_fusion integration
- fingerprint benchmark: add fp_fusion(26-cell fusion) to collect_results/run.py
- run_llmmap.py: default model path to evalstone built-in model_library
- add model libraries (llmdetector 11 refs / fp_fusion 8 fusion refs /
  llmmap templates 60 models incl 8 new: GLM-5.2/5.3, DeepSeek-Flash/Pro/
  Flash-0731, Kimi-K3, MiniMax-M2.7, TianGong-Taie)
- add fp_fusion engine (battery/engine/scorer) + docs
- gitignore: exclude binary model weights and temp backups
2026-09-03 02:38:35 +00:00

62 lines
3.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 指纹 / 模型安全类 Benchmarkllmmap · llm_verify · llm_fingerprint_detector
本目录包含三个**非 EvalScope 数据集管线**的特殊 benchmark。它们把被测端点当作
"未知模型"做身份识别与欺诈检测,并产出与 EvalScope 同构的报告
`output/<folder>/<bench>/seed_<seed>/reports/<bench>.json`,含 `score` 字段),
因此 `bash/collect_results.py` 可以像普通 benchmark 一样把它们汇总进 Excel/CSV。
| benchmark | 工具 | 做什么 | 得分含义0~1 |
|---|---|---|---|
| `llmmap` | [LLMmap](/data1/xii/LLMmap) | 发送 8 条指纹查询 → open-set 与 52 个已知模板比距离 | 有 `--expected-model` 时 = Top-1 身份匹配 flag否则 = 距离置信度 |
| `llm_verify` | [llm-verify](/data1/xii/llm-verify) | 32 条取证探测identity/capability/fingerprint→ 红旗+裁决 | NO_FRAUD_SIGNALS=1.0 / INCONCLUSIVE=0.5 / SUSPICIOUS=0.25 / FRAUD_DETECTED=0.0 |
| `llm_fingerprint_detector` | [llm-fingerprint-detector](/data1/xii/llm-fingerprint-detector) | 单 token 输出分布采样 → JSD 距离 | `max(0, 1-meanJSD)`;无参考时跑自一致模式(采两次互比) |
## 运行
```bash
# 整个指纹套件
python bash/run.py --suite fingerprint \
--model <served-model-name> --api-url http://localhost:30000/v1
# 只跑其中一个
python bash/run.py --datasets llm_verify --model ... --api-url ...
# detector 提供同协议参考指纹(硬比较),缺省为自一致模式
python bash/run.py --datasets llm_fingerprint_detector \
--detector-reference /path/to/reference.json [--detector-preset strict]
# 已知真实身份时llmmap 输出严格匹配得分1.0/0.0
python bash/run.py --datasets llmmap --expected-model GLM-5.2 ...
```
## 依赖与环境(重要)
三个工具仓库默认位于 `/data1/xii`(可用 `--tools-root` 覆盖),
各执行器需要不同的解释器,均可用 CLI 或环境变量覆盖:
| 执行器 | 默认解释器 | 环境变量 | 要求 |
|---|---|---|---|
| run_llmmap.py | `/root/miniconda3/envs/llmmap/bin/python` | `LLMMAP_PYTHON` | torch + transformers + 本地缓存的 e5 嵌入模型 |
| run_llm_verify.py | `/root/miniconda3/envs/llmverify/bin/python` | `LLMVERIFY_PYTHON` | fastapi + httpx + pydantic |
| run_llm_detector.py | `sys.executable`(任意) | `DETECTOR_NODE` | Node ≥18.17 且仓库已 `npm run build` |
> 在 evalstone 的 Docker 容器内运行时,若容器里没有这些解释器/仓库,
> 要么把 `/data1/xii` 与 conda 环境挂载进容器,要么在宿主机上运行指纹套件。
## 实现注意(踩过的坑)
- 对被测端点默认注入 `chat_template_kwargs.thinking=false` 关闭思考链
(可用 `--thinking` 关闭该行为);思考模型会烧 max_tokens 并扭曲指纹。
- LLM Verify 的适配器在 api_key 为空时会因 httpx 拒绝空 Bearer 头而全失败,
runner 已自动填占位 key。
- LLMmap 在超过一半查询失败时直接判 0 分报错,避免用空回答算出假距离。
## 结果示例Qwen3-4B @ CPU :30002
```
分类 Benchmark 得分 实测时间(h) 总样本数
模型安全与指纹 llmmap 0.7115 0.0836 8 ← Top-1=Qwen/Qwen2.5-3B-Instruct
模型安全与指纹 llm_verify 0.25 0.0601 32 ← SUSPICIOUS(仅延迟红旗)
模型安全与指纹 llm_fingerprint_detector 0.9239 0.0671 4 ← 自一致 match, meanJSD=0.076
```