TaurenMountain/dsh-llm-as-a-verifier ↗★ 2
dsh-llm-as-a-verifier
LLM-as-a-Verifier for DeepSeek Harness: fine-grained reward, Probabilistic Pivot Tournament best-of-N selection, and per-step progress tracking as agent tools.
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:TaurenMountain/dsh-llm-as-a-verifier说明文档
阅读完整 README ↗配置验证后端
验证模型必须是能返回 token 级 logprobs 的 OpenAI 兼容服务:DeepSeek 官方 API、vLLM/SGLang 本地服务、OpenAI 等均可。
在你的 profile 配置(~/.dsh/profiles//cordis.patch.yml 或 ~/.dsh/cordis.patch.yml)里写:
- id: llm-verifier
config:
baseUrl: https://api.deepseek.com # 或 vLLM: http://localhost:8000/v1
apiKey: '${DEEPSEEK_API_KEY}' # 推荐用环境变量,见下
model: deepseek-v4-flash # 不填时:DeepSeek 默认 deepseek-v4-flash,其余自动探测 /models
maxConcurrency: 8
凭证解析顺序(与上游一致):插件 config → OPENAI_BASE_URL + OPENAI_API_KEY → DEEPSEEK_API_KEY(自动启用 DeepSeek 端点与 thinking 参数)。什么都不配时,工具注册不受影响,调用时才报 MissingAPIKeyError。
export DEEPSEEK_API_KEY=sk-... # 最省事的配置方式
使用示例
装好后直接在对话里让智能体用(无需额外命令):
我写了三个候选实现,帮我用 verify_select 按「正确性、性能」标准选出最好的,
然后对选中的实现用 verify_track 检查我之前的修复步骤是否有进展。
或者手动指定:
verify_compare: problem="写一个反转字符串的函数", candidateA="def rev(s): return s[::-1]",
candidateB="def rev(s): return s", criteria={"Correctness": "代码是否真的反转了字符串?"}
配置项
| 配置 | 默认 | 说明 |
|---|---|---|
model | DeepSeek: deepseek-v4-flash;其余自动探测 | 验证模型名 |
baseUrl | 按凭证推断 | OpenAI 兼容端点 |
apiKey | 按环境推断 | 建议走环境变量 |
timeoutMs | 60000 | 单次请求超时(毫秒) |
maxConcurrency | 8 | 最大并发验证调用 |
deepseek | 按 baseUrl 推断 | 强制 DeepSeek 调用路径(thinking 开启) |
prefill | true | 非 DeepSeek 服务器上对评分标签做 prefill(vLLM/SGLang 读取字母分布更稳) |
compare / select / track | true | 是否注册对应工具 |
工具参数(nEvaluations 重复评估次数、pivots 枢纽数、seed 环赛种子、groundTruthNote 基准提示等)与上游 llm_verifier Python 包一一对应,详见 使用手册。
作为库使用
import { Verifier } from 'dsh-llm-as-a-verifier'
const verifier = new Verifier({ baseUrl: 'http://localhost:8000/v1' })
const { scoreA, scoreB } = await verifier.compare(problem, a, b, { Correctness: '...' })
const result = await verifier.select(problem, candidates, { Correctness: '...' }, { pivots: 2 })
const curve = await verifier.track(problem, steps, { checkpoints: [1, 3] })