Glossary

Retrieval-augmented generation (RAG)

Retrieval-augmented generation (RAG) is a way of building AI answers in which the system first searches your approved sources for passages relevant to the question, then gives those passages to a language model with an instruction to answer from them and cite them. The model answers from your documents, not only from what it learned in training.

Book a workflow review

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

  1. Ingest. Collect the approved documents, extract clean text and keep metadata such as owner, date, language and who may read it.
  2. Chunk. Split documents into passages that keep headings and tables intact, so each passage makes sense on its own.
  3. 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.
  4. Retrieve. Search both indexes, drop what the user may not see, and re-rank the results.
  5. 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.

A small first step

A 30-minute workflow review

Pick one process that costs your team time. We look at it with you and tell you honestly whether automation or an AI agent pays, what it would take, and what to measure first.

Message us on WhatsApp

Keep exploring

Ready to build something secure?

Tell us about your product. We will reply with a clear plan.

Start a project

We would like to use Microsoft Clarity to see how visitors use the site, so we can improve it. It sets cookies and is off unless you accept. Cookie policy