New Tool Radar

AI Concepts

How to Compare BM25 and Vector Search on the Same RAG Queries

Run BM25 keyword search and vector search side by side on the same questions, so you can see which failure each one owns.

Schematic illustration with three step boxes: pick mixed questions, run both retrievers, and sort the failures.

Dense vector retrieval struggles with rare identifiers, exact codes and names the embedding model barely knows, while BM25 struggles with paraphrases where the question and the document share no words. The two methods tend to fail on different questions, which is why comparing them first tells you whether you need one, the other, or both.

Before you start

A corpus indexed for both BM25 and vector search, and a test set mixing exact-term questions with paraphrase questions.

Pick a mixed question set

Write ten questions that use exact terms from the documents, such as a product code or an error number, and ten that paraphrase the content without reusing its words. Label each question with its type before you run anything.

If all your questions are one type, the comparison will crown the wrong winner.

Run both retrievers on every question

For each question, record whether the answer chunk appears in the top 5 for BM25 and for vector search separately. Use the same chunk set for both, so the only difference is the ranking method.

Note the rank, not just a pass or fail: a method that puts the answer at rank 5 is weaker than one that puts it at rank 1, even if both pass.

Sort the failures by type

Count the failures per question type for each method. If BM25 fails mostly on paraphrases and vector search fails mostly on exact codes, the two are complementary and a hybrid is worth building.

If one method wins on both types, use it alone. Adding a second retriever that never helps only adds cost and moving parts.

Practice check: fictional Maple Corner docs, 20 questions

The table below is fictional practice material, worked out by hand from the stated results. It is the expected result for the practice set, not a run of any search system.

Question type BM25 top 5 Vector top 5 Reading
Exact code or term 9 of 10 5 of 10 BM25 wins on exact terms
Paraphrase 4 of 10 8 of 10 Vector wins on paraphrases
All 20 13 of 20 13 of 20 Tie overall, opposite failures

Both methods score 13 of 20 overall but fail on opposite question types, so a hybrid that runs both should beat either one alone.

Expected result. UNTESTED: the scores in the practice table are worked out by hand, not measured by running a search system. Run your own mixed question set through both retrievers and sort the failures by question type.

Limits

  • A tie on a small test set is not proof: 20 questions can hide a real gap in either direction.
  • BM25 needs an inverted index and vector search needs embeddings; the comparison assumes both are already built.

Sources

See all