# What is RAG (retrieval-augmented generation) and how it works, with examples

> What RAG (retrieval-augmented generation) is, how it works step by step, a field service example, its limits and how it differs from fine-tuning.

Joaquín Tenés · 2026-11-13 · https://delegic.com/en/glossary/rag

It’s what lets an AI agent quote your company’s call-out fee, say who’s on call this weekend or tell a customer what was replaced on their boiler last month, things no model knows out of the box. Here’s what it is, how it works, a field service example and where it fails.

## In short

-   RAG stands for retrieval-augmented generation: first it searches (retrieval), then it writes the answer (generation).
-   A language model knows what it read during training, not what’s in your company. RAG gives it your documents at the moment it answers.
-   It works in four steps: the question comes in, the documents are searched, what was found is put together with the question, and the answer is written.
-   It reduces made-up answers but doesn’t eliminate them: a Stanford study measured 17% to 33% in commercial tools built on RAG.
-   It isn’t fine-tuning: RAG doesn’t change the model, it gives it what to read for each answer.

## What is RAG?

A language model, the engine of any AI agent, learns by reading an enormous amount of text. What wasn’t in that text, it doesn’t know: neither what happened after it was trained nor anything inside your company. If you ask anyway, it answers with what seems most likely, and sometimes it makes things up. That’s called a [hallucination](/en/glossary/ai-hallucinations).

RAG solves this without touching the model. Before answering, the system searches a chosen collection of documents (your procedures, the equipment manuals, the records in the ERP), pulls out what relates to the question and puts it in front of the model along with the question. The model no longer answers from memory: it answers by reading.

