A working RAG demo looks the same as a broken RAG system. Both return fluent, confident answers. The difference only shows up when you ask a question the retriever cannot support, or when the underlying document set drifts and no one notices. Most production RAG problems are not model problems, they are retrieval problems dressed up as model problems.
Chunking is a modeling decision, not a preprocessing step
Fixed-size character or token chunks are convenient but they cut across the shape of the source content. A well-structured document has natural boundaries: sections, sub-sections, function bodies, table rows, API endpoints. When chunking crosses those boundaries, the model retrieves fragments that read plausibly on their own but do not contain the actual answer.
The practical rule: chunk along the structure the document already exposes. Markdown headings, HTML sections, code function bodies, table records. Only fall back to fixed-size chunks when the content genuinely has no structure. Keep chunk metadata (source, section path, document version) attached to every chunk. That metadata is what lets you debug wrong answers later.
Retrieval quality is not the same as answer quality
A common mistake is to only evaluate end-to-end: given a question, is the final answer correct? That answer bakes together retrieval quality and generation quality. When the answer is wrong, you cannot tell which step failed.
Evaluate the retriever on its own. For a set of representative questions, ask a much simpler question: was any of the correct source content in the top-k retrieved chunks? Recall at k is a cheap, honest signal. If recall is low, no amount of prompt engineering will save the answer.
Silent drift is the default
Document sets change. Sources are added, removed, renamed, or restructured. Embeddings computed a month ago will still return results, but the results become less trustworthy. The system does not tell you this is happening.
The mitigation is boring and effective: version the index, log which index version served each response, and re-run retrieval evaluation whenever the index is rebuilt. When retrieval recall drops after an index rebuild, that is the signal to investigate before the drop shows up as user complaints.
Give the model less room to guess
Once retrieval is trustworthy, the generation step is straightforward. Ground the model in the retrieved chunks, ask for citations to specific chunk IDs, and reject or flag responses that cannot be traced back to the source. Structured outputs help here: instead of free-form prose, ask the model to return an object with an answer, a list of source chunk IDs, and a confidence value. That structure gives you something to log, monitor, and evaluate.
What to instrument
- Retrieval recall at k, measured on a small evaluation set that is refreshed with each index rebuild
- Distribution of chunk sources cited in responses (a healthy system draws from many chunks, not the same two)
- Latency at each stage: embedding, retrieval, generation
- Rate of responses without valid citations (a proxy for hallucination pressure)
- Index version and document set size logged with every response
Production RAG is a retrieval system with a language model on top, not a language model with a retrieval system attached. Treating it that way, and instrumenting the retrieval step as its own product, is what turns an impressive demo into something you can actually operate.