Skip to content

Add Support for OpenAI based64 format embedding responses #3786

Open
@asaikali

Description

@asaikali

OpenAI supports returning embedding responses as base64 encoded which can save a lot of resources see this excellent blog post Speed Up OpenAI Embedding By 4x With This Simple Trick!

Currently Spring AI assumes that the response from OpenAI is coming back as an array of floats see

The embedding class constructor assumes a float[]

public Embedding(float[] embedding, Integer index) {

You can find info about how the offical python SDK decodes the response at https://github.com/openai/openai-python/blob/db5c35049accb05f5fb03791ef9c12547fd309a7/src/openai/resources/embeddings.py#L204

The offical python SDK uses base64 encoding as of version 1.62 and other sdks are turning on base64 as the default.

Please add support for base64 embeddings to spring AI.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions