Papers › BM25S: Orders of magnitude faster lexical search via eager sparse scoring

BM25S: Orders of magnitude faster lexical search via eager sparse scoring

4 Jul 2024arXiv:2407.03618archive 2025-07-28

Xing Han Lù

We introduce BM25S, an efficient Python-based implementation of BM25 that only depends on Numpy and Scipy. BM25S achieves up to a 500x speedup compared to the most popular Python-based framework by eagerly computing BM25 scores during indexing and storing them into sparse matrices. It also achieves considerable speedups compared to highly optimized Java-based implementations, which are used by popular commercial products. Finally, BM25S reproduces the exact implementation of five BM25 variants based on Kamphuis et al. (2020) by extending eager scoring to non-sparse variants using a novel score shifting method. The code can be found at https://github.com/xhluca/bm25s

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2407.03618")

Code

Syntology Ran 10 of 22 code samples harvested from 2 repositories linked to this paper; 12 have no recorded run. Of those that ran: 10 ran with no contract checked.

By repository: official repository: 17 samples from 1 repository, 10 ran; community (archive-listed): 5 samples from 1 repository, 0 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

xhluca/bm25s officialmentioned in papermentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

22 samples harvested; 10 ran; 0 honoured the contract we drafted; 12 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

10ran
12unverified

Licence: 0 of the 22 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

can_save_locally xhluca/bm25s/bm25s/hf.py official repository ran MIT (permissive) · e7083f6103f913bb · report
change_extension xhluca/bm25s/bm25s/utils/corpus.py official repository ran fingerprinted MIT (permissive) · 05fff06955fafff6 · report
clean_results_keys xhluca/bm25s/bm25s/utils/beir.py official repository ran MIT (permissive) · d4e1a0e6133bc36b · report
convert_tokenized_to_string_list xhluca/bm25s/bm25s/tokenization.py official repository ran MIT (permissive) · ab7f90eda021ae13 · report
dumps_with_builtin xhluca/bm25s/bm25s/utils/json_functions.py official repository ran MIT (permissive) · 59ca7ac3fdaff9b0 · report
heap_pop xhluca/bm25s/bm25s/numba/selection.py official repository ran MIT (permissive) · 0a07896a7f42f858 · report
is_dir_empty xhluca/bm25s/bm25s/hf.py official repository ran MIT (permissive) · cd3dee563db75da9 · report
postprocess_results_for_eval xhluca/bm25s/bm25s/utils/beir.py official repository ran MIT (permissive) · bd26864807521fc2 · report
topk xhluca/bm25s/bm25s/selection.py official repository ran MIT (permissive) · 679762797d78948e · report
topk xhluca/bm25s/bm25s/numba/selection.py official repository ran MIT (permissive) · 95129e49e1d55862 · report
batch_tokenize xhluca/bm25s/bm25s/hf.py official repository unverified MIT (permissive) · 4690c1cf386dfd10 · report
download_dataset xhluca/bm25s/bm25s/utils/beir.py official repository unverified MIT (permissive) · a195383bf3405f8c · report
dumps_with_orjson xhluca/bm25s/bm25s/utils/json_functions.py official repository unverified MIT (permissive) · 16c525229af810b0 · report
find_newline_positions xhluca/bm25s/bm25s/utils/corpus.py official repository unverified MIT (permissive) · 572c5677af80154d · report
get_max_memory_usage xhluca/bm25s/bm25s/utils/benchmark.py official repository unverified MIT (permissive) · c7e33bb0befabc76 · report
load_mmindex xhluca/bm25s/bm25s/utils/corpus.py official repository unverified MIT (permissive) · 05a414c3417e7237 · report
tokenize xhluca/bm25s/bm25s/tokenization.py official repository unverified MIT (permissive) · 7c70347879b998bf · report
compute_top_k_from_scores xhluca/bm25-benchmarks/benchmark/on_bm25_pt.py community (archive-listed) unverified MIT (permissive) · f16a6001458fe054 · report
compute_top_k_from_scores xhluca/bm25-benchmarks/benchmark/on_rank_bm25.py community (archive-listed) unverified MIT (permissive) · cda747e09a9100fd · report
evaluate xhluca/bm25-benchmarks/benchmark/on_bm25s.py community (archive-listed) unverified MIT (permissive) · cae3ad88ac9412a8 · report
format_beir_result_keys xhluca/bm25-benchmarks/benchmark/on_pisa.py community (archive-listed) unverified MIT (permissive) · ac6986c427c852da · report
load_qrels_dict xhluca/bm25-benchmarks/benchmark/on_bm25s.py community (archive-listed) unverified MIT (permissive) · 4cc099c26fff4c42 · report

Tasks

Passage RetrievalRetrievalText RetrievalZero-shot Text Search

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Retrieval HotpotQA BM25S Queries per second 20.88 #1 of 3 Archive leaderboard report
Retrieval HotpotQA Elasticsearch Queries per second 7.11 #2 of 3 Archive leaderboard report
Retrieval HotpotQA Rank-BM25 Queries per second 0.04 #3 of 3 Archive leaderboard report
Retrieval Natural Questions BM25S Queries per second 41.85 #1 of 3 Archive leaderboard report
Retrieval Natural Questions Elasticsearch Queries per second 12.16 #2 of 3 Archive leaderboard report
Retrieval Natural Questions Rank-BM25 Queries per second 0.10 #3 of 3 Archive leaderboard report
Retrieval Quora Question Pairs BM25S Queries per second 183.53 #1 of 4 Archive leaderboard report
Retrieval Quora Question Pairs Elasticsearch Queries per second 21.8 #2 of 4 Archive leaderboard report
Retrieval Quora Question Pairs BM25-PT Queries per second 6.49 #3 of 4 Archive leaderboard report
Retrieval Quora Question Pairs Rank-BM25 Queries per second 1.18 #4 of 4 Archive leaderboard report
Text Retrieval CLIMATE-FEVER Lucene (BM25S) nDCG@10 16.2 #1 of 1 Archive leaderboard report
Text Retrieval DBpedia Lucene (BM25S) nDCG@10 31.9 #1 of 1 Archive leaderboard report
Text Retrieval FEVER Lucene (BM25S) nDCG@10 63.8 #1 of 1 Archive leaderboard report
Text Retrieval HotpotQA Lucene (BM25S) nDCG@10 62.9 #1 of 1 Archive leaderboard report
Text Retrieval MS MARCO Lucene (BM25S) NDCG@10 22.8 #1 of 1 Archive leaderboard report
Text Retrieval NFCorpus Lucene (BM25S) nDCG@10 31.8 #1 of 1 Archive leaderboard report
Text Retrieval Natural Questions Lucene (BM25S) NDCG@10 30.5 #1 of 1 Archive leaderboard report
Text Retrieval Quora Question Pairs Lucene (BM25S) nDCG@10 78.7 #1 of 1 Archive leaderboard report
Text Retrieval SciDocs Lucene (BM25S) nDCG@10 67.6 #1 of 1 Archive leaderboard report
Text Retrieval SciFact Lucene (BM25S) nDCG@10 15 #1 of 1 Archive leaderboard report
Text Retrieval TREC-COVID Lucene (BM25S) nDCG@10 58.9 #1 of 1 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections