All work
Live2026Personal

Hybrid RAG search and chat over 233 essays

AskGraham · Author

FastAPI and pgvector RAG backend combining vector, keyword, and title search with reciprocal rank fusion, a reranker, and a 40-case evaluation suite.

Context

I built AskGraham to test RAG retrieval quality properly. It indexes all 233 Paul Graham essays and answers questions with paragraph-level citations.

Problem

Vector search alone often misses exact keywords or essay titles. And without an evaluation set, you can't tell if changing chunk sizes or adding a reranker actually improves results.

What I built

Hybrid retrieval with RRF

Combines pgvector dense search, PostgreSQL full-text search, and title matching using weighted reciprocal rank fusion, followed by a local ONNX cross-encoder reranker.

Paragraph citations

Streamed answers cite the exact paragraph ([slug#paragraph]) so the reader can verify every claim against the original text.

40-case evaluation suite

Tracks recall@k, MRR, nDCG, and citation accuracy across 40 test questions at temperature zero, with baseline results committed in the repo.

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

Local ONNX models for embeddings

Running embeddings and reranking locally with ONNX keeps hosting free and removes external API calls during search.

02

Cite paragraphs, not whole essays

Pointing to a full essay doesn't prove the answer is accurate. Paragraph citations make hallucinations obvious right away.

Results

233
essays indexed
40
eval test cases
3-way
hybrid retrieval
$0
embedding cost

In hindsight

Writing good evaluation questions took longer than building the retrieval pipeline, but it saved time later whenever I tuned ranking weights.

Stack & links

FastAPIPostgreSQLpgvectorNext.jsONNXDocker