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

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!

CI License Python 3.10+ Docker DOI status PyPI version Contributors

GitHub stars GitHub forks GitHub watchers


๐Ÿ’– Support QWED Development:

Sponsor on GitHub


Twitter LinkedIn Blog


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.


๐Ÿš€ Quick Start: Install & Verify in 30 Seconds

# Install from PyPI (Recommended)
pip install qwed

# Or install from source
git clone https://github.com/QWED-AI/qwed-verification.git
cd qwed-verification
pip install -e .
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)

๐Ÿ†• NEW: Client-Side Verification (v2.1.0)

No backend server? No problem! Use QWEDLocal:

from qwed_sdk import QWEDLocal

# FREE with Ollama (local LLMs)
client = QWEDLocal(
    base_url="http://localhost:11434/v1",
    model="llama3"
)

# Or use OpenAI
client = QWEDLocal(
    provider="openai",
    api_key="sk-...",
    model="gpt-4o-mini"
)

result = client.verify_math("What is 2+2?")
print(result.verified)  # True
print(result.value)  # 4

Features:

  • โœ… Works with ANY LLM (Ollama, OpenAI, Anthropic, Gemini)
  • โœ… $0 cost with local models
  • โœ… Smart caching (50-80% cost savings)
  • โœ… 100% private (data never leaves your machine)

๐Ÿ”’ NEW in v2.2.0: PII Masking (Enterprise Privacy)

Automatically mask sensitive data before sending to LLMs:

from qwed_sdk import QWEDLocal

# Enable PII masking (requires pip install 'qwed[pii]')
client = QWEDLocal(
    provider="openai",
    api_key="sk-...",
    mask_pii=True  # ๐Ÿ”’ Privacy protection
)

result = client.verify("My email is john@example.com")
# LLM sees: "My email is <EMAIL_ADDRESS>"

# Check what was masked
print(result.evidence['pii_masked'])
# {'pii_detected': 1, 'types': ['EMAIL_ADDRESS']}

Compliance:

  • ๐Ÿฅ HIPAA (Healthcare)
  • ๐Ÿฆ PCI-DSS (Finance)
  • ๐Ÿ‡ช๐Ÿ‡บ GDPR (EU Privacy)

CLI:

qwed verify "Email: user@example.com" --mask-pii
qwed pii "My SSN is 123-45-6789"  # Test detection

๐Ÿ“– PII Masking Guide โ†’ | QWEDLocal Guide โ†’ | CLI Reference โ†’


๐Ÿšจ 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: 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 NeMo Guardrails LangChain Evaluators
The "Judge" Deterministic Solver (Z3/SymPy) Semantic Matcher Another LLM (GPT-4)
Mechanism Translation to DSL Vector Similarity Prompt Engineering
Verification Type Mathematical Proof Policy Adherence Consensus/Opinion
Primary Goal Correctness (Truth) Safety (Appropriateness) Quality Score
False Positives Near Zero (Logic-based) Medium (Semantic drift) High (Subjectivity)
Works Offline โœ… Yes (QWEDLocal) โŒ No โŒ No
Privacy โœ… 100% 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.crewai import QWEDVerifiedAgent

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

๐ŸŒ Multi-Language SDK Support

Language Package Status
๐Ÿ Python qwed โœ… Available on PyPI
๐ŸŸฆ TypeScript @qwed-ai/sdk โœ… Available on npm
๐Ÿน Go qwed-go ๐ŸŸก Coming Soon
๐Ÿฆ€ Rust qwed ๐ŸŸก Coming Soon

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:**
```python
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

If chart doesn't load, click here for alternatives

Current Stars: GitHub stars

View trend: Star History Page


๐Ÿ‘ฅ Contributors

QWED 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:

[![Verified by QWED](https://img.shields.io/badge/Verified_by-QWED-00C853?style=flat&logo=checkmarx)](https://github.com/QWED-AI/qwed-verification)

Preview:
Verified by QWED

This badge tells users that your LLM outputs are deterministically verified, not just "hallucination-prone guesses."


โญ 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.3.0.tar.gz (1.9 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.3.0-py3-none-any.whl (231.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qwed-2.3.0.tar.gz
Algorithm Hash digest
SHA256 b11bb3f6e93cca408167d6c137d4680b38c092f54f1c93162e8e7c066be5c2d3
MD5 678ba0558309b32255dc49f85f479b04
BLAKE2b-256 df19d4db01a823634d8abc86600d84a57daf25923a38f013afadd4244441e073

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qwed-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 231.3 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1992f0a31202dbfa0bf6156b68968ee86508af9b8b6d6d2cae5a2743597b9633
MD5 6d5799f6248680a393fd6f5c2323da89
BLAKE2b-256 26e7c69e6d084ce631de049d865b5eb9430d866a9fd3065f9d62737aaa8b2099

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