Give a model the right documents at question time instead of retraining it.
Starting with What RAG is and when to use it, The RAG pipeline, Chunking, Vector Databases, Reranking, Grounded prompting, Evaluating RAG, and more
Made for you now: slide lessons from basics to production, usually with code and a quiz. See a finished one
Find the few passages that answer the question, then let the model answer from them.
AI EngineeringStage 8 of 17: RAG
A model only knows what was in its training data and what you put in the prompt. Your documents are in neither.
At question time, search your documents for the most relevant passages and put them in the prompt. The model answers from that text instead of from memory, and you can cite the source.
Answer quality is capped by retrieval. If the right passage is not retrieved, the model cannot use it. Chunking, search and reranking are the levers.
Step 1
Chunk and embed
Done once, at indexing time.
Step 2
Retrieve
Find nearest chunks to the question.
Step 3
Rerank
Reorder the candidates with a stronger model.
Step 4
Generate
Answer from the passages, with sources.
Start with these 7. 11 more are one tap away.
Fetch relevant text at question time instead of retraining the model.
Index, retrieve, add to the prompt, generate: the four steps end to end.
Splitting documents so retrieval returns whole ideas.
Fast nearest-neighbour search over embeddings.
A second, slower model that reorders the top candidates.
Tell the model to answer only from the sources and to say when they fall short.
Measure retrieval recall and answer faithfulness separately.