-
Notifications
You must be signed in to change notification settings - Fork 0
/
arguments.py
186 lines (172 loc) · 6.34 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
from dataclasses import dataclass, field
from typing import Optional, List, Union
from transformers import Seq2SeqTrainingArguments
from transformers.trainer import OptimizerNames
@dataclass
class ModelArguments:
model_name_or_path: str = field(
default="t5-base",
metadata={
"help": "Path to pretrained model or model identifier from huggingface.co/models"}
)
config_name: Optional[str] = field(
default=None, metadata={
"help": "Pretrained config name or path if not the same as model_name"}
)
tokenizer_name: Optional[str] = field(
default=None, metadata={
"help": "Pretrained tokenizer name or path if not the same as model_name"}
)
cache_dir: Optional[str] = field(
default=None, metadata={
"help": "Where do you want to store the pretrained models downloaded from s3"}
)
decay_rate: Optional[float] = field(
default=0.6, metadata={"help": "Decay learning rate"}
)
low_cpu_mem_usage: Optional[bool] = field(
default=False, metadata={"help": "low cpu mem usage when load model"}
)
@dataclass
class DataArguments:
original_input_dir: str = field()
predict_only: bool = field(default=False)
data_dir: Optional[str] = field(
default=None, metadata={"help": "Path to data directory"}
)
max_train_len: Optional[int] = field(
default=1536,
metadata={
"help": "maximum train source input length"
},
)
max_train_len_out: Optional[int] = field(
default=2048,
metadata={
"help": "maximum train target decoder length"
},
)
max_eval_len: Optional[int] = field(
default=1536,
metadata={
"help": "maximum dev/test source input length"
},
)
max_eval_len_out: Optional[int] = field(
default=2048,
metadata={
"help": "maximum dev/test target decode length"
},
)
data_cache_dir: Optional[str] = field(
default=None, metadata={
"help": "Where do you want to store the data downloaded from huggingface"}
)
beam_sz: Optional[int] = field(
default=4, metadata={
"help": "num beams"
}
)
oracle_mentions_dir: Optional[str] = field(
default=None, metadata={
"help": "oracle mentions directory"
}
)
language: Optional[str] = field(
default='english', metadata={
"help": "coreference language"
}
)
joint_data_dirs: Optional[str] = field(
default=None, metadata={"help": "datasets dirs for joint training"}
)
joint_max_train_lens: Optional[str] = field(
default=None, metadata={"help": "max train len for each dataset for "
"joint training"}
)
joint_max_eval_lens: Optional[str] = field(
default=None, metadata={"help": "max eval len for each dataset for "
"joint training"}
)
joint_num_samples: Optional[int] = field(
default=2000, metadata={"help": "num samples to subsample for joint "
"training"}
)
@dataclass
class CorefTrainingArguments(Seq2SeqTrainingArguments):
do_train: bool = field(default=True,
metadata={"help": "Whether to run training."})
save_dir: Optional[str] = field(
default=None, metadata={"help": "Path to save predicts directory"}
)
save_predicts: Optional[bool] = field(
default=True, metadata={"help": "whether to save predictions"}
)
mark_sentence: Optional[bool] = field(
default=False, metadata={"help": "mark sentence end for short target?"}
)
align_mode: Optional[str] = field(
default='l', metadata={"help": "alignment mode: highroad (h) or "
"lowroad (l) "}
)
optim: Union[OptimizerNames, str] = field(
default="adamw_apex_fused",
metadata={"help": "The optimizer to use."},
)
parallelize_model: Optional[bool] = field(
default=False, metadata={"help": "whether to enable naive model "
"parallel"}
)
manual_empty_cache: Optional[bool] = field(
default=False, metadata={"help": "whether to empty cuda cache manually"}
)
is_stage3: Optional[bool] = field(
default=False, metadata={"help": "use deepspeed stage3 for inference "
"if is stage3"}
)
val_after_train: Optional[bool] = field(
default=False, metadata={"help": "save the checkpoints then do "
"validation after training"}
)
allow_singletons: Optional[bool] = field(
default=False, metadata={
"help": "whether to allow singletons"
}
)
seq2seq_type: Optional[str] = field(
default='action', metadata={
"help": "seq2seq type: action, short_seq, full_seq, tagging, "
"input_feed, action_non_int"
}
)
action_type: Optional[str] = field(
default='integer', metadata={
"help": "target action type: integer, non_integer"
}
)
do_oracle: Optional[bool] = field(
default=False, metadata={
"help": "do oracle experiments or not. Provide (gold) mentions "
"and ask the model to predict coreference predictions"
}
)
add_mention_end: Optional[bool] = field(
default=False, metadata={
"help": "add mention end token when using non-integer action format"
}
)
joint_data_names: Optional[str] = field(
default=None, metadata={"help": "datasets names for joint training"}
)
joint_min_num_mentions: Optional[str] = field(
default=None, metadata={"help": "threshold for num mentions per epoch "
"in joint training for each dataset"}
)
min_num_mentions: Optional[int] = field(
default=2, metadata={"help": "minimum number of mentions per cluster,"
"ontonotes is 2 other datasets is 1 "
"(allow singletons)"}
)
joint_train: Optional[bool] = field(
default=False, metadata={"help": "whether to use joint training"}
)