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

> Source: <https://dev.to/borjanladinski/bm25-vs-semantic-search-vs-hybrid-rag-what-my-benchmarks-revealed-2klk>
> Published: 2026-11-27 22:09:47+00:00

**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 the playbook "Retrieval and RAG": <https://wpnews.pro/playbooks/rag-retrieval>

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](https://borjan.ladinski.com/articles/bm25-semantic-hybrid-rag-benchmarks/)

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.
