Embeddings
Turn text into numbers for various use-cases.
Embeddings measure the relatedness of text strings. They can be used in:
- Search: to rank results by relevance to query string
- Clustering: to group strings by similarity
- Recommendations: to recommend items with related text strings
- Anomaly detection: to identify outliers
- Diversity measurement: to analyze similarity distribution
- Classification: to classify text strings by their labels
Embeddings are floating-point number vectors where the distance between them indicates relatedness. Shorter distances signify greater relatedness, while longer distances suggest less.
Getting Embeddings
To get and embedding, send a text string and a model name to the embedding API endpoint, for example:
curl -X 'POST' \
'https://deepfellow-server-host/v1/embeddings' \
-H "Authorization: Bearer DEEPFELLOW-PROJECT-API-KEY" \
-H 'Content-Type: application/json' \
-d '{
"input": "Your text",
"model": "mxbai-embed-large"
}'from openai import OpenAI
client = OpenAI(
base_url="https://deepfellow-server-host/v1",
api_key="DEEPFELLOW-PROJECT-API-KEY"
)
response = client.embeddings.create(
input="Your text",
model="mxbai-embed-large"
)
print(response.model_dump_json())import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://deepfellow-server-host/v1',
apiKey: 'DEEPFELLOW-PROJECT-API-KEY'
});
const response = await client.embeddings.create({
input: 'Your text',
model: 'mxbai-embed-large'
});
console.log(response);The response includes an embedding vector, which is a list of floating-point numbers, as well as some extra metadata. This vector can be extracted and stored in a vector database for further use.
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [
-0.006929283495992422, -0.005336422007530928, ..., -4.547132266452536555,
]
}
],
"model": "mxbai-embed-large",
"usage": {
"prompt_tokens": 2,
"total_tokens": 2
}
}To adjust the embedding's dimensions while preserving its ability to represent concepts, specify the dimensions parameter.
See API Reference for details.
To learn more using embeddings in different use-cases, visit OpenAI API Documentation.
We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.