-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
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
Line 181 in 6a1f982
.map(e -> new Embedding(e.embedding(), e.index())) |
The embedding class constructor assumes a float[]
spring-ai/spring-ai-model/src/main/java/org/springframework/ai/embedding/Embedding.java
Line 40 in 6a1f982
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.