All work
Live2026Personal R&D

RAG, measured

askgraham · Full-stack AI engineer

Hybrid retrieval with paragraph-level citations over all 233 Paul Graham essays, kept honest by an eval harness: recall@k, MRR, nDCG, and LLM-as-judge faithfulness against a committed baseline.

Context

Paul Graham's essays are a good RAG testbed: 233 documents, dense with interlocking arguments, short enough to build a serious gold set by hand. The goal was a RAG stack where every design choice is backed by a number.

Problem

Most RAG demos answer questions. The hard part is knowing when retrieval fails, why, and what a reranker or a different fusion weight actually buys. Without a committed eval baseline, every tuning decision is guesswork you cannot verify.

What I built

Three-arm hybrid retrieval

Dense HNSW search through pgvector, lexical search via ts_rank_cd, and a boosted title match, fused with weighted reciprocal rank fusion. An optional cross-encoder rerank sits on top, and every arm earns its place in the ablation sweep.

Citations at paragraph granularity

Streamed answers cite [slug#paragraph], so any claim can be checked against the source in one glance. Related essays are found by embedding centroids.

Evals with a committed baseline

A 40-case hand-labelled gold set scored on recall@k, MRR, nDCG@k, and paragraph coverage, plus LLM-as-judge faithfulness, relevance, and citation precision. Runs are temperature-0 and reproducible; the baseline is committed to the repo, and ablation sweeps show exactly what fusion weights and the rerank stage buy.

Free and offline by default

Local ONNX embeddings and a local reranker mean zero running cost and no API keys. One command brings up the full FastAPI + Postgres + pgvector stack in Docker.

queryam + endense HNSWpgvectorlexicalts_rank_cdtitle boostweightedweighted RRF3-arm fusionablation-committedrerankcross-encoderanswersse-streamed[slug#para] citeseval harness40 gold cases · recall@k · MRR · nDCGLLM-as-judge faithfulness · committed baseline
Three retrieval arms, fused and measured, with the eval harness watching every stage.
askgraham running live
askgraham, live.

Decisions & tradeoffs

01

Hybrid fusion, committed with numbers

Every RAG writeup says hybrid retrieval beats dense-only. I wanted that claim in my own repo, on my own data, with the ablation committed. It does, and the numbers that say so are versioned next to the code.

02

Paragraph-level citations force honesty

A citation that points at a whole essay proves nothing. Pointing at the exact paragraph makes hallucination visible immediately, to the user and to the eval. It is the cheapest faithfulness guard I know.

Results

233
essays, fully indexed
40
hand-labelled gold cases
6
retrieval & faithfulness metrics
$0
running cost, local ONNX

In hindsight

The gold set is the bottleneck: 40 cases took real time to label well, and it should grow. The lesson is that eval infrastructure is a day-one investment, because without it every later decision quietly becomes unfalsifiable.

Stack & links

FastAPIPostgreSQLpgvectorNext.jsONNXDockerSSE streaming