Skip to content

fix: handle NaN and Infinity in embedding normalization#36

Open
echobt wants to merge 1 commit intomainfrom
fix/issue-150
Open

fix: handle NaN and Infinity in embedding normalization#36
echobt wants to merge 1 commit intomainfrom
fix/issue-150

Conversation

@echobt
Copy link
Copy Markdown
Contributor

@echobt echobt commented Jan 20, 2026

This PR fixes a bug where NaN and Infinity values in embeddings would propagate silently, causing undefined behavior in similarity scores and sort ordering.

The normalize function now checks for NaN or Infinity in the input vector. If detected, it returns a zero vector instead of propagating the invalid values. It also handles cases where the magnitude calculation results in NaN or Infinity.

Fixes issue #150.

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