Search
Rank documents or passages by semantic similarity to a query.
AI & ML · Const
Embeddings represent text as vectors that preserve aspects of content or meaning. They support similarity-based tasks such as search, clustering, recommendations, anomaly detection, and classification.
An embedding is a vector representation of text that preserves aspects of its content or meaning. Send one or more text inputs with an embedding model to the embeddings endpoint; the response contains a vector for each input, which can then be compared or indexed for similarity-based applications.
client.embeddings.create(input=[text], model="text-embedding-3-small")| Name | Type | Description |
|---|---|---|
input | string | array of strings | Text, or an array of text inputs, to embed. |
model | string | The identifier of the embedding model, such as text-embedding-3-small. |
An embeddings response containing a data array; each item includes the generated embedding vector.
from openai import OpenAI
client = OpenAI()
response = client.embeddings.create(
input=["The food was delicious"],
model="text-embedding-3-small"
)
print(len(response.data[0].embedding))Creates an embedding for one text string and prints the returned vector’s dimensionality.
Rank documents or passages by semantic similarity to a query.
Group text items by semantic similarity.
Recommend related items based on their text representations.
Assign text to the label with the most similar embedding.
text-embedding-3-smallembeddings APIsemantic searchclusteringrecommendationsclassification