Eugene Siow
commited on
Commit
•
561b9d9
1
Parent(s):
60a1f9c
Initial commit.
Browse files- README.md +64 -0
- config.json +73 -0
- merges.txt +0 -0
- model_args.json +1 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tokenizer.json +0 -0
- tokenizer_config.json +1 -0
- training_args.bin +3 -0
- vocab.json +0 -0
README.md
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
license: apache-2.0
|
4 |
+
tags:
|
5 |
+
- transformers
|
6 |
+
- bart
|
7 |
+
- paraphrase
|
8 |
+
- seq2seq
|
9 |
+
datasets:
|
10 |
+
- quora
|
11 |
+
- paws
|
12 |
+
---
|
13 |
+
# BART Paraphrase Model (Large)
|
14 |
+
A large BART seq2seq (text2text generation) model fine-tuned on 3 paraphrase datasets.
|
15 |
+
|
16 |
+
## Model description
|
17 |
+
The BART model was proposed in [BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension](https://arxiv.org/abs/1910.13461) by Lewis et al. (2019).
|
18 |
+
|
19 |
+
- Bart uses a standard seq2seq/machine translation architecture with a bidirectional encoder (like BERT) and a left-to-right decoder (like GPT).
|
20 |
+
- The pretraining task involves randomly shuffling the order of the original sentences and a novel in-filling scheme, where spans of text are replaced with a single mask token.
|
21 |
+
- BART is particularly effective when fine tuned for text generation. This model is fine-tuned on 3 paraphrase datasets (Quora, PAWS and MSR paraphrase corpus).
|
22 |
+
|
23 |
+
The original BART code is from this [repository](https://github.com/pytorch/fairseq/tree/master/examples/bart).
|
24 |
+
|
25 |
+
## Intended uses & limitations
|
26 |
+
You can use the pre-trained model for paraphrasing an input sentence.
|
27 |
+
### How to use
|
28 |
+
```python
|
29 |
+
import torch
|
30 |
+
from transformers import BartForConditionalGeneration, BartTokenizer
|
31 |
+
|
32 |
+
input_sentence = "They were there to enjoy us and they were there to pray for us."
|
33 |
+
|
34 |
+
model = BartForConditionalGeneration.from_pretrained('eugenesiow/bart-paraphrase')
|
35 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
36 |
+
model = model.to(device)
|
37 |
+
tokenizer = BartTokenizer.from_pretrained('eugenesiow/bart-paraphrase')
|
38 |
+
batch = tokenizer(input_sentence, return_tensors='pt')
|
39 |
+
generated_ids = model.generate(batch['input_ids'])
|
40 |
+
generated_sentence = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
|
41 |
+
|
42 |
+
print(generated_sentence)
|
43 |
+
```
|
44 |
+
### Output
|
45 |
+
```
|
46 |
+
['They were there to enjoy us and to pray for us.']
|
47 |
+
```
|
48 |
+
## Training data
|
49 |
+
The model was fine-tuned on a pretrained [`facebook/bart-large`](https://huggingface.co/facebook/bart-large), using the [Quora](https://huggingface.co/datasets/quora), [PAWS](https://huggingface.co/datasets/paws) and [MSR paraphrase corpus](https://www.microsoft.com/en-us/download/details.aspx?id=52398).
|
50 |
+
## Training procedure
|
51 |
+
|
52 |
+
We follow the training procedure provided in the [simpletransformers](https://github.com/ThilinaRajapakse/simpletransformers) seq2seq [example](https://github.com/ThilinaRajapakse/simpletransformers/blob/master/examples/seq2seq/paraphrasing/train.py).
|
53 |
+
|
54 |
+
## BibTeX entry and citation info
|
55 |
+
```bibtex
|
56 |
+
@misc{lewis2019bart,
|
57 |
+
title={BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension},
|
58 |
+
author={Mike Lewis and Yinhan Liu and Naman Goyal and Marjan Ghazvininejad and Abdelrahman Mohamed and Omer Levy and Ves Stoyanov and Luke Zettlemoyer},
|
59 |
+
year={2019},
|
60 |
+
eprint={1910.13461},
|
61 |
+
archivePrefix={arXiv},
|
62 |
+
primaryClass={cs.CL}
|
63 |
+
}
|
64 |
+
```
|
config.json
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "facebook/bart-large",
|
3 |
+
"activation_dropout": 0.1,
|
4 |
+
"activation_function": "gelu",
|
5 |
+
"add_bias_logits": false,
|
6 |
+
"add_final_layer_norm": false,
|
7 |
+
"architectures": [
|
8 |
+
"BartForConditionalGeneration"
|
9 |
+
],
|
10 |
+
"attention_dropout": 0.1,
|
11 |
+
"bos_token_id": 0,
|
12 |
+
"classif_dropout": 0.1,
|
13 |
+
"classifier_dropout": 0.0,
|
14 |
+
"d_model": 1024,
|
15 |
+
"decoder_attention_heads": 16,
|
16 |
+
"decoder_ffn_dim": 4096,
|
17 |
+
"decoder_layerdrop": 0.0,
|
18 |
+
"decoder_layers": 12,
|
19 |
+
"decoder_start_token_id": 2,
|
20 |
+
"dropout": 0.1,
|
21 |
+
"early_stopping": true,
|
22 |
+
"encoder_attention_heads": 16,
|
23 |
+
"encoder_ffn_dim": 4096,
|
24 |
+
"encoder_layerdrop": 0.0,
|
25 |
+
"encoder_layers": 12,
|
26 |
+
"eos_token_id": 2,
|
27 |
+
"forced_eos_token_id": 2,
|
28 |
+
"gradient_checkpointing": false,
|
29 |
+
"id2label": {
|
30 |
+
"0": "LABEL_0",
|
31 |
+
"1": "LABEL_1",
|
32 |
+
"2": "LABEL_2"
|
33 |
+
},
|
34 |
+
"init_std": 0.02,
|
35 |
+
"is_encoder_decoder": true,
|
36 |
+
"label2id": {
|
37 |
+
"LABEL_0": 0,
|
38 |
+
"LABEL_1": 1,
|
39 |
+
"LABEL_2": 2
|
40 |
+
},
|
41 |
+
"max_position_embeddings": 1024,
|
42 |
+
"model_type": "bart",
|
43 |
+
"no_repeat_ngram_size": 3,
|
44 |
+
"normalize_before": false,
|
45 |
+
"num_beams": 4,
|
46 |
+
"num_hidden_layers": 12,
|
47 |
+
"pad_token_id": 1,
|
48 |
+
"scale_embedding": false,
|
49 |
+
"task_specific_params": {
|
50 |
+
"summarization": {
|
51 |
+
"length_penalty": 1.0,
|
52 |
+
"max_length": 128,
|
53 |
+
"min_length": 12,
|
54 |
+
"num_beams": 4
|
55 |
+
},
|
56 |
+
"summarization_cnn": {
|
57 |
+
"length_penalty": 2.0,
|
58 |
+
"max_length": 142,
|
59 |
+
"min_length": 56,
|
60 |
+
"num_beams": 4
|
61 |
+
},
|
62 |
+
"summarization_xsum": {
|
63 |
+
"length_penalty": 1.0,
|
64 |
+
"max_length": 62,
|
65 |
+
"min_length": 11,
|
66 |
+
"num_beams": 6
|
67 |
+
}
|
68 |
+
},
|
69 |
+
"torch_dtype": "float32",
|
70 |
+
"transformers_version": "4.10.2",
|
71 |
+
"use_cache": true,
|
72 |
+
"vocab_size": 50265
|
73 |
+
}
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
model_args.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"adafactor_beta1": null, "adafactor_clip_threshold": 1.0, "adafactor_decay_rate": -0.8, "adafactor_eps": [1e-30, 0.001], "adafactor_relative_step": true, "adafactor_scale_parameter": true, "adafactor_warmup_init": true, "adam_epsilon": 1e-08, "best_model_dir": "outputs/best_model", "cache_dir": "cache_dir/", "config": {}, "cosine_schedule_num_cycles": 0.5, "custom_layer_parameters": [], "custom_parameter_groups": [], "dataloader_num_workers": 0, "do_lower_case": false, "dynamic_quantize": false, "early_stopping_consider_epochs": false, "early_stopping_delta": 0, "early_stopping_metric": "eval_loss", "early_stopping_metric_minimize": true, "early_stopping_patience": 3, "encoding": null, "eval_batch_size": 64, "evaluate_during_training": true, "evaluate_during_training_silent": true, "evaluate_during_training_steps": 2500, "evaluate_during_training_verbose": true, "evaluate_each_epoch": true, "fp16": false, "gradient_accumulation_steps": 1, "learning_rate": 5e-05, "local_rank": -1, "logging_steps": 50, "manual_seed": null, "max_grad_norm": 1.0, "max_seq_length": 128, "model_name": "facebook/bart-large", "model_type": "bart", "multiprocessing_chunksize": -1, "n_gpu": 1, "no_cache": false, "no_save": false, "not_saved_args": [], "num_train_epochs": 2, "optimizer": "AdamW", "output_dir": "outputs/", "overwrite_output_dir": true, "polynomial_decay_schedule_lr_end": 1e-07, "polynomial_decay_schedule_power": 1.0, "process_count": 254, "quantized_model": false, "reprocess_input_data": true, "save_best_model": true, "save_eval_checkpoints": false, "save_model_every_epoch": true, "save_optimizer_and_scheduler": true, "save_steps": -1, "scheduler": "linear_schedule_with_warmup", "silent": false, "skip_special_tokens": true, "tensorboard_dir": null, "thread_count": null, "tokenizer_name": null, "tokenizer_type": null, "train_batch_size": 8, "train_custom_parameters_only": false, "use_cached_eval_features": false, "use_early_stopping": false, "use_hf_datasets": false, "use_multiprocessing": false, "use_multiprocessing_for_evaluation": true, "wandb_kwargs": {}, "wandb_project": null, "warmup_ratio": 0.06, "warmup_steps": 2047, "weight_decay": 0.0, "model_class": "Seq2SeqModel", "base_marian_model_name": "facebook/bart-large", "dataset_class": null, "dataset_cache_dir": null, "do_sample": true, "early_stopping": true, "evaluate_generated_text": false, "faiss_d": 768, "faiss_m": 128, "include_title_in_knowledge_dataset": true, "length_penalty": 2.0, "max_length": 128, "max_steps": -1, "num_beams": null, "num_return_sequences": 3, "rag_embed_batch_size": 16, "repetition_penalty": 1.0, "save_knowledge_dataset": true, "save_knowledge_dataset_with_checkpoints": false, "split_text_character": " ", "split_text_n": 100, "src_lang": "en_XX", "tgt_lang": "ro_RO", "top_k": 50, "top_p": 0.95, "use_multiprocessed_decoding": false}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:89cee0616fbdc3125ce8db1f5883e5693fea564643666a732f250c263f4246ad
|
3 |
+
size 1625557313
|
special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": false}}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "<unk>", "bos_token": "<s>", "eos_token": "</s>", "add_prefix_space": false, "errors": "replace", "sep_token": "</s>", "cls_token": "<s>", "pad_token": "<pad>", "mask_token": "<mask>", "model_max_length": 1024, "special_tokens_map_file": null, "name_or_path": "facebook/bart-large", "tokenizer_class": "BartTokenizer"}
|
training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:48da8f5990832568039f7a6d8b21377674e536aaa771935f7a44c7cc0f3498f5
|
3 |
+
size 3375
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|