maorivgi
commited on
Commit
•
e3870e9
1
Parent(s):
8ca776a
initial commit
Browse files- README.md +109 -0
- config.json +9 -0
- pytorch_model.bin +3 -0
- tokenizer_config.json +5 -0
README.md
CHANGED
@@ -1,3 +1,112 @@
|
|
1 |
---
|
2 |
license: mit
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
+
language: en
|
4 |
---
|
5 |
+
|
6 |
+
# BART-SLED (SLiding-Encoder and Decoder, base-sized model)
|
7 |
+
|
8 |
+
SLED models use pretrained, short-range encoder-decoder models, and apply them over
|
9 |
+
long-text inputs by splitting the input into multiple overlapping chunks, encoding each independently and perform fusion-in-decoder
|
10 |
+
|
11 |
+
## Model description
|
12 |
+
|
13 |
+
This SLED model is based on the BART model, which is described in its [model card](https://huggingface.co/facebook/bart-base).
|
14 |
+
BART is particularly effective when fine-tuned for text generation (e.g. summarization, translation) but also works
|
15 |
+
well for comprehension tasks (e.g. text classification, question answering). When used as a BART-SLED model, it can be applied on long text tasks.
|
16 |
+
|
17 |
+
This model was finetuned on the [SummScreenFD](https://arxiv.org/abs/2104.07091)
|
18 |
+
|
19 |
+
## Intended uses & limitations
|
20 |
+
|
21 |
+
You can use the raw model for text infilling. However, the model is mostly meant to be fine-tuned on a supervised dataset.
|
22 |
+
|
23 |
+
### How to use
|
24 |
+
To use the model, you first need to install `py-sled` in your environment (or clone the code from the [official repository](https://github.com/Mivg/SLED/blob/main/README.md))
|
25 |
+
```
|
26 |
+
pip install py-sled
|
27 |
+
```
|
28 |
+
For more installation instructions, see [here](https://github.com/Mivg/SLED#Installation).
|
29 |
+
|
30 |
+
|
31 |
+
Once installed, SLED is fully compatible with HuggingFace's AutoClasses (AutoTokenizer, AutoConfig, AutoModel
|
32 |
+
and AutoModelForCausalLM) and can be loaded using the from_pretrained methods
|
33 |
+
```python
|
34 |
+
import sled # *** required so that SledModels will be registered for the AutoClasses ***
|
35 |
+
model = AutoModel.from_pretrained('tau/bart-base-sled')
|
36 |
+
```
|
37 |
+
|
38 |
+
Here is how to use this model in PyTorch:
|
39 |
+
|
40 |
+
```python
|
41 |
+
from sled import SledTokenizer, SledModel
|
42 |
+
tokenizer = SledTokenizer.from_pretrained('tau/bart-base-sled')
|
43 |
+
model = SledModel.from_pretrained('tau/bart-base-sled')
|
44 |
+
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
|
45 |
+
outputs = model(**inputs)
|
46 |
+
last_hidden_states = outputs.last_hidden_state
|
47 |
+
```
|
48 |
+
You can also replace SledModel by SledModelForConditionalGeneration for Seq2Seq generation
|
49 |
+
```python
|
50 |
+
model = SledModelForConditionalGeneration.from_pretrained('tau/bart-base-sled')
|
51 |
+
```
|
52 |
+
In case you wish to apply SLED on a task containing a prefix (e.g. question) which should be given as a context to
|
53 |
+
every chunk, you can pass the `prefix_length` tensor input as well (A LongTensor in the length of the batch size).
|
54 |
+
```python
|
55 |
+
import torch
|
56 |
+
import sled # *** required so that SledModels will be registered for the AutoClasses ***
|
57 |
+
tokenizer = AutoTokenizer.from_pretrained('tau/bart-base-sled')
|
58 |
+
model = AutoModel.from_pretrained('tau/bart-base-sled')
|
59 |
+
document_input_ids = tokenizer("Dogs are great for you.", return_tensors="pt").input_ids
|
60 |
+
prefix_input_ids = tokenizer("Are dogs good for you?", return_tensors="pt").input_ids
|
61 |
+
input_ids = torch.cat((prefix_input_ids, document_input_ids), dim=-1)
|
62 |
+
attention_mask = torch.ones_like(input_ids)
|
63 |
+
prefix_length = torch.LongTensor([[prefix_input_ids.size(1)]])
|
64 |
+
|
65 |
+
outputs = model(input_ids=input_ids, attention_mask=attention_mask, prefix_length=prefix_length)
|
66 |
+
last_hidden_states = outputs.last_hidden_state
|
67 |
+
```
|
68 |
+
|
69 |
+
### BibTeX entry and citation info
|
70 |
+
|
71 |
+
Please cite both the SLED [paper](https://arxiv.org/abs/2208.00748.pdf) and the BART [paper](https://arxiv.org/abs/1910.13461) by Lewis et al as well as SummScreenFD by Chen et. al.
|
72 |
+
|
73 |
+
```bibtex
|
74 |
+
@inproceedings{Ivgi2022EfficientLU,
|
75 |
+
title={Efficient Long-Text Understanding with Short-Text Models},
|
76 |
+
author={Maor Ivgi and Uri Shaham and Jonathan Berant},
|
77 |
+
year={2022}
|
78 |
+
}
|
79 |
+
```
|
80 |
+
|
81 |
+
```bibtex
|
82 |
+
@article{DBLP:journals/corr/abs-1910-13461,
|
83 |
+
author = {Mike Lewis and
|
84 |
+
Yinhan Liu and
|
85 |
+
Naman Goyal and
|
86 |
+
Marjan Ghazvininejad and
|
87 |
+
Abdelrahman Mohamed and
|
88 |
+
Omer Levy and
|
89 |
+
Veselin Stoyanov and
|
90 |
+
Luke Zettlemoyer},
|
91 |
+
title = {{BART:} Denoising Sequence-to-Sequence Pre-training for Natural Language
|
92 |
+
Generation, Translation, and Comprehension},
|
93 |
+
journal = {CoRR},
|
94 |
+
volume = {abs/1910.13461},
|
95 |
+
year = {2019},
|
96 |
+
url = {http://arxiv.org/abs/1910.13461},
|
97 |
+
eprinttype = {arXiv},
|
98 |
+
eprint = {1910.13461},
|
99 |
+
timestamp = {Thu, 31 Oct 2019 14:02:26 +0100},
|
100 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-1910-13461.bib},
|
101 |
+
bibsource = {dblp computer science bibliography, https://dblp.org}
|
102 |
+
}
|
103 |
+
```
|
104 |
+
|
105 |
+
```bibtex
|
106 |
+
@inproceedings{Chen2022SummScreenAD,
|
107 |
+
title={SummScreen: A Dataset for Abstractive Screenplay Summarization},
|
108 |
+
author={Mingda Chen and Zewei Chu and Sam Wiseman and Kevin Gimpel},
|
109 |
+
booktitle={ACL},
|
110 |
+
year={2022}
|
111 |
+
}
|
112 |
+
```
|
config.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"model_type": "tau/sled",
|
3 |
+
"underlying_config": "facebook/bart-base",
|
4 |
+
"context_size": 256,
|
5 |
+
"window_fraction": 0.5,
|
6 |
+
"prepend_prefix": true,
|
7 |
+
"encode_prefix": true,
|
8 |
+
"sliding_method": "dynamic"
|
9 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:edcd7f1b5874f372124539f952b40bb797cf84de646eaff07743f231e495dc99
|
3 |
+
size 558046905
|
tokenizer_config.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"tokenizer_class": "SledTokenizer",
|
3 |
+
"base_tokenizer": "facebook/bart-base",
|
4 |
+
"model_max_length": 16384
|
5 |
+
}
|