- Cloudflare-hosted
- Deprecated
BART 是一个 Transformer 编码器-解码器(seq2seq)模型,包含一个双向(类 BERT)编码器和一个自回归(类 GPT)解码器。您可以使用此模型进行文本摘要。
| 模型信息 | |
|---|---|
| 已弃用 | 2026/5/30 |
| Beta | 是 |
| 单位定价 | $0.00 per M input tokens |
用法
export interface Env {
AI: Ai;
}
export default {
async fetch(request, env): Promise<Response> {
const response = await env.AI.run("@cf/facebook/bart-large-cnn", {
input_text: "Workers AI allows you to run machine learning models, on the Cloudflare network, from your own code – whether that be from Workers, Pages, or anywhere via the Cloudflare API. With the launch of Workers AI, Cloudflare is slowly rolling out GPUs to its global network. This enables you to build and deploy ambitious AI applications that run near your users, wherever they are.",
max_length: 14
});
return Response.json(response);
},
} satisfies ExportedHandler<Env>;
curl https://api.cloudflare.com/client/v4/accounts/{cf_account_id}/ai/run/@cf/facebook/bart-large-cnn \
-H "Authorization: Bearer {cf_api_token}" \
-d '{
"input_text": "Workers AI allows you to run machine learning models, on the Cloudflare network, from your own code – whether that be from Workers, Pages, or anywhere via the Cloudflare API. With the launch of Workers AI, Cloudflare is slowly rolling out GPUs to its global network. This enables you to build and deploy ambitious AI applications that run near your users, wherever they are.",
"max_length": 14
}'参数
input_text
stringrequiredminLength: 1您希望模型进行摘要的文本max_length
integerdefault: 1024生成摘要的最大长度(以 token 计)summary
string输入文本的摘要版本