<!-- generated by build_articles.py — edit content/science/bm25.md instead -->
---
title: "BM25 vs vector search"
canonical: "https://xerj.org/science/bm25"
updated: "2026-11-13"
source: "content/science/bm25.md"
---

# BM25 vs vector search

**Short answer** (updated 2026-11-13): What is the difference between BM25 and vector search? BM25 ranks a document by query-term frequency, how rare those terms are, and document length. A vector query ranks by meaning, so a paraphrase can still match. XERJ uses BM25 by default, and can add a vector arm in hybrid search.

**TL;DR** BM25 vs vector search comes down to shared terms versus meaning. BM25 scores a document by query-term frequency, how rare those terms are, and document length. A vector query can match a paraphrase that uses different words.

## Agent prompt

```text
Act as a coding agent. Read https://xerj.org/llms.txt, install XERJ, start a local node, index one folder I point you to, and run one search so I can see a cited passage.
```

*Figure: The three parts are the usual account of BM25 in Robertson and Zaragoza, The Probabilistic Relevance Framework: BM25 and Beyond (2009). This page does not run BM25 on a new corpus.*

## How it works

Three ideas sit inside a BM25 score.

Term frequency: a document that uses a query term more often gets a higher score, with a cap so repetition does not take over.

Inverse document frequency: a term that appears in few documents is worth more than a term that appears in almost every document.

Length: a long document is not automatically better. BM25 adjusts for document length so a short, on-topic passage can still rank well.

The walkthrough above is a teaching account of those three ideas. It does not run BM25 on a new corpus.

## How XERJ uses it

BM25 is the default lexical ranker in XERJ. You can use it on its own, or as the lexical arm of [hybrid search](/science/hybrid-search). Product examples use k1 = 1.2 and b = 0.75.

For a side-by-side with vector search, see [BM25 vs vector search](/answers/bm25-vs-vector-search). For the how-to on combining both arms, see [how to run hybrid search in XERJ](/answers/what-is-hybrid-search).

## History and research

A standard reference is Robertson and Zaragoza, [The Probabilistic Relevance Framework: BM25 and Beyond](https://doi.org/10.1561/1500000019), Foundations and Trends in Information Retrieval, 2009. That survey is the source for the three-part account on this page.

This page does not rest on a second historical paper. It also does not treat a XERJ benchmark as a BM25 research result.

## Related terms

[Hybrid search](/science/hybrid-search), [semantic search](/science/semantic-search), and [hybrid vs vector vs semantic search](/science/hybrid-vs-vector-vs-semantic-search).

## FAQ

### What does BM25 stand for?

Best Match 25. It is a family of ranking functions from the Okapi retrieval work, later set out in detail by Robertson and Zaragoza.

### What three ideas does the score use?

Term frequency, with a cap so repetition does not take over. Inverse document frequency, so rare terms count more. A length adjustment, so a long document is not automatically better.

### How does XERJ use BM25?

BM25 is the default lexical ranker. You can use it alone, or fuse it with a vector arm in hybrid search. The default k1 and b values used in product examples are k1 = 1.2 and b = 0.75.

### How does BM25 differ from vector search?

BM25 needs shared terms and is strong on exact names. A vector query can match a paraphrase. Hybrid search runs both and fuses the lists.

## Related

- [Hybrid vs vector vs semantic search](/science/hybrid-vs-vector-vs-semantic-search)
- [What is hybrid search?](/science/hybrid-search)
- [What is semantic search?](/science/semantic-search)
- [What is reranking?](/science/reranking)
- [BM25 vs vector search: which one should you use?](/answers/bm25-vs-vector-search)
- [How to run hybrid search in XERJ](/answers/what-is-hybrid-search)
- [Neurosymbolic AI vs LLMs](/science/neurosymbolic-ai) (same intent: Science)
- [What is syntax-aware search?](/science/syntax-aware-search) (same intent: Science)
- [What is agentic memory?](/science/agentic-memory) (same intent: Science)
