01 / COVERAGE
Pay for two perspectives.
Dense and keyword search can recover different relevant results. Running both adds work, and evaluation showed fusion was not always an improvement.
RAG / SCIENTIFIC SEARCH
I built a multi-stage search pipeline for scientific research—and the evaluation harness that exposed where it was quietly falling short.
↓THE TENSION
A search for “sponge” returned Porifera first—but eight of the top ten were names containing similar letters.
The correct scientific group was less than 0.01 ahead of the next result. The ranking looked convincing, but the narrow gap and the near-matches exposed a deeper problem: matching a term is not the same as finding its meaning. For a research tool, that distinction matters.
One query exposed a gap between matching a word and understanding a scientific group.
The correct group, with a lead of less than 0.01 over the second result.
Letter-matching names, including Spongocoelia, Pterospongus, and Heterospongus.
Hybrid retrieval · RAG
Backend / applied AI engineer
Qdrant · BM25 · BEIR
THE IDEA THAT SHAPED THE SYSTEM
Dense retrieval finds conceptual similarity; BM25 preserves exact terms. I combined their rankings, reranked the candidates with a cross-encoder, and built a benchmark around the production retrieval code so each decision could be measured.
A simplified view of the retrieval path, from a researcher’s query to context for the downstream RAG system.
QUERY → DENSE + SPARSE → RRF → RERANK → RAG
Dense embeddings search for meaning while BM25 retrieves exact terms. Each produces its own ranked candidates for the same query.
Conceptual similarity and precise scientific names provide complementary signals.
The choices that mattered most, and the problem each one addressed.
01 / COVERAGE
Dense and keyword search can recover different relevant results. Running both adds work, and evaluation showed fusion was not always an improvement.
02 / FUSION
RRF avoids calibrating two changing score scales, at the cost of discarding the magnitude of each system’s confidence.
03 / RELEVANCE
The cross-encoder considers the query and candidate together. I capped the pool at 100 instead of 300 after observing no quality loss in the comparison.
04 / MEASUREMENT
A reranker can improve one dataset and hurt another. The test harness made those differences visible before treating a stage as a universal win.
The harness ran the production retrieval code against public BEIR datasets, measuring what each stage changed—not just the final score.
SciFact
Each stage improved the reported ranking quality.
NFCorpus
MRR@10 fell, indicating the first relevant result appeared later on average; the observed drop was statistically significant.
DBPedia-Entity
Keyword fusion hurt the score; reranking recovered it above the starting point.
SCIDOCS
Neither fusion nor reranking beat dense-only search in the initial comparison.
WHAT THE BENCHMARK CAUGHT
Building the evaluation took longer than the initial pipeline, and it exposed two concrete issues.
KEYWORD SCORING
The client-side BM25 calculation used an average document length of 150; paper abstracts averaged about 225. That assumption distorted length normalization. Moving to Qdrant’s built-in BM25 removed that client-side calculation.
RERANKING POOL
The first version sent up to 300 candidates for reranking. Testing a cap of 100 showed no quality loss in that comparison and reduced the amount of reranking work.
A Voyage embedding and reranking combination beat the OpenAI + Cohere baseline on every reported metric across the four datasets and resolved the NFCorpus regression. The SCIDOCS pattern persisted, pointing to the keyword leg as a likely contributor rather than proving the cause.
512 and 1,024 dimensions produced scores within 0.002 in this comparison. I selected 512 for the candidate configuration; latency, cost per call, and rate limits still need evaluation before a migration ships.
The benchmark turned retrieval changes into decisions we could examine. It also made clear that no single stage won on every dataset.
Scores describe the reported evaluation, not a guarantee across all workloads. The model migration remains a candidate.