Repository navigation
Rank associative memories by normalized cosine similarity - #393
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
This branch has not been deployed
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
Fixes #392.
Normalize query and stored embeddings when computing retrieval scores. This implements the documented cosine ordering rather than allowing embedding magnitude to dominate relevance. Zero-norm vectors receive similarity zero. Stored embeddings, checkpoint format, recency retrieval and existing tie handling are unchanged.
Validation
python -m pytest -q -o addopts='' -o required_plugins='' concordia/associative_memory15 tests passed. All seven existing memory tests and eight new cases pass. Four new cases fail on unchanged upstream; four controls pass. Tests use real memory banks and deterministic local embeddings, with exact-match ranking, independent rescaling, an explicit normalized-dot oracle, restore/nonmutation, zero vectors and empty/unit-vector controls. Pytest ran serially with the repository's required xdist plugin setting disabled; no parallel-only fixtures are involved. No embedding service or language-model requests were made. Handling nonfinite embeddings and extreme norm overflow/underflow is outside this change.
Tested locally on macOS CPU using real module imports. New-test formatting, scoped static checks, syntax checks and
git diff --checkpass. No dependency or workflow changes. The full repository suite was not run.