fix: decode base64 embeddings as little-endian floats - #3711
Open
HostX0 wants to merge 1 commit into
Open
Conversation
HostX0
marked this pull request as ready for review
August 21, 2026 13:38
HostX0
force-pushed
the
fix/embedding-base64-byte-order
branch
from
August 29, 2026 18:24
6ad2fec to
ac63c61
Compare
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.
Root cause
The base64 embedding representation contains little-endian float32 bytes, but the handwritten response parser used native byte order in both its NumPy and stdlib paths. On big-endian Python platforms, that silently produces incorrect vector values. The existing fixture was also native-endian, so it followed the test host instead of the wire format and could not expose the defect.
Fix
<f4dtype.array("f")path on big-endian hosts.struct.pack("<3f", ...)so the test represents the wire format on every host.The branch is rebased onto current
mainand preserves #3757: NumPy availability is still checked once per response, while each encoded vector is decoded only once.Validation
Before the rebase, the focused embeddings suite passed under both Pydantic environments (58 tests each), along with targeted Ruff, Pyright, and Mypy checks. After rebasing onto #3757, I re-ran syntax checks and an isolated execution harness against the actual parser module covering:
<f4dtypeThe full current suite is left to GitHub Actions because this local macOS workspace does not have the repository's locked uv development environment installed.