- Cloudflare ホスト
PLaMo-Embedding-1B は、Preferred Networks, Inc. が開発した日本語テキスト埋め込みモデルです。 日本語テキストを数値ベクトルに変換でき、情報検索、テキスト分類、クラスタリングなど幅広い用途に使えます。
| モデル情報 | |
|---|---|
| 単価 | $0.019 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/pfnet/plamo-embedding-1b",
{
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/pfnet/plamo-embedding-1b",
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/pfnet/plamo-embedding-1b \
-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
いずれか必須▶data[]
array埋め込みベクトルです。各ベクトルは浮動小数点のリストです。▶shape[]
arrayminItems: 2maxItems: 2埋め込みデータの形状です(`[number_of_embeddings, embedding_dimension]`)。