TechByteByByte

MODERN AI SYSTEMS

Retrieval-Augmented Generation

Learn how AI systems connect language models to external knowledge, from document ingestion and chunking through retrieval, context construction, citations and production architecture.

Documents โ†’ Embeddings โ†’ Retrieval โ†’ Grounded Generation

RAG Learning Path

Work through the modules in order. Each one builds toward a complete mental model for designing, evaluating and operating RAG systems.

01

Why RAG Exists

The realistic problem RAG was built to solve: what happens when an LLM needs to answer questions about information it was never trained on โ€” private, current, or enterprise-specific knowledge.

Start Module โ†’
02

The Fundamental RAG Idea

Formalizing the without-RAG vs. with-RAG mental model as the foundation for this entire course, and precisely distinguishing what RAG is and is not.

Start Module โ†’
03

RAG vs. Prompt Engineering vs. Fine-Tuning

A direct comparison of what each approach actually changes about a model's behavior, and a practical framework for choosing between them โ€” or combining them.

Start Module โ†’
04

The Complete RAG Pipeline

The full, canonical RAG architecture: the offline/indexing pipeline that prepares knowledge, and the online/query pipeline that answers questions โ€” why RAG really has two distinct phases.

Start Module โ†’
05

Documents & Ingestion

What exactly gets loaded into a RAG system, why metadata captured at ingestion time matters for everything downstream, and the wide variety of real-world data sources RAG must handle.

Start Module โ†’
06

Document Parsing

Why extracting usable text from real documents is really harder than it looks โ€” tables, columns, headers, scanned pages โ€” and why poor parsing can silently doom an otherwise well-designed RAG pipeline.

Start Module โ†’
07

Chunking Deep Dive

One of the most important decisions in a RAG system: how documents get split into retrievable units. Chunk size, overlap, and every major chunking strategy โ€” each with full, runnable code.

Start Module โ†’
08

Structure-Aware & Semantic Chunking

Moving beyond structural signals like paragraphs and sentences to really meaning-aware chunking โ€” using document headings and detecting where topics actually change.

Start Module โ†’
09

Chunk Metadata

What a chunk needs to carry beyond its raw text โ€” and why treating a chunk as 'just a string' quietly breaks filtering, citations, and access control later, closing out Level 2.

Start Module โ†’
10

Embeddings in the Context of RAG

How chunks actually become searchable by meaning rather than exact words โ€” building directly on your LLM course's embedding foundations, applied specifically to retrieval.

Start Module โ†’
11

Vector Space & Similarity

The mathematical comparison tools that turn 'close vectors' into an actual, computable ranking โ€” cosine similarity, dot product, and Euclidean distance, with intuition before formulas.

Start Module โ†’
12

Vector Databases

Why storing and searching millions of embedding vectors is a fundamentally different problem than a traditional database's exact-match lookup, and what a vector database actually stores.

Start Module โ†’
13

Vector Indexing & ANN

The actual solution to brute-force search's scaling problem: approximate nearest neighbor search, and why trading a small amount of accuracy for massive speed gains is usually the right choice.

Start Module โ†’
14

HNSW and IVF Deep Dive

Two widely used ANN algorithm families, with a step-by-step walkthrough of how insertion works across their internal structures โ€” layer by layer for HNSW, cell by cell for IVF.

Start Module โ†’
15

Top-K and Metadata Filtering

How many results to actually retrieve, and how to combine vector similarity search with metadata filters like access control and department, using Module 9's structured chunks.

Start Module โ†’
16

BM25 and Sparse Retrieval

A really different retrieval approach from everything covered in Level 3: exact keyword matching, and when it outperforms semantic search entirely.

Start Module โ†’
17

Dense vs. Sparse vs. Hybrid Retrieval

Combining Module 16's BM25 with Level 3's semantic search into one, really more robust retrieval system โ€” and how to merge two fundamentally different scoring systems fairly.

Start Module โ†’
18

Two-Stage Retrieval & Reranking

Adding a second, more precise ranking stage on top of hybrid retrieval's initial candidate set โ€” the recall-first, precision-second mental model, closing out Level 4.

Start Module โ†’
19

Query Transformation

User questions aren't always ideal search queries โ€” rewriting, expanding, and normalizing them before retrieval even happens, starting Level 5: Retrieval Quality.

Start Module โ†’
20

Multi-Query & Query Decomposition

Extending query transformation to really complex questions requiring multiple separate searches โ€” when one question actually needs to become several.

Start Module โ†’
21

Context Construction & Lost-in-the-Middle

Retrieval gives you chunks, but you can't blindly hand them all to the LLM โ€” organizing, deduplicating, and ordering retrieved context effectively, and why more context isn't always better.

Start Module โ†’
22

Prompt Construction for RAG

Closing Level 5: assembling the final prompt from constructed context, system instructions, and the user's question, directly connecting to the Prompt Engineering course's foundations.

Start Module โ†’
23

Grounded Generation & Citations

What it actually means for an answer to be grounded, and how to attach real, verifiable citations to generated responses โ€” starting Level 6: Grounded Generation & Trust.

Start Module โ†’
24

RAG Failure Modes

A complete, end-to-end diagram of every point in the pipeline where things can really go wrong, from ingestion through generation โ€” and why a good LLM can't compensate for bad retrieval.

Start Module โ†’
25

Hallucination in RAG & Conflicting Documents

Going deeper into the generation-stage failure Module 24's diagnostic process points toward, and the practical problem of multiple documents disagreeing with each other.

Start Module โ†’
26

Document Versioning & Freshness

How a knowledge base should manage document updates over time, preventing the conflicts and outdated answers covered in Module 25 from arising in the first place.

Start Module โ†’
27

RAG Security & Access Control

Closing Level 6: the real security requirements around retrieval, including enforcing permissions before content reaches a model and defending against prompt injection via retrieved documents.

Start Module โ†’
28

Naive vs. Advanced RAG

The evolution from basic retrieve-then-generate toward Self-RAG and Corrective RAG architectures that reason about their own retrieval quality โ€” starting Level 7: Advanced RAG Architectures.

Start Module โ†’
29

Agentic RAG & Graph RAG

Taking Self-RAG and Corrective RAG's reasoning further into really autonomous, multi-step retrieval, and introducing graph-based retrieval for relationship-heavy questions vector similarity cannot answer.

Start Module โ†’
30

RAG with Structured Data & Tables

Recognizing when the right answer to 'where should this data live' is a SQL database, not a vector store at all โ€” and handling tables really well when they must live in RAG.

Start Module โ†’
31

Multimodal RAG

Closing Level 7: extending retrieval beyond generic text to PDFs, web content, and code repositories โ€” each with really distinct handling requirements, unified through Module 5's loader pattern.

Start Module โ†’
32

RAG Evaluation

How to systematically measure retrieval quality and generation quality SEPARATELY, closing in on the final production-readiness modules โ€” starting Level 8: Production RAG.

Start Module โ†’
33

Production RAG

The final module of this course: observability, cost, latency, caching, the complete decision framework, common mistakes, case studies, and the final, unified mental model for everything RAG.

Start Module โ†’

WHY RAG?

Build answers on evidence, not memory alone

RAG systems retrieve relevant source material at request time and place it in the model's context. That makes it possible to work with private, current and domain-specific knowledge without retraining the language model for every document change.