RAG & Documents
Why doesn't your AI document search find what you're looking for? Keyword search, semantic search and reranking measured in Spanish
What to ask whoever builds you a chat over your contracts or manuals: keyword search, semantic search or both, plus a reranking step. Measured in Spanish: what really improves and how long it takes.
- Date
- Nov 25, 2026
- Reading time
- 11 min
- Result
- Mixing keywords and meaning: +3.91 points on MLQA and −4.69 on MIRACL • mixing and reranking: +9.91 and +10.78 • reranking: 765–988 ms per query
Translated from the Spanish original. The code, data and READMEs on GitHub are in Spanish.
If your AI assistant “can’t find” what’s in your documents, it’s almost never the fault of the model that writes the answer: the step before fails, the search that chooses which chunks to read. We measured it in Spanish. Mixing keyword search and semantic search doesn’t always help: it raised the score by 3.91 points on one set of questions and lowered it by 4.69 on another. What improved both was adding a reranking step over the first 20 results: between 9.91 and 10.78 points more than semantic search alone, at the cost of almost one more second per query (765 to 988 ms) on a laptop. Measured on 28 October 2026 with 1,648 questions in Spanish from two public datasets (MIRACL and MLQA), on an Apple M1 Max. Figures, code and the score for every question, published.
The problem, with a small-business example
Imagine a 15-person law firm that has commissioned a chat to query its contracts and case files. A lawyer asks “what does the penalty clause in case file 2024/0317 say?” or “what deadline did we agree with Construcciones Ruiz?”, and the assistant answers with a clause from another contract, or says it can’t find it.
The example is illustrative: we haven’t measured any firm’s search. But the mechanism is always the same. Before answering, the assistant searches your documents for the chunks that look relevant and reads only those. If the right chunk doesn’t come up near the top, the AI can’t use it, however good the model is. This setup is called RAG (retrieval-augmented generation): search first, then write with what was found.
The three parts of the search, in one sentence each
- Keyword search (in the trade, BM25): finds the chunks that share words with the question. It gets case numbers, proper names and exact terms right; it fails if the document says the same thing in other words (“penalty” vs “liquidated damages clause”).
- Semantic search (vector search or search with embeddings): turns the question and each chunk into a numerical fingerprint and looks for the most similar ones. It understands synonyms and paraphrases; it can fail with exact figures and names.
- Hybrid search: does both and merges the lists. The most common merge (RRF) only looks at what position each chunk takes in each list.
- Reranking (reranker): a second model reads the question together with each of the top results and reorders them. It’s more accurate and much slower, so it’s only applied to the first 20, not to every document.
The “score” we use runs from 0 to 100 and measures how high the right chunks appear among the first 10 results (in the trade, nDCG@10). The higher it is, the more likely the AI reads the correct chunk.
What the result means for your company
- Mixing keywords and meaning isn’t a guaranteed improvement. It helped when the questions repeated the document’s words (+3.91 points on MLQA) and hurt when people asked in their own words (−4.69 on MIRACL). If your provider tells you “hybrid always wins”, ask them to measure it with your questions.
- Reranking was what improved things most in both cases. With hybrid search plus reranking, out of every 100 right chunks, 65 appeared among the first 10 results on MIRACL, compared with 58 with semantic search alone, on the same sample of 300 questions.
- The price is response time. Semantic search took about 15 ms per query; reranking, between 765 and 988 ms on this laptop. For an internal assistant used by lawyers or the admin team, one extra second is usually acceptable; for a customer-facing search on the website, you need to measure it. Everything ran locally, with open models you can download for free, and without sending the documents anywhere.
- Case numbers and proper names weren’t where keyword search helped most. We expected it to, and it didn’t happen in this data. But these are Wikipedia questions, without codes like “2024/0317”. If your business searches a lot by exact reference, include those in the test.
What to ask your provider
- Which search it uses: semantic only, keyword only or both. If they don’t know, that’s a sign.
- That it has a reranking step over the top results, or an explanation of why not.
- That they measure it with your questions. A set of 30 to 50 real questions from your team, with the correct document noted next to each, is enough to compare options. Without that, any figure is the provider’s, not yours.
- The response time with and without reranking, on the machine or service where it will run.
- Where the documents are processed. Search and reranking can run on your own server, as in this test; if they go to an external service with customer data, the GDPR applies and you need a data processing agreement.
What to do on Monday
- Ask three people on the team to note down for a week the questions they ask (or would ask) the assistant, and which document has the answer.
- Try them yourself in the current assistant: note how many it finds first time. Separate the ones that include a case number, a tax ID or a proper name.
- With that list, ask the provider for the five answers above. If the chat doesn’t exist yet, give it to them as a requirement before signing.
For technical readers: the full experiment
What follows is the measurement exactly as it was done, with the trade’s terminology. The figures come from the published code and haven’t been touched.
- nDCG@10: from 0 to 100, how high relevant passages appear in the top 10. Recall@10 / @100: what share of the relevant ones is in the top 10 or 100. MRR@10: how high the first relevant one comes up.
- RRF (Reciprocal Rank Fusion): each passage adds 1/(60 + position) from each list. It only uses positions, not scores. The reranker is a cross-encoder.
- Literal query: one containing figures or proper names, where BM25 is supposed to help.
Hypotheses
- Hybrid search beats BM25 and dense search separately.
- BM25 contributes mainly on queries with figures and proper names.
- The reranker improves the result, but its latency cost is high.
Setup
- Datasets: Spanish MIRACL (dev), in MTEB’s reduced version with hard negatives: 146,750 Wikipedia passages and 648 questions written by people, with 4.61 relevant passages on average. Spanish-Spanish MLQA (test): 4,761 passages and a fixed sample of 1,000 SQuAD-style questions, written from the passage itself and with 1 relevant passage.
- Retrievers: BM25 (bm25s 0.3.15, Spanish Snowball); dense with multilingual-e5-small on both datasets and with bge-m3 (fp16) on MLQA only; RRF (k = 60) of the top 100 from BM25 and from each dense retriever; bge-reranker-v2-m3 (fp16) over the top 20 from BM25 and from the hybrid with e5-small, on a fixed sample of 300 questions per dataset.
- Metrics: nDCG@10, Recall@10, Recall@100 and MRR@10 per question. nDCG@10 differences with a 95% confidence interval by paired bootstrap.
- Latency: one question at a time, 30 fixed questions × 5 repetitions per dataset (150 measurements per step). The BM25 index was built 5 times.
- Machine: Apple M1 Max laptop with 64 GB, macOS 26.6.2, Python 3.12.13; embeddings and reranker on the GPU (MPS).
Results
Quality with all questions
| Dataset and method | nDCG@10 | Recall@10 | Recall@100 | MRR@10 |
|---|---|---|---|---|
| MIRACL · BM25 | 26.02 | 30.63% | 76.72% | 38.26 |
| MIRACL · e5-small | 51.21 | 57.96% | 95.08% | 66.14 |
| MIRACL · RRF BM25 + e5-small | 46.52 | 53.10% | 94.92% | 60.52 |
| MLQA · BM25 | 68.41 | 79.05% | 88.55% | 65.06 |
| MLQA · e5-small | 69.87 | 81.25% | 92.25% | 66.26 |
| MLQA · bge-m3 | 71.05 | 81.75% | 93.05% | 67.67 |
| MLQA · RRF BM25 + e5-small | 73.78 | 84.75% | 93.75% | 70.33 |
| MLQA · RRF BM25 + bge-m3 | 74.31 | 85.15% | 95.05% | 70.89 |
- On MLQA, hybrid wins. RRF with e5-small gains 3.91 points over e5-small alone (95% CI: 2.45 to 5.39) and 5.37 over BM25. With bge-m3, 3.26 points more than bge-m3 alone.
- On MIRACL, hybrid loses. BM25 stays at 26.02 and drags the fusion down: RRF ends up 4.69 points below e5-small alone (95% CI: -6.83 to -2.70). Recall@100 is almost the same (94.92% vs 95.08%): the good passages are still in the top 100, but lower down.
- The difference between datasets is the type of question. In MLQA the question was written while reading the passage and repeats its words; in MIRACL it was written by someone who hadn’t seen it, and the hard negatives share vocabulary with it.
Queries with figures or proper names
| Dataset and method | Literal nDCG@10 | Non-literal nDCG@10 |
|---|---|---|
| MIRACL · BM25 | 26.40 | 25.47 |
| MIRACL · e5-small | 52.96 | 48.69 |
| MIRACL · RRF BM25 + e5-small | 46.71 | 46.25 |
| MLQA · BM25 | 78.86 | 54.55 |
| MLQA · e5-small | 82.33 | 53.36 |
| MLQA · RRF BM25 + e5-small | 84.53 | 59.53 |
Hypothesis 2 doesn’t hold: on MIRACL hybrid also loses with figures and proper names (46.71 vs 52.96). On MLQA, BM25 beats e5-small precisely on questions without figures or names (54.55 vs 53.36), and hybrid wins in both groups.
With a reranker (sample of 300 questions per dataset)
| Dataset and method | nDCG@10 | Recall@10 | MRR@10 |
|---|---|---|---|
| MIRACL · e5-small | 52.80 | 57.94% | 69.25 |
| MIRACL · RRF BM25 + e5-small | 48.16 | 53.16% | 62.59 |
| MIRACL · BM25 + reranker | 43.92 | 40.87% | 66.83 |
| MIRACL · RRF + reranker | 63.58 | 65.16% | 81.45 |
| MLQA · e5-small | 69.97 | 79.33% | 67.04 |
| MLQA · RRF BM25 + e5-small | 73.66 | 83.67% | 70.57 |
| MLQA · BM25 + reranker | 78.42 | 82.67% | 77.04 |
| MLQA · RRF + reranker | 79.89 | 85.67% | 78.04 |
| Comparison (nDCG@10, same sample) | MIRACL | MLQA |
|---|---|---|
| RRF + reranker vs e5-small alone | +10.78 (7.94 to 13.48) | +9.91 (6.93 to 13.26) |
| RRF + reranker vs RRF without reranker | +15.42 (13.03 to 17.96) | +6.23 (3.87 to 8.67) |
| RRF + reranker vs BM25 + reranker | +19.66 (16.96 to 22.61) | +1.46 (-0.60 to 3.53) |
In brackets, the 95% confidence interval. The reranker improves 211 of the 300 MIRACL questions and worsens 47; on MLQA it improves 55, worsens 12 and leaves 233 unchanged (many already had the relevant passage in first place).
This is where hybrid does earn its keep: as the reranker’s input. RRF without a reranker loses on MIRACL, but its top 20 contains more good passages than BM25’s, and the reranker moves them up. Reranking only BM25’s top 20 ends up 8.88 points below dense alone on MIRACL.
Latency per query (median of 150 measurements, one question at a time)
| Step | MIRACL (146,750 passages) | MLQA (4,761 passages) |
|---|---|---|
| BM25, top 100 | 1.03 ms | 0.45 ms |
| e5-small: encode the question and search | 14.84 ms | 8.50 ms |
| bge-m3: encode the question and search | — | 18.56 ms |
| RRF fusion | 0.05 ms | 0.05 ms |
| Reranker, 20 passages | 765.12 ms | 987.73 ms |
| Reranker, 20 passages (p90) | 1200.51 ms | 1254.16 ms |
Spread between repetitions is low: the reranker’s median ranges from 759.20 to 765.29 ms across the 5 repetitions on MIRACL. The MIRACL BM25 index builds in 6.57 s (median of 5); MLQA’s in 0.26 s. Computing the embeddings for the 146,750 passages with e5-small took 489.48 s, in a single run.
What it means
- Hypothesis 1: it depends on the questions. If your users ask with the document’s words (support with error codes, catalogues, cited regulations), hybrid adds a few points. If they ask in their own words, BM25 can subtract.
- Hypothesis 2: it doesn’t hold in this data. Figures and proper names weren’t where BM25 helped most.
- Hypothesis 3: it holds. The reranker is the piece that raises quality most (from 9.91 to 10.78 points over dense) and the one that costs most: 765.12 ms per query on MIRACL vs 14.84 ms for dense search, on this machine.
When to use each option
- Dense only: the starting point. With questions written by users, it beat hybrid without a reranker.
- Hybrid without a reranker: when questions share vocabulary with the documents and you can’t add a second of latency. Measure it with your questions before taking it for granted.
- Hybrid with a reranker: when quality matters more than latency (internal assistants, document search, answers that get reviewed). It was the best option on both datasets. On a server GPU or with a smaller reranker, latency drops; that wasn’t measured here.
- BM25 with a reranker: only if you don’t have embeddings. On MLQA it came close to the best; on MIRACL, below dense alone.
Limitations
- Two public Wikipedia datasets, not company documents. MLQA has 1 relevant passage per question and a lot of lexical overlap; MIRACL has incomplete relevance judgements (an unmarked good passage counts as a miss).
- The MIRACL corpus is MTEB’s reduced version, made up of the passages that several retrievers returned for these questions. That makes every negative resemble the question and may penalise BM25 more than a full corpus would.
- bge-m3 was only measured on MLQA: computing its embeddings for the full MIRACL didn’t fit in the compute time. Its sparse vectors and ColBERT, other values of k in RRF, weighted score fusion and other top sizes for the reranker weren’t tested either.
- The reranker was evaluated on 300 questions per dataset; the confidence intervals reflect that.
- A single Apple Silicon laptop, on battery and with other apps open. Reranker latency depends heavily on the GPU and passage length; it’s good for the order of magnitude. All the computation fit in under 30 minutes.
How to reproduce it
Code, pinned data and model revisions, every question’s score and raw latencies: yeswelab-laboratorio/busqueda-hibrida-bm25-embeddings-rag-espanol on GitHub. It runs with no accounts or keys; the first time it downloads from Hugging Face the data, the two embedding models and the reranker (several GB).
Related
- What chunk size should you use in a Spanish RAG?: how to split documents before searching.
- Which PDF parser should you use for RAG in Spanish?: if the text comes out of the PDF badly, no search will fix it.
- Which vector database should you use locally for RAG?: where to keep semantic search without uploading documents to the cloud.
- AI agents for business: use cases by department.
Your assistant can’t find what’s in your documents and you don’t know whether search, reranking or chunking is failing? Commission the test with your documents and your team’s questions: we measure it before you pay for the solution.