Milvus OpenAi embedding function #42867
-
Hello guys, I just know if the embedding function for OpenAI uses batches or are they single api calls ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Insert request is received by proxy node, the proxy node calls Function.ProcessInsert() to generate embeddings here: milvus/internal/proxy/task_insert.go Line 177 in 6798fdc The implementation of TextEmbeddingFunction.ProcessInsert() is here: The TextEmbeddingFunction.ProcessInsert() calls EmbeddingsProvider.CallEmbedding() here: Before the TextEmbeddingFunction.ProcessInsert() is called(with a test text "check"), the TextEmbeddingFunction.Check() is called to verify the embedding provider: In the implementation of OpenAIEmbeddingProvider, there is a member named "maxBatch", default value is 128: The OpenAIEmbeddingProvider calls OpenAI client API to generate embeddings batch by batch in this loop: So, if you insert N rows in an insert request, there will be (math.Floor(N/128) + 2) calls of OpenAI API. |
Beta Was this translation helpful? Give feedback.
Insert request is received by proxy node, the proxy node calls Function.ProcessInsert() to generate embeddings here:
milvus/internal/proxy/task_insert.go
Line 177 in 6798fdc
The implementation of TextEmbeddingFunction.ProcessInsert() is here:
milvus/internal/util/function/text_embedding_function.go
Line 227 in 6798fdc
The TextEmbeddingFunction.ProcessInsert() calls EmbeddingsProvider.CallEmbedding() here:
milvus/internal/util/function/text_embedding_function.go
Line 241 in 6798fdc