- Cloudflare ホスト
- バッチ
任意のテキストを 768 次元のベクトルに変換する BAAI general embedding(Base)モデルです。
| モデル情報 | |
|---|---|
| コンテキストウィンドウ ↗ | 153,600 トークン |
| 詳細情報 | リンク ↗ |
| 最大入力トークン数 | 512 |
| 出力次元数 | 768 |
| バッチ | はい |
| 単価 | $0.067 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-base-en-v1.5",
{
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-base-en-v1.5",
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-base-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"] }'同期 — リクエストを送り、完了した応答を受け取ります
▶text
いずれか必須pooling
stringデフォルト: meanenum: mean, cls埋め込み処理で使うプーリング方法です。`cls` プーリングは大きな入力でより正確な埋め込みを生成します。ただし `cls` で作った埋め込みは `mean` プーリングの埋め込みと互換性がありません。破壊的変更を避けるためデフォルトは `mean` ですが、精度向上には `cls` の利用を強く推奨します。▶shape[]
array▶data[]
arrayリクエストしたテキスト値の埋め込みですpooling
stringenum: mean, cls埋め込み処理で使うプーリング方法です。バッチ — 1 回の API 呼び出しで複数のリクエストを送ります
▶requests[]
array必須async-queue で実行する埋め込みリクエストのバッチです▶shape[]
array▶data[]
arrayリクエストしたテキスト値の埋め込みですpooling
stringenum: mean, cls埋め込み処理で使うプーリング方法です。