# What is RAG? How AI answers from your own documents

RAG, retrieval-augmented generation, is how an AI app answers from documents the model never read. It finds the right pages, adds them to your question and has the model answer from them. This lesson follows one question through the 4 steps, shows the message the AI really receives, and names the 3 ways it still goes wrong.

- Page: https://tecyfy.com/learn/rag/what-is-rag
- Path: RAG: AI that answers from your documents (https://tecyfy.com/learn/rag), lesson 1 of 2
- Full video (13:14): https://www.youtube.com/watch?v=MSUvVQJTsK0

## A washer error that no AI could answer

Watch this part (1:29): https://www.youtube.com/shorts/C-Y68vJGfRw

A washing machine stops halfway through a wash and its screen blinks E21. The answer is in the manual, somewhere in 60 pages, in a drawer. So you ask an AI instead: "My washer shows E21. What do I do?"

We tried this with ChatGPT, Claude and Gemini on 7 October 2026. None of them could give the steps for this machine. Claude said it had no reliable information about it. ChatGPT looked online, found nothing and would not say for sure. Gemini was certain: E21 is a drain problem, here are 3 steps. That was a fair guess, but it was built from a general video about washing machines, not from this machine's manual.

They could not have known. The washer, the Sudsley S7, is one we made up, with a manual we wrote ourselves. No model has read it. Your own documents are in the same position: a company handbook, last week's meeting notes, a manual from a small brand. They are private, or newer than the model, or both. A model learned from what was public before its [knowledge cutoff](https://tecyfy.com/concepts/knowledge-cutoff), as [How AI learns](/learn/how-ai-works/how-ai-learns) explains, and your files were never in that pile.

So hand it the right page at the moment you ask. That is [RAG](https://tecyfy.com/concepts/rag).

## RAG is an open-book exam

Watch this part (1:15): https://www.youtube.com/shorts/JhvqTRoHKqo

2 students sit the same exam. One has the book closed and works from memory, so a question they never learned gets a guess. That is a model on its own. The other has the book open. They read the question, find the right page, read it and write the answer in their own words.

RAG hands the AI the open book. The letters stand for retrieval-augmented generation. Retrieval finds the right pages. Augmented means they are added to the question. Generation is the model writing the answer.

Notice what does not change: the student. Nobody retrains the model, the part that writes the answers. It knows exactly what it knew before and gets the right page at the right moment. That is why RAG is easy to keep current. A new manual next month means new pages, not a new model.

One word from here on. Everything the model reads before it answers, your question and whatever is added to it, is its context. How much fits at once is the [context window](https://tecyfy.com/concepts/context-window).

## Why not paste the whole manual?

Watch this part (1:27): https://www.youtube.com/shorts/ATIbKDXxvlU

For a 60-page manual, pasting it all into the chat often works. Some models now take 1 million [tokens](https://tecyfy.com/concepts/token) or more, and a token is a small piece of text, a few letters long. A useful line for builders: under about 200,000 tokens, roughly 500 pages, you can put the whole thing in the prompt. With [caching](https://tecyfy.com/concepts/prompt-caching), where the provider keeps what it has already read for a while, sending it again with every question costs much less.

A company's documents are rarely 60 pages. Every manual for every machine it has sold, the help articles, the repair notes: thousands of pages, changing every week. AI is paid for by the token, so pasting all of it into every question means paying for all of it to be read every time. More is not always better either. When a model has to find several specific facts in a huge pile, it gets less accurate.

The rule of thumb: small and stable, hand it everything. Big or changing, hand it only the pages that matter. Finding those pages is RAG's job, in 4 steps.

## Step 1: prepare the documents

Watch this part (1:28): https://www.youtube.com/shorts/IX_NqRaHCJk

The first step happens once, before anyone asks anything. The manual is cut into pieces of a few paragraphs, like index cards. Builders call them chunks, and the step is [Chunking](https://tecyfy.com/concepts/chunking). The point is to hand the model later just the part that matters, not the chapter around it. One card holds the error-code table from page 34. Another holds the drain-filter steps from page 41.

Each card then gets an [Embedding](https://tecyfy.com/concepts/embedding), a code that captures what the card is about. It lets the system find cards by meaning, not only by matching the exact words, which is called semantic search. An embedding is a long list of numbers, a vector, so the cards and their embeddings are filed in a [vector database](https://tecyfy.com/concepts/vector-database), an index built for this job. Cards about similar things get similar embeddings. How that works is the subject of [how RAG search works](/learn/rag/how-rag-search-works).

A new manual goes through the same step: chunk it, embed it, file it. Nothing is retrained.

## Step 2: retrieve the closest pages

Watch this part (1:16): https://www.youtube.com/shorts/XudqWLyUNyU

The second step happens every time someone asks. The question "My washer shows E21. What do I do?" gets an embedding made the same way as the cards'. The system then finds the cards whose embeddings are closest to it, which is [similarity search](https://tecyfy.com/concepts/vector-search): the 2 lists of numbers are compared, and the more alike they are, the closer the meaning.

It keeps the closest few. How many is a setting builders call top-k, here 3: the error table from page 34, the drain filter from page 41, and page 39 on pump noises, which is close but not what we need. That is normal. The search returns what is closest, not what is correct, and the model sorts out the rest. Because it compares lists of numbers instead of reading pages, it is fast, even across thousands of pages.

## Step 3: the message the AI really receives

Watch this part (1:14): https://www.youtube.com/shorts/ih2VpxrNnUc

This is the step almost nobody shows. The app builds one message, the prompt, in 3 parts. First, instructions: "Answer the customer's question using only the pages below. Say which page you used. If the answer isn't in these pages, say you don't know." Then the 3 cards, each with its page number. Then, at the end, the question.

That is the "augmented" in RAG: the question, the pages and the rules for using them. It is all plain text. The model gets no special access to your files, only what is written into this prompt.

Each rule narrows a gap. "Only from these pages" tells the model not to fill gaps from what it learned in training, which cuts down how often it does. "Say which page" lets you check its work. "Say you don't know" gives it a way out instead of a guess. Leave them out and you have handed over the right pages without asking the model to stick to them.

## Step 4: an answer you can check

Watch this part (1:21): https://www.youtube.com/shorts/cTxwsl58JIQ

The model writes: "E21 means the water isn't draining. Switch the machine off, open the small flap at the bottom right, and unscrew the drain filter to clear it. See pages 34 and 41." It used 2 of the 3 cards and left the pump page out. Picking what matters from a few pages is something these models do well.

Now you can check it. Page 34 says E21 is "drain blocked". Page 41 has the filter steps. An answer built from pages you supplied, and traceable back to them, is [grounded](https://tecyfy.com/concepts/grounding). At the start the same kind of model gave a polite "I don't know" or a confident guess from other machines. The difference is these 4 steps.

When we gave the same 3 apps the whole manual, all 3 got E21 right. For 60 pages, handing over everything works. For thousands, you need the 4 steps.

## Where you already use RAG

Watch this part (1:00): https://www.youtube.com/shorts/_b9SaddPa7A

Claude projects make the paste-or-search choice for you. While a project's files fit in the context window, Claude reads all of them. As they approach the limit, it switches on its own to a search tool that retrieves just the relevant parts, and a project can then take in up to 10 times as much. ChatGPT also takes uploaded files and answers questions about them.

If you build apps, you do not have to make every step yourself. Gemini's File Search and OpenAI's file search do the cutting, embedding and searching for you, and their answers come with citations, like our page numbers. [Build a RAG](/learn/rag/build-a-rag) compares that with building your own.

A help chat that answers and points you to an article may well be doing the same thing.

## 3 ways RAG still gets it wrong

Watch this part (1:20): https://www.youtube.com/shorts/tSrRB7wDdf8

RAG is a large improvement and not magic. It fails in 3 ways, and knowing them is most of the skill.

**The wrong cards come back.** If the search returns the pump page, the dryer page and the warranty page, the model never sees E21. At best it says it does not know. At worst it guesses.

**The right page was cut badly.** If the cut falls through the E21 row, one card says "E21" and the next says "drain blocked". Neither makes sense alone, and the search may find only one.

**The answer goes beyond the pages.** The model adds a step from memory that is not in your manual, so the answer is no longer grounded. A statement that is wrong, or does not match the pages the model was given, is called a [Hallucination](https://tecyfy.com/concepts/hallucination). The rules and the page numbers are there so you can catch it.

The first 2 are search problems, which is why the search gets [a lesson of its own](/learn/rag/how-rag-search-works).

## The 4 steps, and a quick test

Watch this part (59 s): https://www.youtube.com/shorts/TCxM7NCgR0o

Prepare once: chunk the documents, embed each chunk, store them in a vector database. Retrieve: embed the question and pull back the closest chunks. Augment: instructions, chunks and question go to the model as one prompt. Generate: the model writes a grounded answer with page numbers you can check.

A new question arrives: "How do I set a quick 30-minute wash?" Which step finds the right page? Step 2, retrieve. And which step makes the model say "I don't know" when that page is missing? Step 3, through the instructions it was given.

## RAG makes AI informed, not smarter

Watch this part (48 s): https://www.youtube.com/shorts/sJooXL_ikUo

RAG does not make a model smarter. It makes it informed. Most of the time the answer you need is not something the model should know. It is something your documents already say.

So when an app answers from your files, read it the way you would read a colleague's summary: which pages did it use, and do they say that? An answer with no page you can open is a guess until you check it. An answer that says the pages do not cover your question is the system working as it should.

## What changes for you

It is easy to think an AI app that answers from your files has learned them, or that the model got smarter. In fact the app finds a few pages and pastes them into the prompt next to your question, so when an answer matters, look at which pages it used and open them.

## Try it with your own AI: Be the app for one question

This takes about 5 minutes in any assistant. You do step 3 by hand, so you can see what a RAG app sends and what the rules in it change. Turn web search off if your assistant has a switch; the first prompt also asks it not to search.

1. Send the first prompt in a new chat. It asks about a washer that does not exist, with nothing to read.
2. Send the second prompt in a new chat. It is the message a RAG app would build, with 3 short pages, the rules and the same question.
3. Send the third prompt in the same chat as the second. Its answer is not on any of the 3 pages.

Prompt 1. The closed book

```
My Sudsley S7 washing machine shows error E21. What do I do? Do not search the web.
```

Prompt 2. The open book, as a RAG app sends it

```
Answer the customer's question using only the pages below. Say which page you used. If the answer is not in these pages, say you don't know.

Page 34, error codes: E18 door not locked. E21 drain blocked: the water cannot leave the drum. E24 heater fault, call a technician.
Page 39, noises: a humming pump during draining is normal. A loud rattle can mean a coin in the pump.
Page 41, cleaning the drain filter: switch the machine off. Open the small flap at the bottom right. Put a towel down and unscrew the filter slowly to let the water out. Rinse the filter and screw it back in.

Question: My Sudsley S7 shows E21. What do I do?
```

Prompt 3. A question the pages cannot answer

```
How long is the warranty on the Sudsley S7?
```

What to look for:

- The first answer has nothing to read. Expect "I don't know this model", or a confident general guess about drain errors. Either way it is not this machine's manual, because the machine was made up for the video.
- The second answer should say E21 means a blocked drain, give the filter steps and name pages 34 and 41. The pump page should be left out. Open the 2 pages and check the answer against them.
- If the second answer adds a step that is not on the pages, such as checking the hose, it went beyond them. That is the third way RAG goes wrong, and the reason for the page numbers.
- The third answer should say the pages do not cover it. If it gives a warranty length, it ignored the rule and guessed, which is what the rule is there to catch.

## Check yourself

1. A help chat answers your question about a delivery fee and links to a help article. The fee it states is wrong, and the article it links says the right fee. Which step of RAG went wrong?

   A. Prepare. The article was never cut up and stored, so the search could not find it.
   B. Retrieve. The search returned the wrong article.
   C. Generate. The right page was retrieved, and the answer went beyond what it says.
   D. Augment. The app sent the question without any pages, so the model wrote from memory.

2. Your team keeps one 40-page policy document that changes twice a year. A colleague wants to set up a vector database so an assistant can answer from it. What is the simpler option worth trying first?

   A. Put the whole document in the prompt, and use caching if questions are frequent.
   B. Retrain the model on the document so it knows the policy by heart.
   C. Cut the document into chunks, but skip the embeddings and search by page number.
   D. Ask the assistant without the document, since a policy is common knowledge.

3. You add a new price list to an AI app's documents and delete the old one. What has to happen before its answers use the new prices?

   A. The model has to be retrained on the new list, which takes days.
   B. Nothing. The model reads the list from the shared drive every time you ask.
   C. The model has to forget the old prices first, because it memorised them.
   D. The new list has to be chunked, embedded and filed, the same as every other document.

### Answers

1. C. The linked article holds the right fee, so the search found the right page and it reached the model. The mistake came when the answer was written. A retrieval miss would show a link to the wrong article, and a missing page could not be linked at all.
2. A. A small, stable document fits easily in today's context windows, so the model can read all of it, and caching cuts the cost of sending it again. Search earns its place when the documents are too big or change too often. RAG never retrains the model, and a company's own policy is not something the model learned.
3. D. In a RAG app the documents sit outside the model. A new file goes through step 1 like any other, and from then on the search can return it. Nothing inside the model changes, so there is no retraining and nothing to forget. The model never reads the drive itself. It reads only the pages the app puts in the prompt.

## Sources

1. [Introducing Contextual Retrieval](https://www.anthropic.com/news/contextual-retrieval)
2. [Long context](https://ai.google.dev/gemini-api/docs/long-context)
3. [Reduce hallucinations](https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/reduce-hallucinations)
4. [Retrieval augmented generation (RAG) for projects](https://support.claude.com/en/articles/11473015-retrieval-augmented-generation-rag-for-projects)
5. [File search](https://ai.google.dev/gemini-api/docs/file-search)
6. [File search](https://developers.openai.com/api/docs/guides/tools-file-search)
7. [Uploading files and audio to ChatGPT](https://help.openai.com/en/articles/8555545-file-uploads-faq)
