Skip to content

fix: align batch embeddings with their input indices - #593

Merged
codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
lll-hhh:fix/batch-embedding-order
Nov 7, 2026
Merged

codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
lll-hhh:fix/batch-embedding-order

Conversation

@lll-hhh

@lll-hhh lll-hhh commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

EmbeddingClient.get_embedding([a, b, c]) returns vectors in response-array order, ignoring each embedding's index. An OpenAI-compatible endpoint returning indices [2, 0, 1] therefore associates every vector with the wrong input.

Sort batch response entries by their input index before extracting vectors. Single-string requests and the existing failure fallback retain their behavior. The regression uses a real OpenAI SDK CreateEmbeddingResponse with shuffled entries; the ordered-response fixture now also supplies the SDK's index field.

Validation on Windows / Python 3.12:

  • The shuffled-response regression fails on unchanged main (0fa8c4d); the eight existing embedding tests pass there.
  • OPENAI_API_KEY=test-key-for-unit-tests python -m unittest tests.test_embedding tests.test_embedding_api_base tests.test_novelty_rejection tests.test_novelty_response_parsing -v: 23 passed.
  • All applicable pre-commit hooks (isort, black) and git diff --check pass.
  • Ran python -m unittest discover tests on both head and untouched base in the same environment. Head ran 1,075 tests and base ran 1,074. Both reported 24 failures, 94 errors and 8 skips; the 118 failing test/subtest identities are identical after normalizing generated temporary-directory names. The added regression passes on head. The complete suite is not green locally; no new failing tests were introduced in that comparison.

No real embedding requests or model inference were used. AI assistance: Codex investigated, implemented and validated this change.

Signed-off-by: Liu Hao <169072815+lll-hhh@users.noreply.github.com>
@codelion
codelion merged commit 7ca91c2 into algorithmicsuperintelligence:main Nov 7, 2026
5 checks passed
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.

2 participants