Skip to content
Meta logo

bart-large-cnn Beta

SummarizationMetaHosted

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.

Model Info
BetaYes
Unit Pricing$0.00 per M input tokens

Usage

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>;

Parameters

input_text
stringrequiredminLength: 1The text that you want the model to summarize
max_length
integerdefault: 1024The maximum length of the generated summary in tokens

API Schemas

{
"type": "object",
"properties": {
"input_text": {
"type": "string",
"minLength": 1,
"description": "The text that you want the model to summarize"
},
"max_length": {
"type": "integer",
"default": 1024,
"description": "The maximum length of the generated summary in tokens"
}
},
"required": [
"input_text"
]
}