How it works

Documents are chunked, embedded into vectors and indexed. At query time the system embeds the question, retrieves nearest neighbours, usually reranks them with a cross-encoder, and assembles a prompt containing the surviving passages plus instructions to answer only from them and to cite. Strong systems add lexical search alongside vector search, because exact identifiers, part numbers and error codes are precisely what embeddings blur.

Example

An internal support assistant asked "is the 90-day return window different for enterprise contracts?" needs the one clause that mentions both. Semantic similarity will happily return five paragraphs about consumer returns; a hybrid retriever plus reranking is what surfaces the clause. If it never enters the prompt, no amount of prompt engineering downstream recovers the answer.

Why it matters

RAG is the default architecture for grounding model output in material an organisation can audit, update and permission. It also makes the failure surface legible: you can measure retrieval separately from generation, which is the only reliable way to debug these systems.