Info

groundlens groundlens

groundlens

groundlens is a Python library for detecting LLM hallucinations using embedding geometry.

Two methods, zero LLM dependencies:

  • SGI (Semantic Grounding Index) — measures whether a response engages its source material. For RAG systems with context.
  • DGI (Directional Grounding Index) — measures whether a response’s displacement in embedding space aligns with grounded patterns. Context-free.
Terminal window
pip install groundlens
from groundlens import compute_sgi
result = compute_sgi(
question="What is the capital of France?",
context="France is in Western Europe. Its capital is Paris.",
response="The capital of France is Paris.",
)
# result.flagged → False

Domain-specific calibration achieves AUROC 0.90-0.99. Generic calibration: AUROC ~0.76.


GitHub repository · Documentation · PyPI


← Back to projects