Retrieval-Augmented Generation (RAG)

  • Context
  • Standard term

Retrieval-augmented generation (RAG) is a setup where an AI looks up relevant material, such as documents or database records, at the moment you ask, then answers using what it found.

Ahead of time, the source documents are split into passages and indexed for search. When you ask, the system searches that index with your question, places the best few passages in the request beside it, and the model writes its answer from them.

Where you’ll meet it

Your small online shop has a help bot that answers from your policy pages. A customer asks about returns. The bot finds last year's 60-day policy, worded almost exactly like this year's 30-day page, and answers with confidence.

What to do

Ask whoever set up the bot, or your coding agent, to remove last year's page from the bot's sources and to make each answer show the passage it used. Then ask the bot about returns yourself and check its quote against this year's page.

Easy to mix up

How soon does an update take effect?
Retrieval-Augmented Generation (RAG)Fine-tuning
Once the changed page is indexed againAfter another round of training finishes

Check yourself

Your company's handbook allows dogs in the office on Fridays only. You ask the handbook bot whether you can bring your dog on Tuesday. It says yes, and shows the passage it used, the handbook's “Animals in the workplace” section. Where did the error happen?

Go deeperThe name has grown looser, and each stage needs its own test

Patrick Lewis and colleagues named the method in a 2020 paper that trained a retriever and a text generator together. Today the name covers almost any system that inserts retrieved text into a request, usually with no joint training. Retrieval may use keyword search, embeddings (numbers that place passages with similar meanings near each other), database filters, or a mix.

Each stage gets its own test. Collect questions your users ask, mark the passage that answers each, and measure how often retrieval returns it. Separately, have a person or a second model check each claim in the answer against the passages retrieved for it.

Practice Modern AI

Or take the learning quiz on a mix of every set