Skip to content

embedder: tolerate float rounding at similarity bounds - #383

Merged
anish749 merged 1 commit into
mainfrom
worktree-fix-embedder-sim-tolerance
Jul 10, 2026
Merged

embedder: tolerate float rounding at similarity bounds#383
anish749 merged 1 commit into
mainfrom
worktree-fix-embedder-sim-tolerance

Conversation

@anish749

Copy link
Copy Markdown
Owner

The similarity integration test asserted cosine similarity fell within a hard [min, max] range, with max exactly 1.0. Cosine similarity of identical embeddings is mathematically 1.0 but floating-point accumulation in the dot product and norms yields 1.0000000000000002, one ULP above 1.0, so the strict upper-bound check failed.

The bound checks now tolerate rounding at the edges using gonum's ULP comparison (scalar.EqualWithinULP) rather than a hand-rolled epsilon, and the failure message prints full precision instead of a rounded value that masked the real number.

@anish749
anish749 merged commit 6906cd9 into main Jul 10, 2026
1 check passed
@anish749
anish749 deleted the worktree-fix-embedder-sim-tolerance branch July 10, 2026 05:49
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