跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com
BAAI logo

bge-m3

Text Embeddings • BAAI

查看 MarkdownAgent 设置
  • Cloudflare-hosted

支持多功能(Multi-Functionality)、多语言(Multi-Linguality)和多粒度(Multi-Granularity)的嵌入模型。

模型信息
上下文窗口 ↗60,000 个 token
单位定价$0.012 per M input tokens

用法


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-m3",
      {
        text: stories,
      }
    );

    return Response.json(embeddings);
  },
} satisfies ExportedHandler<Env>;

import os
import 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-m3",
  headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
  json={"text": stories}
)

print(response.json())

curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/baai/bge-m3  \
  -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"] }'

参数

Synchronous — Send a request and receive a complete response
query
stringminLength: 1您希望针对所提供上下文执行的查询。如果未提供查询,模型将返回上下文的嵌入
truncate_inputs
booleandefault: false当提供的上下文过长时,模型应报错,还是截断上下文以适应长度?
request_id
string可用于获取结果的异步请求 ID。
Batch — Send multiple requests in a single API call
request_id
string可用于获取结果的异步请求 ID。

API schema(原始)

Synchronous输入
Synchronous输出
Batch输入
Batch输出

这篇文档对您有帮助吗?