Why teams use it
A large language model knows nothing about your price list, policies or contracts, and its general knowledge stops at a cutoff date. Retraining it whenever a document changes would be slow and costly. RAG keeps the knowledge in documents you control: update the document, re-index it, and the next answer uses the new version. Citations let the reader check the source.
The pipeline, step by step
- Ingest. Collect the approved documents, extract clean text and keep metadata such as owner, date, language and who may read it.
- Chunk. Split documents into passages that keep headings and tables intact, so each passage makes sense on its own.
- Index. Turn each passage into embeddings for search by meaning, often stored in a vector database, and usually add a keyword index that catches names, codes and numbers.
- Retrieve. Search both indexes, drop what the user may not see, and re-rank the results.
- Generate. Send the most relevant passages with the question and clear rules: answer only from these sources, cite them, and say so when they do not hold the answer.
An example
Imagine an HR assistant at a company whose staff write in Arabic and English. An employee asks in Arabic about carrying over unused leave. The system retrieves the clause from the English policy and from its Arabic summary, and the model answers in Arabic with links to both. A manager-only document on salary bands never reaches the model, because the permission check removed it at retrieval. This example is hypothetical.
Common mistakes
- Applying permissions after the answer is generated instead of at retrieval, so restricted text has already reached the model.
- Indexing once and never again, so answers quote superseded policies.
- Judging quality by a few demo questions instead of an evaluation set that scores retrieval and answers separately.
- Forgetting that retrieved documents can carry hidden instructions, a form of indirect prompt injection.
- Assuming RAG removes hallucination. It reduces it; testing and citations make the rest visible.
Related terms
Fine-tuning changes how a model behaves; RAG changes what it knows at the moment it answers, and many systems use both. Read how we build internal knowledge assistants on this pattern.