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

distilbert-sst-2-int8

Text Classification • HuggingFace

查看 MarkdownAgent 设置
  • Cloudflare-hosted

在 SST-2 上微调、用于情感分类的蒸馏 BERT 模型

模型信息
更多信息链接 ↗
单位定价$0.026 per M input tokens

用法


export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const response = await env.AI.run(
      "@cf/huggingface/distilbert-sst-2-int8",
      {
        text: "This pizza is great!",
      }
    );

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

API_BASE_URL = "https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/"
headers = {"Authorization": "Bearer {API_KEY}"}

def run(model, input):
    response = requests.post(f"{API_BASE_URL}{model}", headers=headers, json=input)
    return response.json()

output = run("@cf/huggingface/distilbert-sst-2-int8", { "text": "This pizza is great!" })
print(output)

curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/huggingface/distilbert-sst-2-int8  \
  -X POST  \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
  -d '{ "text": "This pizza is great!" }'

参数

text
stringrequiredminLength: 1您希望分类的文本
type
array
contentType
application/json
description
输入文本的分类结果数组
items
[object Object]

API schema(原始)

输入
输出

这篇文档对您有帮助吗?