bge-large-en-v1.5
Model ID: @cf/baai/bge-large-en-v1.5
BAAI general embedding (bge) models transform any given text into a compact vector
Properties
Task Type: Text Embeddings
Max input tokens: 512
Output dimensions: 1024
Code Examples
Worker - TypeScript
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-large-en-v1.5", { text: stories, } );
return Response.json(embeddings); },
} satisfies ExportedHandler<Env>;
Python
import osimport requests
ACCOUNT_ID = "your-account-id"AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")
stories = [ 'This is a story about an orange cloud', 'This is a story about a llama', 'This is a story about a hugging emoji'
]
response = requests.post( f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/baai/bge-large-en-v1.5", headers={"Authorization": f"Bearer {AUTH_TOKEN}"}, json={"text": stories}
)
print(response.json())
curl
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/baai/bge-large-en-v1.5 \ -X POST \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -d '{ "text": ["This is a story about an orange cloud", "This is a story about a llama", "This is a story about a hugging emoji"] }'
Responses
Single string:
{ "shape":[1,768], "data": [ [0.03190500661730766, 0.006071353796869516, 0.025971125811338425,...] ]
}
Batch of two strings:
{ "shape":[2,768], "data":[ [0.03190416097640991, 0.006062490865588188, 0.025968171656131744,...], [0.002439928939566016, -0.021352028474211693, 0.06229676678776741,...], [-0.02154572866857052,0.09098546206951141,0.006273532286286354,...] ]
}
API Schema
The following schema is based on JSON SchemaInput JSON Schema
Output JSON Schema