space / app.py
Sarahmohd's picture
Create app.py
132f714 verified
Raw
History Blame Contribute Delete
1.07 kB
from IPython.display import Image
Image(filename='Self_Attention.png')
# Code to ignore warnings
from transformers.utils import logging
logging.set_verbosity_error()
# Code 1 - Use a pipeline as a high-level helper
from transformers import pipeline
# Code 2 - create a summarizer object
summarizer = pipeline(task="summarization", model="facebook/bart-large-cnn")
text = """BART is a transformer encoder-encoder (seq2seq) model with a bidirectional (BERT-like) encoder and an autoregressive (GPT-like) decoder.
BART is pre-trained by (1) corrupting text with an arbitrary noising function, and (2) learning a model to reconstruct the original text.
BART is particularly effective when fine-tuned for text generation (e.g. summarization, translation) but also works well for comprehension tasks (e.g. text classification, question answering).
This particular checkpoint has been fine-tuned on CNN Daily Mail, a large collection of text-summary pairs."""
Summarize the text. the length here is in tokens
summary = summarizer(text, min_length=10, max_length=100)
summary