open source · Apache-2.0

Check whether an LLM's answer actually came from its source.

Fast, deterministic, no second LLM.

For RAG systems and agent loops in regulated industries.

$pip install groundlens
Try the live demo Read the docs
Claude · Groundlens MCP
A deterministic CHECK printed live under every answer inside Claude
A deterministic CHECK printed under every answer, live inside Claude.
Install & first check

One question, one answer, one source. One reading you can act on.

You give Groundlens a question, an answer, and the source it was supposed to use. It returns a plain-language CHECK — and does it in milliseconds, the same way every time.

Read the docs
first_check.py
from groundlens import compute_sgi, check

question = "What is the daily transfer limit?"
context  = "The daily transfer limit is 1,000 EUR per day."
response = "The daily limit is 500 EUR per transaction."  # not in the source

print(check(compute_sgi(
    question=question, context=context, response=response,
)).render())

# CHECK: Not supported by the document (SGI=0.00)
# The answer stays closer to the question than to the
# source, so it may not come from the document.
The verification pipeline

You have to verify every LLM call. You can't afford to verify them all the expensive way.

Verification is a pipeline of six stages, ordered cheapest to most expensive. Each stage is a filter: it settles what it can and passes only the doubtful cases forward. Groundlens is stages 1–4 — geometry, a state switch, consistency, and rules. So the slow, costly stages 5–6 only ever see the few answers that were actually flagged.

← cheap · fast · deterministic expensive · slow · human →
100%~70%~45%~30%~15%a few %
Groundlens · fast & cheap · geometry + switch + small open model + rules
You add · slow · expensive
01
Geometry
SGI / DGI

Did the answer come from its source, or drift off it?

no model
02
Switch
state gate

May this answer enter agent or RAG state?

no model
03
Consistency
resample

Does the model agree with itself when asked again?

small model
04
Rules
named checks

Did it break a policy, invent a number, skip a disclosure?

policy
05
LLM as judge
your stage

Hard cases that need real reasoning over the evidence.

tokens
06
Human review
your stage

A person makes the final call.

a person

This is the whole reason Groundlens exists. Use it as triage at the front of the pipeline: clear the obvious cases in milliseconds, keep ungrounded answers out of agent state, and escalate only what's flagged to a judge model or a human. Same coverage on every call — a fraction of the time and cost.

The proof

What it catches, what it doesn't, and why you can check both.

!

SGI and DGI measure grounding, not truth. These two geometric scores tell you whether an answer is grounded in its source — not whether it is true. A hallucination phrased faithfully can still score as grounded. That gap is why the pipeline has Consistency: it probes truth by asking the model again. Read an SGI/DGI score as "did this come from the source?" — and lean on Consistency for "does the model actually know this?"

What it catches

Answers that ignore the source or drift off the question — the failures that leave a trace in the geometry of the text.

The blind spot, said out loud

A wrong fact phrased exactly like a right one sits next to a correct answer. Geometry can't separate them — which is precisely why a consistency stage exists.

Reproducible

Thresholds and reference direction are calibrated and versioned. The same input gives the same result — today and two years from now.

Semantic Grounding Index — geometric bounds on context engagement in RAG systems arXiv:2512.13771 → A Geometric Taxonomy of Hallucinations in LLMs arXiv:2602.13224 → How Transformers Reject Wrong Answers — rotational dynamics of factual constraint arXiv:2603.13259 →
Benchmarks → Live demo → Source →
Integrations

Drop it into the stack you already run.

Score every response in place — SGI when you pass the source, DGI otherwise — and collect the readings.

LangChain LangGraph CrewAI Semantic Kernel AutoGen
Claude · GPT · Gemini — for the consistency stage.
In your editor — the MCP server

The same first-stage check inside Claude, Cursor, and VS Code. It prints a CHECK under each answer, with no model in the scoring path.

groundlens-dev/groundlens-mcp →
Data handling

No server. No account. Runs on your infrastructure.

Read DATA_HANDLING.md
  • The core scores on your machine. It never sends your data out.
  • API keys are yours; calls go direct to the provider you choose.
  • No telemetry. Same inputs, same scores — a trail you can reproduce and audit.
Who maintains it

Javier Marín created the method and the library. Published in the open, maintained in the open — the three papers above are the method on the record.

GitHub → LinkedIn → javier@groundlens.dev
Fund the work

One person maintains this in the open. If it verifies answers you ship, funding buys more of it — and keeps it free for everyone else.

Support on Manifund