RAG and embeddings
The largest folder here, because it is what most applied-AI roles actually build. Read 01 and 02 first; everything else refines one stage of the pipeline they describe.
Foundations
| # | File | Covers |
|---|---|---|
| 01 | What is RAG? | two pipelines, RAG vs fine-tuning, where it fails |
| 02 | What are embeddings? | static vs contextual, normalisation, the re-embed trap |
| 03 | RAG Architecture Patterns | naive, advanced, modular, agentic |
The pipeline, stage by stage
| # | File | Covers |
|---|---|---|
| 05 | Chunking Strategies and Retrieval Techniques | chunk size, overlap, strategies |
| 07 | Structured Document Pipelines — Parsing, Tables, OCR, Extraction | PDFs, tables, OCR, vision fallback |
| 08 | Hybrid search and reranking | BM25 fusion, cross-encoders, RRF |
| 11 | Fine-tuning embeddings | when the embedder itself is the problem |
Storage
| # | File | Covers |
|---|---|---|
| 04 | Vector Databases | index algorithms, the landscape, filtering |
| 10 | pgvector in production | HNSW vs IVFFlat, ef_search, the filtered-ANN cliff |
| 06 | Knowledge Graphs and GraphRAG | when graphs beat vectors |
Making it good
| # | File | Covers |
|---|---|---|
| 09 | Agentic RAG and evaluating retrieval | recall@k, MRR, faithfulness, agentic retrieval |
The three answers worth having
RAG turns a knowledge problem into a retrieval problem. It is two pipelines, not one: ingest runs per document, query runs per request. Naming rewrite and rerank as distinct stages is what separates a production answer from a demo.
RAG systems fail at retrieval, not generation. Measure recall@k before touching the prompt — if the evidence was never in the candidate set, no amount of prompt engineering recovers it.
Changing the embedding model means re-indexing everything. Vectors from two models are not comparable and there is no conversion, so it is a migration rather than a config change. Version the index and cut over.
The order to improve things
- Chunking — usually the largest win, and free.
- Hybrid search plus a reranker — the second largest, and cheap.
- Query rewriting — when queries are conversational or underspecified.
- Fine-tuning the embedder — last, and only for genuinely unusual vocabulary.