Build your own semantic search
Setup & orientation·4 min

What you're building

0 / 1

You are about to build semantic search — the thing that lets you type "does vitamin D prevent respiratory infections?" and get back the actual papers that answer it, even when none of those words appear in the abstract. By the end you'll have a CLI that does exactly that over a corpus of documents, and you'll be able to prove it's good with the same metrics a published retrieval paper reports.

The whole pipeline, in one line

The journey of one query
"vitamin D infection" → [tokenize → embed] → 384-d vector → cosine vs N docs → top-k → ranked abstracts

Every box in that line is something you'll implement. The two in brackets we hand you frozen vectors for (until the final chapter, where you see how they're produced); everything else — the vector math, the index, the metrics — you write from scratch in TypeScript.

Keyword search vs semantic search

Old-school search matches words: a query for "heart attack" misses a doc that only says "myocardial infarction." Semantic search matches meaning — both phrases land near each other in vector space. That's the whole trick, and it's just geometry.

No GPU, no API keys, no Python

The embeddings are precomputed and shipped as fixtures, so the core course is pure TypeScript over Float32Array and runs in seconds on CPU. The two yardsticks you finish with — recall@10 vs exact-NN = 1.000 (your engine is correct) and nDCG@10 (your engine is good) — are computed by your own code, deterministically, on every machine.