Problem
A customer-support assistant built on retrieval-augmented generation (RAG) sometimes gives a wrong answer, and the team cannot tell which stage broke. The cause can be missing content, a retriever or ranker that drops the right document, or a generator that ignores the format or answers at the wrong level of detail. At Lemonade the chat interface carries all support and claims.
Example from the article: a flow in an agent the team was building kept producing a wrong answer, and the team first had to find whether the prompt or the data was at fault.
Solution in brief
Profile the pipeline first to find the failing stage. Then pick a fix from a catalogue of six failure types: missing content, retriever miss, ranker miss, answer not extracted, wrong format and incorrect specificity. Iterate in stages, and look at the data first.
Questions this case answers
- How to diagnose which stage of a retrieval-augmented pipeline produces wrong answers and pick a targeted fix for that stage
- How to keep a grounded answer generator from returning unsupported or off-format answers when retrieval is imperfect
- How to find out which stage of a RAG assistant causes a wrong answer?
- How to fix a RAG pipeline when the retriever misses the relevant document in the top k?
Tools and methods
- Pipeline profiling — find which stage (content, retriever, ranker, generator) caused the wrong answer
- Data cleaning and markdown parsing (Unstructured, GCP tools) — remove noise and duplicates; parse tables and PDFs
- Grounding critic prompt — check that the answer rests on the context and answers the question
- LlamaIndex parameter tuner — grid search over chunk size and retriever k
- Embedding fine-tuning, HyDE, sub-queries — improve retrieval
- LLM ranker — rank retrieved documents with rules written in a prompt
- JSON mode, function calling, XML, examples — force the output format
Google or a one-time email code. No password.