← Back to the course home

📐 The 8 lessons as diagrams

Blue = the idea (1–4) · green = for real (5–8). Follow the circled numbers.

1 🗺️ Why vector DBs

The library sorted by MEANING — keywords match strings, not ideas.

📇 keyword catalog'kind to animals' →match exact strings →❌ 'Every Living Thing' missedstrings, not meaning1🗺️ the meaning hall — a vector DB1 seat the question(embed it)2 find nearest seatsfast, at any scale3 ✅ 'Every Living Thing'zero shared words!2store millions of seats · return the k nearest · with stickers 🏷️ — that's the whole product

Read full lesson 01 →

2 🔢 Text to vectors

Giving every text a seat — our honest toy vs learned embeddings.

🔤 toy: count wordshash each word → bump 1 of256 buckets → normalize😬 nearsighted: shared WORDS'pupils' ≠ 'students' (0.00!)1🧠 real: embedding modela trained network → 768-3072dims where directions = MEANING✅ 'pupils' sits beside 'students'across phrasing & languages2🗺️ the DB doesn't carevectors in, neighbors out —embed() is ONE swappablefunction (lesson 05)3⚠️ the same-model rule: query and documents must use the SAME embedder — change it → re-embed everything

Read full lesson 02 →

3 📐 Similarity

Direction beats distance — and the normalize-then-dot trick.

🧭 cosine: compare DIRECTIONS10-page robot essay & 1-line robot notepoint the SAME way → 0.95 ✅ siblingsmeaning is a direction; length is volume 📢1📏 distance: compare POSITIONSthe essay 'stands far' from the note →fooled by length — wrong verdict for text2⚡ the trick: normalize at WRITE time → cosine = plain dot product at READ timeone line, hardware-fast — our cosine() is just sum(x·y) because _normalize already ran3

Read full lesson 03 →

4 🏃 Nearest neighbors

Asking everyone vs the friendship map (HNSW) — the recall dial.

🚶 brute force - exactcompare with ALL N seatsN=7k: fine · N=7M: 💀1🗺️ HNSW - friendship maplocal friends + pen-pals acrossthe hall → log-ish greedy hops2🏘️ IVF - neighborhoodspre-cluster districts; searchonly the nearest few3🎯 the recall dial: speed ↔ % of TRUE neighbors found95-99% recall at 100-1000× speedup is the standard trade — benchmarks without recall numbers are marketing4

Read full lesson 04 →

5 🔬 Build a vector DB

70 honest lines: embed, cosine, store, filter, top-k.

1 🔢 embed()hash words → 256 dims →normalize · ← swap for amodel call HEREembedder and store areseparate jobs — by design12 📐 cosine()one line: dot product(normalize made it cheap)23 🗄️ MiniVectorDBadd: embed + store(id, vector, TEXT, stickers)search: filter 🏷️ FIRST →score → sort → top-kmissing on purpose: persistence,deletes, ANN — your homework3~70 lines, zero dependencies — a database you can hold entirely in your head

Read full lesson 05 →

6 ✂️ Chunking & metadata

Cards and colored stickers — the quality lever bigger than any index.

📚 400-page bookcan't sit in one chair✂️ chunking - the craftnatural seams · self-contained ·~hundreds of tokens · 10-15% overlap 🔁1🗂️ cards + stickers 🏷️room:3A · kind:rules ·source:handbook-p12 (receipts!)2❌ too big: five topics, one murky seat❌ too small: '…it must be returned' — WHAT must?chunking moves quality 2-5× · indexes move it 1.1×3🤝 hybrid searchmeaning-search misses 'E-4012'; keywords misssynonyms — run BOTH, merge (RRF)4

Read full lesson 06 →

7 📖 RAG wiring

The open-book exam, end to end — with OUR page-finder.

🗂️ index time - once, on changedocs → ✂️ chunk → 🔢 embed → 🗄️ store(re-index tonight, 'knows' it tomorrow)1❓ question time - every queryembed the question (SAME model) → search k=4(+ stickers 🏷️) → optional rerank 🧐2🪑 the desk: cards + 'answer ONLY from these, cite ids'→ ✅ grounded answer with receipts 🧾 (AI school L08-L10, now with YOUR page-finder)debugging drill: bad answer? print the CARDS first — retrieval bug ≠ generation bug3

Read full lesson 07 →

8 🏬 The landscape

pgvector, Pinecone, Chroma, FAISS — picking without a bake-off.

🐘 pgvectorthe library you already have —SQL + vectors, one backup1☁️ managed - Pinecone & cothe rented hall — scale withoutops (the AWS build-vs-rent call)2🧪 Chroma · Qdrant · LanceDBthe lab bench — developer-first,embedded to mid-scale3⚙️ FAISS · hnswlibengine blocks, not databases —max control, zero ops help4🔎 your old store, new tricksOpenSearch/Redis/Mongo grewa vector column — one less system5the boring pick order: pgvector → embedded lab bench → managed/self-hosted at real scale · <100k vectors? a loop is fine 😄

Read full lesson 08 →