Building RAG that answers correctly
Most wrong answers from a RAG system start with retrieval, not with the model. That's good news, because retrieval can be measured.
Retrieval-augmented generation, or RAG, answers a question by first finding relevant passages in your own documents, then asking a model to answer from those passages. It’s the usual way to build a help assistant, a search box that answers in sentences, or an internal tool that knows company policy. A demo takes an afternoon. Getting it to answer correctly, with sources, every day, takes more care.
Retrieval decides the answer
If the right passage isn’t found, the model can’t use it, and it may answer anyway. Vector search, which matches by meaning, handles paraphrases well but can miss exact terms like product codes, error messages and names. Keyword search is the opposite. Most good systems run both and merge the results, then rank them again so the best few passages come first. Filters help too: product, version, language, date.
Chunk along the document’s own lines
Documents are split into chunks before they’re indexed. Splitting every few hundred words cuts sentences and tables in half and separates answers from their headings. Split along the structure instead: sections, headings, list items, table rows. Keep the document title and section heading with each chunk, so a passage still makes sense on its own. Try a few sizes on real questions rather than guessing.
Respect who can see what
If different people can see different documents, retrieval must apply the same permissions. Filter by the person’s access during the search, not after the answer is written, or the model may summarize something the person was never allowed to read. Remove deleted documents from the index promptly and re-index changed ones, so old answers don’t linger.
Make it cite, and let it say no
Ask the model to answer only from the passages it was given, to cite the ones it used, and to say plainly when they don’t contain the answer. Show the citations as links to the source. A citation lets people check, and an honest “I couldn’t find that” is far better than a confident guess. If the search finds nothing relevant, don’t ask the model at all.
Test retrieval and answers separately
Build a set of real questions, each with the passage that answers it and a good answer. Then measure two things. First, retrieval: did the right passage come back near the top? Second, the answer: is it correct, and does it stick to the passages? When the system gets something wrong, the split tells you where to look. Run the set again after every change to chunking, search settings, prompts or models.
Keep the index fresh
An index is a copy, and copies go stale. Re-index when documents change rather than on a fixed schedule, and record when each passage was last updated. Show that date next to the citation where it matters, like prices, policies and release notes, so people can judge whether the answer is still current.
The short version
Combine meaning and keyword search, chunk along headings, filter by permissions during the search, require citations, allow “I don’t know”, and test retrieval and answers as separate steps. Most of the work is finding the right passage. Once that’s reliable, the model’s part is the easy one.