Skip to content

support base64 for embeddings #473

Closed
@stillmatic

Description

@stillmatic

Is your feature request related to a problem? Please describe.
The OpenAI embeddings API has an option to return the results as base64 encoded float32's. The Python library uses it to retrieve the results: https://github.com/openai/openai-python/blob/main/openai/api_resources/embedding.py#L25

Doing so would result in a small performance improvement - the results can be marshaled directly to float32 instead of being sent over the wire as JSON float (untyped) and converting back to float32.

Describe the solution you'd like

The embeddings method should include encoding_format=base64 in its call to OpenAI and decode the results.

Describe alternatives you've considered

The python library uses this unless the encoding format is set to anything. I think that's reasonable, and we should match the Python behavior.

Additional context
https://news.ycombinator.com/item?id=37135823

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions