RAG
An approach in which a system looks up relevant information before asking a language model to write an answer. The model receives the retrieved material along with the question.
Also known as: Retrieval-Augmented Generation
What RAG does
Retrieval-augmented generation (RAG) combines a search step with a language model. Think of it as an open-book question: instead of relying on what the model learned during training, the application gives it a few relevant pages at the time of the request. The search component decides what material to bring back; the large language model (LLM) uses that material to write the response.
What happens behind the scenes
Prepare the collection. A typical document pipeline splits long documents into smaller passages called chunks, indexes them, and keeps metadata such as product version, source location, and access permissions. Chunks need enough surrounding text to make sense on their own. A fragment that says “restart the service” is ambiguous if the heading that names the service was dropped.
Retrieve evidence. At request time, the system searches material the user is allowed to access. Keyword search is useful for exact strings such as E104; embedding search can find passages with similar meaning even when the wording differs. A hybrid system combines these approaches. A reranker can then reorder the candidates before the application selects which passages to send to the model.
Generate a response. The application supplies the question and selected passages as context. It may also ask the model to cite source identifiers and say when the evidence is insufficient. Neither the search nor the added context updates the model's weights.
Example: a product support assistant
A customer asks how long their device keeps diagnostic logs. The search returns a manual for firmware 3.2 that says “seven days” and an older manual that says “three days.” If the customer's version is known, the system can filter by version and cite the matching manual. If it's unknown, the assistant can ask which version they're running rather than silently picking one figure.
When to use it and where it fails
RAG is useful for answers based on internal policies, support articles, or other material that changes independently of the model. Updating the collection and its index is usually more practical than fine-tuning a model whenever a document changes. A vector database is optional; the best search method depends on the collection and the kinds of questions people ask.
Retrieval makes an answer easier to verify, not automatically correct. The search may miss the relevant passage, and the generator may misread a good one. Even a real citation can point to a passage that doesn't support the claim. Sending more passages can help recall, but it also adds latency and may bury the useful evidence in irrelevant text.
What interviewers look for
When asked to debug a wrong answer, separate retrieval from generation. First check whether the right evidence was found and actually made it into the final prompt. Then test whether the model answers correctly when given that evidence directly. The result tells you whether to investigate indexing and ranking, context assembly, or how the model uses the material.