Skip to content
AI|Course

Stage 2 · Build · Intermediate

Chat with Your Documents (RAG)

Build an assistant that answers from your own documents and shows its sources. Prepare and chunk documents, search with embeddings, keyword search and reranking, generate cited answers that decline when the documents do not say, and measure retrieval and answers with a test set you can re-run.

7 lessons · 13 hr · Free

You will learn to

  • ▸Explain how RAG works and decide between RAG, long context and other approaches
  • ▸Load, clean and chunk documents, keeping the metadata you need for citations and access control
  • ▸Build semantic search with embeddings and understand where it fails
  • ▸Compare keyword, embedding, hybrid and reranked retrieval using measurements
  • ▸Generate answers with citations, decline when the sources do not contain the answer, and defend against injected instructions
  • ▸Build a test set, evaluate retrieval and answers separately, and find the cause of a failure

Before you start

  • ·Comfortable with Python and the Claude API, as taught in Build with LLM APIs
  • ·Machine Learning Basics is helpful for thinking about evaluation, but not required
  • ·A computer that can download a small embedding model (about 100 MB), and API credit for the answer-generation calls

Syllabus

  1. 01What RAG is and when to use itThe problem, the two phases, a tiny RAG, and RAG versus long context.1 hr
  2. 02Preparing documentsLoading, metadata, chunking strategies and keeping an index in sync.1 hr 30 min
  3. 03Embeddings and searchEmbeddings, a vector index from scratch, filters and where search surprises you.1 hr 30 min
  4. 04Better retrievalKeyword search, hybrid search, reranking, query rewriting and context.2 hr
  5. 05Generating grounded answersCitations with search results, declining, follow-ups and injected instructions.1 hr 30 min
  6. 06Evaluating RAGTest sets, retrieval and answer measures, judges and finding failure causes.1 hr 30 min
  7. 07Capstone: an assistant for your documentsBuild, test and evaluate a complete cited-answer assistant.4 hr