Update README.md
Browse files
README.md
CHANGED
|
@@ -1,9 +1,20 @@
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
- generated_from_trainer
|
|
|
|
| 4 |
model-index:
|
| 5 |
- name: distilbart-finetuned-summarization
|
| 6 |
results: []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
---
|
| 8 |
|
| 9 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
|
@@ -11,34 +22,126 @@ should probably proofread and complete it, then remove this comment. -->
|
|
| 11 |
|
| 12 |
# distilbart-finetuned-summarization
|
| 13 |
|
| 14 |
-
This model
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
## Training procedure
|
| 29 |
|
|
|
|
|
|
|
| 30 |
### Training hyperparameters
|
| 31 |
|
| 32 |
The following hyperparameters were used during training:
|
| 33 |
-
-
|
| 34 |
-
-
|
| 35 |
-
-
|
| 36 |
-
-
|
| 37 |
-
-
|
|
|
|
|
|
|
| 38 |
- total_train_batch_size: 128
|
| 39 |
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
| 40 |
- lr_scheduler_type: linear
|
| 41 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
### Framework versions
|
| 44 |
|
|
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
- generated_from_trainer
|
| 4 |
+
- distilbart
|
| 5 |
model-index:
|
| 6 |
- name: distilbart-finetuned-summarization
|
| 7 |
results: []
|
| 8 |
+
license: apache-2.0
|
| 9 |
+
datasets:
|
| 10 |
+
- cnn_dailymail
|
| 11 |
+
- xsum
|
| 12 |
+
- samsum
|
| 13 |
+
- ccdv/pubmed-summarization
|
| 14 |
+
language:
|
| 15 |
+
- en
|
| 16 |
+
metrics:
|
| 17 |
+
- rouge
|
| 18 |
---
|
| 19 |
|
| 20 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
|
|
|
| 22 |
|
| 23 |
# distilbart-finetuned-summarization
|
| 24 |
|
| 25 |
+
This model is a further fine-tuned version of [distilbart-cnn-12-6](https://huggingface.co/sshleifer/distilbart-cnn-12-6) on the the combination of 4 different summarisation datasets:
|
| 26 |
+
- [cnn_dailymail](https://huggingface.co/datasets/cnn_dailymail)
|
| 27 |
+
- [samsum](https://huggingface.co/datasets/samsum)
|
| 28 |
+
- [xsum](https://huggingface.co/datasets/xsum)
|
| 29 |
+
- [ccdv/pubmed-summarization](https://huggingface.co/datasets/ccdv/pubmed-summarization)
|
| 30 |
|
| 31 |
+
Please check out the offical model page and paper:
|
| 32 |
+
- [sshleifer/distilbart-cnn-12-6](https://huggingface.co/sshleifer/distilbart-cnn-12-6)
|
| 33 |
+
- [Pre-trained Summarization Distillation](https://arxiv.org/abs/2010.13002)
|
| 34 |
|
| 35 |
+
## Training and evaluation data
|
| 36 |
|
| 37 |
+
One can reproduce the dataset using the following code:
|
| 38 |
|
| 39 |
+
```python
|
| 40 |
+
from datasets import DatasetDict, load_dataset
|
| 41 |
+
from datasets import concatenate_datasets
|
| 42 |
|
| 43 |
+
xsum_dataset = load_dataset("xsum")
|
| 44 |
+
pubmed_dataset = load_dataset("ccdv/pubmed-summarization").rename_column("article", "document").rename_column("abstract", "summary")
|
| 45 |
+
cnn_dataset = load_dataset("cnn_dailymail", '3.0.0').rename_column("article", "document").rename_column("highlights", "summary")
|
| 46 |
+
samsum_dataset = load_dataset("samsum").rename_column("dialogue", "document")
|
| 47 |
+
|
| 48 |
+
summary_train = concatenate_datasets([xsum_dataset["train"], pubmed_dataset["train"], cnn_dataset["train"], samsum_dataset["train"]])
|
| 49 |
+
summary_validation = concatenate_datasets([xsum_dataset["validation"], pubmed_dataset["validation"], cnn_dataset["validation"], samsum_dataset["validation"]])
|
| 50 |
+
summary_test = concatenate_datasets([xsum_dataset["test"], pubmed_dataset["test"], cnn_dataset["test"], samsum_dataset["test"]])
|
| 51 |
+
|
| 52 |
+
raw_datasets = DatasetDict()
|
| 53 |
+
raw_datasets["train"] = summary_train
|
| 54 |
+
raw_datasets["validation"] = summary_validation
|
| 55 |
+
raw_datasets["test"] = summary_test
|
| 56 |
+
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Inference example
|
| 60 |
+
|
| 61 |
+
```python
|
| 62 |
+
from transformers import pipeline
|
| 63 |
+
|
| 64 |
+
pipe = pipeline("text2text-generation", model="lxyuan/distilbart-finetuned-summarization")
|
| 65 |
+
|
| 66 |
+
text = """SINGAPORE: The Singapore Police Force on Sunday (Jul 16) issued a warning over a
|
| 67 |
+
fake SMS impersonating as its "anti-scam centre (ASC)".
|
| 68 |
+
|
| 69 |
+
"In this scam variant, members of the public would receive a scam SMS from 'ASC',
|
| 70 |
+
requesting them to download and install an “anti-scam” app to ensure the security
|
| 71 |
+
of their devices," said the police.
|
| 72 |
+
|
| 73 |
+
"The fake SMS would direct members of the public to a URL link leading to an
|
| 74 |
+
Android Package Kit (APK) file, an application created for Android’s operating
|
| 75 |
+
system purportedly from 'ASC'."
|
| 76 |
|
| 77 |
+
The fake website has an icon to download the “anti-scam” app and once downloaded,
|
| 78 |
+
Android users are asked to allow accessibility services to enable the service.
|
| 79 |
+
|
| 80 |
+
While the fake app purportedly claims to help identify and prevent scams by
|
| 81 |
+
providing comprehensive protection and security, downloading it may enable
|
| 82 |
+
scammers to gain remote access to devices.
|
| 83 |
+
|
| 84 |
+
"Members of the public are advised not to download any suspicious APK files
|
| 85 |
+
on their devices as they may contain malware which will allow scammers to
|
| 86 |
+
access and take control of the device remotely as well as to steal passwords
|
| 87 |
+
stored in the device," said the police.
|
| 88 |
+
|
| 89 |
+
Members of the public are advised to adopt the following precautionary measures,
|
| 90 |
+
including adding anti-virus or anti-malware apps to their devices. They should
|
| 91 |
+
also disable “install unknown app” or “unknown sources” in their phone settings.
|
| 92 |
+
|
| 93 |
+
Users should check the developer information on the app listing as well as the
|
| 94 |
+
number of downloads and user reviews to ensure it is a reputable and legitimate
|
| 95 |
+
app, the police said.
|
| 96 |
+
|
| 97 |
+
Any fraudulent transactions should be immediately reported to the banks.
|
| 98 |
+
"""
|
| 99 |
+
|
| 100 |
+
pipe(text)
|
| 101 |
+
|
| 102 |
+
>>>"""The Singapore Police Force has issued a warning over a fake SMS
|
| 103 |
+
impersonating as its "anti-scam centre" that asks members of the public
|
| 104 |
+
to download an Android app to ensure the security of their devices, the
|
| 105 |
+
force said on Sunday. The fake SMS would direct people to a URL link
|
| 106 |
+
leading to an Android Package Kit (APK) file, an application created
|
| 107 |
+
for Android’s operating system purportedly from "ASC".
|
| 108 |
+
"""
|
| 109 |
+
```
|
| 110 |
|
| 111 |
## Training procedure
|
| 112 |
|
| 113 |
+
Notebook link: [here](https://github.com/LxYuan0420/nlp/blob/main/notebooks/distilbart-finetune-summarisation.ipynb)
|
| 114 |
+
|
| 115 |
### Training hyperparameters
|
| 116 |
|
| 117 |
The following hyperparameters were used during training:
|
| 118 |
+
- evaluation_strategy="epoch",
|
| 119 |
+
- save_strategy="epoch",
|
| 120 |
+
- logging_strategy="epoch",
|
| 121 |
+
- learning_rate=2e-5,
|
| 122 |
+
- per_device_train_batch_size=2,
|
| 123 |
+
- per_device_eval_batch_size=2,
|
| 124 |
+
- gradient_accumulation_steps=64,
|
| 125 |
- total_train_batch_size: 128
|
| 126 |
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
| 127 |
- lr_scheduler_type: linear
|
| 128 |
+
- weight_decay=0.01,
|
| 129 |
+
- save_total_limit=2,
|
| 130 |
+
- num_train_epochs=4,
|
| 131 |
+
- predict_with_generate=True,
|
| 132 |
+
- fp16=True,
|
| 133 |
+
- push_to_hub=True
|
| 134 |
+
|
| 135 |
+
### Training results
|
| 136 |
+
_Training is still in progress_
|
| 137 |
+
|
| 138 |
+
| Epoch | Training Loss | Validation Loss | Rouge1 | Rouge2 | RougeL | RougeLsum | Gen Len |
|
| 139 |
+
|-------|---------------|-----------------|--------|--------|--------|-----------|---------|
|
| 140 |
+
| 0 | 1.779700 | 1.719054 | 40.003900 | 17.907100 | 27.882500 | 34.888600 | 88.893600 |
|
| 141 |
+
| 1 | 1.633800 | 1.710876 | 40.628800 | 18.470200 | 28.428100 | 35.577500 | 88.885000 |
|
| 142 |
+
| 2 | 1.566100 | 1.694476 | 40.928500 | 18.695300 | 28.613300 | 35.813300 | 88.993700 |
|
| 143 |
+
| 3 | 1.515700 | 1.691141 | 40.860500 | 18.696500 | 28.672700 | 35.734600 | 88.457300 |
|
| 144 |
+
|
| 145 |
|
| 146 |
### Framework versions
|
| 147 |
|