Views
No views yet
1from transformers import BigBirdPegasusForConditionalGeneration, AutoTokenizer
2
3tokenizer = AutoTokenizer.from_pretrained("google/bigbird-pegasus-large-arxiv")
4
5# by default encoder-attention is `block_sparse` with num_random_blocks=3, block_size=64
6model = BigBirdPegasusForConditionalGeneration.from_pretrained("google/bigbird-pegasus-large-arxiv")
7
8# decoder attention type can't be changed & will be "original_full"
9# you can change `attention_type` (encoder only) to full attention like this:
10model = BigBirdPegasusForConditionalGeneration.from_pretrained("google/bigbird-pegasus-large-arxiv", attention_type="original_full")
11
12# you can change `block_size` & `num_random_blocks` like this:
13model = BigBirdPegasusForConditionalGeneration.from_pretrained("google/bigbird-pegasus-large-arxiv", block_size=16, num_random_blocks=2)
14
15text = "Replace me by any text you'd like."
16inputs = tokenizer(text, return_tensors='pt')
17prediction = model.generate(**inputs)
18prediction = tokenizer.batch_decode(prediction)BigBirdPegasusForConditionalGeneration for summarization on arxiv dataset from scientific_papers.1@misc{zaheer2021big,
2 title={Big Bird: Transformers for Longer Sequences},
3 author={Manzil Zaheer and Guru Guruganesh and Avinava Dubey and Joshua Ainslie and Chris Alberti and Santiago Ontanon and Philip Pham and Anirudh Ravula and Qifan Wang and Li Yang and Amr Ahmed},
4 year={2021},
5 eprint={2007.14062},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG}
8}