RAG faithfulness
Spent a day fixing my RAG's faithfulness! Turns out the bug was in my judge!
Setup: local RAG over books. I use an LLM as a judge to score faithfulness. Is the answer actually in the retrieved context? It breaks each answer into claims and checks them.
The judge kept flagging up to 14% of claims as "contradicted" per book. That reads as real hallucination. So I went and read the flagged cases by hand.
None of them were contradictions.
Two bugs, both in the judge:
- Truncation. The judge only got the first 600 chars of each chunk. On some questions the supporting line was past char 600. Judge never saw it, called it a contradiction.
- No guard. I also had a hard string-match that could confirm a quote was word-for-word in the chunk. The soft LLM judge overruled it anyway.
Fixed both. Bumped the context cap, and let the hard match win over the soft verdict! "Contradicted" dropped from 14% to about 1% across all books NICE!! 🐼 Correctness didn't move (~93%). So it was never the RAG. It was the ruler I was measuring with.
Bonus I had also built a "cite mode" where the answere must quote sources verbatim. Ran it A/B. It barely moved faithfulness, because the truncation fix had already done the work. But it did cut the padding! correct claims that weren't actually grounded in the text dropped a lot. So cite mode does help, just not where I expected. Nice lesson: before you fix the RAG, check if your evaluator is lying to you.
How do you all keep your judge honest? Do you actually read the flagged cases, or trust the number?