Skip to content

Is the order of batched embeddings data indeterministic? #420

@ravwojdyla

Description

@ravwojdyla

Describe the bug

Looking over the code related to embeddings, I've noticed:

data = openai.Embedding.create(input=list_of_text, engine=engine, **kwargs).data
data = sorted(data, key=lambda x: x["index"]) # maintain the same order as input.

Which I have not seen in the API documentation (or other examples), tho I may have missed it. Should the user expect that the order of returned batched embeddings from the API may not be deterministic and thus not be in the same order as input data?

To Reproduce

get_embeddings(["foo bar", "foo baz"])

Code snippets

No response

OS

macOS

Python version

python 3.10

Library version

0.27.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions