Add BM25SRetriever: pure-Python BM25 with no Java/Pyserini dependency#116
Draft
Add BM25SRetriever: pure-Python BM25 with no Java/Pyserini dependency#116
Conversation
Agent-Logs-Url: https://github.com/DataScienceUIBK/Rankify/sessions/9e4d6c84-c9c5-4b75-b11a-e82fe15ba9a1 Co-authored-by: abdoelsayed2016 <27821589+abdoelsayed2016@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add BM25s as a replacement for Pyserini
Add BM25SRetriever: pure-Python BM25 with no Java/Pyserini dependency
Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing
BM25Retrieverrequires Pyserini (~7GB install) and a JVM. This addsBM25SRetrieverbacked bybm25s— a pure-Python implementation that runs significantly faster and weighs ~479MB total.New:
BM25SRetrieverrankify/retrievers/bm25s_retriever.py— new retriever; builds a bm25s index from a JSONL or TSV corpus on first use, persists it to disk, and loads it on subsequent runs. No Java, no JVM, no Lucene.{"id", "title", "text"}) and TSV (id\ttext\ttitle, same layout aspsgs_w100.tsv)stemmer_langparameter_has_answers— no pyserini import requiredIntegration
retriever.py— adds"bm25s"toMETHOD_MAP; all retriever imports wrapped intry/exceptso missing optional deps (pyserini, faiss, gensim, etc.) no longer block imports of unrelated retrievers__init__.py— exportsBM25SRetriever; same graceful import handlingbm25_retriever.py/diver_bm25_retriever.py— pyserini imports made lazy; raise a descriptiveImportErrorpointing toBM25SRetrieverif pyserini is absentpyproject.toml—bm25s>=0.2.0added to[retriever]optional depsUsage