Leanpub Header

Skip to main content

AI Engineering Visualized: RAG, The Course

Build RAG answers you can trace to a source, module by module: over 2 hours of video, 100+ doodles, 16 exercises, 16 quizzes and a certificate.

Minimum price

$34.99

$49.99

You pay

Author earns

$

Also available for 1 course credit with a Learner Membership

PDF
EPUB
WEB
About

About

About the Course

Your search found a match. It was an old ticket that said a delivered parcel was still on its way. A better search would still find that ticket: the code around the search decides which sources may answer, and that's what this course builds. You pick up the support assistant for a fictional store, Northwind Goods, and give it real knowledge: source contracts, ingestion with stable ids and provenance, documents with tables and scans, chunks that know where they apply, access checks, hybrid search, reranking, query routing, abstain floors, evidence packs with checked citations, safe SQL, a knowledge graph, index syncs, evals and a regression gate. Each module gives you a short video, a reading lesson, a one-page doodle cheat sheet, a small coding exercise and a quiz. The code runs on Python with a built-in stub model, so you don't need an API key. One knowledge system, built module by module. I wrote this course for developers who have built a retrieval feature and now have to trust its answers: from manuals with tables, from an order database, from past tickets and from rules that change by region. Retrieval only proposes evidence. The code around the search decides which sources may answer, and that's what we draw and build here, one part at a time. What you'll build You start with an assistant whose best search match is a stale ticket. By the end, your knowledge system: • gives every source a contract: which questions it may answer, its authority, freshness, owner and scope • ingests with stable ids, provenance and a manifest, so reruns are safe • keeps table rows as records and reads the page image when the layout carries the meaning • cuts chunks at headings and rows, and tags each one with where it applies • takes identity from the session and checks access at search, expansion, rerank, cache and citation • picks its embedder on your own golden set, and puts exact product codes ahead of the fused ranking • retrieves wide, reranks to five, and rewrites, routes and splits questions before search • decides which source wins when two disagree, and abstains below a calibrated floor • packs evidence the model can cite, and validates every citation • answers from records with allow-listed, parameterized SQL, and follows multi-hop paths through a knowledge graph • keeps the index in sync with updates, deletes and rebuilds, and is graded with retrieval metrics, a faithfulness judge and a regression gate What's inside • 16 modules, plus a short Start Here module that sets up the code • 16 video lessons, about 8 minutes each, so over 2 hours of video in all • 100+ hand-drawn doodles, each one a named mental model like the Knowledge Sources Map or the Regression Gate • 16 one-page doodle cheat sheets • 16 coding exercises, each with a prediction question, the expected output and a worked solution • 16 quizzes. Conceptual questions only. Retake as often as you like; your best result counts. • A certificate of completion: pass with 70% or more, or 90% or more for a distinction How each module works Watch the video. Read the lesson. Keep the cheat sheet. Do the exercise: predict what the code will print, run it, compare. Take the quiz. That's it, at your own pace, with no start date and no deadline. The code Everything runs on Python 3.10 or newer, with git and one requirements file to install. A built-in stub model means you don't need an API key, a network connection or a paid account, and every exercise has an expected output you can check against. If you'd like to try a real model, you can point a chapter at Ollama on your own machine. Who it's for Developers who can read Python and have taken Volume 1, or covered the same ground: embeddings, search, chunking, a RAG pipeline, grounded answers and evals. The code starts from Volume 2's final code; where a chapter uses Volume 2's harness, it's recapped in a line. You don't need a machine learning background. Who it's not for If you want a tour of vector databases or RAG frameworks, or want to train models, this isn't that course. It builds plain code so that every check is code you can read. Modules 0 Start Here · 1 The Knowledge Map · 2 Ingestion Pipelines · 3 Documents With Layout · 4 Structure-Aware Chunking and Applicability Metadata · 5 Knowledge Access · 6 Embedding Models and Vector Indexes · 7 Hybrid Search · 8 Reranking · 9 Query Understanding · 10 When Sources Disagree · 11 Context Assembly · 12 Structured Knowledge · 13 Knowledge Graphs and Multi-Hop Retrieval · 14 Index Lifecycle · 15 Evaluating RAG · 16 RAG Test Sets and Regression Gates The course and the book The course follows the book AI Engineering Visualized, Volume 3: RAG & Knowledge Systems (Vol 3), chapter for chapter. If you already have the book, the course adds the videos in each module, the one-page doodle cheat sheets, the prediction questions, the quizzes and the certificate, with your progress tracked as you go.

Share this course

Instructor

About the Instructor

Prateek Singh

Prateek Singh is the solo technical founder of Ganak AI Labs, an Indian AI SaaS startup that also runs AI workshops for builders. Its product, Cloudeval AI, runs pre-deployment reviews for Azure, plus AWS CloudFormation (beta), with evidence-backed reports, through the web, a CLI, GitHub and MCP. Before AI, he worked as an infrastructure and cloud developer and was an active PowerShell community writer.

Books and courses: AI Engineering Visualized (Vols 1–4), Learn Windows Subsystem for Linux (Apress, 2020), The UX Foundations of Agentic AI Systems, PowerShell to C# and back, Learn C# in 30 Minutes, PowerShell Guide to Python, Plain Perception, and the Educative course Learning Python through PowerShell Concepts.

Find him on LinkedIn, X, Instagram, YouTube and GitHub.

Material

Course Material

  • Module 0: Start Here

  • Welcome to the Course

  • How each module works

  • Setting Up the Code

  • How to Read the Doodles

  • The visual language

  • The text walkthrough

  • Reuse them

  • A worked example

  • Finishing the Course

  • Module 1: The Knowledge Map: Source Contracts and Access Paths

  • Watch: The Knowledge Map: Source Contracts and Access Paths

  • Read: The Knowledge Map: Source Contracts and Access Paths

  • The Knowledge Sources Map

  • Retrieve or Look Up?

  • Tables vs Text

  • Sidebar: RAG vs Long Context

  • Further Reading

  • Next

  • Doodle Cheat Sheet: The Knowledge Map: Source Contracts and Access Paths

  • Cheat Sheet at a Glance

  • Exercise: Route the stock question

  • Check Your Work

  • Quiz: The Knowledge Map

    99 attempts allowed

  • Module 2: Ingestion Pipelines: Stable IDs, Provenance and Re-Runs

  • Watch: Ingestion Pipelines: Stable IDs, Provenance and Re-Runs

  • Read: Ingestion Pipelines: Stable IDs, Provenance and Re-Runs

  • The Ingestion Conveyor

  • Every Chunk Knows Its Source

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Ingestion Pipelines: Stable IDs, Provenance and Re-Runs

  • Cheat Sheet at a Glance

  • Exercise: Fail halfway

  • Check Your Work

  • Quiz: Ingestion Pipelines

    99 attempts allowed

  • Module 3: Documents With Layout: Tables, Scans and Images

  • Watch: Documents With Layout: Tables, Scans and Images

  • Read: Documents With Layout: Tables, Scans and Images

  • The Messy PDF

  • Read the Page, Not Just the Text

  • Sidebar: OCR vs Native Text Extraction

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Documents With Layout: Tables, Scans and Images

  • Cheat Sheet at a Glance

  • Exercise: Add the Swiss row

  • Check Your Work

  • Quiz: Documents With Layout

    99 attempts allowed

  • Module 4: Structure-Aware Chunking and Applicability Metadata

  • Watch: Structure-Aware Chunking and Applicability Metadata

  • Read: Structure-Aware Chunking and Applicability Metadata

  • Chunks That Follow the Document

  • Small to Find, Big to Read

  • Metadata Tags and Filters

  • Sidebar: The Overlap Trade-off

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Structure-Aware Chunking and Applicability Metadata

  • Cheat Sheet at a Glance

  • Exercise: The rule that starts next month

  • Check Your Work

  • Quiz: Structure-Aware Chunking and Applicability Metadata

    99 attempts allowed

  • Module 5: Knowledge Access: Permissions, Tenants and Poisoned Documents

  • Watch: Knowledge Access: Permissions, Tenants and Poisoned Documents

  • Read: Knowledge Access: Permissions, Tenants and Poisoned Documents

  • Who May See This?

  • Poisoned Pages

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Knowledge Access: Permissions, Tenants and Poisoned Documents

  • Cheat Sheet at a Glance

  • Exercise: Revoke and re-ask

  • Check Your Work

  • Quiz: Knowledge Access

    99 attempts allowed

  • Module 6: Embedding Models and Vector Indexes

  • Watch: Embedding Models and Vector Indexes

  • Read: Embedding Models and Vector Indexes

  • Choosing an Embedding Model

  • The Approximate Neighbourhood

  • Sidebar: Flat, Graph and Clustered Indexes

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Embedding Models and Vector Indexes

  • Cheat Sheet at a Glance

  • Exercise: Search one more cluster

  • Check Your Work

  • Quiz: Embedding Models and Vector Indexes

    99 attempts allowed

  • Module 7: Hybrid Search: Keywords Plus Meaning

  • Watch: Hybrid Search: Keywords Plus Meaning

  • Read: Hybrid Search: Keywords Plus Meaning

  • The Exact-Match Lane

  • Weighted Fusion

  • Sidebar: Lexical Scoring (BM25) in One Picture

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Hybrid Search: Keywords Plus Meaning

  • Cheat Sheet at a Glance

  • Exercise: Tell the twins apart

  • Check Your Work

  • Quiz: Hybrid Search

    99 attempts allowed

  • Module 8: Reranking: The Second Opinion

  • Watch: Reranking: The Second Opinion

  • Read: Reranking: The Second Opinion

  • The Two-Stage Funnel

  • The Cross-Encoder Judge

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Reranking: The Second Opinion

  • Cheat Sheet at a Glance

  • Exercise: Find the smallest net

  • Check Your Work

  • Quiz: Reranking

    99 attempts allowed

  • Module 9: Query Understanding: Rewrite, Route and Decompose

  • Watch: Query Understanding: Rewrite, Route and Decompose

  • Read: Query Understanding: Rewrite, Route and Decompose

  • The Query Rewriter

  • The Query Router

  • Sidebar: Hypothetical-Answer Search (HyDE)

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Query Understanding: Rewrite, Route and Decompose

  • Cheat Sheet at a Glance

  • Exercise: Route a mixed-language ticket

  • Check Your Work

  • Quiz: Query Understanding

    99 attempts allowed

  • Module 10: When Sources Disagree: Authority, Applicability and Abstain

  • Watch: When Sources Disagree: Authority, Applicability and Abstain

  • Read: When Sources Disagree: Authority, Applicability and Abstain

  • When Sources Disagree

  • Abstain Thresholds Across Sources

  • Sidebar: Citation Formats

  • Further Reading

  • Next

  • Doodle Cheat Sheet: When Sources Disagree: Authority, Applicability and Abstain

  • Cheat Sheet at a Glance

  • Exercise: Out-rank the newer ticket

  • Check Your Work

  • Quiz: When Sources Disagree

    99 attempts allowed

  • Module 11: Context Assembly: Packing Evidence for the Model

  • Watch: Context Assembly: Packing Evidence for the Model

  • Read: Context Assembly: Packing Evidence for the Model

  • The Evidence Pack

  • When Evidence Distracts

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Context Assembly: Packing Evidence for the Model

  • Cheat Sheet at a Glance

  • Exercise: Sweep k

  • Check Your Work

  • Quiz: Context Assembly

    99 attempts allowed

  • Module 12: Structured Knowledge: Query Specs, Scope and Safe SQL

  • Watch: Structured Knowledge: Query Specs, Scope and Safe SQL

  • Read: Structured Knowledge: Query Specs, Scope and Safe SQL

  • Question to Query

  • Scope Before You Query

  • Sidebar: The Read-Only SQL Guard

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Structured Knowledge: Query Specs, Scope and Safe SQL

  • Cheat Sheet at a Glance

  • Exercise: Find my final-sale orders

  • Check Your Work

  • Quiz: Structured Knowledge

    99 attempts allowed

  • Module 13: Knowledge Graphs and Multi-Hop Retrieval

  • Watch: Knowledge Graphs and Multi-Hop Retrieval

  • Read: Knowledge Graphs and Multi-Hop Retrieval

  • Entities and Edges

  • The Multi-Hop Path

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Knowledge Graphs and Multi-Hop Retrieval

  • Cheat Sheet at a Glance

  • Exercise: Three kinds of answer

  • Check Your Work

  • Quiz: Knowledge Graphs and Multi-Hop Retrieval

    99 attempts allowed

  • Module 14: Index Lifecycle: Updates, Deletes, Rebuilds and Drift

  • Watch: Index Lifecycle: Updates, Deletes, Rebuilds and Drift

  • Read: Index Lifecycle: Updates, Deletes, Rebuilds and Drift

  • The Stale Index

  • Build, Check, Switch

  • Sidebar: Incremental Re-Indexing

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Index Lifecycle: Updates, Deletes, Rebuilds and Drift

  • Cheat Sheet at a Glance

  • Exercise: Change only who may see it

  • Check Your Work

  • Quiz: Index Lifecycle

    99 attempts allowed

  • Module 15: Evaluating RAG: Retrieval Metrics and Faithfulness Judges

  • Watch: Evaluating RAG: Retrieval Metrics and Faithfulness Judges

  • Read: Evaluating RAG: Retrieval Metrics and Faithfulness Judges

  • The RAG Metrics Map

  • The Full RAG Scorecard

  • The Faithfulness Judge

  • Sidebar: Judge Bias (Position, Length)

  • Further Reading

  • Next

  • Doodle Cheat Sheet: Evaluating RAG: Retrieval Metrics and Faithfulness Judges

  • Cheat Sheet at a Glance

  • Exercise: Swap the order

  • Check Your Work

  • Quiz: Evaluating RAG

    99 attempts allowed

  • Module 16: RAG Test Sets and Regression Gates

  • Watch: RAG Test Sets and Regression Gates

  • Read: RAG Test Sets and Regression Gates

  • The Synthetic Question Factory

  • The Regression Gate

  • Further Reading

  • Next

  • Doodle Cheat Sheet: RAG Test Sets and Regression Gates

  • Cheat Sheet at a Glance

  • Exercise: Pass the knowledge exam

  • Check Your Work

  • Quiz: RAG Test Sets and Regression Gates

    99 attempts allowed

  • Wrap-Up

  • You Built the Whole Knowledge System

  • Get Your Certificate

  • Where to Go Next

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub