Skip to content

Rank associative memories by normalized cosine similarity - #393

Open
sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/associative-cosine-normalization-20261006
Open

sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/associative-cosine-normalization-20261006

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

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_memory

15 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 --check pass. No dependency or workflow changes. The full repository suite was not run.

Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Associative memory uses dot products instead of documented cosine similarity

1 participant