Skip to content

RAG in plain English: how AI looks things up before it answers

Retrieval-augmented generation is the most common way to connect AI to an organization’s own documents. How it works, why it reduces made-up answers, and where it still goes wrong.

Priya Natarajan

3 min read

A wooden chest of drawers with round knobs against a white wall

If you have used a chatbot that answers questions about a company’s help center, searches your files or cites the web pages it used, you have probably used retrieval-augmented generation, or RAG. It is the most common technique for connecting AI models to information they were not trained on, and once you understand how it works, you will understand a lot about why these systems succeed and fail.

The problem RAG solves

A language model knows only what was in its training data, and that knowledge stops at a cutoff date. It has never seen your internal policies, last week’s sales figures or the manual for the product you launched yesterday. Retraining the model every time something changes would be slow and expensive. RAG offers a shortcut: instead of teaching the model new facts, you look them up and hand them over at the moment of the question.

The approach was named in a 2020 paper led by researchers at Facebook AI Research, and it has since become a standard pattern.

How it works, step by step

  1. Prepare the documents. Your source material is split into chunks, often a few paragraphs each.
  2. Turn chunks into embeddings. Each chunk is converted into an embedding, a list of numbers that captures its meaning. Chunks about similar topics end up with similar numbers, even if they use different words.
  3. Store them in an index. The embeddings go into a database built to find similar vectors quickly.
  4. Search at question time. When someone asks a question, the question is turned into an embedding too, and the system retrieves the chunks closest to it in meaning.
  5. Answer with the evidence. The retrieved chunks are placed in the model’s prompt along with the question and an instruction such as “answer using only the sources below, and cite them.”

The model is still doing what it always does, predicting text, but now it is predicting from relevant evidence sitting right in front of it rather than from hazy memory.

Why it helps

  • Fewer made-up answers. Grounding a model in real documents substantially reduces hallucination, especially for specific facts.
  • Fresh information. Update the documents and the answers update with them. No retraining required.
  • Citations. Because the system knows which chunks it used, it can show you where an answer came from, so you can check it.
  • Access control. A well-built system retrieves only the documents the person asking is allowed to see.

Where it goes wrong

Most RAG failures are search failures. If the right passage is never retrieved, the model cannot use it, and it may fill the gap with a plausible guess. Common culprits include:

  • Bad chunking. Splitting a document in the wrong place can separate a question from its answer, or a table from its headings.
  • Meaning-only search. Embedding search is good at concepts but can miss exact terms like product codes or names. Many systems combine it with old-fashioned keyword search, an approach called hybrid search.
  • Too much or too little context. Retrieve too few chunks and the answer is incomplete. Retrieve too many and the important one gets lost among the rest.
  • Untrusted content. If retrieved documents contain hidden instructions, a model may follow them. This attack, called prompt injection, is a real security concern for systems that read web pages or emails.

Does long context make RAG obsolete?

As context windows have grown to hundreds of thousands of tokens and beyond, some have predicted the end of RAG. Why search when you can paste in everything? For a single long document, that often works well. But most organizations have far more text than any context window can hold, and paying to process all of it for every question is slow and expensive. In practice the two approaches complement each other: retrieval finds the relevant material, and a long context window lets the model consider more of it at once.

Questions to ask about any RAG system

  1. Does it show its sources, and do the sources actually support the answer?
  2. What happens when it cannot find anything relevant? A good system says so.
  3. How fresh is the index, and how quickly do changes appear?
  4. Has anyone measured how often it retrieves the right material, not just how fluent the answers sound?

RAG is not glamorous, but it is often the difference between an AI that sounds knowledgeable and one that can show its work.

Filed underTools

Written by

Priya Natarajan

Staff writer

Priya writes hands-on guides to using AI tools well, and reports on how AI is reshaping media, trust and the information we see online.

Keep reading

More from Long Context

A dirt road running into a hazy desert valley between red rock cliffs
Research

Why AI models still make things up

Hallucinations are not a glitch that one more update will patch. They fall out of how language models are trained and how we grade them. Here is what causes them, and what actually helps.

Daniel Reyes3 min read

Abstract web of fine glowing threads in pale pink and lavender against a blue background
Explainers

How large language models actually work

Tokens, embeddings, attention and a lot of next-word guessing. A plain-language tour of what happens between your prompt and the model’s reply, with no math required.

Maya Okafor3 min read

The newsletter

Understand AI, one clear idea at a time.

New explainers and research breakdowns, written in plain language and delivered to your inbox. No hype, no spam.

  • Free to read, always
  • Sources linked, claims checked
  • Unsubscribe in one click