Retrieval-Augmented Generation Tutorial
Ground a language model in your own documents: chunk, embed, retrieve, assemble and evaluate
Intermediate4 lessonsabout 23 min of reading
This course is for developers and data-minded engineers who know the basics of calling a language model and now need it to answer questions about documents it was never trained on: a handbook, a policy library, a product catalogue. It assumes you have read the basics of Large Language Models and Prompt Engineering, or already know them. The code is pure Python and runs with no account, key or download.
You will be able to decide when retrieval is the right tool and when fine-tuning or plain prompt stuffing is better, split documents into sensible chunks, understand what an embedding is by building a toy one, retrieve and rank passages with filters and thresholds, assemble a prompt that cites its sources and admits when it does not know, and measure retrieval and answer quality separately so you can tell which half is broken.
The lessons follow the pipeline in the order data flows through it: why and when, then chunking and embeddings, then retrieval and prompt assembly, and finally evaluation and the failure modes that cause most real-world disappointments.
Retrieval-Augmented Generation lessons
- 1Why RAG? Retrieval-Augmented Generation vs Fine-Tuning ExplainedWhy retrieval-augmented generation exists, how the RAG pipeline works, and a clear decision guide for RAG versus fine-tuning versus pasting documents in.5 min read
- 2RAG Chunking and Embeddings: Build a Toy Vector Search in PythonRAG chunking and embeddings explained: split documents into overlapping chunks, build a toy TF-IDF vector search in Python and see how real embeddings differ.6 min read
- 3RAG Retrieval, Ranking and Prompt Assembly with CitationsRAG retrieval and ranking in practice: top-k, thresholds, hybrid search, re-ranking, recency, and assembling a prompt that cites sources and admits uncertainty.6 min read
- 4Evaluating RAG: Retrieval Metrics, Faithfulness and Failure ModesHow to evaluate RAG: measure retrieval with recall@k and MRR, check answer faithfulness, and diagnose bad chunks, stale data and lost context in a pipeline.6 min read
Preparing for an interview? Practise Generative AI & LLMs interview questions
Learning Retrieval-Augmented Generation to land a job? Browse open roles or check which skills are trending.