-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patharguments.py
154 lines (144 loc) · 5.39 KB
/
arguments.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
from dataclasses import dataclass, field
from typing import Optional, Tuple
from transformers import TrainingArguments
from transformers.trainer_utils import IntervalStrategy
@dataclass
class SettingsArguments:
pretrained_model_name_or_path: str = field(default="klue/roberta-large")
trained_model_path: str = field(default="/opt/ml/mrc-level2-nlp-08/output/")
trainset_path: str = field(default="../data/new_train_dataset")
testset_path: str = field(default="../data/test_dataset")
load_from_cache_file: bool = field(default=False)
num_proc: Optional[int] = field(default=None)
@dataclass
class Arguments(TrainingArguments):
per_device_train_batch_size: int = field(
default=16,
metadata={"help": "Batch size per GPU/TPU core/CPU for training."},
)
per_device_eval_batch_size: int = field(
default=16,
metadata={"help": "Batch size per GPU/TPU core/CPU for evaluation."},
)
gradient_accumulation_steps: int = field(
default=8,
metadata={
"help": "Number of updates steps to accumulate before performing a backward/update pass."
},
)
learning_rate: float = field(
default=1.809598615643362e-05,
metadata={"help": "The initial learning rate for AdamW."},
)
weight_decay: float = field(
default=0.19132033828553255,
metadata={"help": "Weight decay for AdamW if we apply some."},
)
num_train_epochs: float = field(
default=1.0, metadata={"help": "Total number of training epochs to perform."}
)
output_dir: str = field(
default="output",
metadata={
"help": "The output directory where the model predictions and checkpoints will be written."
},
)
overwrite_output_dir: bool = field(
default=True,
metadata={
"help": (
"Overwrite the content of the output directory."
"Use this to continue training if output_dir points to a checkpoint directory."
)
},
)
seed: int = field(
default=107,
metadata={"help": "Random seed that will be set at the beginning of training."},
)
do_train: bool = field(default=True, metadata={"help": "Whether to run training."})
do_eval: bool = field(
default=True, metadata={"help": "Whether to run eval on the dev set."}
)
do_predict: bool = field(
default=False, metadata={"help": "Whether to run predictions on the test set."}
)
evaluation_strategy: IntervalStrategy = field(
default="epoch",
metadata={"help": "The evaluation strategy to use."},
)
logging_strategy: IntervalStrategy = field(
default="epoch",
metadata={"help": "The logging strategy to use."},
)
save_strategy: IntervalStrategy = field(
default="epoch",
metadata={"help": "The checkpoint save strategy to use."},
)
save_total_limit: Optional[int] = field(
default=2,
metadata={
"help": (
"Limit the total amount of checkpoints."
"Deletes the older checkpoints in the output_dir. Unlimited checkpoints if 'None'"
)
},
)
fp16: bool = field(
default=True,
metadata={"help": "Whether to use 16-bit (mixed) precision instead of 32-bit"},
)
pad_to_multiple_of: int = field(
default=8, metadata={"help": "Pad to multiple of set number"}
)
label_names: Optional[Tuple[str]] = field(
default=("start_positions", "end_positions"),
metadata={
"help": "The list of keys in your dictionary of inputs that correspond to the labels."
},
)
load_best_model_at_end: Optional[bool] = field(
default=True,
metadata={
"help": "Whether or not to load the best model found during training at the end of training."
},
)
metric_for_best_model: Optional[str] = field(
default="f1",
metadata={"help": "The metric to use to compare two different models."},
)
max_length: Optional[int] = field(default=384)
stride: int = field(
default=128,
metadata={"help": "The stride to use when handling overflow."},
)
max_answer_length: int = field(
default=30,
metadata={
"help": "The maximum length of an answer tokens that can be generated."
"This is needed because the start and end predictions are not conditioned on one another."
},
)
resume_from_checkpoint: Optional[str] = field(
default=None,
metadata={
"help": "The path to a folder with a valid checkpoint for your model."
},
)
num_max_prediction: int = field(default=20)
eval_retrieval: bool = field(
default=True,
metadata={"help": "Whether to run passage retrieval using sparse embedding."},
)
top_k_retrieval: int = field(
default=3,
metadata={
"help": "Define how many top-k passages to retrieve based on similarity."
},
)
use_faiss: bool = field(
default=False, metadata={"help": "Whether to build with faiss"}
)
num_clusters: int = field(
default=5, metadata={"help": "Define how many clusters to use for faiss."}
)