# QWED Protocol — Deterministic LLM Verification > QWED Protocol is a deterministic trust boundary for LLMs: verify math/logic/code/SQL claims and block unverified outputs before they hit production. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash pip install qwed qwed init qwed doctor qwed test ``` ## Intro QWED Protocol is a deterministic trust boundary for LLMs: verify math/logic/code/SQL claims and block unverified outputs before they hit production. - **Best for:** agent teams that want deterministic gates (math/logic/code/SQL) before shipping outputs - **Works with:** Python SDK + CLI; optional Docker; model-agnostic verification boundary (per README) - **Setup time:** 10–25 minutes ## Practical Notes - Per README: `pip install qwed` installs core engines (Math, Code, Facts); `qwed[full]` adds SQL + logic/Z3 and more. - Per README: `qwed test` runs 12 deterministic tests as a pre-production gate. - Treat verification failures as product signals: log failures, route to fallback, and add tests for recurring mistakes. ## Main A safe integration pattern: 1. **Wrap your model call** with a verification step (or verify the final answer + key tool outputs). 2. Classify failures into: *correctable* (auto-fix), *requires human review*, and *block*. 3. Start with deterministic domains: math, SQL, code safety checks, logic constraints. 4. Add a CI gate: if your “golden tests” fail, don’t deploy the agent prompt/toolchain update. Verification works best when it’s explicit: decide what must be true (constraints) instead of hoping the model “usually” gets it right. ### FAQ **Q: Does verification reduce hallucinations?** A: Per README: it focuses on making hallucinations irrelevant by catching/blocking unverified outputs before production. **Q: What’s a good first use case?** A: Math and SQL checks are low-cost and high-impact. Add code-safety checks for tools that run commands. **Q: How strict should I be?** A: Start strict on critical facts/tool actions, but allow fallbacks (re-ask model, different tool, or human review) to avoid dead ends. ## Source & Thanks > Source: https://github.com/QWED-AI/qwed-verification > License: Apache-2.0 > GitHub stars: 57 · forks: 9 --- ## 快速使用 ```bash pip install qwed qwed init qwed doctor qwed test ``` ## 简介 QWED Protocol 是面向 LLM/Agent 的确定性“信任边界”:内置 SymPy、Z3、AST、SQLGlot 等验证引擎,支持 `pip install qwed` 与 `qwed init/doctor/test`,把不可验证输出在上线前拦住。 - **适合谁:** 希望在上线前用确定性规则验证(数学/逻辑/代码/SQL)的 agent 团队 - **可搭配:** Python SDK + CLI;可选 Docker;模型无关的验证边界(见 README) - **准备时间:** 10–25 分钟 ## 实战建议 - README:`pip install qwed` 安装核心引擎(Math/Code/Facts);`qwed[full]` 扩展 SQL/逻辑(Z3) 等能力。 - README:`qwed test` 运行 12 条确定性测试,可作为上线前门禁。 - 把验证失败当作产品信号:记录失败样本、做 fallback,并为常见错误补测试用例。 ## 主要内容 安全接入方式(从易到难): 1. **把模型输出包一层验证**(或只验证最终结论 + 关键工具输出)。 2. 把失败分成三类:*可自动修正*、*需要人工复核*、*必须阻断*。 3. 先从确定性强的域开始:数学、SQL、代码安全检查、逻辑约束。 4. 在 CI 里加门禁:黄金测试不过,就不要发布 prompt/toolchain 更新。 验证体系要“显式”:先定义必须成立的约束,而不是指望模型大多数时候都对。 ### FAQ **它会让模型不幻觉吗?** 答:README 的定位是:不是减少幻觉,而是通过验证/阻断让幻觉变得无害。 **最先落地哪个场景?** 答:数学与 SQL 检查成本低、收益高;对能执行命令的工具链再加代码安全检查。 **门禁要多严格?** 答:关键事实与工具动作要严格;但保留 fallback(重问、换工具、人工复核)避免流程卡死。 ## 来源与感谢 > Source: https://github.com/QWED-AI/qwed-verification > License: Apache-2.0 > GitHub stars: 57 · forks: 9 --- Source: https://tokrepo.com/en/workflows/qwed-protocol-deterministic-llm-verification Author: Agent Toolkit