MENU

GET IN TOUCH

Back

ragbench: Retrieval Benchmarking for RAG

Year

2026

Tech & Technique

Python, NumPy, FastAPI, Docker, GitHub Actions

Description

An open-source retrieval benchmark for RAG. BM25, TF-IDF and hybrid Reciprocal Rank Fusion implemented from scratch with NumPy, scored with standard IR metrics and latency.

Key facts:
  • Metrics: Recall@k, Precision@k, Hit@k, MRR and graded nDCG@k, with mean and p95 latency per query.
  • Measured on BEIR SciFact (5,183 documents, 300 queries): nDCG@10 of 0.647 for BM25, 0.612 for TF-IDF and 0.635 for the hybrid.
  • Moving both retrievers to an inverted index took TF-IDF query latency from 216 ms to 0.22 ms and peak indexing memory from 4.1 GB to 123 MB, with identical top-10 results for all 300 queries.
  • CLI with table, Markdown, JSON and CSV output, a FastAPI service and a Docker image.

The before and after numbers are explained in the write-up.

My Role

Author and maintainer
  • Retrievers, metrics, CLI and API service.
  • CI with lint, type checks, tests on Python 3.10 to 3.13, a package build and a container smoke test.
BM25, TF-IDF and hybrid on BEIR SciFact
Real output of the benchmark on 5,183 documents and 300 queries. Latency varies by machine and run; the quality metrics do not.

VISHAL-KRISHNA

vishalkrishnakkr@gmail.com