All work

Evaluation-Driven Local RAG

Jun to Jul 2026, complete

Retrieval-augmented generation over 5 ML books, built evaluation-first: a fixed, hand-labelled query set decides every change. Embeddings, retrieval, reranking, generation and the judge all run locally on one laptop with a 6 GB GPU. No cloud calls at runtime or in evaluation.

Reading
0.942recall@5n = 43 answerable queries from a 48-query gold set
Limitation
Only 5 paraphrase and 2 multi-hop queries; the judge is the same model as the generator; 1 of 5 unanswerable questions is still answered.

Hybrid + rerank, the shipped configuration. Hand-labelled gold set.

  1. Problem

    Answer questions over 5 ML books on one laptop with a 6 GB GPU and no cloud calls, and know how often the answers are right.

  2. Approach

    Evaluation came first: a hand-labelled gold set of 48 queries, 43 answerable and 5 unanswerable, with retrieval scored by recall@k, MRR and NDCG, and answers judged locally for faithfulness, relevancy and context. Three retrieval configurations ran against the same 1,721 chunks. 41 tests. No LangChain.

  3. Result

    Hybrid + rerank ships with recall@5 of 0.942 against 0.884 for dense, and refuses 4 of 5 unanswerable questions against 2 of 5. Context recall rose from 0.556 to 0.716. Dense still ranks best at top-1: R@1 of 0.616 against 0.570.

  4. Limitation

    Only 5 paraphrase and 2 multi-hop queries; the judge is the same model as the generator; 1 of 5 unanswerable questions is still answered.

  5. Finding

    On the first 25 queries the reranker seemed to win every metric. At 48 queries its top-1 lead vanished. Dense is the best top-1 ranker; hybrid + rerank wins recall@5, which is what feeds the generator.

Retrieval, n = 43
ConfigurationR@1R@3R@5R@10MRRNDCG@10
Dense0.6160.8600.8840.9300.7530.799
Hybrid0.4070.7910.8600.9190.6200.687
Hybrid + rerank (shipped)0.5700.8950.9420.9540.7290.783
Generation
ConfigurationFaithfulnessRelevancyContext precisionContext recallRefusals
Dense0.6650.8740.6860.5562/5
Hybrid + rerank (shipped)0.6700.9260.7540.7164/5

Specification

Corpus
5 ML books, 1,721 chunks after 24,286 repeated header and footer lines were stripped
Gold set
48 queries: 36 factoid, 5 paraphrase, 2 multi-hop, 5 unanswerable
Pipeline
Token-aware recursive chunker (about 900 tokens, 15% overlap); bge-m3 into pgvector with an HNSW cosine index; dense top-50 and BM25 top-50 fused by RRF (k = 60); cross-encoder rerank to 5; answers cite chunk IDs or refuse
Evaluation
Retrieval: recall@k, MRR, NDCG@10. Generation: faithfulness, answer relevancy, context precision and context recall, judged by qwen2.5:7b at temperature 0
Tests
41; ruff and mypy clean
Hardware
One laptop, 6 GB GPU, no cloud calls
Stack
Python 3.12, PostgreSQL 17 + pgvector, bge-m3 embeddings, bm25s, bge-reranker-v2-m3, qwen2.5:7b via Ollama, FastAPI, React. No LangChain.

Yash Gurjar

AI & ML Engineer. I build LLM systems and measure them.

Available for a full-time internship, January to June 2027.

  • 3merged PRs in PyTorch, including Dynamo (the torch.compile frontend)
  • 0.94recall@5 on a hand-labelled 48-query gold set
  • 60+users on CodeNeuron, a live ML practice platform