← 返回列表
未验证
模糊匹配源文档,揪出 RAG 答案里的虚假引用
尚未跑自动兼容性验证,可查看页面内的依赖与入口分析。 · 最近上游提交 2026/8/22 · 已提供中文文档
A lightweight CLI tool to validate citations in RAG (Retrieval-Augmented Generation) model outputs. 一个轻量级的 CLI 工具,用于验证 RAG(检索增强生成)模型输出中的引用真实性。
综合分
28.2
GitHub 分
28.2
用户评分
—
★ Stars
1
周下载量
—
安装插件(需先安装 dsh CLI 引擎:npm install -g @deepseek-ai/dsh)
dsh plugin --profile web add PerryLink/Citation-Validator-Lite该插件未发布到 npm,走 GitHub 源安装(pnpm 若拦截 prepare 脚本,按其提示在 pnpm-workspace.yaml 的 allowBuilds 中放行后重跑)
数据截至 2026/9/16(元数据每日更新 · 实装验证按队列轮转,单条结论的验证时间见上方)
用户评分
还没有人投票,来当第一个
订阅周报,不错过优质插件更新
每周一封 · 高评分插件 + 新用户活动
README
Citation-Validator-Lite
使用模糊匹配校验 RAG 模型输出中的引用是否与源文档一致、轻量级的命令行工具。
已移植到 dsh-library —— PerryLink DSH 插件家族的一员。
License
English · 简体中文
功能简介
Citation-Validator-Lite 从 AI 生成的答案中提取 [1]、[2] 等引用标记,并将每个标记与源文档字典逐一比对。它使用模糊字符串匹配对每个引用周围的句子与对应源文本打分,低于可配置阈值的引用会被标记为可疑。
功能特性
- 使用正则表达式提取 [1]、[2] 等引用标记
- 模糊匹配(FuzzyWuzzy 部分比率),阈值可在 0–100 之间配置
- 终端中以红色删除线高亮无效引用
- 答案与源文档支持直接文本或文件输入
- 可选的 JSON 输出
- 可作为 Python 库导入使用
快速开始
需要 Python 3.8+。
git clone https://github.com/PerryLink/Citation-Validator-Lite.git
cd Citation-Validator-Lite
pip install -e .
使用方法
citation-validator-lite --answer-file answer.txt --sources-file sources.json
answer.txt:
According to [1], Python is a high-level programming language that emphasizes code readability.
Python was created by Guido van Rossum and first released in [2], and it has become one of the most popular programming languages.
However, [3] incorrectly states that Python was invented in 1995.
sources.json:
{
"1": "Python is a high-level, interpreted programming language that emphasizes code readability and simplicity.",
"2": "Guido van Rossum created Python and first released it in 1991.",
"3": "Java was released in 1995 by Sun Microsystems."
}
其中引用 [3] 与其来源不匹配,因此会被标记为虚假引用。
| 参数 | 默认值 | 说明 |
|------|--------|------|
| --answer | — | 答案文本 |
| --answer-file | — | 从文件读取答案 |
| --sources | — | 源文档 JSON 对象 |
| --sources-file | — | 从 JSON 文件读取源文档 |
| --threshold | 80 | 匹配阈值(0–100) |
| --json | 关 | 以 JSON 格式输出结果 |
作为库使用:
from citation_validator_lite import validate_citations
result = validate_citations(answer, sources, threshold=80)
基于 Click、FuzzyWuzzy + python-Levenshtein 与 Rich 构建;测试使用 pytest。
开发
pip install -e ".[dev]"
pytest tests/ -v
相关项目
- dsh-library —— 本工具已移植进的 DSH 插件
- PerryLink —— PerryLink DSH 插件家族
许可证
Apache License 2.0 © 2026 PerryLink扫码进群