Technical Writing
Published July 2026 · 5 min read
Building an Evidence Gate: How to Stop a RAG System from Hallucinating
How PolicyGPT moved beyond thresholded vector retrieval into calibrated answerability, controlled unsupported states, provider-resilient citation fallback, and a repeatable evaluation workflow.
The problem with naive RAG
The common retrieval-augmented generation pattern is:
Embed the question
→ retrieve the nearest chunks
→ place them in a prompt
→ let the model answer
This works when the retrieved text directly supports the question.
The dangerous failure appears when the retrieved chunks are only topically related, numerically inconsistent, or unable to answer the request. A language model may still produce fluent prose because nothing in the architecture requires the evidence to prove answerability.
For HR and compliance documents, a plausible but unsupported answer is worse than an explicit refusal.
Retrieval similarity is not confidence
Vector similarity is a retrieval signal. It is not the probability that an answer is correct.
PolicyGPT evaluates answerability using several signals:
- top and average retrieval strength
- retrieval margin
- lexical coverage
- numeric consistency
- direct-support detection
- scope and external-authority risk
Generation is allowed only when the combined evidence state is answer-ready.
Architecture Flow
- 01Stage
Embed question
Local SentenceTransformer query embedding
- 02Stage
Retrieve candidates
Persistent ChromaDB evidence
- 03Stage
Inspect support
Scores, lexical coverage, numbers, direct support, and scope risk
- 04Stage
Apply evidence gate
Supported, provider-degraded, or unsupported
- 05Stage
Generate when allowed
Groq or OpenAI-compatible provider
- 06Stage
Return traceable result
Page citations, confidence reasons, or controlled refusal
Three truthful outcomes
PolicyGPT separates evidence quality from provider availability.
Supported evidence and provider available
The system generates a response and attaches page-level citations.
Supported evidence and provider unavailable
The evidence is still answer-ready. Instead of pretending the policy is unsupported, the system returns citation-only evidence and identifies the provider as degraded.
Unsupported evidence
The evidence gate blocks generation and explains that the indexed documents do not provide enough support.
This distinction is important because an LLM outage and missing policy evidence are different operational states.
The evaluation that replaced spot checks
The original evidence gate was first tested with individual supported and unsupported questions. That was useful, but insufficient.
PolicyGPT v0.3.0 now includes a versioned 16-case benchmark:
- 11 expected-supported questions
- 5 expected-unsupported questions
- expected source pages
- answer concepts
- difficulty and category labels
- per-case confidence and retrieval diagnostics
- repeatable JSON and CSV artifacts
Provider-Disabled Release Run
100% answer-readiness · 100% expected-page hit rate
Across 16 controlled cases, the run recorded 100% fallback accuracy and 0 request errors. Supported questions returned citation-only evidence because generation was intentionally unavailable. Generated-answer quality was therefore not evaluated.
The benchmark result does not prove production accuracy. It proves that, for this controlled dataset, the system correctly separated supported and unsupported requests, retrieved expected pages, and remained useful without a generation provider.
Why refusing to answer is a feature
A controlled unsupported response gives the user an actionable boundary:
- inspect the source document
- reframe the question
- upload the correct policy
- escalate to a human owner
That is safer than letting a model fill the gap with plausible language.
What the evidence gate still does not solve
An evidence gate cannot guarantee that:
- the source document is current
- the policy itself is correct
- the retrieved excerpt is interpreted correctly in every context
- the benchmark represents all future documents
- citations equal legal or compliance approval
- the application is secure enough for production use
Trustworthy RAG therefore requires document governance, larger human-reviewed evaluation, access control, monitoring, retention policies, and operational ownership in addition to retrieval and prompting.
The main lesson is that hallucination control is not a single prompt instruction. It is an architecture that makes unsupported evidence, provider failure, citations, and evaluation visible as separate product states.
The v0.3.0 results here document the provider-disabled release baseline. The case study shows the later generation-enabled holdout. PolicyGPT Enterprise case study.