Skip to main content

🛡️ RAGGround

Sub-15ms Deterministic & ONNX-Powered Hallucination Guardrail & Citation Verifier for RAG

PyPI version Python versions License: Apache-2.0 Type Checked: mypy Code style: ruff

Stop wasting 4 seconds and thousands of dollars on LLM-as-a-judge evaluators. Verify groundedness, highlight hallucinations at sentence-level granularity, and inject verified citations in sub-15 milliseconds.


⚡ Why RAGGround?

Most RAG teams evaluate hallucinations using Ragas or LLM-as-a-judge. In production, this causes 3 critical problems:

  1. Unusable Latency: Calling GPT-4 to judge an answer adds 3,000–8,000 ms to every response.
  2. Double API Bills: Every token generated requires an extra LLM call to evaluate.
  3. No Span Citations: LLM judges give vague scores (0.75) without pinpointing the exact hallucinated sentence or linking claims to documents.

RAGGround solves this with a 2-Tiered Local Engine:

  • Tier 1 (Sub-1ms): Deterministic token-alignment, sequence matching (LCS), and entity consistency verification.
  • 🧠 Tier 2 (~10ms CPU): Quantized INT8 Natural Language Inference (NLI) model executed locally with ONNX Runtime. Zero PyTorch installation required (< 45MB RAM).

🚀 Quickstart

1. Installation

pip install ragground

2. Verify RAG Outputs (Python API)

from ragground import RAGGround

guard = RAGGround()

context = """
Tesla reported Q3 revenue of $25.18 billion, an 8% increase year-over-year.
Operating margin came in at 10.8% with free cash flow of $2.74 billion.
"""

answer = """
Tesla's Q3 revenue rose 8% to $25.18 billion.
Free cash flow reached $2.74 billion.
The company also announced plans to launch humanoid robots by Christmas.
"""

report = guard.verify(context=context, answer=answer)

print(f"Grounded: {report.is_grounded}")          # False
print(f"Score: {report.grounding_score:.2f}")     # 0.67 (2 of 3 verified)
print(f"Latency: {report.latency_ms} ms")         # 11.2 ms

# Inspect flagged hallucinations
for h in report.hallucinations:
    print(f"⚠️ Hallucination: {h.text}")
    print(f"   Status: {h.status.value} (Confidence: {h.confidence:.2f})")

# View augmented answer with exact citations injected
print("\n--- Cited Output ---")
print(report.cited_answer)

📊 Benchmark: RAGGround vs. LLM-as-a-Judge

Metric RAGGround (Tier 1 + ONNX) Ragas (GPT-4o-mini / 3.5) Regex / Exact Match
P50 Latency (per query) ~8.2 ms(300x faster) ~3,400 ms 🐢 < 1 ms
P99 Latency (per query) ~14.5 ms ~6,800 ms < 2 ms
Cloud API Cost $0.00 (Runs locally) $150–$400 / 100k calls $0.00
Paraphrase Understanding ✅ High (Neural NLI) ✅ High ❌ None (Breaks on synonyms)
Number & Entity Checking ✅ Strict Entity Matching ⚠️ LLM Drift ⚠️ High False Positives
Deterministic Output ✅ 100% Reproducible ❌ Nondeterministic ✅ 100% Reproducible
Citations Generated ✅ Exact Sentence-to-Source ⚠️ Vague Overall Score ❌ None

💻 Command Line Interface (CLI)

Audit any context and answer directly in your terminal:

ragground verify \
  -c "Python 3.12 introduced improved error messages and isolated subinterpreters." \
  -a "Python 3.12 added isolated subinterpreters. It also removed the GIL completely."

Benchmark your local CPU:

ragground benchmark

🏗️ Architecture

[ User Context & Answer ] ──► [ Claim Decomposition ] ──► [ Tier 1: Token & LCS Shortcut (< 1ms) ]
                                                                     │
                                  ┌──────────────────────────────────┴─────────────────────────────────┐
                                  ▼ (High Overlap)                                                     ▼ (Paraphrased / Fuzzy)
                         [ Mark Verified ]                                                [ Tier 2: ONNX NLI Transformer (~10ms) ]
                                  │                                                                    │
                                  └───────────────────────────────┬────────────────────────────────────┘
                                                                  ▼
                                                   [ Citation & GuardReport ]

📚 Documentation

For in-depth guides and references, check the docs/ directory:


📄 License

Apache 2.0 License. See LICENSE for details.

Download files

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

Source Distribution

ragground-0.1.0.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

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

ragground-0.1.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file ragground-0.1.0.tar.gz.

File metadata

  • Download URL: ragground-0.1.0.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for ragground-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4aa93dc7b3b384440aa151fae0d3d454328d37f6486951e301c1a693c4d2291e
MD5 d45cc3f9495105f10ebea38a78f15306
BLAKE2b-256 6eef764c89e42aeb298b9332fceb4e437831e931808e94a0fe11b2d16c3618f5

See more details on using hashes here.

File details

Details for the file ragground-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ragground-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for ragground-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf34b425d66daad39a0aa077d25356adbe7005256e3085871f410b8f27e934f9
MD5 fac5b25308b73d2d7efd4fcb6dfc6a7f
BLAKE2b-256 59f827fb8cc1677d47802ac14bcb8ef627be2633bb65148848c33712668baec4

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page