RAG is a pattern where, instead of relying on what a model memorised during training, you retrieve relevant documents at query time and put them into the prompt so the model answers from evidence you control.
There are two pipelines. Offline (indexing): documents are loaded, cleaned, split into chunks, passed through an embedding model that turns each chunk into a dense vector, and written to a vector store alongside the original text and metadata.
Online (query time):
- The user's query is embedded with the same model used at index time.
- The vector store runs an approximate nearest-neighbour search and returns the top-k most similar chunks.
- Optionally a reranker — usually a cross-encoder — rescores those candidates and keeps the best few.
- The surviving chunks are pasted into a prompt template alongside the question and an instruction like “answer only from the context; if the answer isn't there, say so.”
- The LLM generates the answer, ideally citing the chunk IDs it used.
The key insight to say out loud: RAG does not change the model's weights. It changes what is in the context window at inference time. That is why it is cheap to update — reindex a document and the system's knowledge changes instantly.
Don't describe RAG as "the model searches the internet." The model does no searching — your retrieval layer does, and the model only sees text you chose to hand it. Interviewers use this to check whether you understand where the boundary sits.