The Deterministic Verification Protocol for AI - 8 verification engines for math, logic, code, SQL, facts, images, and more.
Project description
QWED Protocol
Model Agnostic Verification Layer for AI
QWED Verification - Production-grade deterministic verification layer for Large Language Models. Works with ANY LLM - OpenAI, Anthropic, Gemini, Llama (via Ollama), or any local model. Detect and prevent AI hallucinations through 8 specialized verification engines. Your LLM, Your Choice, Our Verification.
Don't fix the liar. Verify the lie.
QWED does not reduce hallucinations. It makes them irrelevant.
If an AI output cannot be proven, QWED will not allow it into production.
๐ Model Agnostic: Local ($0) โข Budget ($5/mo) โข Premium ($100/mo) - You choose!
๐ Support QWED Development:
Quick Start ยท ๐ QWEDLocal ยท The Problem ยท The 8 Engines ยท ๐ Integration ยท โก QWEDLocal ยท ๐ฅ๏ธ CLI ยท ๐ Ollama (FREE!) ยท ๐ Full Documentation
โ ๏ธ What QWED Is (and Isn't)
QWED is: An open-source engineering tool that combines existing verification libraries (SymPy, Z3, SQLGlot, AST) into a unified API for LLM output validation.
QWED is NOT: Novel research. We don't claim algorithmic innovation. We claim practical integration for production use cases.
Works when: Developer provides ground truth (expected values, schemas, contracts) and LLM generates structured output.
Doesn't work when: Specs come from natural language, outputs are freeform text, or verification domain is unsupported.
๐ฌ On "Deterministic" Verification
QWED uses deterministic computation (no neural networks, no embeddings, no vibes) wherever possible. Math, Logic, SQL, Code, and Schema engines produce 100% reproducible results using symbolic solvers. For fact-checking, we use TF-IDF (not embeddings) because it's transparent and inspectableโsame query always returns same score. For image/reasoning domains that require LLM fallback, we clearly mark outputs as
HEURISTICin the response.
๐ Quick Start: Install & Verify in 30 Seconds
Python SDK (PyPI)
pip install qwed
Go SDK
go get github.com/QWED-AI/qwed-verification/sdk-go
TypeScript SDK (npm)
npm install @qwed-ai/sdk
From Source
git clone https://github.com/QWED-AI/qwed-verification.git
cd qwed-verification
pip install -e .
๐ NEW: Free Course on AI Verification
Learning Path: From Zero to Production-Ready AI Verification
๐ Start the Free Course โ
What You'll Learn:
- ๐ก Artist vs. Accountant: Why LLMs are creative but terrible at math
- ๐งฎ Neurosymbolic AI: How deterministic verification catches 100% of errors*
- ๐๏ธ Production Patterns: Build guardrails that actually work
- ๐ HIPAA/GDPR Compliance: PII masking for regulated industries
- ๐ฆ Framework Integration: LangChain, LlamaIndex, and more
Total Time: ~3 hours | Modules: 4 | Examples: Production-ready code
Perfect for: Developers integrating LLMs, ML engineers, Tech leads evaluating AI safety
from qwed_sdk import QWEDClient
client = QWEDClient(api_key="your_key")
# The LLM says: "Derivative of x^2 is 3x" (Hallucination!)
response = client.verify_math(
query="What is the derivative of x^2?",
llm_output="3x"
)
print(response)
# -> โ CORRECTED: The derivative is 2x. (Verified by SymPy)
๐ก Want to use QWED locally without our backend? Check out QWEDLocal - works with Ollama (FREE), OpenAI, Anthropic, or any LLM provider.
๐จ The LLM Hallucination Problem: Why AI Can't Be Trusted
Everyone is trying to fix AI hallucinations by Fine-Tuning (teaching it more data).
This is like forcing a student to memorize 1,000,000 math problems.
What happens when they see the 1,000,001st problem? They guess.
๐ The Proof: Why Enterprise AI Needs QWED Verification
We benchmarked Claude Opus 4.5 (one of the world's best LLMs) on 215 critical tasks.
| Finding | Implication |
|---|---|
| Finance: 73% accuracy | Banks can't use raw LLM for calculations |
| Adversarial: 85% accuracy | LLMs fall for authority bias tricks |
| QWED: 100% error detection | All 22 errors caught before production |
QWED doesn't compete with LLMs. We ENABLE them for production use.
๐ Full Benchmark Report โ
๐ฏ Use Cases & Applications
QWED is designed for industries where AI errors have real consequences:
| Industry | Use Case | Risk Without QWED |
|---|---|---|
| ๐ฆ Financial Services | Transaction validation, fraud detection | $12,889 error per miscalculation |
| ๐ฅ Healthcare AI | Drug interaction checking, diagnosis verification | Patient safety risks |
| โ๏ธ Legal Tech | Contract analysis, compliance checking | Regulatory violations |
| ๐ Educational AI | AI tutoring, assessment systems | Misinformation to students |
| ๐ญ Manufacturing | Process control, quality assurance | Production defects |
โ The Solution: Verification Layer
QWED is the first open-source Neurosymbolic AI Verification Layer.
We combine:
- Neural Networks (LLMs) for natural language understanding
- Symbolic Reasoning (SymPy, Z3, AST) for deterministic verification
The Core Philosophy: "The Untrusted Translator"
QWED operates on a strict principle: Don't trust the LLM to compute or judge; trust it only to translate.
Example Flow:
User Query: "If all A are B, and x is A, is x B?"
โ (LLM translates)
Z3 DSL: Implies(A(x), B(x))
โ (Z3 proves)
Result: TRUE (Proven by formal logic)
The LLM is an Untrusted Translator. The Symbolic Engine is the Trusted Verifier.
๐ก How QWED Compares
The "Judge" Problem
Most AI safety tools use "LLM-as-a-Judge" (asking GPT-4 to grade GPT-3.5). This is fundamentally unsafe:
- Recursive Hallucination: If the judge has the same bias as the generator, errors go undetected
- Probabilistic Evaluation: LLMs give probability, not proof
- Subjectivity: Different judges = different answers
QWED introduces "Solver-as-a-Judge": Replace neural network opinions with compiler execution and mathematical proof.
Comparison Table
| Feature | QWED Protocol | BEAVER | NeMo Guardrails | LangChain Evaluators |
|---|---|---|---|---|
| The "Judge" | Deterministic Solver (Z3/SymPy) | Probability Bounds | Semantic Matcher | Another LLM (GPT-4) |
| Mechanism | Translation to DSL | Token Trie Search | Vector Similarity | Prompt Engineering |
| Verification Type | Mathematical Proof | Probabilistic Bounds | Policy Adherence | Consensus/Opinion |
| Primary Goal | Correctness (Truth) | Constraint Satisfaction | Safety (Appropriateness) | Quality Score |
| False Positives | Near Zero (Logic-based) | Low (Statistical) | Medium (Semantic drift) | High (Subjectivity) |
| Works Offline | โ Yes (QWEDLocal) | โ Yes | โ No | โ No |
| Privacy | โ 100% Local | โ Local | โ Cloud-based | โ Cloud-based |
QWED's Advantage: When you need proof, not opinion.
๐ฌ The Verification Engines
QWED routes queries to specialized engines that act as DSL interpreters:
โโโโโโโโโโโโโโโโ
โ User Query โ
โโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ LLM (The Guesser)โ
โ GPT-4 / Claude โ
โโโโโโโโฌโโโโโโโโโโโโ
โ Unverified Output
โผ
โโโโโโโโโโโโโโโโโโโโโโ
โ QWED Protocol โ
โ (Verification) โ
โโโโโโโโฌโโโโโโโโโโโโโโ
โ
โโโโโดโโโโโ
โผ โผ
โ Reject โ
Verified
โ
โผ
โโโโโโโโโโโโโโโโโโ
โ Your Applicationโ
โโโโโโโโโโโโโโโโโโ
QWED ๐ Traditional AI Safety Approaches
| Approach | Accuracy | Deterministic | Explainable | Best For |
|---|---|---|---|---|
| QWED Verification | โ 99%+ | โ Yes | โ Full trace | Production AI |
| Fine-tuning / RLHF | โ ๏ธ ~85% | โ No | โ Black box | General improvement |
| RAG (Retrieval) | โ ๏ธ ~80% | โ No | โ ๏ธ Limited | Knowledge grounding |
| Prompt Engineering | โ ๏ธ ~70% | โ No | โ ๏ธ Limited | Quick fixes |
| Guardrails | โ ๏ธ Variable | โ No | โ ๏ธ Reactive | Content filtering |
QWED doesn't replace these - it complements them with mathematical certainty.
๐ง The 8 Verification Engines: How QWED Validates LLM Outputs
We don't use another LLM to check your LLM. That's circular logic.
We use Hard Engineering:
| Engine | Tech Stack | What it Solves |
|---|---|---|
| ๐งฎ Math Verifier | SymPy + NumPy |
Calculus, Linear Algebra, Finance. No more $1 + $1 = $3. |
| โ๏ธ Logic Verifier | Z3 Prover |
Formal Verification. Checks for logical contradictions. |
| ๐ก๏ธ Code Security | AST + Semgrep |
Catches eval(), secrets, vulnerabilities before code runs. |
| ๐ Stats Engine | Pandas + Wasm |
Sandboxed execution for trusted data analysis. |
| ๐๏ธ SQL Validator | SQLGlot |
Prevents Injection & validates schema. |
| ๐ Fact Checker | TF-IDF + NLI |
Checks grounding against source docs. |
| ๐๏ธ Image Verifier | OpenCV + Metadata |
Verifies image dimensions, format, pixel data. |
| ๐ค Consensus Engine | Multi-Provider |
Cross-checks GPT-4 vs Claude vs Gemini. |
๐ง The QWED Philosophy: Verification Over Correction
| โ Wrong Approach | โ QWED Approach |
|---|---|
| "Let's fine-tune the model to be more accurate" | "Let's verify the output with math" |
| "Trust the AI's confidence score" | "Trust the symbolic proof" |
| "Add more training data" | "Add a verification layer" |
| "Hope it doesn't hallucinate" | "Catch hallucinations deterministically" |
QWED = Query with Evidence and Determinism
Probabilistic systems should not be trusted with deterministic tasks. If it can't be verified, it doesn't ship.
๐ LLM Framework Integrations
Already using an Agent framework? QWED drops right in.
๐ฆ LangChain (Native Integration)
Install: pip install 'qwed[langchain]'
from qwed_sdk.integrations.langchain import QWEDTool
from langchain.agents import initialize_agent
from langchain_openai import ChatOpenAI
# Initialize QWED verification tool
tool = QWEDTool(provider="openai", model="gpt-4o-mini")
# Add to your agent
llm = ChatOpenAI()
agent = initialize_agent(tools=[tool], llm=llm)
# Agent automatically uses QWED for verification
agent.run("Verify: what is the derivative of x^2?")
๐ค CrewAI
from qwed_sdk.integrations.crewai import QWEDVerifiedAgent
agent = QWEDVerifiedAgent(role="Analyst", verify_math=True)
๐ฆ LlamaIndex
from qwed_sdk.integrations.llamaindex import QWEDQueryEngine
# Add Fact Guard verification to any query engine
verified_engine = QWEDQueryEngine(base_engine, verify_facts=True)
๐ QWED Integrations & Extensions
QWED extends beyond core verification with specialized integrations:
๐ QWED-UCP (Commerce Verification)
Prevent AI hallucinations in e-commerce: wrong prices, fake inventory, invalid transactions.
from qwed_ucp import UCPGuard
guard = UCPGuard()
result = guard.verify_transaction({
"product": "iPhone 15",
"price": 999.00,
"quantity": 2,
"total": 1998.00 # AI calculated this
})
# โ
VERIFIED: total = price ร quantity
๐ QWED-MCP (Claude Desktop)
Use QWED verification directly in Claude Desktop via MCP:
{
"mcpServers": {
"qwed": {
"command": "uvx",
"args": ["qwed-mcp"]
}
}
}
๐ Multi-Language SDK Support
| Language | Package | Status |
|---|---|---|
| ๐ Python | qwed |
โ Available on PyPI |
| ๐ฆ TypeScript | @qwed-ai/sdk |
โ Available on npm |
| ๐น Go | qwed-go |
โ Available |
| ๐ฆ Rust | qwed |
๐ก Coming Soon |
# Python
pip install qwed
# Go
go get github.com/QWED-AI/qwed-verification/sdk-go
# TypeScript
npm install @qwed-ai/sdk
๐ฏ Real Example: The $12,889 Bug
User asks AI: "Calculate compound interest: $100K at 5% for 10 years"
GPT-4 responds: "$150,000"
(Used simple interest by mistake)
With QWED:
response = client.verify_math(
query="Compound interest: $100K, 5%, 10 years",
llm_output="$150,000"
)
# -> โ INCORRECT: Expected $162,889.46
# Error: Used simple interest formula instead of compound
Cost of not verifying: $12,889 error per transaction ๐ธ
โ Frequently Asked Questions
Q: How does QWED differ from RAG (Retrieval Augmented Generation)?
A: RAG improves the input to the LLM by grounding it in documents. QWED verifies the output deterministically. RAG adds knowledge; QWED adds certainty.
Q: Can QWED work with any LLM?
A: Yes! QWED is model-agnostic and works with GPT-4, Claude, Gemini, Llama, Mistral, and any other LLM. We verify outputs, not models.
Q: Does QWED replace fine-tuning?
A: No. Fine-tuning makes models better at tasks. QWED verifies they got it right. Use both.
Q: Is QWED open source?
A: Yes! Apache 2.0 license. Enterprise features (audit logs, multi-tenancy) are in a separate repo.
Q: What's the latency overhead?
A: Typically <100ms for most verifications. Math and logic proofs are instant. Consensus checks take longer (multiple API calls).
๐ Documentation & Resources
Main Documentation:
| Resource | Description |
|---|---|
| ๐ Full Documentation | Complete API reference and guides |
| ๐ง API Reference | Endpoints and schemas |
| โก QWEDLocal Guide | Client-side verification setup |
| ๐ฅ๏ธ CLI Reference | Command-line interface |
| ๐ PII Masking Guide | HIPAA/GDPR compliance |
| ๐ Ollama Integration | Free local LLM setup |
Project Documentation:
| Resource | Description |
|---|---|
| ๐ Benchmarks | LLM accuracy testing results |
| ๐บ๏ธ Project Roadmap | Future features and timeline |
| ๐ Changelog | Version history summary |
| ๐ Release Notes | Detailed version release notes |
| ๐ฌ GitHub Action Guide | CI/CD integration |
| ๐๏ธ Architecture | System design and engine internals |
Community:
| Resource | Description |
|---|---|
| ๐ค Contributing Guide | How to contribute to QWED |
| ๐ Code of Conduct | Community guidelines |
| ๐ Security Policy | Reporting vulnerabilities |
| ๐ Citation | Academic citation format |
๐ข Enterprise Features
Need observability, multi-tenancy, audit logs, or compliance exports?
๐ง Contact: rahul@qwedai.com
๐ License
Apache 2.0 - See LICENSE
โญ Star History
๐ฅ Contributors
๐ Citation
If you use QWED in your research or project, please cite our archived paper:
@software{dass2025qwed,
author = {Dass, Rahul},
title = {QWED Protocol: Deterministic Verification for Large Language Models},
year = {2025},
publisher = {Zenodo},
version = {v1.0.0},
doi = {10.5281/zenodo.18110785},
url = {https://doi.org/10.5281/zenodo.18110785}
}
Plain text:
Dass, R. (2025). QWED Protocol: Deterministic Verification for Large Language Models (Version v1.1.0). Zenodo. https://doi.org/10.5281/zenodo.18110785
โ Using QWED in Your Project?
Add this badge to your README to show you're using verified AI:
[](https://github.com/QWED-AI/qwed-verification#%EF%B8%8F-what-does-verified-by-qwed-mean)
This badge tells users that your LLM outputs are deterministically verified, not just "hallucination-prone guesses."
๐ก๏ธ What does "Verified by QWED" mean?
When you see the [Verified by QWED] badge on a repository or application, it is a technical guarantee, not a marketing claim.
It certifies that the software adheres to the QWED Protocol for AI Safety:
-
The Zero-Hallucination Warranty: The application does not rely on LLM probabilities for Math, Logic, or Code. It uses Deterministic Engines (SymPy, Z3, AST) to prove correctness before outputting data.
-
The "Untrusted Translator" Architecture: The system treats the LLM solely as a translator (Natural Language โ DSL), never as a judge. If the translation cannot be mathematically proven, the system refuses to answer rather than guessing.
-
Cryptographic Accountability: The application generates JWT-based Attestations (ES256 signatures) for its critical operations. Every "Verified" output comes with a cryptographic receipt proving a solver validated it.
In short: The badge means "We don't trust the AI. We trust the Math."
โญ Star us if you believe AI needs verification
Ready to trust your AI?
"Safe AI is the only AI that scales."
Contribute ยท Architecture ยท Security ยท Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qwed-2.4.0.tar.gz.
File metadata
- Download URL: qwed-2.4.0.tar.gz
- Upload date:
- Size: 1.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccc338e5e8549df653b8ff793d5105f573e05bde0da5758655a6fadc2742c35a
|
|
| MD5 |
cf8b18536348494d34f0e9e7caabf2fe
|
|
| BLAKE2b-256 |
ce790f93f22fa82c99741c594894639d821ba4448738ffba1d24713d506dbbfe
|
Provenance
The following attestation bundles were made for qwed-2.4.0.tar.gz:
Publisher:
publish.yml on QWED-AI/qwed-verification
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qwed-2.4.0.tar.gz -
Subject digest:
ccc338e5e8549df653b8ff793d5105f573e05bde0da5758655a6fadc2742c35a - Sigstore transparency entry: 836211774
- Sigstore integration time:
-
Permalink:
QWED-AI/qwed-verification@e61c4472eef9fd116b012462636f5d2dcdc0b73f -
Branch / Tag:
refs/tags/v2.4.1 - Owner: https://github.com/QWED-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e61c4472eef9fd116b012462636f5d2dcdc0b73f -
Trigger Event:
release
-
Statement type:
File details
Details for the file qwed-2.4.0-py3-none-any.whl.
File metadata
- Download URL: qwed-2.4.0-py3-none-any.whl
- Upload date:
- Size: 256.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4998c1b0cfc545901dc246067421243018acb08f8e8667459c2f41f5f526f735
|
|
| MD5 |
578dc6f1d2ffb48881341ad4fec6dcb0
|
|
| BLAKE2b-256 |
ddfa6fd9c303339f68fe693de116a3a7a7c51d5b38ecdd928ec472aca12b0d5a
|
Provenance
The following attestation bundles were made for qwed-2.4.0-py3-none-any.whl:
Publisher:
publish.yml on QWED-AI/qwed-verification
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qwed-2.4.0-py3-none-any.whl -
Subject digest:
4998c1b0cfc545901dc246067421243018acb08f8e8667459c2f41f5f526f735 - Sigstore transparency entry: 836211780
- Sigstore integration time:
-
Permalink:
QWED-AI/qwed-verification@e61c4472eef9fd116b012462636f5d2dcdc0b73f -
Branch / Tag:
refs/tags/v2.4.1 - Owner: https://github.com/QWED-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e61c4472eef9fd116b012462636f5d2dcdc0b73f -
Trigger Event:
release
-
Statement type: