Repository navigation
feat: Lightly stem BM25 tokens - #311
Closed
flyinprogrammer wants to merge 1 commit into
Closed
flyinprogrammer wants to merge 1 commit into
flyinprogrammer wants to merge 1 commit into
Conversation
Natural-language queries often use a different inflection than the code they
target ("handlers" vs EventHandler, "parsing" vs parse). Strip plurals, -ing and
-ed from every BM25 token, at index and query time alike. Short tokens and tokens
with digits or underscores are left untouched. Bump CACHE_FORMAT_VERSION so
existing indexes are rebuilt with the new tokens.
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.
Closes #309
Summary
Every BM25 token goes through a light suffix stemmer, at index and query time alike, so "handlers" and
EventHandlershare the termhandler.CACHE_FORMAT_VERSIONgoes 2 → 3, so cached indexes are rebuilt instead of mixing stemmed and unstemmed terms.Evidence
Tests: the new
tests/test_tokens.py(13 cases) can't importstemfrommain'stokens.pyand passes here.Full suite:
make test404 passed;make lintandmake typecheckclean.NDCG@10, positive but not statistically clear on its own (95% CIs resample repos):
run_benchmark: 0.852 → 0.855.Known quirk: "uses" stems to "us"; deliberately not special-cased, to keep the stemmer small.
Merge Danger
Door: two-way, with a cost
Reverting restores the old tokenization, but every user's index is rebuilt once on upgrade, and again on revert.
Blast Radius: indexing
All BM25 scores change slightly. The first search after upgrading reindexes, so it's slower. Conflicts with any other change that bumps
CACHE_FORMAT_VERSION.