Skip to content

What is RAG (retrieval-augmented generation)?

Giving the model the documents instead of hoping it memorised them.

By Fiqhro Dedhen3 min readEdited by Fiqhro Dedhen

Retrieval-augmented generation (RAG) is a straightforward idea: before asking the model a question, go and find the documents that answer it, and include them in the prompt.

That's it. The model isn't recalling anything — it's reading material you just handed it and answering from that.

Why bother

A model's knowledge is fixed at training time, general, and impossible to audit. Your company handbook is none of those things. RAG closes the gap:

  • Current — retrieval hits a live index, so today's document gets used today.
  • Private — your data stays in your database and is passed in at query time.
  • Attributable — because you know which documents you supplied, you can cite them.
  • Correctable — fix the source document and the answer changes. No retraining.

The last two are why RAG dominates in business settings. An answer you cannot trace to a document is not much use in a support tool.

How it works

  1. Split your documents into chunks.
  2. Convert each chunk to an embedding and store it.
  3. When a question arrives, embed it and retrieve the closest chunks.
  4. Paste those chunks into the prompt alongside the question.
  5. The model answers from the supplied text.

RAG vs. the alternatives

The three ways to make a model know something it doesn't:

RAGFine-tuningLong context
Best forFacts that changeFormat, tone, behaviourOne-off, self-contained documents
Update costEdit the documentRetrainNot applicable
Can cite sourcesYesNoYes
Cost per queryLow — a few chunksLowHigh — you pay for everything, every turn
Handles private dataYesYes, but baked inYes

The common mistake is reaching for fine-tuning to teach a model facts. Fine-tuning teaches a model how to behave, not what is true. If the answer lives in a document, retrieve the document.

What RAG does not fix

RAG grounds answers; it does not guarantee them. It fails in specific, predictable ways:

  • Retrieval misses. If the right chunk isn't retrieved, the model answers from memory anyway — and may hallucinate confidently. Bad retrieval is worse than no retrieval, because the answer looks sourced.
  • Chunking destroys context. A paragraph severed from its heading may be retrieved into a context where it means something different.
  • Similarity isn't relevance. A chunk about the right topic can state the opposite of what's needed. Embeddings handle negation poorly.
  • Conflicting sources. Given an outdated and a current policy, the model has no reliable way to know which wins unless you tell it.

Most "RAG doesn't work" complaints are retrieval problems wearing a costume. If the system is answering badly, look at what it retrieved before you blame the model.

What we addedA direct comparison of RAG against fine-tuning and long-context prompting, with the failure modes RAG does not fix.

This article was researched and drafted with AI assistance from the sources listed below, then checked and edited by Fiqhro Dedhen before publication. How we work.

Sources

3 cited · 3 primary

  1. 1
    PrimaryarXiv (Lewis et al.)
    Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks

    The 2020 paper that named and defined the technique.

    arxiv.org · accessed 17 Jul 2026

  2. 2
    PrimaryHugging Face
    RAG

    Reference implementation and documentation of the original architecture.

    huggingface.co · accessed 17 Jul 2026

  3. 3
    PrimaryGoogle (Gemini API Docs)
    Embeddings

    Vendor docs for the retrieval step RAG depends on.

    ai.google.dev · accessed 17 Jul 2026

Primary sources are the company, paper or repository itself. Reporting is established press, used to corroborate. Community is used to find stories, never to establish facts.