Pre-release v0.2.0: Speeding up retrieval with numba, and new stopwords #46
xhluca
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is a pretty exciting pre-release! It is a major new feature for the v0.2.0 that will come out soon. I hope you get to try this and share your thoughts in this thread!
to try:
pip install numba pip install "bm25s[full]==0.2.0rc6"
What's Changed
texts
argument intokenize
function and replacetime.time() with
time.monotonic()` by @dantetemplar in Add type hint fortexts
argument intokenize
function, usetime.monotonic
instead oftime.time
#44New Contributors
texts
argument intokenize
function, usetime.monotonic
instead oftime.time
#44Full Changelog: 0.1.10...0.2.0rc6
Notes about new numba integration
In PR #41, we add support for Numba's no-python JIT compiling, allowing substantial speedup. For example, we went from 41 queries/s for NQ to 91.83 q/s (see bm25-benchmark).
Changes
retriever.retrieve(... backend_selection="numba")
to activate it.retriever.activate_numba_scorer()
to enable numbatests/numba/test_topk_numba.py
examples/retrieve_with_numba.py
Detailed notes
New scoring approaches (numba ready)
You can find the function
_compute_relevance_from_scores_legacy
inbm25s/scoring.py
to see how the old scoring worked. We now also have a_compute_relevance_from_scores_jit_ready
which is an alternative to the legacy and default relevance scoring function, which is slow out of the box but can be muich faster when we callnumba.njit(_compute_relevance_from_scores_jit_ready)
. Moreover, our default relevance scoring function is now faster than the legacy approach, and has been moved directly to the mainBM25
class as astaticmethod
called_compute_relevance_from_scores
. That can be overwritten to use your custom function, such as_compute_relevance_from_scores_jit_ready
or_compute_relevance_from_scores_legacy
.New selection algorithm powered by numba (
topk
)We created a
bm25s.numba.selection
module that can be imported only when numba is available, and offers atopk
function that behaves mostly the same asbm25s.selection.topk
(only difference might be that some of the order of retrieved documents differ if they have the same score). It is automatically selected whenbackend_selection="numba"
is selected)Usage
Here's an example of how to leverage numba speedups
Beta Was this translation helpful? Give feedback.
All reactions