Your progress — 0 of 13 concepts0%
Next up: What is Artificial Intelligence?
⚙️ How AI WorksIntermediate⏱ 8 min

RAG — Retrieval-Augmented Generation

KEY TAKEAWAY

RAG gives an AI access to external documents before answering — like letting a student use notes during an exam.

💡 EVERYDAY ANALOGY — BEFORE THE TECH
📝

RAG is an open-book exam for AI

Imagine two students. The first relies only on memory — they might confuse facts or make things up. The second is allowed to reference their notes during the exam. They can give precise, accurate answers because they're reading from verified material. RAG turns AI from a memory-only model into a note-checking one: search first, then answer.

👁️ Visual Explanation

1Question2Search3Retrieve4LLM+Context5Answer📄 Document DatabaseVector store — semantic search over your documents

RAG flow: User question → Retrieve relevant documents → Inject into prompt → LLM generates grounded answer

🌍 In Plain English

When you ask an AI a question with RAG, it first searches a database of documents, finds the relevant ones, reads them, and then generates an answer based on what it found. The answer is grounded in real content — not just training memory.

Real-World Example

SumQ uses RAG: when you ask a question, it searches the web first, retrieves current information, and feeds it to the AI model — so the answer is grounded in today's real data, not just the model's training.

🎓 For Students

Upload your lecture notes and ask the AI questions — it reads your notes and answers from them. Your notes become the AI's reference material.

💼 For Professionals

A law firm uses RAG to let lawyers ask questions about contracts. The AI searches the actual contract and answers from it — not from its general legal training.

💬 Example Prompt to Try
"Summarise the key points from the attached document and highlight any risks I should know about."
🔧 Technical DepthOptional — expand when ready

RAG architecture: (1) Documents are split into chunks and converted to vector embeddings. (2) The user's query is also converted to an embedding. (3) Nearest-neighbour search finds the most semantically similar chunks. (4) Those chunks are inserted into the prompt as context. (5) The LLM generates a response grounded in that context.

Key Terms
EmbeddingA numerical representation of text that captures its meaning — similar meanings have similar numbers
Vector databaseA database optimised for finding documents that are semantically similar to a query
GroundingConnecting AI output to real, verified sources to improve accuracy and reduce hallucination
⚠️ Common Misconception

RAG doesn't eliminate hallucination — it reduces it. The AI can still misinterpret retrieved documents or add information not in them.

✅ Quick Quiz

1

What is the key benefit of RAG?

2

The open-book exam analogy for RAG means:

🧑‍🏫 Ask the AI Tutor

✦ TRY THIS IN SUMQ — QUERY PRE-FILLED

See RAG in action — SumQ searches the web before answering to ground its responses →

Query that will be auto-filled:
"Summarise the key points from the attached document and highlight any risks I should know about."
Try in SumQ →
NEXT LESSON →
AI Agents
7 min · Intermediate
Related Concepts
← Back to all concepts