Views
No views yet
py-sled in your environment (or clone the code from the official repository)pip install py-sled1import sled # *** required so that SledModels will be registered for the AutoClasses ***
2model = AutoModel.from_pretrained('tau/bart-large-sled')1from sled import SledTokenizer, SledModel
2tokenizer = SledTokenizer.from_pretrained('tau/bart-large-sled')
3model = SledModel.from_pretrained('tau/bart-large-sled')
4inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
5outputs = model(**inputs)
6last_hidden_states = outputs.last_hidden_statemodel = SledModelForConditionalGeneration.from_pretrained('tau/bart-large-sled')prefix_length tensor input as well (A LongTensor in the length of the batch size).1import torch
2import sled # *** required so that SledModels will be registered for the AutoClasses ***
3tokenizer = AutoTokenizer.from_pretrained('tau/bart-large-sled')
4model = AutoModel.from_pretrained('tau/bart-large-sled')
5document_input_ids = tokenizer("Dogs are great for you.", return_tensors="pt").input_ids
6prefix_input_ids = tokenizer("Are dogs good for you?", return_tensors="pt").input_ids
7input_ids = torch.cat((prefix_input_ids, document_input_ids), dim=-1)
8attention_mask = torch.ones_like(input_ids)
9prefix_length = torch.LongTensor([[prefix_input_ids.size(1)]])
10
11outputs = model(input_ids=input_ids, attention_mask=attention_mask, prefix_length=prefix_length)
12last_hidden_states = outputs.last_hidden_state1@inproceedings{Ivgi2022EfficientLU,
2 title={Efficient Long-Text Understanding with Short-Text Models},
3 author={Maor Ivgi and Uri Shaham and Jonathan Berant},
4 year={2022}
5}1@article{DBLP:journals/corr/abs-1910-13461,
2 author = {Mike Lewis and
3 Yinhan Liu and
4 Naman Goyal and
5 Marjan Ghazvininejad and
6 Abdelrahman Mohamed and
7 Omer Levy and
8 Veselin Stoyanov and
9 Luke Zettlemoyer},
10 title = {{BART:} Denoising Sequence-to-Sequence Pre-training for Natural Language
11 Generation, Translation, and Comprehension},
12 journal = {CoRR},
13 volume = {abs/1910.13461},
14 year = {2019},
15 url = {http://arxiv.org/abs/1910.13461},
16 eprinttype = {arXiv},
17 eprint = {1910.13461},
18 timestamp = {Thu, 31 Oct 2019 14:02:26 +0100},
19 biburl = {https://dblp.org/rec/journals/corr/abs-1910-13461.bib},
20 bibsource = {dblp computer science bibliography, https://dblp.org}
21}1@inproceedings{huang2021govreport,
2 title = "Efficient Attentions for Long Document Summarization",
3 author = "Huang, Luyang and
4 Cao, Shuyang and
5 Parulian, Nikolaus and
6 Ji, Heng and
7 Wang, Lu",
8 booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
9 month = jun,
10 year = "2021",
11 address = "Online",
12 publisher = "Association for Computational Linguistics",
13 url = "https://aclanthology.org/2021.naacl-main.112",
14 doi = "10.18653/v1/2021.naacl-main.112",
15 pages = "1419--1436"
16}