LongTracer¶
RAG hallucination detection, multi-project tracing, and pluggable backends — all batteries included.
What is LongTracer?¶
LongTracer is an open-source Python SDK that detects hallucinations in LLM-generated responses. It verifies every claim in an LLM output against your source documents using a two-stage hybrid pipeline:
- STS (Semantic Textual Similarity) — fast bi-encoder finds the best-matching source sentence for each claim
- NLI (Natural Language Inference) — cross-encoder classifies entailment / contradiction / neutral
The result is a trust_score (0.0–1.0), a list of flagged claims, and a full trace of the verification pipeline.
Why LongTracer?¶
| Problem | LongTracer's answer |
|---|---|
| LLMs hallucinate facts not in your documents | Detects contradictions at the claim level |
| Hard to debug which claim failed | Full trace with per-claim evidence mapping |
| Tied to a specific vector store or LLM | Works with any RAG framework — just strings in |
| Verification adds too much latency | Parallel pipeline: relevance scoring runs alongside LLM generation |
| Need to track verification across projects | Multi-project tracing with pluggable storage backends |
Install¶
30-Second Example¶
from longtracer import CitationVerifier
verifier = CitationVerifier()
result = verifier.verify_parallel(
response="The Eiffel Tower is 330 meters tall and located in Berlin.",
sources=["The Eiffel Tower is a wrought-iron lattice tower in Paris, France. It is 330 metres tall."]
)
print(result.trust_score) # 0.5
print(result.hallucination_count) # 1 ("Berlin" contradicts "Paris")
print(result.all_supported) # False
No vector store dependency. No LLM dependency. Just strings in, verification out.
Next Steps¶
- Installation guide — all install options including extras
- Quick Start — working examples in 5 minutes
- How It Works — deep dive into the STS + NLI pipeline
- Integrations — LangChain, LlamaIndex, direct API