Skip to content

3.10 — RAG: connect the agent to YOUR documents

An agent is smart, but it does not know your documents: your internal procedures, your product catalogue, your reports. RAG gives it a documentary memory: it first searches the right passages in your content, then answers based on them.

🟢 In plain terms — RAG stands for Retrieval-Augmented Generation. In other words: before answering, the AI searches the useful passages in your documents, then writes its answer from them. It doesn’t “know” your docs by heart — it looks them up on every question.

📚 The open-book exam analogy. Without RAG, the AI answers from memory — and may make things up (hallucinate). With RAG, you open the right binder at the right page: it reads YOUR document, then answers. The knowledge stays in your binder, not in its head.

RAG comes down to three steps (the first done once, the other two on every question):

  • 1. Prepare (once) — your documents are split into small chunks and indexed by meaning (a kind of “meaning map”, called embeddings).
  • 2. Retrieve (every question) — you find the chunks whose meaning is closest to the question — not just keyword matches.
  • 3. Answer — those chunks are slipped into the prompt: the AI answers based on them, and can cite its sources.

🔎 A question’s journey: Question ❓ → 🔎 search the base → 📄 relevant passages → 🤖 grounded answer (+ sources)

🧪 Try it — ask a fictional shop’s support a question: compare the from-memory answer (without RAG) with the answer grounded in the docs (with RAG), and see which passages get retrieved.

RAG Search— searches your docs, then answers
Ask the support a question

Pick a question above to see RAG in action.

⚠️ Educational simulation in your browser (no AI, no real vector database). "Similarity" here is a plain shared-word count; a real RAG compares *meaning* (embeddings).

🧩 Concrete example — a customer-support agent connected to your FAQ and procedures base. To “how do I cancel my order?”, it retrieves the exact procedure and answers “per the ‘Cancellation’ procedure, step 2…” — instead of making up a plausible but wrong answer.

Why it’s a turning point for an agent:

  • Fewer hallucinations: the answer relies on real text, not the model’s fuzzy memory.
  • Always up to date: you update your documents, not the model. No retraining.
  • Verifiable: the agent cites where the information comes from.

🔧 Link to tools (3.2) — RAG is often the first “tool” you connect to an agent: search_my_documents(question). In no-code (Make/n8n) it takes the form of a “knowledge base / vector store” node; via MCP (3.3), a documentary resource exposed to the agent.

⚠️ Common mistake — confusing RAG with training the AI on your data (fine-tuning). RAG does not modify the model: it gives it the right excerpts at the right moment. It’s cheaper, more up to date and more controllable than retraining — and it’s the first reflex for most business cases. (Fine-tuning mostly changes the style or format of an answer, not the knowledge.)

Check your understanding — your agent must answer from your 200 pages of internal procedures, which change often. Fine-tuning or RAG?

See the answer

RAG. Your procedures change (RAG updates by editing the documents, no retraining), you want cited sources (verifiable), and you’re adding knowledge, not a style. Fine-tuning would be more expensive, quickly outdated and not verifiable.

In short

  • RAG = search YOUR documents first, then answer based on them.
  • 3 steps: index your docs → retrieve the useful passages → answer (+ sources).
  • Benefits: fewer hallucinations, up to date without retraining, verifiable.
  • ≠ fine-tuning: RAG adds knowledge without touching the model.

🔍 Going further (tech). Chunks are turned into vectors (embeddings) stored in a vector database; search compares the vectors (meaning similarity). Advanced topics: smart chunking, passage re-ranking, and above all evaluating your RAG (is the answer faithful to the sources? are the right passages retrieved?). (A “minimal RAG, no API key” notebook is planned for technical profiles.)

How would you rate this lesson?
📝 My note

A training byBaxIA