The name comes from a paper by researchers at Facebook AI Research, University College London and New York University, [published in 2020](https://arxiv.org/abs/2005.11401). What they proposed was combining two memories: the model’s own, which holds what it learned in training, and an external one, which is consulted for each answer and can be changed without retraining anything.

Lewis et al., “Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks”, 2020, on [arXiv](https://arxiv.org/abs/2005.11401).

## Why does a company need it?

Because what makes an agent useful in a field service company isn’t what it knows about the world, but what it knows about you. Almost everything a customer asks is answered by something written down somewhere in the company:

-   **What a procedure says:** whether a boiler with no hot water on a Saturday is an emergency, what the call-out fee is and who’s on call.
-   **What the ERP says:** whether this customer has a contract, what equipment they have and what was done on the last visit.
-   **What a manual says:** what an error code means on a specific model and what the customer can safely check.

Without RAG, the agent would answer with an average rate from the internet or with what “a company” usually does. With RAG, it answers with yours. And when a document changes, the next answer already reflects it, with no retraining.

## How does RAG work, step by step?

1.  1The customer asks by phone, WhatsApp, chat or email.
2.  2The agent searches your documents and the ERP for what relates to that question.
3.  3It passes that to the model together with the question and its instructions.
4.  4The model writes the answer from what it has read, and the agent replies.

The step that gives the technique its name is the second one, and everything else depends on it: if the agent doesn’t find the section of the procedure or the customer record it needed, the model will answer anyway, with whatever it has. Done well, it also records which document each fact came from, so it can be checked.

## A field service example

On a Saturday night, a customer of a heating company sends a WhatsApp message. It’s a made-up case that follows the path of a real service request. This is what the agent replies, and where each fact comes from:

The customer, on WhatsApp, on a Saturday at 10:10 p.m.

“The boiler isn’t heating and there’s an error code on the display.”

The agent’s answer

That code usually means low pressure1: could you check the boiler’s pressure gauge and tell me what it reads? Since you have a contract with 24-hour service2, I’m logging this as an emergency3 for the on-call technician, and I’ll let them know it’s the same fault as three weeks ago2.

1.  1**The model’s manual,** error codes section.
2.  2**Your ERP,** the customer record: their contract and their boiler’s history.
3.  3**On-call procedure:** “no heating and under contract means emergency”.

The on-call technician heads out knowing what they’ll find, and the customer already has an answer. None of those facts were in the model. All of them were in the company.

## Which documents work, and which ones spoil the answers

RAG is only as good as what it reads. If a procedure is out of date, the agent will quote last year’s rate with complete confidence, and with its source.

**What works:** one procedure per topic (on-call, rates, areas, emergencies), a single current version of each thing, manuals as PDFs with real text, customer data read from the ERP at the time, and clear sentences like “no heating and under contract means emergency”.

**What spoils the answers:** an 80-page document that mixes everything, two rates without saying which one applies, crooked scans, a six-month-old Excel copy of the ERP and phrases like “depending on the case” or “the supervisor decides”.

The rule of thumb: if a new person in the office couldn’t answer by reading that document, the agent can’t either.

## The limits of RAG: it doesn’t eliminate hallucinations

RAG greatly reduces made-up answers, but it doesn’t remove them. The best independent study available was done by [Stanford University’s RegLab in 2024](https://arxiv.org/abs/2405.20362), with more than 200 pre-registered questions put to the legal research tools of LexisNexis and Thomson Reuters, which were marketed as “hallucination-free” thanks to RAG. The result: they got fewer things wrong than a general chatbot, but they made something up between 17% and 33% of the time.

Magesh et al., “Hallucination-Free? Assessing the Reliability of Leading AI Legal Research Tools”, 2024, on [arXiv](https://arxiv.org/abs/2405.20362). Published in 2025 in the Journal of Empirical Legal Studies.

The failures of a RAG system are almost always one of these three:

-   **It doesn’t find the passage it needed** and answers with what it has, which wasn’t it.
-   **It finds an old or wrong one**, because there were two versions of the same document.
-   **It finds it but misreads it**: it mixes two sections or draws a conclusion the text doesn’t support.

That’s why a serious agent isn’t switched on without first testing it on the company’s real cases, is built to say “I don’t know” and hand over to a person when it can’t find the answer, and keeps a record of what it consulted for each answer, so the office can review it.

## RAG vs fine-tuning vs putting everything in the prompt

There are three ways for a model to know things about your company, and they’re often confused:

| Comparison | RAGThe usual choice in field service | Fine-tuning | Everything in the prompt |
| --- | --- | --- | --- |
| What it is | Finds what’s needed for each answer | The model is retrained with your examples | All the documents are passed with every answer |
| What it’s for | Facts that change: rates, on-call, customers | A fixed style or format | A few short documents |
| When a fact changes | Change the document and that’s it | It has to be retrained | Change the document and that’s it |
| You can see the source | Yes | No | Partly |
| Cost | Low per answer | Expensive to prepare | Grows with every document |

For a field service company the answer is almost always RAG: what the agent needs to know changes every week, and what matters is being able to check where each fact came from. Fine-tuning makes sense for something else, like getting the model to always write in a specific format. More in [what is fine-tuning](/en/glossary/fine-tuning).

## Classic RAG and RAG with an agent

The RAG explained almost everywhere is the classic kind: the documents are split into chunks, each chunk is turned into a list of numbers that represents its meaning (an [embedding](/en/glossary/embeddings)) and stored in a [vector database](/en/glossary#vector-database). When a question comes in, the chunks with the most similar numbers are found and passed to the model.

AI agents have brought another way: instead of searching blindly by similarity, the agent sees an index of what’s there and decides what to open, the way a person would with a binder of procedures. It asks for the document or section it needs, reads it and, if that’s not enough, opens another.

With thousands of documents, similarity search is the only practical way. With dozens, the index has an edge: the agent doesn’t settle for a loose chunk that looks like the question, it reads the whole section that answers it.

## How Delegic does it

Delegic’s agents use the second way. Each company document carries a line saying when to read it, written by whoever writes it (“read this when they ask about prices or the call-out fee”), and long ones are split into sections. The agent reads that index, opens only what it needs for each conversation and looks up the customer and their equipment in your ERP. What it consulted is kept with each conversation. There’s more in [what is an AI agent](/en/blog/what-is-an-ai-agent), and how it applies to service requests in [customer service](/en/solutions/customer-service).

## Frequently asked questions

### What does RAG stand for?

Retrieval-augmented generation: an answer written by an AI model (generation) from information that was searched for first (retrieval).

### Is RAG the same as a chatbot?

No. A chatbot is what talks to the customer; RAG is a way of making what it says come from your documents. A chatbot may or may not use RAG, and an AI agent almost always does.

### Does RAG train the AI on our data?

No. RAG doesn’t change the model: the documents are read at the moment of answering. If a document is deleted, it stops being used in the next answer.

### Does RAG prevent all made-up answers?

No. It reduces them, but a RAG system can miss the fact, find an old one or misread it. That’s why it has to be tested on real cases and made to hand over to a person when it isn’t sure.

### What documents do you need to start?

The ones the office already has: the emergency and on-call procedure, the rates and the service areas. With those and the ERP, most of what customers ask can be answered.

## Related terms

-   [Hallucination](/en/glossary/ai-hallucinations): when the model gives a fact that sounds right but is false.
-   [Large language model (LLM)](/en/glossary/llm): the engine that writes the answer.
-   [Knowledge base](/en/glossary#knowledge-base): the documents the agent reads.
-   [Embeddings](/en/glossary/embeddings) and [vector database](/en/glossary#vector-database): the pieces of classic RAG.
-   [Context window](/en/glossary#context-window): how much text the model can read at once.
