25
Lesson 25 · 2 min
RAG: give AI your documents
RAG lets a chatbot look up the right pages in your own documents before it answers, so it can use facts it was never trained on.
A model only knows its training data. It does not know your company handbook, your school's rules or last week's prices.
Retrieval-augmented generation, or RAG, fixes this in two steps. First, it searches your documents for the most relevant passages, usually with embeddings stored in a vector database. Second, it gives those passages to the model with your question.
The model then answers using that text, and good systems show which document each answer came from. This reduces hallucination and keeps answers up to date.
You already use RAG when you upload a PDF to a chatbot, or use a company help bot. It is only as good as the documents it finds.
Do it now
Make a mini RAG yourself
- 1.Upload a document you know well to a chatbot: a manual, a policy or a long article.
- 2.Ask a question with the prompt below.
- 3.Check whether the quoted part really exists in your document.
Using only the document I uploaded, answer: [YOUR QUESTION]. Quote the exact part you used. If the document does not answer it, say so instead of guessing.
Words from this lesson
- RAG
- Having an AI look up relevant passages from your documents first, then answer using them, so replies are more accurate.
- Embedding
- A list of numbers that captures what a piece of text or image means, so similar meanings get similar numbers.
- Vector database
- A database that stores embeddings so a system can quickly find the items closest in meaning to a question.
- Hallucination
- When an AI states something false with confidence, such as a made-up fact, quote or source.
- Training data
- The examples, such as text, images or recordings, that a model learns its patterns from.