AI Hints
Home›Generative AI Tutorial›Search by Meaning and RAG
Generative AI · Lesson 36 of 77

Retrieval Augmented Generation

Give the model your own knowledge.

⏱ 2 min read▶ Video at 1:23:40🎓 Free
Watch this lesson in the Generative AI courseWatch on YouTube ↗Full Generative AI course

A language model does not know your company's documents, your private notes, or yesterday's news. And it may invent answers, instead of admitting that. Retrieval augmented generation, or R A G, solves both problems. It is the most widely used pattern for useful A I apps, and you are ready to understand it.

Retrieval Augmented Generation
From the video: Retrieval Augmented Generation
  • The model does not know your documents
  • RAG: look it up first, then answer
  • The most popular AI app pattern

The RAG pipeline

Here is the pipeline. A user asks a question. We turn the question into an embedding, and search the vector database, for the most relevant chunks. We then build a prompt, that contains the question, and those chunks, with the instruction, answer using only this information. The model writes an answer, grounded in your documents, and can mention its sources. Look it up first, then answer.

  1. Questionthe user asks
  2. Retrievefind the best chunks
  3. Augmentput them in the prompt
  4. Generateanswer from the sources
Look it up first, then answer
The RAG pipeline
From the video: The RAG pipeline

A RAG answer

Here is how it looks to a user. They ask, what is the refund period for online orders? The system finds the matching paragraph in the company policy. The model answers, you can return online orders within thirty days, and it points to the document it used. Without retrieval, the model would have guessed. With retrieval, it reads the real policy.

Company assistant
YouWhat is the refund period for online orders?
AIYou can return online orders within 30 days of delivery for a full refund. (Source: Returns Policy, section 2)

Why do so many teams choose R A G? It uses fresh information, because you can update the documents any time, without retraining. It reduces hallucinations, because the answer comes from real sources. It shows its sources, so people can verify. It keeps private data in your control. And it is far cheaper than training a new model. For most business uses, R A G is the first thing to try.

Without RAG

  • Only knows its training data
  • May invent answers
  • Cannot see your documents
  • Out of date

With RAG

  • Reads your latest documents
  • Answers grounded in sources
  • Can cite where it looked
  • Update with no retraining

Summary

Excellent. R A G retrieves relevant chunks, adds them to the prompt, and asks the model to answer from them. It keeps answers fresh, grounded, and traceable. Next, we look at what goes wrong in real R A G systems, and how to fix it.

Key takeaways
  • RAG = retrieve, augment, generate
  • Grounded in your documents
  • No retraining needed
Next up: Making RAG Work — common problems and fixes