feat: Jaccard token similarity as post-RRF reranking signal#723
Merged
Conversation
Add Jaccard token overlap as an orthogonal recall signal (#719): - New jaccard.rs module with tokenize() and jaccard_similarity() - Post-RRF additive boost when jaccard_weight > 0.0 - CLI config [recall].jaccard_weight (default 0.0 = off) - Setter API: Uteke::set_jaccard_weight() - Tag tokens included in content token set for richer overlap Jaccard catches different cases than BM25 (IDF-weighted) and vector cosine (semantic). When enabled (recommended 0.10-0.15), it boosts results with high token overlap regardless of term rarity or embedding distance. Closes #719
🔍 Cora AI Code Review🟡 Warning (1)
Review powered by cora-cli · BYOK · MIT |
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
Add Jaccard token overlap as an orthogonal recall reranking signal (#719).
Problem
Current recall uses two signals: BM25 (FTS5, IDF-weighted) and vector cosine (semantic embedding). Both miss a simple but effective signal: raw token overlap. A query "rust memory engine" and content "rust is a fast memory engine for AI" have 3/8 token overlap — but BM25 may downweight common terms while cosine may miss exact keyword matches.
Hermes holographic memory uses Jaccard as a 0.3-weighted signal in its hybrid fusion (alongside 0.4 FTS + 0.3 HRR).
Changes
New:
crates/uteke-core/src/jaccard.rstokenize(text)→ lowercase HashSet, strips punctuationjaccard_similarity(query, content)→ |A∩B| / |A∪B| in [0, 1]Modified:
crates/uteke-core/src/operations.rsjaccard_weight > 0.0Modified:
crates/uteke-core/src/lib.rsUtekestruct: newjaccard_weight: f32field (default 0.0)set_jaccard_weight()setter with 0.0-1.0 clampModified:
crates/uteke-cli/src/{config.rs, main.rs}[recall].jaccard_weightin uteke.toml (default 0.0 = off)Configuration
Trade-offs
Closes #719