Build your own semantic search
Is it correct? (recall@k vs exact NN)·10 min

recall@10 over all queries

0 / 1
# grade this stage (from your course directory)
npx theinference test --stage recall-eval --watch

Run your search over every query embedding, compare each result to gt_knn.json, and average recall@10. This is your end-to-end correctness gate — the proof that your brute force reproduces the exact float64 nearest neighbors.

What to build

Your task

Wire the recall eval

In src/eval.ts, implement evalRecall(pack, k): for each query run search(pack.queries.subarray(...), pack.corpus, pack.dim, k), compute recallAtK vs pack.gtKnn[q].slice(0, k), and return the mean. The CLI command eval-recall prints { recall } from it.

src/eval.ts
export function evalRecall(pack: Pack, k: number): number {
  // mean recallAtK over all queries vs pack.gtKnn top-k
}
What the grader runs
./your_program.sh eval-recall fixtures/pack    # prints {"recall": ...}
How it's graded

process — your printed { recall } is exact-matched to the frozen reference value (atol 1e-6). A correct engine reproduces the exact NN, so the value is 1.000000. The "≥ 0.999" framing you'll hear for real benchmarks lives in the prose; the grade is equality to the reference's deterministic computation.