AI Retrieval Augmented Generation Tutorial: RAG Basics

TL;DRRAG (retrieval-augmented generation) feeds an LLM relevant documents so it answers from real sources.

LLMs have a fixed knowledge cutoff and hallucinate on specifics. RAG retrieves relevant documents (from your data) at query time and puts them in the prompt, so the model answers grounded in real, current, citable sources. It's the standard way to build "chat with your docs / knowledge base" — cheaper and more current than fine-tuning, and it lets you cite where answers came from.

Key points

Common mistakes

Try it: Explain why RAG beats fine-tuning for answering from a changing knowledge base.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>question → retrieve top docs → put in prompt → LLM answers
grounded + current + citable
(no retraining when docs change)</pre></body></html>
Open the interactive lesson →
Self-Consistency · Sample and Vote RAG · Vector Stores · Embeddings · Chunking