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 an 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 input parameter accepts a single string or an array of strings, letting you embed multiple inputs in a single request.
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
}
}Optional Parameters
You can configure the following optional request parameters:
dimensions: The number of dimensions the resulting output embeddings will have, while preserving their ability to represent concepts.encoding_format: The format to return the embeddings in, for examplefloat.user: A unique identifier for the end-user.
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.