Skip to content

[MOD-17920] Keep cosine distances finite for zero vectors - #1107

Closed
lerman25 wants to merge 1 commit into
mainfrom
codex/mod-17920-zero-cosine
Closed

lerman25 wants to merge 1 commit into
mainfrom
codex/mod-17920-zero-cosine

Conversation

@lerman25

@lerman25 lerman25 commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Describe the changes in the pull request

Zero COSINE vectors currently produce NaN distances, which can change rankings or break result merging during tier migration. Preserve zero floating-point vectors and store a safe norm for integer vectors, giving a defined distance of 1 whenever either vector is zero.

Regression tests cover FLOAT32, FLOAT64, BFLOAT16, FLOAT16, INT8 and UINT8; zero stored/query vectors; FLAT, HNSW and controlled tier migration; and single/multi-value labels.

This applies to newly normalized vectors. Already serialized VecSim indexes containing NaNs or zero norm payloads require rebuilding from the original vectors; no serialization format changes.

Which issues this PR fixes

Main objects this PR modified

  • COSINE normalization and its documented zero-vector behavior.
  • Shared regression tests for normalization and top-K results.

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

Release Notes

  • This PR requires release notes
  • This PR does not require release notes

@lerman25 lerman25 closed this Nov 30, 2026
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.

1 participant