Skip to content

feat: Store BM25 postings as numpy arrays - #284

Merged
Pringled merged 7 commits into
mainfrom
perf/bm25-array-index
Oct 6, 2026
Merged

Pringled merged 7 commits into
mainfrom
perf/bm25-array-index

Conversation

@Pringled

@Pringled Pringled commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Loading a cached index rebuilt the BM25 inverted index in Python on every load. BM25 postings are now stored as term-sorted numpy arrays, and loading them is a plain np.load which is much faster on large caches while also reducing peak memory and making the index slightly smaller. This mainly matters for the CLI since there every query is a warm query. The benchmark scores are the exact same.

Results on a repo with 27k files and 443k chunks:

main new
Warm CLI query ~11s ~3.6s
Peak memory (warm query) 5.0 GB 2.3 GB
BM25 index on disk 278 MB 210 MB

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/semble/index/bm25.py 100.00% <100.00%> (ø)
src/semble/index/create.py 100.00% <100.00%> (ø)
src/semble/index/types.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Refactors BM25 index storage from JSON to numpy arrays.

The PR appears safe to merge; no outstanding findings remain.

Reviews (2) · Last reviewed commit: "Save BM25 as a single index.npz, drop un..."

Comment thread src/semble/index/bm25.py Outdated
Comment thread src/semble/index/bm25.py Outdated
Comment thread src/semble/index/bm25.py Outdated
@Pringled
Pringled requested a review from stephantul October 6, 2026 10:30

@stephantul stephantul left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments, looks great

Comment thread src/semble/index/bm25.py Outdated
Comment thread src/semble/index/bm25.py Outdated
Comment thread src/semble/index/bm25.py Outdated
Comment thread src/semble/index/bm25.py Outdated
…t renumber pairs, NUL check, consistency check function
@Pringled
Pringled merged commit 4478583 into main Oct 6, 2026
16 checks passed
@Pringled
Pringled deleted the perf/bm25-array-index branch October 6, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants