#Embedding dimension reduced

1 messages · Page 1 of 1 (latest)

stuck osprey
#

any Python example for using embedding-3-large models with dimension reduced?

lofty tulipBOT
#

Hi @stuck osprey. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

I'm sorry, but the provided extracts do not contain a Python example for using the text-embedding-3-large model with reduced dimensions. However, the OpenAI API documentation does mention that you can reduce the dimensions of the embedding by passing in the dimensions parameter without the embedding losing its concept-representing properties. You can find more details in the OpenAI API documentation (https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-dimensions).

For reducing the dimensionality of embeddings, a common technique used is Principal Component Analysis (PCA). Here's an example of how it's done using the sklearn library, extracted from the OpenAI Cookbook (https://cookbook.openai.com/examples/visualizing_embeddings_in_3d#2-reduce-the-embedding-dimensionality):

from sklearn.decomposition import PCA
pca = PCA(n_components=3)
vis_dims = pca.fit_transform(matrix)
samples["embed_vis"] = vis_dims.tolist()

In this example, matrix would be the matrix of embeddings you've obtained from the text-embedding-3-large model. The PCA is reducing the dimensionality of these embeddings to 3. You can adjust the n_components parameter to reduce the dimensions to your desired number.

Please note that this is a general example and may need to be adjusted based on your specific use case and data.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: