Upload 15 files
Browse files- README.md +75 -0
- all_results.json +18 -0
- config.json +70 -0
- eval_results.json +13 -0
- generation_config.json +15 -0
- merges.txt +0 -0
- pytorch_model.bin +3 -0
- run_summarization.py +759 -0
- special_tokens_map.json +51 -0
- tokenizer.json +0 -0
- tokenizer_config.json +64 -0
- train_results.json +8 -0
- trainer_state.json +25 -0
- training_args.bin +3 -0
- vocab.json +0 -0
README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- generated_from_trainer
|
| 5 |
+
datasets:
|
| 6 |
+
- ccdv/arxiv-summarization
|
| 7 |
+
metrics:
|
| 8 |
+
- rouge
|
| 9 |
+
model-index:
|
| 10 |
+
- name: results
|
| 11 |
+
results:
|
| 12 |
+
- task:
|
| 13 |
+
name: Summarization
|
| 14 |
+
type: summarization
|
| 15 |
+
dataset:
|
| 16 |
+
name: ccdv/arxiv-summarization
|
| 17 |
+
type: ccdv/arxiv-summarization
|
| 18 |
+
config: section
|
| 19 |
+
split: validation
|
| 20 |
+
args: section
|
| 21 |
+
metrics:
|
| 22 |
+
- name: Rouge1
|
| 23 |
+
type: rouge
|
| 24 |
+
value: 35.6639
|
| 25 |
+
---
|
| 26 |
+
|
| 27 |
+
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
| 28 |
+
should probably proofread and complete it, then remove this comment. -->
|
| 29 |
+
|
| 30 |
+
# results
|
| 31 |
+
|
| 32 |
+
This model is a fine-tuned version of [sshleifer/distilbart-xsum-12-1](https://huggingface.co/sshleifer/distilbart-xsum-12-1) on the ccdv/arxiv-summarization dataset.
|
| 33 |
+
It achieves the following results on the evaluation set:
|
| 34 |
+
- Loss: 4.3066
|
| 35 |
+
- Rouge1: 35.6639
|
| 36 |
+
- Rouge2: 10.5717
|
| 37 |
+
- Rougel: 21.095
|
| 38 |
+
- Rougelsum: 31.2685
|
| 39 |
+
- Gen Len: 81.44
|
| 40 |
+
|
| 41 |
+
## Model description
|
| 42 |
+
|
| 43 |
+
More information needed
|
| 44 |
+
|
| 45 |
+
## Intended uses & limitations
|
| 46 |
+
|
| 47 |
+
More information needed
|
| 48 |
+
|
| 49 |
+
## Training and evaluation data
|
| 50 |
+
|
| 51 |
+
More information needed
|
| 52 |
+
|
| 53 |
+
## Training procedure
|
| 54 |
+
|
| 55 |
+
### Training hyperparameters
|
| 56 |
+
|
| 57 |
+
The following hyperparameters were used during training:
|
| 58 |
+
- learning_rate: 5e-05
|
| 59 |
+
- train_batch_size: 4
|
| 60 |
+
- eval_batch_size: 4
|
| 61 |
+
- seed: 42
|
| 62 |
+
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
| 63 |
+
- lr_scheduler_type: linear
|
| 64 |
+
- num_epochs: 3.0
|
| 65 |
+
|
| 66 |
+
### Training results
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
### Framework versions
|
| 71 |
+
|
| 72 |
+
- Transformers 4.29.0.dev0
|
| 73 |
+
- Pytorch 2.0.0
|
| 74 |
+
- Datasets 2.10.1
|
| 75 |
+
- Tokenizers 0.13.2
|
all_results.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"epoch": 3.0,
|
| 3 |
+
"eval_gen_len": 81.44,
|
| 4 |
+
"eval_loss": 4.306642055511475,
|
| 5 |
+
"eval_rouge1": 35.6639,
|
| 6 |
+
"eval_rouge2": 10.5717,
|
| 7 |
+
"eval_rougeL": 21.095,
|
| 8 |
+
"eval_rougeLsum": 31.2685,
|
| 9 |
+
"eval_runtime": 462.9321,
|
| 10 |
+
"eval_samples": 100,
|
| 11 |
+
"eval_samples_per_second": 0.216,
|
| 12 |
+
"eval_steps_per_second": 0.054,
|
| 13 |
+
"train_loss": 4.326354817708333,
|
| 14 |
+
"train_runtime": 8399.8868,
|
| 15 |
+
"train_samples": 500,
|
| 16 |
+
"train_samples_per_second": 0.179,
|
| 17 |
+
"train_steps_per_second": 0.045
|
| 18 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "sshleifer/distilbart-xsum-12-1",
|
| 3 |
+
"_num_labels": 3,
|
| 4 |
+
"activation_dropout": 0.0,
|
| 5 |
+
"activation_function": "gelu",
|
| 6 |
+
"add_bias_logits": false,
|
| 7 |
+
"add_final_layer_norm": false,
|
| 8 |
+
"architectures": [
|
| 9 |
+
"BartForConditionalGeneration"
|
| 10 |
+
],
|
| 11 |
+
"attention_dropout": 0.0,
|
| 12 |
+
"bos_token_id": 0,
|
| 13 |
+
"classif_dropout": 0.0,
|
| 14 |
+
"classifier_dropout": 0.0,
|
| 15 |
+
"d_model": 1024,
|
| 16 |
+
"decoder_attention_heads": 16,
|
| 17 |
+
"decoder_ffn_dim": 4096,
|
| 18 |
+
"decoder_layerdrop": 0.0,
|
| 19 |
+
"decoder_layers": 1,
|
| 20 |
+
"decoder_start_token_id": 2,
|
| 21 |
+
"dropout": 0.1,
|
| 22 |
+
"early_stopping": true,
|
| 23 |
+
"encoder_attention_heads": 16,
|
| 24 |
+
"encoder_ffn_dim": 4096,
|
| 25 |
+
"encoder_layerdrop": 0.0,
|
| 26 |
+
"encoder_layers": 12,
|
| 27 |
+
"eos_token_id": 2,
|
| 28 |
+
"eos_token_ids": [
|
| 29 |
+
2
|
| 30 |
+
],
|
| 31 |
+
"extra_pos_embeddings": 2,
|
| 32 |
+
"forced_eos_token_id": 2,
|
| 33 |
+
"gradient_checkpointing": false,
|
| 34 |
+
"id2label": {
|
| 35 |
+
"0": "LABEL_0",
|
| 36 |
+
"1": "LABEL_1",
|
| 37 |
+
"2": "LABEL_2"
|
| 38 |
+
},
|
| 39 |
+
"init_std": 0.02,
|
| 40 |
+
"is_encoder_decoder": true,
|
| 41 |
+
"label2id": {
|
| 42 |
+
"LABEL_0": 0,
|
| 43 |
+
"LABEL_1": 1,
|
| 44 |
+
"LABEL_2": 2
|
| 45 |
+
},
|
| 46 |
+
"length_penalty": 0.5,
|
| 47 |
+
"max_length": 62,
|
| 48 |
+
"max_position_embeddings": 1024,
|
| 49 |
+
"min_length": 11,
|
| 50 |
+
"model_type": "bart",
|
| 51 |
+
"no_repeat_ngram_size": 3,
|
| 52 |
+
"normalize_before": false,
|
| 53 |
+
"normalize_embedding": true,
|
| 54 |
+
"num_beams": 6,
|
| 55 |
+
"num_hidden_layers": 12,
|
| 56 |
+
"output_past": true,
|
| 57 |
+
"pad_token_id": 1,
|
| 58 |
+
"prefix": " ",
|
| 59 |
+
"replacing_rate": 0,
|
| 60 |
+
"save_step": 52,
|
| 61 |
+
"scale_embedding": false,
|
| 62 |
+
"static_position_embeddings": false,
|
| 63 |
+
"student_decoder_layers": null,
|
| 64 |
+
"student_encoder_layers": null,
|
| 65 |
+
"task_specific_params": {},
|
| 66 |
+
"torch_dtype": "float32",
|
| 67 |
+
"transformers_version": "4.29.0.dev0",
|
| 68 |
+
"use_cache": true,
|
| 69 |
+
"vocab_size": 50265
|
| 70 |
+
}
|
eval_results.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"epoch": 3.0,
|
| 3 |
+
"eval_gen_len": 81.44,
|
| 4 |
+
"eval_loss": 4.306642055511475,
|
| 5 |
+
"eval_rouge1": 35.6639,
|
| 6 |
+
"eval_rouge2": 10.5717,
|
| 7 |
+
"eval_rougeL": 21.095,
|
| 8 |
+
"eval_rougeLsum": 31.2685,
|
| 9 |
+
"eval_runtime": 462.9321,
|
| 10 |
+
"eval_samples": 100,
|
| 11 |
+
"eval_samples_per_second": 0.216,
|
| 12 |
+
"eval_steps_per_second": 0.054
|
| 13 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 0,
|
| 4 |
+
"decoder_start_token_id": 2,
|
| 5 |
+
"early_stopping": true,
|
| 6 |
+
"eos_token_id": 2,
|
| 7 |
+
"forced_eos_token_id": 2,
|
| 8 |
+
"length_penalty": 0.5,
|
| 9 |
+
"max_length": 62,
|
| 10 |
+
"min_length": 11,
|
| 11 |
+
"no_repeat_ngram_size": 3,
|
| 12 |
+
"num_beams": 6,
|
| 13 |
+
"pad_token_id": 1,
|
| 14 |
+
"transformers_version": "4.29.0.dev0"
|
| 15 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:62a8f1fb574cd567297d24fdb381d588c35fe715a9bbe3464aadf94703f695ba
|
| 3 |
+
size 886386773
|
run_summarization.py
ADDED
|
@@ -0,0 +1,759 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# coding=utf-8
|
| 3 |
+
# Copyright 2021 The HuggingFace Team. All rights reserved.
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
# you may not use this file except in compliance with the License.
|
| 7 |
+
# You may obtain a copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
# See the License for the specific language governing permissions and
|
| 15 |
+
# limitations under the License.
|
| 16 |
+
"""
|
| 17 |
+
Fine-tuning the library models for sequence to sequence.
|
| 18 |
+
"""
|
| 19 |
+
# You can also adapt this script on your own sequence to sequence task. Pointers for this are left as comments.
|
| 20 |
+
|
| 21 |
+
import logging
|
| 22 |
+
import os
|
| 23 |
+
import sys
|
| 24 |
+
from dataclasses import dataclass, field
|
| 25 |
+
from typing import Optional
|
| 26 |
+
|
| 27 |
+
import datasets
|
| 28 |
+
import evaluate
|
| 29 |
+
import nltk # Here to have a nice missing dependency error message early on
|
| 30 |
+
import numpy as np
|
| 31 |
+
from datasets import load_dataset
|
| 32 |
+
from filelock import FileLock
|
| 33 |
+
|
| 34 |
+
import transformers
|
| 35 |
+
from transformers import (
|
| 36 |
+
AutoConfig,
|
| 37 |
+
AutoModelForSeq2SeqLM,
|
| 38 |
+
AutoTokenizer,
|
| 39 |
+
DataCollatorForSeq2Seq,
|
| 40 |
+
HfArgumentParser,
|
| 41 |
+
MBart50Tokenizer,
|
| 42 |
+
MBart50TokenizerFast,
|
| 43 |
+
MBartTokenizer,
|
| 44 |
+
MBartTokenizerFast,
|
| 45 |
+
Seq2SeqTrainer,
|
| 46 |
+
Seq2SeqTrainingArguments,
|
| 47 |
+
set_seed,
|
| 48 |
+
)
|
| 49 |
+
from transformers.trainer_utils import get_last_checkpoint
|
| 50 |
+
from transformers.utils import check_min_version, is_offline_mode, send_example_telemetry
|
| 51 |
+
from transformers.utils.versions import require_version
|
| 52 |
+
|
| 53 |
+
train_num = range(500)
|
| 54 |
+
test_num = range(100)
|
| 55 |
+
val_num = range(100)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
| 59 |
+
check_min_version("4.29.0.dev0")
|
| 60 |
+
|
| 61 |
+
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/summarization/requirements.txt")
|
| 62 |
+
|
| 63 |
+
logger = logging.getLogger(__name__)
|
| 64 |
+
|
| 65 |
+
try:
|
| 66 |
+
nltk.data.find("tokenizers/punkt")
|
| 67 |
+
except (LookupError, OSError):
|
| 68 |
+
if is_offline_mode():
|
| 69 |
+
raise LookupError(
|
| 70 |
+
"Offline mode: run this script without TRANSFORMERS_OFFLINE first to download nltk data files"
|
| 71 |
+
)
|
| 72 |
+
with FileLock(".lock") as lock:
|
| 73 |
+
nltk.download("punkt", quiet=True)
|
| 74 |
+
|
| 75 |
+
# A list of all multilingual tokenizer which require lang attribute.
|
| 76 |
+
MULTILINGUAL_TOKENIZERS = [MBartTokenizer, MBartTokenizerFast, MBart50Tokenizer, MBart50TokenizerFast]
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
@dataclass
|
| 80 |
+
class ModelArguments:
|
| 81 |
+
"""
|
| 82 |
+
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
|
| 83 |
+
"""
|
| 84 |
+
|
| 85 |
+
model_name_or_path: str = field(
|
| 86 |
+
metadata={"help": "Path to pretrained model or model identifier from huggingface.co/models"}
|
| 87 |
+
)
|
| 88 |
+
config_name: Optional[str] = field(
|
| 89 |
+
default=None, metadata={"help": "Pretrained config name or path if not the same as model_name"}
|
| 90 |
+
)
|
| 91 |
+
tokenizer_name: Optional[str] = field(
|
| 92 |
+
default=None, metadata={"help": "Pretrained tokenizer name or path if not the same as model_name"}
|
| 93 |
+
)
|
| 94 |
+
cache_dir: Optional[str] = field(
|
| 95 |
+
default=None,
|
| 96 |
+
metadata={"help": "Where to store the pretrained models downloaded from huggingface.co"},
|
| 97 |
+
)
|
| 98 |
+
use_fast_tokenizer: bool = field(
|
| 99 |
+
default=True,
|
| 100 |
+
metadata={"help": "Whether to use one of the fast tokenizer (backed by the tokenizers library) or not."},
|
| 101 |
+
)
|
| 102 |
+
model_revision: str = field(
|
| 103 |
+
default="main",
|
| 104 |
+
metadata={"help": "The specific model version to use (can be a branch name, tag name or commit id)."},
|
| 105 |
+
)
|
| 106 |
+
use_auth_token: bool = field(
|
| 107 |
+
default=False,
|
| 108 |
+
metadata={
|
| 109 |
+
"help": (
|
| 110 |
+
"Will use the token generated when running `huggingface-cli login` (necessary to use this script "
|
| 111 |
+
"with private models)."
|
| 112 |
+
)
|
| 113 |
+
},
|
| 114 |
+
)
|
| 115 |
+
resize_position_embeddings: Optional[bool] = field(
|
| 116 |
+
default=None,
|
| 117 |
+
metadata={
|
| 118 |
+
"help": (
|
| 119 |
+
"Whether to automatically resize the position embeddings if `max_source_length` exceeds "
|
| 120 |
+
"the model's position embeddings."
|
| 121 |
+
)
|
| 122 |
+
},
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
@dataclass
|
| 127 |
+
class DataTrainingArguments:
|
| 128 |
+
"""
|
| 129 |
+
Arguments pertaining to what data we are going to input our model for training and eval.
|
| 130 |
+
"""
|
| 131 |
+
|
| 132 |
+
lang: Optional[str] = field(default=None, metadata={"help": "Language id for summarization."})
|
| 133 |
+
|
| 134 |
+
dataset_name: Optional[str] = field(
|
| 135 |
+
default=None, metadata={"help": "The name of the dataset to use (via the datasets library)."}
|
| 136 |
+
)
|
| 137 |
+
dataset_config_name: Optional[str] = field(
|
| 138 |
+
default=None, metadata={"help": "The configuration name of the dataset to use (via the datasets library)."}
|
| 139 |
+
)
|
| 140 |
+
text_column: Optional[str] = field(
|
| 141 |
+
default=None,
|
| 142 |
+
metadata={"help": "The name of the column in the datasets containing the full texts (for summarization)."},
|
| 143 |
+
)
|
| 144 |
+
summary_column: Optional[str] = field(
|
| 145 |
+
default=None,
|
| 146 |
+
metadata={"help": "The name of the column in the datasets containing the summaries (for summarization)."},
|
| 147 |
+
)
|
| 148 |
+
train_file: Optional[str] = field(
|
| 149 |
+
default=None, metadata={"help": "The input training data file (a jsonlines or csv file)."}
|
| 150 |
+
)
|
| 151 |
+
validation_file: Optional[str] = field(
|
| 152 |
+
default=None,
|
| 153 |
+
metadata={
|
| 154 |
+
"help": (
|
| 155 |
+
"An optional input evaluation data file to evaluate the metrics (rouge) on (a jsonlines or csv file)."
|
| 156 |
+
)
|
| 157 |
+
},
|
| 158 |
+
)
|
| 159 |
+
test_file: Optional[str] = field(
|
| 160 |
+
default=None,
|
| 161 |
+
metadata={
|
| 162 |
+
"help": "An optional input test data file to evaluate the metrics (rouge) on (a jsonlines or csv file)."
|
| 163 |
+
},
|
| 164 |
+
)
|
| 165 |
+
overwrite_cache: bool = field(
|
| 166 |
+
default=False, metadata={"help": "Overwrite the cached training and evaluation sets"}
|
| 167 |
+
)
|
| 168 |
+
preprocessing_num_workers: Optional[int] = field(
|
| 169 |
+
default=None,
|
| 170 |
+
metadata={"help": "The number of processes to use for the preprocessing."},
|
| 171 |
+
)
|
| 172 |
+
max_source_length: Optional[int] = field(
|
| 173 |
+
default=1024,
|
| 174 |
+
metadata={
|
| 175 |
+
"help": (
|
| 176 |
+
"The maximum total input sequence length after tokenization. Sequences longer "
|
| 177 |
+
"than this will be truncated, sequences shorter will be padded."
|
| 178 |
+
)
|
| 179 |
+
},
|
| 180 |
+
)
|
| 181 |
+
max_target_length: Optional[int] = field(
|
| 182 |
+
default=128,
|
| 183 |
+
metadata={
|
| 184 |
+
"help": (
|
| 185 |
+
"The maximum total sequence length for target text after tokenization. Sequences longer "
|
| 186 |
+
"than this will be truncated, sequences shorter will be padded."
|
| 187 |
+
)
|
| 188 |
+
},
|
| 189 |
+
)
|
| 190 |
+
val_max_target_length: Optional[int] = field(
|
| 191 |
+
default=None,
|
| 192 |
+
metadata={
|
| 193 |
+
"help": (
|
| 194 |
+
"The maximum total sequence length for validation target text after tokenization. Sequences longer "
|
| 195 |
+
"than this will be truncated, sequences shorter will be padded. Will default to `max_target_length`."
|
| 196 |
+
"This argument is also used to override the ``max_length`` param of ``model.generate``, which is used "
|
| 197 |
+
"during ``evaluate`` and ``predict``."
|
| 198 |
+
)
|
| 199 |
+
},
|
| 200 |
+
)
|
| 201 |
+
pad_to_max_length: bool = field(
|
| 202 |
+
default=False,
|
| 203 |
+
metadata={
|
| 204 |
+
"help": (
|
| 205 |
+
"Whether to pad all samples to model maximum sentence length. "
|
| 206 |
+
"If False, will pad the samples dynamically when batching to the maximum length in the batch. More "
|
| 207 |
+
"efficient on GPU but very bad for TPU."
|
| 208 |
+
)
|
| 209 |
+
},
|
| 210 |
+
)
|
| 211 |
+
max_train_samples: Optional[int] = field(
|
| 212 |
+
default=None,
|
| 213 |
+
metadata={
|
| 214 |
+
"help": (
|
| 215 |
+
"For debugging purposes or quicker training, truncate the number of training examples to this "
|
| 216 |
+
"value if set."
|
| 217 |
+
)
|
| 218 |
+
},
|
| 219 |
+
)
|
| 220 |
+
max_eval_samples: Optional[int] = field(
|
| 221 |
+
default=None,
|
| 222 |
+
metadata={
|
| 223 |
+
"help": (
|
| 224 |
+
"For debugging purposes or quicker training, truncate the number of evaluation examples to this "
|
| 225 |
+
"value if set."
|
| 226 |
+
)
|
| 227 |
+
},
|
| 228 |
+
)
|
| 229 |
+
max_predict_samples: Optional[int] = field(
|
| 230 |
+
default=None,
|
| 231 |
+
metadata={
|
| 232 |
+
"help": (
|
| 233 |
+
"For debugging purposes or quicker training, truncate the number of prediction examples to this "
|
| 234 |
+
"value if set."
|
| 235 |
+
)
|
| 236 |
+
},
|
| 237 |
+
)
|
| 238 |
+
num_beams: Optional[int] = field(
|
| 239 |
+
default=None,
|
| 240 |
+
metadata={
|
| 241 |
+
"help": (
|
| 242 |
+
"Number of beams to use for evaluation. This argument will be passed to ``model.generate``, "
|
| 243 |
+
"which is used during ``evaluate`` and ``predict``."
|
| 244 |
+
)
|
| 245 |
+
},
|
| 246 |
+
)
|
| 247 |
+
ignore_pad_token_for_loss: bool = field(
|
| 248 |
+
default=True,
|
| 249 |
+
metadata={
|
| 250 |
+
"help": "Whether to ignore the tokens corresponding to padded labels in the loss computation or not."
|
| 251 |
+
},
|
| 252 |
+
)
|
| 253 |
+
source_prefix: Optional[str] = field(
|
| 254 |
+
default="", metadata={"help": "A prefix to add before every source text (useful for T5 models)."}
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
forced_bos_token: Optional[str] = field(
|
| 258 |
+
default=None,
|
| 259 |
+
metadata={
|
| 260 |
+
"help": (
|
| 261 |
+
"The token to force as the first generated token after the decoder_start_token_id."
|
| 262 |
+
"Useful for multilingual models like mBART where the first generated token"
|
| 263 |
+
"needs to be the target language token (Usually it is the target language token)"
|
| 264 |
+
)
|
| 265 |
+
},
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
def __post_init__(self):
|
| 269 |
+
if (
|
| 270 |
+
self.dataset_name is None
|
| 271 |
+
and self.train_file is None
|
| 272 |
+
and self.validation_file is None
|
| 273 |
+
and self.test_file is None
|
| 274 |
+
):
|
| 275 |
+
raise ValueError("Need either a dataset name or a training, validation, or test file.")
|
| 276 |
+
else:
|
| 277 |
+
if self.train_file is not None:
|
| 278 |
+
extension = self.train_file.split(".")[-1]
|
| 279 |
+
assert extension in ["csv", "json"], "`train_file` should be a csv or a json file."
|
| 280 |
+
if self.validation_file is not None:
|
| 281 |
+
extension = self.validation_file.split(".")[-1]
|
| 282 |
+
assert extension in ["csv", "json"], "`validation_file` should be a csv or a json file."
|
| 283 |
+
if self.test_file is not None:
|
| 284 |
+
extension = self.test_file.split(".")[-1]
|
| 285 |
+
assert extension in ["csv", "json"], "`test_file` should be a csv or a json file."
|
| 286 |
+
if self.val_max_target_length is None:
|
| 287 |
+
self.val_max_target_length = self.max_target_length
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
summarization_name_mapping = {
|
| 291 |
+
"amazon_reviews_multi": ("review_body", "review_title"),
|
| 292 |
+
"big_patent": ("description", "abstract"),
|
| 293 |
+
"cnn_dailymail": ("article", "highlights"),
|
| 294 |
+
"orange_sum": ("text", "summary"),
|
| 295 |
+
"pn_summary": ("article", "summary"),
|
| 296 |
+
"psc": ("extract_text", "summary_text"),
|
| 297 |
+
"samsum": ("dialogue", "summary"),
|
| 298 |
+
"thaisum": ("body", "summary"),
|
| 299 |
+
"xglue": ("news_body", "news_title"),
|
| 300 |
+
"xsum": ("document", "summary"),
|
| 301 |
+
"wiki_summary": ("article", "highlights"),
|
| 302 |
+
"multi_news": ("document", "summary"),
|
| 303 |
+
"ccdv/arxiv-summarization": ("article", "abstract"),
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
def main():
|
| 308 |
+
# See all possible arguments in src/transformers/training_args.py
|
| 309 |
+
# or by passing the --help flag to this script.
|
| 310 |
+
# We now keep distinct sets of args, for a cleaner separation of concerns.
|
| 311 |
+
|
| 312 |
+
parser = HfArgumentParser((ModelArguments, DataTrainingArguments, Seq2SeqTrainingArguments))
|
| 313 |
+
if len(sys.argv) == 2 and sys.argv[1].endswith(".json"):
|
| 314 |
+
# If we pass only one argument to the script and it's the path to a json file,
|
| 315 |
+
# let's parse it to get our arguments.
|
| 316 |
+
model_args, data_args, training_args = parser.parse_json_file(json_file=os.path.abspath(sys.argv[1]))
|
| 317 |
+
else:
|
| 318 |
+
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
| 319 |
+
|
| 320 |
+
# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
|
| 321 |
+
# information sent is the one passed as arguments along with your Python/PyTorch versions.
|
| 322 |
+
send_example_telemetry("run_summarization", model_args, data_args)
|
| 323 |
+
|
| 324 |
+
# Setup logging
|
| 325 |
+
logging.basicConfig(
|
| 326 |
+
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
| 327 |
+
datefmt="%m/%d/%Y %H:%M:%S",
|
| 328 |
+
handlers=[logging.StreamHandler(sys.stdout)],
|
| 329 |
+
)
|
| 330 |
+
|
| 331 |
+
if training_args.should_log:
|
| 332 |
+
# The default of training_args.log_level is passive, so we set log level at info here to have that default.
|
| 333 |
+
transformers.utils.logging.set_verbosity_info()
|
| 334 |
+
|
| 335 |
+
log_level = training_args.get_process_log_level()
|
| 336 |
+
logger.setLevel(log_level)
|
| 337 |
+
datasets.utils.logging.set_verbosity(log_level)
|
| 338 |
+
transformers.utils.logging.set_verbosity(log_level)
|
| 339 |
+
transformers.utils.logging.enable_default_handler()
|
| 340 |
+
transformers.utils.logging.enable_explicit_format()
|
| 341 |
+
|
| 342 |
+
# Log on each process the small summary:
|
| 343 |
+
logger.warning(
|
| 344 |
+
f"Process rank: {training_args.local_rank}, device: {training_args.device}, n_gpu: {training_args.n_gpu}"
|
| 345 |
+
+ f"distributed training: {bool(training_args.local_rank != -1)}, 16-bits training: {training_args.fp16}"
|
| 346 |
+
)
|
| 347 |
+
logger.info(f"Training/evaluation parameters {training_args}")
|
| 348 |
+
|
| 349 |
+
if data_args.source_prefix is None and model_args.model_name_or_path in [
|
| 350 |
+
"t5-small",
|
| 351 |
+
"t5-base",
|
| 352 |
+
"t5-large",
|
| 353 |
+
"t5-3b",
|
| 354 |
+
"t5-11b",
|
| 355 |
+
]:
|
| 356 |
+
logger.warning(
|
| 357 |
+
"You're running a t5 model but didn't provide a source prefix, which is the expected, e.g. with "
|
| 358 |
+
"`--source_prefix 'summarize: ' `"
|
| 359 |
+
)
|
| 360 |
+
|
| 361 |
+
# Detecting last checkpoint.
|
| 362 |
+
last_checkpoint = None
|
| 363 |
+
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
| 364 |
+
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
| 365 |
+
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
| 366 |
+
raise ValueError(
|
| 367 |
+
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
| 368 |
+
"Use --overwrite_output_dir to overcome."
|
| 369 |
+
)
|
| 370 |
+
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
| 371 |
+
logger.info(
|
| 372 |
+
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
| 373 |
+
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
| 374 |
+
)
|
| 375 |
+
|
| 376 |
+
# Set seed before initializing model.
|
| 377 |
+
set_seed(training_args.seed)
|
| 378 |
+
|
| 379 |
+
# Get the datasets: you can either provide your own CSV/JSON training and evaluation files (see below)
|
| 380 |
+
# or just provide the name of one of the public datasets available on the hub at https://huggingface.co/datasets/
|
| 381 |
+
# (the dataset will be downloaded automatically from the datasets Hub).
|
| 382 |
+
#
|
| 383 |
+
# For CSV/JSON files this script will use the first column for the full texts and the second column for the
|
| 384 |
+
# summaries (unless you specify column names for this with the `text_column` and `summary_column` arguments).
|
| 385 |
+
#
|
| 386 |
+
# In distributed training, the load_dataset function guarantee that only one local process can concurrently
|
| 387 |
+
# download the dataset.
|
| 388 |
+
if data_args.dataset_name is not None:
|
| 389 |
+
# Downloading and loading a dataset from the hub.
|
| 390 |
+
raw_datasets = load_dataset(
|
| 391 |
+
data_args.dataset_name,
|
| 392 |
+
data_args.dataset_config_name,
|
| 393 |
+
cache_dir=model_args.cache_dir,
|
| 394 |
+
use_auth_token=True if model_args.use_auth_token else None,
|
| 395 |
+
)
|
| 396 |
+
else:
|
| 397 |
+
data_files = {}
|
| 398 |
+
if data_args.train_file is not None:
|
| 399 |
+
data_files["train"] = data_args.train_file
|
| 400 |
+
extension = data_args.train_file.split(".")[-1]
|
| 401 |
+
if data_args.validation_file is not None:
|
| 402 |
+
data_files["validation"] = data_args.validation_file
|
| 403 |
+
extension = data_args.validation_file.split(".")[-1]
|
| 404 |
+
if data_args.test_file is not None:
|
| 405 |
+
data_files["test"] = data_args.test_file
|
| 406 |
+
extension = data_args.test_file.split(".")[-1]
|
| 407 |
+
raw_datasets = load_dataset(
|
| 408 |
+
extension,
|
| 409 |
+
data_files=data_files,
|
| 410 |
+
cache_dir=model_args.cache_dir,
|
| 411 |
+
use_auth_token=True if model_args.use_auth_token else None,
|
| 412 |
+
)
|
| 413 |
+
# See more about loading any type of standard or custom dataset (from files, python dict, pandas DataFrame, etc) at
|
| 414 |
+
# https://huggingface.co/docs/datasets/loading_datasets.html.
|
| 415 |
+
|
| 416 |
+
# Load pretrained model and tokenizer
|
| 417 |
+
#
|
| 418 |
+
# Distributed training:
|
| 419 |
+
# The .from_pretrained methods guarantee that only one local process can concurrently
|
| 420 |
+
# download model & vocab.
|
| 421 |
+
config = AutoConfig.from_pretrained(
|
| 422 |
+
model_args.config_name if model_args.config_name else model_args.model_name_or_path,
|
| 423 |
+
cache_dir=model_args.cache_dir,
|
| 424 |
+
revision=model_args.model_revision,
|
| 425 |
+
use_auth_token=True if model_args.use_auth_token else None,
|
| 426 |
+
)
|
| 427 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 428 |
+
model_args.tokenizer_name if model_args.tokenizer_name else model_args.model_name_or_path,
|
| 429 |
+
cache_dir=model_args.cache_dir,
|
| 430 |
+
use_fast=model_args.use_fast_tokenizer,
|
| 431 |
+
revision=model_args.model_revision,
|
| 432 |
+
use_auth_token=True if model_args.use_auth_token else None,
|
| 433 |
+
)
|
| 434 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(
|
| 435 |
+
model_args.model_name_or_path,
|
| 436 |
+
from_tf=bool(".ckpt" in model_args.model_name_or_path),
|
| 437 |
+
config=config,
|
| 438 |
+
cache_dir=model_args.cache_dir,
|
| 439 |
+
revision=model_args.model_revision,
|
| 440 |
+
use_auth_token=True if model_args.use_auth_token else None,
|
| 441 |
+
)
|
| 442 |
+
|
| 443 |
+
# We resize the embeddings only when necessary to avoid index errors. If you are creating a model from scratch
|
| 444 |
+
# on a small vocab and want a smaller embedding size, remove this test.
|
| 445 |
+
embedding_size = model.get_input_embeddings().weight.shape[0]
|
| 446 |
+
if len(tokenizer) > embedding_size:
|
| 447 |
+
model.resize_token_embeddings(len(tokenizer))
|
| 448 |
+
|
| 449 |
+
if model.config.decoder_start_token_id is None and isinstance(tokenizer, (MBartTokenizer, MBartTokenizerFast)):
|
| 450 |
+
if isinstance(tokenizer, MBartTokenizer):
|
| 451 |
+
model.config.decoder_start_token_id = tokenizer.lang_code_to_id[data_args.lang]
|
| 452 |
+
else:
|
| 453 |
+
model.config.decoder_start_token_id = tokenizer.convert_tokens_to_ids(data_args.lang)
|
| 454 |
+
|
| 455 |
+
if model.config.decoder_start_token_id is None:
|
| 456 |
+
raise ValueError("Make sure that `config.decoder_start_token_id` is correctly defined")
|
| 457 |
+
|
| 458 |
+
if (
|
| 459 |
+
hasattr(model.config, "max_position_embeddings")
|
| 460 |
+
and model.config.max_position_embeddings < data_args.max_source_length
|
| 461 |
+
):
|
| 462 |
+
if model_args.resize_position_embeddings is None:
|
| 463 |
+
logger.warning(
|
| 464 |
+
"Increasing the model's number of position embedding vectors from"
|
| 465 |
+
f" {model.config.max_position_embeddings} to {data_args.max_source_length}."
|
| 466 |
+
)
|
| 467 |
+
model.resize_position_embeddings(data_args.max_source_length)
|
| 468 |
+
elif model_args.resize_position_embeddings:
|
| 469 |
+
model.resize_position_embeddings(data_args.max_source_length)
|
| 470 |
+
else:
|
| 471 |
+
raise ValueError(
|
| 472 |
+
f"`--max_source_length` is set to {data_args.max_source_length}, but the model only has"
|
| 473 |
+
f" {model.config.max_position_embeddings} position encodings. Consider either reducing"
|
| 474 |
+
f" `--max_source_length` to {model.config.max_position_embeddings} or to automatically resize the"
|
| 475 |
+
" model's position encodings by passing `--resize_position_embeddings`."
|
| 476 |
+
)
|
| 477 |
+
|
| 478 |
+
prefix = data_args.source_prefix if data_args.source_prefix is not None else ""
|
| 479 |
+
|
| 480 |
+
# Preprocessing the datasets.
|
| 481 |
+
# We need to tokenize inputs and targets.
|
| 482 |
+
if training_args.do_train:
|
| 483 |
+
if "train" not in raw_datasets:
|
| 484 |
+
raise ValueError("--do_train requires a train dataset")
|
| 485 |
+
column_names = raw_datasets["train"].column_names
|
| 486 |
+
elif training_args.do_eval:
|
| 487 |
+
if "validation" not in raw_datasets:
|
| 488 |
+
raise ValueError("--do_eval requires a validation dataset")
|
| 489 |
+
column_names = raw_datasets["validation"].column_names
|
| 490 |
+
elif training_args.do_predict:
|
| 491 |
+
if "test" not in raw_datasets:
|
| 492 |
+
raise ValueError("--do_predict requires a test dataset")
|
| 493 |
+
column_names = raw_datasets["test"].column_names
|
| 494 |
+
else:
|
| 495 |
+
logger.info("There is nothing to do. Please pass `do_train`, `do_eval` and/or `do_predict`.")
|
| 496 |
+
return
|
| 497 |
+
|
| 498 |
+
if isinstance(tokenizer, tuple(MULTILINGUAL_TOKENIZERS)):
|
| 499 |
+
assert (
|
| 500 |
+
data_args.lang is not None
|
| 501 |
+
), f"{tokenizer.__class__.__name__} is a multilingual tokenizer which requires --lang argument"
|
| 502 |
+
|
| 503 |
+
tokenizer.src_lang = data_args.lang
|
| 504 |
+
tokenizer.tgt_lang = data_args.lang
|
| 505 |
+
|
| 506 |
+
# For multilingual translation models like mBART-50 and M2M100 we need to force the target language token
|
| 507 |
+
# as the first generated token. We ask the user to explicitly provide this as --forced_bos_token argument.
|
| 508 |
+
forced_bos_token_id = (
|
| 509 |
+
tokenizer.lang_code_to_id[data_args.forced_bos_token] if data_args.forced_bos_token is not None else None
|
| 510 |
+
)
|
| 511 |
+
model.config.forced_bos_token_id = forced_bos_token_id
|
| 512 |
+
|
| 513 |
+
# Get the column names for input/target.
|
| 514 |
+
dataset_columns = summarization_name_mapping.get(data_args.dataset_name, None)
|
| 515 |
+
if data_args.text_column is None:
|
| 516 |
+
text_column = dataset_columns[0] if dataset_columns is not None else column_names[0]
|
| 517 |
+
else:
|
| 518 |
+
text_column = data_args.text_column
|
| 519 |
+
if text_column not in column_names:
|
| 520 |
+
raise ValueError(
|
| 521 |
+
f"--text_column' value '{data_args.text_column}' needs to be one of: {', '.join(column_names)}"
|
| 522 |
+
)
|
| 523 |
+
if data_args.summary_column is None:
|
| 524 |
+
summary_column = dataset_columns[1] if dataset_columns is not None else column_names[1]
|
| 525 |
+
else:
|
| 526 |
+
summary_column = data_args.summary_column
|
| 527 |
+
if summary_column not in column_names:
|
| 528 |
+
raise ValueError(
|
| 529 |
+
f"--summary_column' value '{data_args.summary_column}' needs to be one of: {', '.join(column_names)}"
|
| 530 |
+
)
|
| 531 |
+
|
| 532 |
+
# Temporarily set max_target_length for training.
|
| 533 |
+
max_target_length = data_args.max_target_length
|
| 534 |
+
padding = "max_length" if data_args.pad_to_max_length else False
|
| 535 |
+
|
| 536 |
+
if training_args.label_smoothing_factor > 0 and not hasattr(model, "prepare_decoder_input_ids_from_labels"):
|
| 537 |
+
logger.warning(
|
| 538 |
+
"label_smoothing is enabled but the `prepare_decoder_input_ids_from_labels` method is not defined for"
|
| 539 |
+
f"`{model.__class__.__name__}`. This will lead to loss being calculated twice and will take up more memory"
|
| 540 |
+
)
|
| 541 |
+
|
| 542 |
+
def preprocess_function(examples):
|
| 543 |
+
# remove pairs where at least one record is None
|
| 544 |
+
|
| 545 |
+
inputs, targets = [], []
|
| 546 |
+
for i in range(len(examples[text_column])):
|
| 547 |
+
if examples[text_column][i] and examples[summary_column][i]:
|
| 548 |
+
inputs.append(examples[text_column][i])
|
| 549 |
+
targets.append(examples[summary_column][i])
|
| 550 |
+
|
| 551 |
+
inputs = [prefix + inp for inp in inputs]
|
| 552 |
+
model_inputs = tokenizer(inputs, max_length=data_args.max_source_length, padding=padding, truncation=True)
|
| 553 |
+
|
| 554 |
+
# Tokenize targets with the `text_target` keyword argument
|
| 555 |
+
labels = tokenizer(text_target=targets, max_length=max_target_length, padding=padding, truncation=True)
|
| 556 |
+
|
| 557 |
+
# If we are padding here, replace all tokenizer.pad_token_id in the labels by -100 when we want to ignore
|
| 558 |
+
# padding in the loss.
|
| 559 |
+
if padding == "max_length" and data_args.ignore_pad_token_for_loss:
|
| 560 |
+
labels["input_ids"] = [
|
| 561 |
+
[(l if l != tokenizer.pad_token_id else -100) for l in label] for label in labels["input_ids"]
|
| 562 |
+
]
|
| 563 |
+
|
| 564 |
+
model_inputs["labels"] = labels["input_ids"]
|
| 565 |
+
return model_inputs
|
| 566 |
+
|
| 567 |
+
if training_args.do_train:
|
| 568 |
+
print(type(raw_datasets["train"]))
|
| 569 |
+
train_dataset = raw_datasets["train"].select(train_num)
|
| 570 |
+
if data_args.max_train_samples is not None:
|
| 571 |
+
max_train_samples = min(len(train_dataset), data_args.max_train_samples)
|
| 572 |
+
train_dataset = train_dataset.select(range(max_train_samples))
|
| 573 |
+
with training_args.main_process_first(desc="train dataset map pre-processing"):
|
| 574 |
+
train_dataset = train_dataset.map(
|
| 575 |
+
preprocess_function,
|
| 576 |
+
batched=True,
|
| 577 |
+
num_proc=data_args.preprocessing_num_workers,
|
| 578 |
+
remove_columns=column_names,
|
| 579 |
+
load_from_cache_file=not data_args.overwrite_cache,
|
| 580 |
+
desc="Running tokenizer on train dataset",
|
| 581 |
+
)
|
| 582 |
+
|
| 583 |
+
if training_args.do_eval:
|
| 584 |
+
max_target_length = data_args.val_max_target_length
|
| 585 |
+
eval_dataset = raw_datasets["validation"].select(val_num)
|
| 586 |
+
if data_args.max_eval_samples is not None:
|
| 587 |
+
max_eval_samples = min(len(eval_dataset), data_args.max_eval_samples)
|
| 588 |
+
eval_dataset = eval_dataset.select(range(max_eval_samples))
|
| 589 |
+
with training_args.main_process_first(desc="validation dataset map pre-processing"):
|
| 590 |
+
eval_dataset = eval_dataset.map(
|
| 591 |
+
preprocess_function,
|
| 592 |
+
batched=True,
|
| 593 |
+
num_proc=data_args.preprocessing_num_workers,
|
| 594 |
+
remove_columns=column_names,
|
| 595 |
+
load_from_cache_file=not data_args.overwrite_cache,
|
| 596 |
+
desc="Running tokenizer on validation dataset",
|
| 597 |
+
)
|
| 598 |
+
|
| 599 |
+
if training_args.do_predict:
|
| 600 |
+
max_target_length = data_args.val_max_target_length
|
| 601 |
+
predict_dataset = raw_datasets["test"].select(test_num)
|
| 602 |
+
if data_args.max_predict_samples is not None:
|
| 603 |
+
max_predict_samples = min(len(predict_dataset), data_args.max_predict_samples)
|
| 604 |
+
predict_dataset = predict_dataset.select(range(max_predict_samples))
|
| 605 |
+
with training_args.main_process_first(desc="prediction dataset map pre-processing"):
|
| 606 |
+
predict_dataset = predict_dataset.map(
|
| 607 |
+
preprocess_function,
|
| 608 |
+
batched=True,
|
| 609 |
+
num_proc=data_args.preprocessing_num_workers,
|
| 610 |
+
remove_columns=column_names,
|
| 611 |
+
load_from_cache_file=not data_args.overwrite_cache,
|
| 612 |
+
desc="Running tokenizer on prediction dataset",
|
| 613 |
+
)
|
| 614 |
+
|
| 615 |
+
# Data collator
|
| 616 |
+
label_pad_token_id = -100 if data_args.ignore_pad_token_for_loss else tokenizer.pad_token_id
|
| 617 |
+
data_collator = DataCollatorForSeq2Seq(
|
| 618 |
+
tokenizer,
|
| 619 |
+
model=model,
|
| 620 |
+
label_pad_token_id=label_pad_token_id,
|
| 621 |
+
pad_to_multiple_of=8 if training_args.fp16 else None,
|
| 622 |
+
)
|
| 623 |
+
|
| 624 |
+
# Metric
|
| 625 |
+
metric = evaluate.load("rouge")
|
| 626 |
+
|
| 627 |
+
def postprocess_text(preds, labels):
|
| 628 |
+
preds = [pred.strip() for pred in preds]
|
| 629 |
+
labels = [label.strip() for label in labels]
|
| 630 |
+
|
| 631 |
+
# rougeLSum expects newline after each sentence
|
| 632 |
+
preds = ["\n".join(nltk.sent_tokenize(pred)) for pred in preds]
|
| 633 |
+
labels = ["\n".join(nltk.sent_tokenize(label)) for label in labels]
|
| 634 |
+
|
| 635 |
+
return preds, labels
|
| 636 |
+
|
| 637 |
+
def compute_metrics(eval_preds):
|
| 638 |
+
preds, labels = eval_preds
|
| 639 |
+
if isinstance(preds, tuple):
|
| 640 |
+
preds = preds[0]
|
| 641 |
+
# Replace -100s used for padding as we can't decode them
|
| 642 |
+
preds = np.where(preds != -100, preds, tokenizer.pad_token_id)
|
| 643 |
+
decoded_preds = tokenizer.batch_decode(preds, skip_special_tokens=True)
|
| 644 |
+
labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
|
| 645 |
+
decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)
|
| 646 |
+
|
| 647 |
+
# Some simple post-processing
|
| 648 |
+
decoded_preds, decoded_labels = postprocess_text(decoded_preds, decoded_labels)
|
| 649 |
+
|
| 650 |
+
result = metric.compute(predictions=decoded_preds, references=decoded_labels, use_stemmer=True)
|
| 651 |
+
result = {k: round(v * 100, 4) for k, v in result.items()}
|
| 652 |
+
prediction_lens = [np.count_nonzero(pred != tokenizer.pad_token_id) for pred in preds]
|
| 653 |
+
result["gen_len"] = np.mean(prediction_lens)
|
| 654 |
+
return result
|
| 655 |
+
|
| 656 |
+
# Override the decoding parameters of Seq2SeqTrainer
|
| 657 |
+
training_args.generation_max_length = (
|
| 658 |
+
training_args.generation_max_length
|
| 659 |
+
if training_args.generation_max_length is not None
|
| 660 |
+
else data_args.val_max_target_length
|
| 661 |
+
)
|
| 662 |
+
training_args.generation_num_beams = (
|
| 663 |
+
data_args.num_beams if data_args.num_beams is not None else training_args.generation_num_beams
|
| 664 |
+
)
|
| 665 |
+
|
| 666 |
+
# Initialize our Trainer
|
| 667 |
+
trainer = Seq2SeqTrainer(
|
| 668 |
+
model=model,
|
| 669 |
+
args=training_args,
|
| 670 |
+
train_dataset=train_dataset if training_args.do_train else None,
|
| 671 |
+
eval_dataset=eval_dataset if training_args.do_eval else None,
|
| 672 |
+
tokenizer=tokenizer,
|
| 673 |
+
data_collator=data_collator,
|
| 674 |
+
compute_metrics=compute_metrics if training_args.predict_with_generate else None,
|
| 675 |
+
)
|
| 676 |
+
|
| 677 |
+
# Training
|
| 678 |
+
if training_args.do_train:
|
| 679 |
+
checkpoint = None
|
| 680 |
+
if training_args.resume_from_checkpoint is not None:
|
| 681 |
+
checkpoint = training_args.resume_from_checkpoint
|
| 682 |
+
elif last_checkpoint is not None:
|
| 683 |
+
checkpoint = last_checkpoint
|
| 684 |
+
train_result = trainer.train(resume_from_checkpoint=checkpoint)
|
| 685 |
+
trainer.save_model() # Saves the tokenizer too for easy upload
|
| 686 |
+
|
| 687 |
+
metrics = train_result.metrics
|
| 688 |
+
max_train_samples = (
|
| 689 |
+
data_args.max_train_samples if data_args.max_train_samples is not None else len(train_dataset)
|
| 690 |
+
)
|
| 691 |
+
metrics["train_samples"] = min(max_train_samples, len(train_dataset))
|
| 692 |
+
|
| 693 |
+
trainer.log_metrics("train", metrics)
|
| 694 |
+
trainer.save_metrics("train", metrics)
|
| 695 |
+
trainer.save_state()
|
| 696 |
+
|
| 697 |
+
# Evaluation
|
| 698 |
+
results = {}
|
| 699 |
+
if training_args.do_eval:
|
| 700 |
+
logger.info("*** Evaluate ***")
|
| 701 |
+
metrics = trainer.evaluate(metric_key_prefix="eval")
|
| 702 |
+
max_eval_samples = data_args.max_eval_samples if data_args.max_eval_samples is not None else len(eval_dataset)
|
| 703 |
+
metrics["eval_samples"] = min(max_eval_samples, len(eval_dataset))
|
| 704 |
+
|
| 705 |
+
trainer.log_metrics("eval", metrics)
|
| 706 |
+
trainer.save_metrics("eval", metrics)
|
| 707 |
+
|
| 708 |
+
if training_args.do_predict:
|
| 709 |
+
logger.info("*** Predict ***")
|
| 710 |
+
|
| 711 |
+
predict_results = trainer.predict(predict_dataset, metric_key_prefix="predict")
|
| 712 |
+
metrics = predict_results.metrics
|
| 713 |
+
max_predict_samples = (
|
| 714 |
+
data_args.max_predict_samples if data_args.max_predict_samples is not None else len(predict_dataset)
|
| 715 |
+
)
|
| 716 |
+
metrics["predict_samples"] = min(max_predict_samples, len(predict_dataset))
|
| 717 |
+
|
| 718 |
+
trainer.log_metrics("predict", metrics)
|
| 719 |
+
trainer.save_metrics("predict", metrics)
|
| 720 |
+
|
| 721 |
+
if trainer.is_world_process_zero():
|
| 722 |
+
if training_args.predict_with_generate:
|
| 723 |
+
predictions = predict_results.predictions
|
| 724 |
+
predictions = np.where(predictions != -100, predictions, tokenizer.pad_token_id)
|
| 725 |
+
predictions = tokenizer.batch_decode(
|
| 726 |
+
predictions, skip_special_tokens=True, clean_up_tokenization_spaces=True
|
| 727 |
+
)
|
| 728 |
+
predictions = [pred.strip() for pred in predictions]
|
| 729 |
+
output_prediction_file = os.path.join(training_args.output_dir, "generated_predictions.txt")
|
| 730 |
+
with open(output_prediction_file, "w") as writer:
|
| 731 |
+
writer.write("\n".join(predictions))
|
| 732 |
+
|
| 733 |
+
kwargs = {"finetuned_from": model_args.model_name_or_path, "tasks": "summarization"}
|
| 734 |
+
if data_args.dataset_name is not None:
|
| 735 |
+
kwargs["dataset_tags"] = data_args.dataset_name
|
| 736 |
+
if data_args.dataset_config_name is not None:
|
| 737 |
+
kwargs["dataset_args"] = data_args.dataset_config_name
|
| 738 |
+
kwargs["dataset"] = f"{data_args.dataset_name} {data_args.dataset_config_name}"
|
| 739 |
+
else:
|
| 740 |
+
kwargs["dataset"] = data_args.dataset_name
|
| 741 |
+
|
| 742 |
+
if data_args.lang is not None:
|
| 743 |
+
kwargs["language"] = data_args.lang
|
| 744 |
+
|
| 745 |
+
if training_args.push_to_hub:
|
| 746 |
+
trainer.push_to_hub(**kwargs)
|
| 747 |
+
else:
|
| 748 |
+
trainer.create_model_card(**kwargs)
|
| 749 |
+
|
| 750 |
+
return results
|
| 751 |
+
|
| 752 |
+
|
| 753 |
+
def _mp_fn(index):
|
| 754 |
+
# For xla_spawn (TPUs)
|
| 755 |
+
main()
|
| 756 |
+
|
| 757 |
+
|
| 758 |
+
if __name__ == "__main__":
|
| 759 |
+
main()
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": true,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"cls_token": {
|
| 10 |
+
"content": "<s>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": true,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"eos_token": {
|
| 17 |
+
"content": "</s>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": true,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"mask_token": {
|
| 24 |
+
"content": "<mask>",
|
| 25 |
+
"lstrip": true,
|
| 26 |
+
"normalized": true,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
},
|
| 30 |
+
"pad_token": {
|
| 31 |
+
"content": "<pad>",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": true,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false
|
| 36 |
+
},
|
| 37 |
+
"sep_token": {
|
| 38 |
+
"content": "</s>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": true,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false
|
| 43 |
+
},
|
| 44 |
+
"unk_token": {
|
| 45 |
+
"content": "<unk>",
|
| 46 |
+
"lstrip": false,
|
| 47 |
+
"normalized": true,
|
| 48 |
+
"rstrip": false,
|
| 49 |
+
"single_word": false
|
| 50 |
+
}
|
| 51 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"bos_token": {
|
| 4 |
+
"__type": "AddedToken",
|
| 5 |
+
"content": "<s>",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": true,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false
|
| 10 |
+
},
|
| 11 |
+
"clean_up_tokenization_spaces": true,
|
| 12 |
+
"cls_token": {
|
| 13 |
+
"__type": "AddedToken",
|
| 14 |
+
"content": "<s>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": true,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false
|
| 19 |
+
},
|
| 20 |
+
"eos_token": {
|
| 21 |
+
"__type": "AddedToken",
|
| 22 |
+
"content": "</s>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": true,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": false
|
| 27 |
+
},
|
| 28 |
+
"errors": "replace",
|
| 29 |
+
"mask_token": {
|
| 30 |
+
"__type": "AddedToken",
|
| 31 |
+
"content": "<mask>",
|
| 32 |
+
"lstrip": true,
|
| 33 |
+
"normalized": true,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false
|
| 36 |
+
},
|
| 37 |
+
"model_max_length": 1024,
|
| 38 |
+
"pad_token": {
|
| 39 |
+
"__type": "AddedToken",
|
| 40 |
+
"content": "<pad>",
|
| 41 |
+
"lstrip": false,
|
| 42 |
+
"normalized": true,
|
| 43 |
+
"rstrip": false,
|
| 44 |
+
"single_word": false
|
| 45 |
+
},
|
| 46 |
+
"sep_token": {
|
| 47 |
+
"__type": "AddedToken",
|
| 48 |
+
"content": "</s>",
|
| 49 |
+
"lstrip": false,
|
| 50 |
+
"normalized": true,
|
| 51 |
+
"rstrip": false,
|
| 52 |
+
"single_word": false
|
| 53 |
+
},
|
| 54 |
+
"tokenizer_class": "BartTokenizer",
|
| 55 |
+
"trim_offsets": true,
|
| 56 |
+
"unk_token": {
|
| 57 |
+
"__type": "AddedToken",
|
| 58 |
+
"content": "<unk>",
|
| 59 |
+
"lstrip": false,
|
| 60 |
+
"normalized": true,
|
| 61 |
+
"rstrip": false,
|
| 62 |
+
"single_word": false
|
| 63 |
+
}
|
| 64 |
+
}
|
train_results.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"epoch": 3.0,
|
| 3 |
+
"train_loss": 4.326354817708333,
|
| 4 |
+
"train_runtime": 8399.8868,
|
| 5 |
+
"train_samples": 500,
|
| 6 |
+
"train_samples_per_second": 0.179,
|
| 7 |
+
"train_steps_per_second": 0.045
|
| 8 |
+
}
|
trainer_state.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_metric": null,
|
| 3 |
+
"best_model_checkpoint": null,
|
| 4 |
+
"epoch": 3.0,
|
| 5 |
+
"global_step": 375,
|
| 6 |
+
"is_hyper_param_search": false,
|
| 7 |
+
"is_local_process_zero": true,
|
| 8 |
+
"is_world_process_zero": true,
|
| 9 |
+
"log_history": [
|
| 10 |
+
{
|
| 11 |
+
"epoch": 3.0,
|
| 12 |
+
"step": 375,
|
| 13 |
+
"total_flos": 1547877482496000.0,
|
| 14 |
+
"train_loss": 4.326354817708333,
|
| 15 |
+
"train_runtime": 8399.8868,
|
| 16 |
+
"train_samples_per_second": 0.179,
|
| 17 |
+
"train_steps_per_second": 0.045
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"max_steps": 375,
|
| 21 |
+
"num_train_epochs": 3,
|
| 22 |
+
"total_flos": 1547877482496000.0,
|
| 23 |
+
"trial_name": null,
|
| 24 |
+
"trial_params": null
|
| 25 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b0413397f351779dc3eb1a10fae5091f14a4dc475b25cb11fad75b557e43c1f7
|
| 3 |
+
size 3707
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|