Skip to main content

The Deterministic Verification Protocol for AI - 8 verification engines for math, logic, code, SQL, facts, images, and more.

Project description

QWED Logo - AI Verification Engine

QWED Protocol

The Deterministic Verification Layer for AI

QWED Verification - Production-grade deterministic verification layer for Large Language Models (LLMs). Detect and prevent AI hallucinations through 8 specialized verification engines. Open-source Python framework for AI safety, LLM accuracy testing, and model output validation.

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.

CI License Python 3.10+ Docker DOI status Contributors

GitHub stars GitHub forks GitHub watchers


Twitter LinkedIn Blog


Quick Start · The Problem · The 8 Engines · FAQ · 📄 Whitepaper · 📚 Docs

⚠️ 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.


🚀 Quick Start: Install & Verify in 30 Seconds

⚠️ Note: SDK is coming soon to PyPI. For now, install from source:

# Clone and install
git clone https://github.com/QWED-AI/qwed-verification.git
cd qwed-verification
pip install -r requirements.txt
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)

🚨 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.

QWED Benchmark Results - LLM Accuracy Testing

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: Give the AI a Calculator

QWED doesn't try to make the LLM "smarter".

It treats the LLM as an untrusted translator and verifies its output using Deterministic Engines (SymPy, Z3, SQLGlot, AST).

"If an AI writes code, QWED runs the security audit.
If an AI does math, QWED runs the calculus."

graph LR
    User[User Query] --> LLM[LLM - The Guesser]
    LLM -.->|Unverified Output| QWED{QWED Protocol}
    QWED -->|❌ Hallucination| LLM
    QWED -->|✅ Mathematically Proven| App[Your Application]
    
    style QWED fill:#00C853,stroke:#333,stroke-width:2px,color:white
    style LLM fill:#FF5252,stroke:#333,stroke-width:2px,color:white

🆚 QWED vs 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

from qwed_sdk.langchain import QWEDTool

tools = [QWEDTool(verification_type="math"), QWEDTool(verification_type="sql")]

🤖 CrewAI

from qwed_sdk.crewai import QWEDVerifiedAgent

agent = QWEDVerifiedAgent(role="Analyst", allow_dangerous_code=False)

🌍 Multi-Language SDK Support

⚠️ Note: SDKs are in development. PyPI/npm packages coming soon after organization approval.

Language Package Status
🐍 Python qwed 🟡 Coming Soon
🟦 TypeScript @qwed-ai/sdk 🟡 Coming Soon
🐹 Go qwed-go 🟡 Coming Soon
🦀 Rust qwed 🟡 Coming Soon

Install from source now:

git clone https://github.com/QWED-AI/qwed-verification.git
cd qwed-verification
pip install -r requirements.txt

🎯 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

Resource Description
📖 Full Documentation Complete API reference and guides
🔧 API Reference Endpoints and schemas
📊 Benchmarks LLM accuracy testing results
🤝 Contributing Guide How to contribute to QWED
🏗️ Architecture System design and engine internals
🔒 Security Policy Reporting vulnerabilities

🏢 Enterprise Features

Need observability, multi-tenancy, audit logs, or compliance exports?

📧 Contact: rahul@qwedai.com


📄 License

Apache 2.0 - See LICENSE


⭐ Star History

Star History Chart


👥 Contributors

QWED Contributors

⭐ Star us if you believe AI needs verification

GitHub Stars



Ready to trust your AI?

"Safe AI is the only AI that scales."


Contribute · Architecture · Security · Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qwed-2.0.0.tar.gz (78.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qwed-2.0.0-py3-none-any.whl (215.1 kB view details)

Uploaded Python 3

File details

Details for the file qwed-2.0.0.tar.gz.

File metadata

  • Download URL: qwed-2.0.0.tar.gz
  • Upload date:
  • Size: 78.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for qwed-2.0.0.tar.gz
Algorithm Hash digest
SHA256 72fec4f717e80acec7674156f28dfce1621f85f4102c813992e9c83ac4aa4f0a
MD5 a5fdaf78839f51a7f5785c013f1ec366
BLAKE2b-256 09f9a2b5936047b355615e64ba13b6b01063cb0d3cd66487d0bb80ec74fc658d

See more details on using hashes here.

File details

Details for the file qwed-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: qwed-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 215.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for qwed-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8eb5908a10d84afaec0a256607316d3eb30847a9870d01f0793ed5e1198e72af
MD5 e74144975ad5a49bb596e9d976c73c34
BLAKE2b-256 08b60240ac2072fc82692637e76952ec49b42183d651f6b4c862f396b2d19110

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page