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-base-sled')1from sled import SledTokenizer, SledModel
2tokenizer = SledTokenizer.from_pretrained('tau/bart-base-sled')
3model = SledModel.from_pretrained('tau/bart-base-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-base-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-base-sled')
4model = AutoModel.from_pretrained('tau/bart-base-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{koreeda-manning-2021-contractnli-dataset,
2 title = "{C}ontract{NLI}: A Dataset for Document-level Natural Language Inference for Contracts",
3 author = "Koreeda, Yuta and
4 Manning, Christopher",
5 booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2021",
6 month = nov,
7 year = "2021",
8 address = "Punta Cana, Dominican Republic",
9 publisher = "Association for Computational Linguistics",
10 url = "https://aclanthology.org/2021.findings-emnlp.164",
11 doi = "10.18653/v1/2021.findings-emnlp.164",
12 pages = "1907--1919"
13}