← Projects Applied AI Personal project · 2026

Testing the RAG defaults one at a time

RAG retrieval settings are often picked by habit: use RRF, always rerank, chunk at 512. I changed each one in isolation on three public corpora with paired significance tests, and two of three popular rerankers made every corpus worse.

  • Python
  • bm25s
  • Sentence Transformers
  • FAISS
  • MLflow
  • FastAPI
0.251 → 0.487
FiQA nDCG@10, BM25 → best
2 of 3
Rerankers that hurt every corpus
98.8% in 0.42 ms
HNSW recall of exact top-10
within ±0.002
Dense scores vs published MTEB

Architecture

  1. 01 BEIR corpora SciFact, NFCorpus, FiQA
  2. 02 First stage BM25 + dense bi-encoders
  3. 03 Fusion weighted, α tuned on dev
  4. 04 Rerank three cross-encoders
  5. 05 Paired tests bootstrap + sign-flip, Holm

The problem

Every retrieval-augmented generation pipeline makes the same handful of decisions: BM25 or dense embeddings, which embedding model, how to fuse the two, whether to rerank, how big to chunk, which FAISS index. In practice these get picked by habit. “Use RRF.” “Always rerank.” “Chunk at 512.”

I wanted to know which of those choices actually move retrieval quality, and by how much, with enough rigour that the answer would hold up.

The constraint

The easy way to benchmark this is to try settings on the test set until one looks good. That produces numbers nobody should trust. So every tuning decision is made on a dev split, results are reported on a held-out test split, and each claim gets a paired test over queries: a bootstrap CI and a sign-flip randomisation test, Holm-corrected within each corpus.

Before trusting the pipeline I checked it against published results. All 12 dense-model scores match the official MTEB results within ±0.002 nDCG@10.

What I built

Three BEIR corpora: SciFact (science), NFCorpus (medical) and FiQA (finance). The pieces:

  • BM25 with bm25s, and dense retrieval with Sentence Transformers bi-encoders (MiniLM, BGE-small, BGE-base, E5-base) over exact FAISS search.
  • Fusion: reciprocal rank fusion, and a weighted min-max fusion where the weight α is tuned on dev.
  • Reranking of the hybrid top-100 with three cross-encoders: MS MARCO MiniLM-L6, BGE-reranker-base and GTE-reranker-ModernBERT.
  • Chunking into 64, 128 and 256-word windows, and a comparison of FAISS index types.

Every configuration is logged as an MLflow run. The best quality-per-latency setup is served through a small FastAPI search endpoint.

Results

A tuned hybrid is the best first stage on every corpus. It beat its own dense model by +0.031 nDCG@10 on FiQA (significant), +0.017 on SciFact and +0.009 on NFCorpus. The last two are not significant after correction. The α chosen on dev turned out to be exactly the best α on test.

RRF, the untuned default, is significantly worse than tuned fusion on all three corpora. On FiQA it even fell below dense-only retrieval.

Reranking helps only with the right model. GTE-reranker-ModernBERT added +0.056 on FiQA. The other two made every corpus worse, by 0.03 to 0.10, and the deeper they reranked the more damage they did. All three corpora were already ranked well by the hybrid, and a reranker that judges relevance worse than that ranking replaces it with a worse one.

The first stage still matters after reranking. On FiQA the GTE reranker scored 0.057 lower on BM25 candidates than on hybrid ones. It can’t recover documents BM25 never retrieved.

The popular default embedding model loses to BM25. all-MiniLM-L6-v2 scored below BM25 on SciFact and NFCorpus, because its 256-token limit truncates 71-79% of those documents.

The index is almost a free choice at this scale. HNSW returned 98.8% of the exact top-10 in 0.42 ms against 16 ms for exact search. Product quantization cut memory 25x but lost half the true neighbours unless the shortlist was re-scored.

Overall, the best FiQA setup reached 0.487 against 0.251 for BM25.

What didn’t hold up

I went in expecting BM25 to win on queries with a rare exact term: tickers, drug names, acronyms. The data doesn’t support that. The dense model’s lead was positive in every tercile of query specificity. BM25 still wins on 10-33% of individual queries, and that is the room fusion exploits.

The chunking results are single-run effect sizes without confidence intervals, so I treat them as direction, not proof.

Limits

  • Three English corpora with short-to-medium documents. Long manuals or contracts would stress chunking much harder.
  • Dev splits are small (324-809 queries) and only one fusion weight was tuned.
  • Rerankers were used off the shelf. Fine-tuning on in-domain data could change those results.
  • Latencies come from one laptop GPU and are relative, not absolute. ANN results are for 57k vectors; at millions, the trade-offs shift.

Contact

Want the longer version?

Happy to walk through any of this in detail — the parts that broke are usually the interesting bit.