cd /news/ai-tools/bm25-vs-semantic-search-vs-hybrid-ra… · home › topics › ai-tools › article
[ARTICLE · art-177494] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=· neutral

BM25 vs Semantic Search vs Hybrid RAG: What My Benchmarks Revealed

A developer building an open-source codebase RAG system called AI Codebase Intelligence benchmarked four retrieval methods and found that equal-weight hybrid RRF underperformed semantic search alone, scoring an MRR@5 of 0.692 versus 0.854. Adding cross-encoder reranking after RRF recovered the gap, reaching a Hit@5 of 1.000 and MRR@5 of 0.875, slightly above semantic search. The developer cautioned that the evaluation set was small and measured retrieval quality only, not end-to-end answer accuracy or latency.

recommendation

Benchmark hybrid retrieval against semantic-only on your own eval set before shipping it, and add cross-encoder reranking after RRF to recover ranking quality.

more in playbook: Retrieval and RAG
by read3 min views2 publishedNov 27, 2026

I built a codebase RAG system using BM25, semantic search, reciprocal rank fusion (RRF), and cross-encoder reranking.

I expected hybrid search to outperform semantic search alone.

It didn't.

On my evaluation set, semantic search achieved an MRR@5 of 0.854, while hybrid RRF dropped to 0.692.

Adding cross-encoder reranking changed the result.

Here's what I tested and what I learned.

Searching a codebase isn't the same as searching ordinary text.

A developer might ask:

Where does the application check whether a user is logged in?

But the relevant implementation could be a function named decode_access_token.

BM25 can find exact identifiers. Semantic search can match questions to code with different wording.

I wanted to see whether combining both approaches would improve retrieval quality.

My project, AI Codebase Intelligence, indexes software repositories and lets developers ask questions about their code.

The system uses:

The retrieval pipeline looks like this:

Question
   |
   v
BM25 + Semantic Search
   |
   v
Reciprocal Rank Fusion
   |
   v
Cross-Encoder Reranking
   |
   v
Relevant Code Chunks
   |
   v
Local LLM
   |
   v
Answer + Source Citations

I created a small ground-truth evaluation set and compared four retrieval methods.

I measured:

Hit@5: Whether at least one relevant result appears in the top five.

MRR@5: How highly the first relevant result ranks within the top five, averaged across queries.

Here are the results:

Retrieval Method Hit@5 MRR@5
BM25 0.750 0.500
Semantic Search 1.000 0.854
Hybrid RRF 0.875 0.692
RRF + Reranking 1.000 0.875

These results come from my project's evaluation set, not a standardized public benchmark.

Hybrid RRF performed worse than semantic search alone.

Combining BM25 and semantic search actually reduced both Hit@5 and MRR@5 in this experiment.

The initial hybrid implementation used equal-weight RRF.

One possible explanation is that combining the ranked lists pushed some relevant semantic results lower. However, I haven't isolated the exact cause.

The important point is that adding another retrieval component did not automatically improve the results.

I added a cross-encoder reranker after RRF.

Instead of relying only on the original retrieval rankings, the cross-encoder evaluates the query and each candidate together to produce a new ordering.

The result:

Compared with semantic search alone, the final pipeline achieved the same Hit@5 and a slightly higher MRR@5.

That improvement gave me a measurable reason to keep the reranking stage.

The project also includes the engineering needed to make the retrieval system usable.

Repository indexing runs asynchronously using Celery and Redis.

Repeated RAG responses can be cached in Redis.

Generated answers include source file and line-range citations, making it easier to verify the retrieved evidence.

I also added read-only MCP tools for searching code, retrieving files, listing symbols, and asking questions about a repository.

This was a small evaluation, so the results shouldn't be treated as universal.

Different datasets, repositories, embedding models, fusion parameters, and rerankers may produce different outcomes.

I also measured retrieval quality, not end-to-end answer accuracy or latency.

Those would be important next steps.

The biggest lesson from this project wasn't that hybrid RAG is better or worse than semantic search.

It was that retrieval quality needs to be measured instead of assumed.

My first hybrid implementation added complexity while reducing performance.

Cross-encoder reranking improved the results, but the benefit only became clear after running the evaluation.

A more complicated RAG architecture isn't automatically a better one.

Read the full technical article, including the architecture and implementation details:

BM25 vs Semantic Search vs Hybrid RAG: What My Benchmarks Revealed

I'm Borjan Ladinski, an AI Engineer and AI Consultant based in Skopje, North Macedonia. I work on AI agents, LLM applications, RAG, machine learning, and business automation.

── more in #ai-tools 4 stories · sorted by recency
── more on @ai codebase intelligence 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/bm25-vs-semantic-sea…] indexed:0 read:3min 2026-11-27 · —