Module 3 · Lesson 7 of 7
Why a RAG answer is wrong
- Customer — asks a question — healthy
- Support assistant — searches, then asks — healthy — NOW — question in
- Document index — chunks and vectors — healthy
- Model — writes the answer — healthy
- Question or prompt
- Search
- Chunks or answer
Step 1 of 7 · Support assistant
Done: A customer asks about the Team plan
- What happens
- "How much storage does the Team plan include?"
- Why
- The answer is a fact that changes with each price update, so the assistant looks it up in your documents.
- What changes
- The assistant searches the index first.
- Next
- The index finds the 2 closest chunks
Event log
6 more to go. Press a line to go back to that step.
The index, closest chunk first
Not searched yet.
Step 1 of 7: Support assistant. A customer asks about the Team plan. "How much storage does the Team plan include?"
What this simplifies. The four chunks and their scores are stated examples, not real embeddings, and the model's answer is fixed for each case. A real index holds thousands of chunks, and a real check reads every claim in a long answer. The method is the same: look at what the search found before you blame the model.
When a (Looking up relevant documents first and putting them in the prompt, so the model answers from them instead of from memory alone.) answer is wrong, one of two parts failed: the search or the answer. The fixes are different, so find the failing part first. Look at the (A short passage cut from a longer document, so it can be turned into an embedding and found on its own.) sent with the (Everything sent to a language model in one request: instructions, context and the question.). Is the fact the answer needed in one of them?
If it is not, the search failed. The right page may be missing from the (An extra structure, kept sorted or grouped, that lets a database find matching items without reading all of them.), ranked too low, or beaten by an old copy that was never deleted.
If it is, the answer failed. The model dropped a detail, mixed up two chunks, or added a fact of its own. Asking it to quote its source, and checking each claim against the chunks, catches much of this.
A missing fact also tests the prompt. Tell the model to reply that it does not know when no chunk answers the question. Otherwise it may fill the gap with a number from somewhere else.
In system design: Log the chunk ids sent with every answer, so a bad answer can be traced to the search or the model. Test each part on its own.