Skip to content
BAAI logo

bge-base-en-v1.5

Text EmbeddingsBAAIHosted

BAAI general embedding (Base) model that transforms any given text into a 768-dimensional vector

Model Info
Context Window153,600 tokens
More informationlink
Maximum Input Tokens512
Output Dimensions768
BatchYes
Unit Pricing$0.067 per M input tokens

Usage

export interface Env {
AI: Ai;
}
export default {
async fetch(request, env): Promise<Response> {
// Can be a string or array of strings]
const stories = [
"This is a story about an orange cloud",
"This is a story about a llama",
"This is a story about a hugging emoji",
];
const embeddings = await env.AI.run(
"@cf/baai/bge-base-en-v1.5",
{
text: stories,
}
);
return Response.json(embeddings);
},
} satisfies ExportedHandler<Env>;

Parameters

Synchronous — Send a request and receive a complete response
pooling
stringdefault: meanenum: mean, clsThe pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
Batch — Send multiple requests in a single API call

API Schemas (Raw)

Synchronous — Send a request and receive a complete response
{
"properties": {
"text": {
"oneOf": [
{
"type": "string",
"description": "The text to embed",
"minLength": 1
},
{
"type": "array",
"description": "Batch of text values to embed",
"items": {
"type": "string",
"description": "The text to embed",
"minLength": 1
},
"maxItems": 100
}
]
},
"pooling": {
"type": "string",
"enum": [
"mean",
"cls"
],
"default": "mean",
"description": "The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy."
}
},
"required": [
"text"
]
}
Batch — Send multiple requests in a single API call
{
"properties": {
"requests": {
"type": "array",
"description": "Batch of the embeddings requests to run using async-queue",
"items": {
"properties": {
"text": {
"oneOf": [
{
"type": "string",
"description": "The text to embed",
"minLength": 1
},
{
"type": "array",
"description": "Batch of text values to embed",
"items": {
"type": "string",
"description": "The text to embed",
"minLength": 1
},
"maxItems": 100
}
]
},
"pooling": {
"type": "string",
"enum": [
"mean",
"cls"
],
"default": "mean",
"description": "The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy."
}
},
"required": [
"text"
]
}
}
},
"required": [
"requests"
]
}