Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

OpenAI Embeddings API: How to change the embedding output dimension?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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:

Screenshot

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading