thon | |
from transformers import BartForConditionalGeneration, BartTokenizer | |
model = BartForConditionalGeneration.from_pretrained("facebook/bart-large", forced_bos_token_id=0) | |
tok = BartTokenizer.from_pretrained("facebook/bart-large") | |
example_english_phrase = "UN Chief Says There Is No in Syria" | |
batch = tok(example_english_phrase, return_tensors="pt") | |
generated_ids = model.generate(batch["input_ids"]) | |
assert tok.batch_decode(generated_ids, skip_special_tokens=True) == [ | |
"UN Chief Says There Is No Plan to Stop Chemical Weapons in Syria" | |
] | |
Resources | |
A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with BART. |