feat/bm25-market-similarity#14
Open
vaisd wants to merge 2 commits into
Open
Conversation
|
@vaisd is attempting to deploy a commit to the Victor's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Replaces the manual keyword-overlap path in areMarketsSimilar() with BM25 similarity scoring, as suggested by Taylor in the previous PR review.
Changes
detectArbitrage() builds stats once over the full candidate pool and passes them into each pair check
Title similarity, entity tiebreaker, and category gate are all unchanged.
Tradeoffs
Threshold tuning: 0.4 works well against the current test suite (rejects top out at ~14%, matches start at ~67%) but the corpus is small (~27 markets with padding). Will probably need retuning as more real cases come in, and might eventually make sense to be category-specific
IDF rebuild on cache miss: detectArbitrage sits behind a 15s cache so this isn't a per-request cost, but worth keeping an eye on if the market pool grows a lot
Confidence values changed: the old path mapped keyword count to confidence linearly from 0.5, the new path returns the BM25 ratio directly. The 0.5 floor in normalizeMinConfidence() still holds but downstream consumers may see different distributions
Test plan
Already Done
node --import tsx src/api/tests/arbitrage-detector.test.ts — 8/8 pass
tsc --noEmit -p tsconfig.json and tsc --noEmit -p api/tsconfig.json — clean
Need to be Done
Spot-check staging arbitrage results against the new threshold before merging