Skip to content

bart-large-cnn

Beta

Model ID: @cf/facebook/bart-large-cnn

BART is a transformer encoder-encoder (seq2seq) model with a bidirectional (BERT-like) encoder and an autoregressive (GPT-like) decoder. You can use this model for text summarization.

Properties

Task Type: Summarization

Code Examples

Workers - Typescript

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

Terminal window
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
}'

Response

{
"summary": "Workers AI allows you to run machine learning models."
}

API Schema

The following schema is based on JSON Schema

Input JSON Schema

{
"type": "object",
"properties": {
"input_text": {
"type": "string",
"minLength": 1
},
"max_length": {
"type": "integer",
"default": 1024
}
},
"required": [
"input_text"
]
}

Output JSON Schema

{
"type": "object",
"contentType": "application/json",
"properties": {
"summary": {
"type": "string"
}
}
}