What Is RAG
Retrieval-augmented generation (RAG) is a way of answering questions in which the system first retrieves relevant passages from your own documents and then has a model generate an answer from those passages. It is used when answers must come from information the model never saw in training: internal policies, product manuals, school rules or yesterday's update.
A model doesn't know your organization's documents. RAG doesn't teach it them; it hands the model the right page at the moment of the question, like an open-book exam.
The Problem RAG Solves
Srihitha, a teacher, is taking students to a science fair in October and asks: "Can I claim my hotel for the trip?" The answer is in the school district's staff travel reimbursement policy, a document no public model has ever read.
| Without RAG | With RAG | |
|---|---|---|
| What the model knows | Its training data only | Training data plus the retrieved passages |
| Answer about your policy | A general guess, sometimes wrong | Based on your document |
| Can show a source | No | Yes, the document it used |
| When the policy changes | Still the old or general answer | Update the document; answers follow |
The RAG Pipeline
- Question: a person asks in their own words.
- Search: the system searches your documents, usually with embeddings (see the previous chapter).
- Retrieve: it takes the few most relevant passages.
- Augment: it sends those passages to the model with the question and rules such as "answer only from these".
- Generate: the model writes the answer.
- Cite: the answer shows which documents it came from.
Where RAG Is Used
| Use | Description |
|---|---|
| Policy and HR assistants | It is used to answer staff questions from internal handbooks |
| Customer support | It is used to answer from product manuals and help articles |
| School and government services | It is used to answer fee, admission and form questions from official documents |
| Research and legal work | It is used to find and quote relevant passages from large collections |
Common Mistakes
Expecting RAG to fix bad documents. Outdated or conflicting documents produce outdated or conflicting answers.
Skipping the "answer only from these" rule. Without it, the model may mix in general knowledge.
Hiding the sources. People need to see where an answer came from to trust it and check it.
Interview Corner
What is retrieval-augmented generation?
A pattern where relevant passages are retrieved from your documents and given to a model, which answers from them and cites them. It grounds answers in information the model wasn't trained on.
Does RAG make answers correct?
No. It makes them grounded in retrieved text, which helps a lot, but wrong retrieval or wrong documents still produce wrong answers. Test retrieval and keep sources visible.
Practice
Exercise: map a RAG idea. Pick a document set you know, such as a club's rules or a product manual. Write five questions a person might ask, find each answer in the documents by hand, and note any question the documents can't answer.
Check your understanding:
- What does the "retrieval" step do?
- Why can't a model answer from a private policy without RAG?
- What happens when the retrieved passage is wrong?
Key Takeaways
Quick reference
| Step | What happens |
|---|---|
| Retrieve | Find the closest passages |
| Augment | Add them to the prompt |
| Generate | The model answers from them |
| Cite | Show the source documents |
Was this tutorial helpful?