6 min read
RAG in AI, Explained With a Customer Support Example
RAG lets an AI model look up your own documents before it answers. Here is how it works, a support example step by step, and three things people get wrong about it.
By AssistBot Team
Ask around and you'll hear that an AI chatbot which knows a company's refund policy must have been trained on that policy, the way the underlying model was trained on public text. Usually nothing of the sort happened. RAG, short for retrieval-augmented generation, is a method in which the AI looks up the passages most relevant to a question at the moment it is asked, then writes its answer from those passages. The model itself never changes. What changes is what it gets to read before it replies.
The name comes from a 2020 paper by Patrick Lewis and colleagues at Facebook AI Research, "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks". Today people use "RAG" for the general pattern rather than that paper's exact design, and it sits behind most AI tools that answer from a company's own documents.
How it works
A RAG system has two phases. One happens once, ahead of time. The other happens every time someone asks something.
Ahead of time: building the library
- Collect the material the AI should answer from: web pages, PDFs, help articles, policy documents.
- Split it into chunks of a paragraph or a few paragraphs. Small pieces let the system hand over the part that matters instead of a whole manual.
- Index each chunk so it can be found by meaning. The usual approach turns each chunk into an embedding, a long list of numbers that places text with similar meaning close together, and stores those in a search index, often called a vector database. Many systems also keep an ordinary keyword index alongside it, because exact terms like product codes are easier to match that way.
Every question: retrieve, augment, generate
- Retrieve. The question is turned into an embedding the same way, and the system pulls the chunks closest in meaning. "Can I send it back?" finds the returns paragraph even if that paragraph never uses the words "send it back".
- Augment. Those chunks are placed into the prompt with instructions, typically something like "answer using only these passages, and say so if the answer isn't there".
- Generate. The large language model (LLM) reads the passages and writes the reply.
That also answers a common question about RAG and LLMs. The LLM is the writer. Retrieval is the assistant who hands it the right pages first. RAG describes how an LLM gets used; the model underneath is the same one.
A customer support example
Take a hypothetical online shop that sells ceramic planters. Its library holds three sources: a shipping page, a returns page, and a care guide in PDF. A customer opens the chat and types: "My pot arrived cracked. Do I have to pay to send it back?"
| Stage | What happens |
|---|---|
| Retrieve | The top three chunks come back: the "Damaged on arrival" paragraph from the returns page, the "Return shipping costs" paragraph from the same page, and a care guide paragraph about frost cracks |
| Augment | The question and the three chunks go into the prompt, with an instruction to answer only from them |
| Generate | The model writes a reply grounded in the damaged-on-arrival rule |
The prompt the model receives looks roughly like this (an illustration, not any product's real prompt):
Answer the customer using only the passages below.
If they don't contain the answer, say you'll pass the question to the team.
[1] Damaged on arrival: If an item arrives broken, email a photo within
14 days of delivery. We send a replacement or refund. No need to return it.
[2] Return shipping costs: For change-of-mind returns, the customer pays
return postage. We cover it when the item was faulty or damaged.
[3] Frost: Unglazed pots can crack if left outside below freezing...
Customer: My pot arrived cracked. Do I have to pay to send it back?
And the answer comes out along these lines: "Sorry it arrived broken. You don't need to send it back at all. Email us a photo within 14 days of delivery and we'll send a replacement or a refund, whichever you prefer."
Two things are worth seeing here. Without retrieval, the model would fall back on what shops in general tend to do and might confidently describe a return process this shop doesn't have. With retrieval, the reply follows the shop's own policy, and when that policy changes, the shop edits one page. Nobody retrains anything.
Second, the frost paragraph was retrieved even though it doesn't help. Retrieval returns what is close in meaning, which is not always what is useful. A well-written instruction and a capable model will ignore it. Messy source material makes that harder.
Three misconceptions
"With RAG, the AI can't make things up"
RAG cuts down invented answers a great deal, but it doesn't remove them. A model can misread a passage, merge two passages into a rule that exists in neither, or fill a gap when retrieval came back with nothing useful. The fixes are unglamorous: tell the model plainly what to do when the answer is missing, write sources that say one thing clearly, and test with the questions customers really send.
"ChatGPT is a RAG system"
ChatGPT is an assistant built on an LLM. When it searches the web or reads a file you've uploaded before answering, it is doing retrieval-augmented generation in that moment. When it answers from what the model already learned, it isn't. RAG is a technique that products switch on when they need it.
"Long context windows have made RAG obsolete"
Newer models can read very long inputs, so why not paste in everything? For a small, stable set of documents, that can work. But every question then pays to process the whole pile, and models tend to make less use of details buried in the middle of a long input, a pattern described by Nelson Liu and colleagues at Stanford in "Lost in the Middle" (2023). Retrieval stays useful as a filter that puts the right paragraph in front of the model.
When RAG matters, and when it doesn't
It matters when:
- the right answer depends on facts specific to you, such as prices, policies, product details or opening hours
- those facts change more often than anyone would retrain a model, which for a small business means all the time
- you want to know which source an answer came from, so you can fix the source when an answer is wrong
It doesn't help much when:
- the task is general writing, like rewording an email or brainstorming names
- the answer lives in a live system rather than a document. "Where is order 4471?" needs a lookup against your order system. A PDF of your shipping policy can't answer it
- the knowledge is so small and stable that it fits in a prompt as it is
For website support, most of the work sits on the library side, and you don't have to build the pipeline to get it. AssistBot lets you crawl your site and choose the pages to keep, upload PDF, Word, TXT or Markdown files, paste text, and write your own question and answer pairs, then answers visitors from that material. The setup is described on the knowledge sources page. The lever you control is the content itself: one clear paragraph per policy beats a long page where the answer hides in the fourth sentence.
If you're weighing up a chatbot built on this pattern, the RAG chatbot post covers what goes into one, and build vs buy covers whether to write it yourself.