In the official OpenAI node library Create embeddings if for example using the model text-embedding-ada-002 the embeddings returned is an array of around 1536.
import {Configuration, OpenAIApi} from 'openai'
openai = new OpenAIApi(this.configuration)
const parameters= {
model: 'text-embedding-ada-002',
input: text,
}
// Make the embedding request and return the result
const resp = await openai.createEmbedding(parameters)
const embeddings = embedding?.data.data[0].embedding
I would like to be able to limit the length of the list of embeddings returned.
>Solution :
This is not how OpenAI Embeddings API endpoint works.
You can’t change the embedding output dimension. If you use the text-embedding-ada-002 model, you’ll always get a 1536-dimensional embedding vector (i.e., there are 1536 numbers inside).
It’s pre-defined, as stated in the official OpenAI documentation:
