Embeddings
New Embedding Models
The latest embedding models from AI/ML API, text-embedding-3-small
and text-embedding-3-large
, are now available. These models offer cost savings, enhanced multilingual support, and customizable parameters to manage their size.
What are Embeddings?
Embeddings from AI/ML API quantify the similarity between text strings. These embeddings are particularly useful for:
Search: Rank search results by their relevance to a query.
Clustering: Group similar text strings together.
Recommendations: Suggest items based on related text strings.
Anomaly Detection: Identify outliers that differ significantly from the norm.
Diversity Measurement: Analyze the spread of similarities within a dataset.
Classification: Categorize text strings by comparing them to labeled examples.
An embedding is a vector (list) of floating-point numbers, where the distance between vectors indicates their relatedness. Smaller distances indicate higher similarity, while larger distances suggest lower similarity.
For more information on Embeddings pricing, visit our pricing page. Costs are calculated based on the number of tokens in the input.
Example: Generating Embeddings
The response will include the embedding vector and additional metadata.
Example Embedding Response
By default, the length of the embedding vector is 1536 for text-embedding-3-small
or 3072 for text-embedding-3-large
. You can reduce the dimensions of the embedding using the dimensions
parameter without losing its ability to represent concepts. More details on embedding dimensions can be found in the embedding use case section.
Embedding Models
AI/ML API offers two robust third-generation embedding models (indicated by -3 in the model ID).
text-embedding-3-small
62,500
62.3%
8191
text-embedding-3-large
9,615
64.6%
8191
text-embedding-ada-002
12,500
61.0%
8191
Example in Python
Here's how to use the embeddings API in Python:
This Python example shows how to set up an API client, send text to the embeddings API, and handle the response to extract and print the embedding vector.
Last updated