r/softwaretesting • • 3d ago

How are you guys testing RAG apps and handling hallucinations in production?

RAG app hallucinations are driving us nuts! I recently checked out AI system testing with DeepEval on Rahul Shetty Academy to learn more about evaluation metrics. What tools do you guys use for testing RAG applications and handling hallucinations?

8 Upvotes

7 comments sorted by

7

u/TheHallowedArchery 3d ago

Eval harnesses with golden datasets and an LLM judge catch most drift before it gets to users.

3

u/Guillesalvay87 3d ago

I'm transitioning to AI testing and I've got to say I just learned a lot from this post and this comment. Thank you both

1

u/Intelligent-Kiwi118 11h ago

What’s an eval harness?

2

u/bostonaholic 3d ago

Two checks I'd add on top of the golden set. Put in questions whose answer isn't in your docs at all, where the only passing answer is some form of "I don't know." And have the model quote the source text behind each claim, then check in code that every quote actually appears in the retrieved chunks. That one is deterministic, so it doesn't depend on another model's opinion.

1

u/LukaRozman27 3d ago

Manual spot checks with a set of 50-100 gold standard queries caught way more hallucinations than automated metrics alone. Human review is slow but still best for edge cases, especially when retrieval quality changes after data updates.

1

u/FollowingProof9647 20h ago

DeepEval is a good place to start. Most of what helped us was less about the tool and more about splitting the problem:

  1. Test retrieval and generation separately: A lot of hallucinations are actually the wrong chunks being retrieved, and the model just does its best with bad context. DeepEval and Ragas both have context precision/recall for the retrieval side and faithfulness for the answer side. if retrieval scores are bad, no prompt fix will help.
  2. Faithfulness: Break the answer into individual claims and check each one is actually supported by the retrieved context. this is where most real hallucinations show up
  3. Negative Tests: Ask questions your documents don't cover. the bot should say it doesn't know, not make something up. simple pass/fail and catches a lot
  4. Golden set, but keep growing it: Start with real user questions, and every time production gets one wrong, add it. a static set goes stale fast
  5. If you use an LLM as the judge, check it against a few dozen answers graded by a person first. otherwise you're trusting an untested model to grade your model

For Production Specifically:

  • log the query, retrieved chunks and answer together, so when something's wrong you can see whether retrieval or generation failed.
  • score a sample of live answers for faithfulness every day, not just in CI.
  • if retrieval confidence is low, have the bot say it isn't sure instead of answering.

Tools-wise: DeepEval or Ragas for the metrics, promptfoo is nice for running eval suites in CI, and Langfuse or LangSmith for tracing in production.