feat(lib): add Unlimiformer-style kNN attention retrieval helpers#830
feat(lib): add Unlimiformer-style kNN attention retrieval helpers#830kayo09 wants to merge 3 commits intosupermemoryai:mainfrom
Conversation
EntelligenceAI PR SummaryImplements Unlimiformer-style kNN retrieval in
Confidence Score: 5/5 - Safe to MergeSafe to merge — this PR cleanly introduces Key Findings:
Files requiring special attention
|
WalkthroughThis PR introduces a new Changes
🔗 Cross-Repository Impact AnalysisEnable automatic detection of breaking changes across your dependent repositories. → Set up now Learn more about Cross-Repository AnalysisWhat It Does
How to Enable
Benefits
|
packages/lib/unlimiformer.ts
Outdated
| const scored: AttentionTopK[] = keys.map((key, index) => ({ | ||
| index, | ||
| score: attentionScore(query, key), | ||
| })) |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Implement the score-and-top-k pattern from Bertsch et al. (arXiv:2305.01625) for embedding vectors: dot-product attention scores with top-k key selection, plus multi-head and generic item ranking utilities. Add Bun tests and a test script for @repo/lib.
Skip mismatched key/query lengths instead of throwing from cosineSimilarity; attentionScore returns NaN for length mismatch; extend tests.
1cb9c52 to
33f47db
Compare
81b9112 to
c452e15
Compare
…ings Return NaN when vectors contain NaN, Infinity, or non-numbers instead of throwing from cosineSimilarity. Skip non-finite query and item embeddings in rankItemsByAttentionTopK. Add tests.
c452e15 to
e0eccbd
Compare
Implement the score-and-top-k pattern from Bertsch et al. (arXiv:2305.01625) for embedding vectors: dot-product attention scores with top-k key selection, plus multi-head and generic item ranking utilities. Add Bun tests and a test script for @repo/lib.