Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,51 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
datasets: billsum
|
4 |
+
tags:
|
5 |
+
- summarization
|
6 |
---
|
7 |
+
|
8 |
+
# Longformer Encoder-Decoder (LED) fine-tuned on Billsum
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
This model is a fine-tuned version of [led-base-16384](https://huggingface.co/allenai/led-base-16384) on the [billsum](https://huggingface.co/datasets/billsum) dataset.
|
13 |
+
|
14 |
+
As described in [Longformer: The Long-Document Transformer](https://arxiv.org/pdf/2004.05150.pdf) by Iz Beltagy, Matthew E. Peters, Arman Cohan, *led-base-16384* was initialized from [*bart-base*](https://huggingface.co/facebook/bart-base) since both models share the exact same architecture. To be able to process 16K tokens, *bart-base*'s position embedding matrix was simply copied 16 times.
|
15 |
+
|
16 |
+
|
17 |
+
## How to use
|
18 |
+
|
19 |
+
```Python
|
20 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
21 |
+
|
22 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
23 |
+
|
24 |
+
tokenizer = AutoTokenizer.from_pretrained("d0r1h/LEDBill")
|
25 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("d0r1h/LEDBill", return_dict_in_generate=True).to(device)
|
26 |
+
|
27 |
+
case = "......."
|
28 |
+
|
29 |
+
input_ids = tokenizer(case, return_tensors="pt").input_ids.to(device)
|
30 |
+
global_attention_mask = torch.zeros_like(input_ids)
|
31 |
+
global_attention_mask[:, 0] = 1
|
32 |
+
|
33 |
+
sequences = model.generate(input_ids,
|
34 |
+
global_attention_mask=global_attention_mask).sequences
|
35 |
+
summary = tokenizer.batch_decode(sequences,
|
36 |
+
skip_special_tokens=True)
|
37 |
+
|
38 |
+
```
|
39 |
+
|
40 |
+
|
41 |
+
## Evaluation results
|
42 |
+
|
43 |
+
When the model is used for summarizing Billsum documents(10 sample), it achieves the following results:
|
44 |
+
|
45 |
+
| Model | rouge1-f | rouge1-p | rouge2-f | rouge2-p | rougeL-f | rougeL-p |
|
46 |
+
|:-----------:|:-----:|:-----:|:------:|:-----:|:------:|:-----:|
|
47 |
+
| LEDBill | **34** | **37** | **15** | **16** | **30** | **32** |
|
48 |
+
| led-base | 2 | 15 | 0 | 0 | 2 | 15 |
|
49 |
+
|
50 |
+
[This notebook](https://colab.research.google.com/drive/1iEEFbWeTGUSDesmxHIU2QDsPQM85Ka1K?usp=sharing) shows how *led* can effectively be used for downstream task such summarization.
|
51 |
+
|