Architecture
How this site works
A course about retrieval systems, built so that it needs no server of its own. Everything is computed at build time or in your browser.
Static export
Next.js builds every page to plain HTML at build time. A content validator fails the build on a broken page, a missing quiz explanation or a prerequisite that does not exist.
- Why
- No server to run, patch or pay for. Any static host can serve it.
- Trade-off
- No server features: no accounts, no stored answers. Progress lives in the reader's browser.
Precomputed vectors
npm run precompute chunks the 25 documents in 16 settings, embeds every chunk and every golden question with bge-small-en-v1.5, and writes JSON to public/data.
- Why
- Labs load the vectors instead of computing them, so a lab opens in about a second, and the numbers on every page can be reproduced with one command.
- Trade-off
- 3.4 MB of lab data in the repository, rebuilt whenever the corpus or chunker changes.
Labs in the browser
BM25, cosine similarity, reciprocal rank fusion and the metrics run as plain TypeScript in the page. A test checks that the browser code gives the same evidence recall as the precompute script for all 16 settings.
- Why
- Every control changes a real computation, not a canned answer, and nothing leaves the reader's machine.
- Trade-off
- Only small corpora fit. A real system with millions of chunks needs a vector database.
Typed questions embedded on demand
The Mini RAG Lab loads the same 34 MB quantized model in the browser the first time a reader types a question, with a progress bar. The browser caches it.
- Why
- Free text search with no API and no cost, in the same vector space as the stored chunks.
- Trade-off
- A one-time 34 MB download, so it loads only when asked for.
Bring your own key
For a live answer, the reader pastes their own Anthropic key. It stays in session storage (local storage only if they tick remember) and goes only to the provider's API. A test checks the request host and headers.
- Why
- Live answers with no proxy and no bill for the site.
- Trade-off
- Readers without a key see the reference answer from the golden set instead.
Try it: the labs are the same code described here.