-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsmall_experiments.py
307 lines (282 loc) · 13.2 KB
/
small_experiments.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#%%
from torch import dropout
from notebook import *
# Prototype - for listing the valid keyword args (given with default values)
# model_type, epochs = "t5", 30
# wandb_run_name=f"{now()}_{epochs}ep_{model_type}_"
# full_experiment(model_type=model_type, # e.g. "t5", "bart", "iarfmoose/t5-base-question-generator"
# train_dataset="joint_qasrl",
# do_eval_on="validation", # or "test" # whether to do the final evaluation ("do eval") on validation set or on test set
# qanom_joint_factor=1, # how many times to duplicate qanom training set in joint training
# train_epochs=epochs,
# batch_size=12,
# gradient_accumulation_steps=1,
# learning_rate=.00005,
# fp16=True,
# source_prefix="Generate QAs for <predicate_type> QASRL: ",
# preprocess_input_func="input_predicate_marker",
# preprocess_output_func="all_by_answer_ordering", # "permutate_sample_fixed", "permutate_sample_num_of_qas", "permutate_all", "all_shuffled", "all_random_order", "all_by_answer_ordering", "all_by_role_ordering"
# append_verb_form=True,
# predicate_marker_type="generic", # or "pred_type"
# use_bilateral_predicate_marker=False,
# load_best_model_at_end=True,
# metric_for_best_model="rouge1", # or "eval_loss" / "rougeL"
# learn_predicate_type=None, # or "pre" or "post"
# limit_train_data=1.0,
# limit_eval_data=1.0,
# logging_steps=500,
# eval_steps=500,
# save_steps=500,
# overwrite_output_dir=True,
# wandb_run_name=wandb_run_name,
# dir_switch="qasrl-no-order",
# description="",
# )
## Actual Experiments:
# train best single-domain models for cross-domain experiments
best_hparams = {
"TQA": dict(
gradient_accumulation_steps=14,
learning_rate=0.005,
dropout_rate=0.15,
),
# "wikinews": dict(
# gradient_accumulation_steps=8,
# learning_rate=0.001,
# dropout_rate=0.10,
# ),
# "wikipedia": dict(
# gradient_accumulation_steps=14,
# learning_rate=0.005,
# dropout_rate=0.10,
# )
}
for domain, hparams in best_hparams.items():
wandb_run_name=f"{now()} qasrl (large) trained on {domain} (eval on wikipedia test)"
full_experiment(model_type="t5",
train_dataset="qasrl",
training_domains=domain,
validation_domains="wikipedia",
test_domains="wikipedia",
do_eval_on="test",
train_epochs=20,
batch_size=12,
seed=44,
source_prefix="parse: ",
preprocess_input_func="input_predicate_marker",
preprocess_output_func="all_by_answer_ordering",
use_bilateral_predicate_marker=True,
overwrite_output_dir=True,
num_beams=5,
logging_steps=500,
eval_steps=500,
save_steps=500,
wandb_run_name=wandb_run_name,
# max_train_samples=15079,
dir_switch=f"qasrl/cross_domain/best/{domain}",
description=f"optimal large qasrl {domain} model, based on grid sweep",
**hparams
)
# for output_linearization in ["permutate_sample_fixed", "permutate_sample_num_of_qas",
# "all_shuffled", "all_by_answer_ordering",
# "permutate_all"]:
# wandb_run_name=f"{now()}_5ep_joint_{output_linearization}"
# full_experiment(model_type="t5",
# train_dataset="joint_qanom",
# train_epochs=5,
# batch_size=12,
# gradient_accumulation_steps=14,
# learning_rate=0.001,
# dropout_rate=0.1,
# seed=44,
# source_prefix="parse: ",
# preprocess_input_func="input_predicate_marker",
# preprocess_output_func=output_linearization, # "permutate_sample_fixed", "permutate_sample_num_of_qas", "permutate_all", "all_shuffled", "all_random_order", "all_by_answer_ordering"
# use_bilateral_predicate_marker=True,
# overwrite_output_dir=True,
# num_beams=3,
# logging_steps=500,
# eval_steps=500,
# save_steps=500,
# wandb_run_name=wandb_run_name,
# qanom_joint_factor=14,
# dir_switch=f"linearization/{output_linearization}",
# description=f"best joint with output_linearization={output_linearization}, with best hyperparamters for 'by_answer_order' (5ep, accum=14, lr=.001) ",
# )
# for output_linearization in ["permutate_sample_num_of_qas", "permutate_sample_fixed",
# "all_by_answer_ordering", "all_shuffled", "permutate_all"]: # "all_shuffled", "all_by_answer_ordering",
# for output_linearization in ["all_by_role_ordering"]:
# output_linearization = "all_by_role_ordering"
# wandb_run_name=f"{now()} joint, {output_linearization} - on qanom test"
# full_experiment(model_type="t5",
# train_dataset="joint_qanom",
# train_epochs=20,
# batch_size=12,
# gradient_accumulation_steps=14,
# learning_rate=0.001,
# dropout_rate=0.1,
# seed=44,
# do_eval_on="test",
# source_prefix="parse: ",
# preprocess_input_func="input_predicate_marker",
# preprocess_output_func=output_linearization, # "permutate_sample_fixed", "permutate_sample_num_of_qas", "permutate_all", "all_shuffled", "all_random_order", "all_by_answer_ordering"
# use_bilateral_predicate_marker=True,
# overwrite_output_dir=True,
# num_beams=5,
# logging_steps=500,
# eval_steps=500,
# save_steps=500,
# wandb_run_name=wandb_run_name,
# # dir_switch=f"debug/{output_linearization}",
# dir_switch=f"lin-{output_linearization}",
# # limit_train_data=0.07,
# qanom_joint_factor=14,
# description=f"joint with output_linearization={output_linearization}",
# )
# model_dir=f"/home/nlp/kleinay/tmp/t5-tst-summarization/joint_qanom/lin-{output_linearization}"
# load_and_evaluate(model_dir,
# test_dataset = "qanom",
# output_dir=None,
# wandb_run_name=f"evaluate joint {output_linearization} on qanom test",
# # wandb_run_name=f"debug evaluate",
# do_eval_on_dev=False,
# evaluation_protocol="qanom",
# constrain_generation=False,
# # limit_eval_data=0.05,
# batch_size=12,
# num_beams=5,
# )
# load_and_evaluate(model_dir,
# test_dataset = "qasrl",
# output_dir=None,
# wandb_run_name=f"evaluate joint {output_linearization} on qasrl test",
# # wandb_run_name=f"debug evaluate",
# do_eval_on_dev=False,
# evaluation_protocol="qanom",
# constrain_generation=False,
# # limit_eval_data=0.05,
# batch_size=12,
# num_beams=5,
# )
# optimal qasrl-baseline based on sweep:
# wandb_run_name=f"{now()}_t5_baseline_qasrl_small"
# full_experiment(model_type="t5",
# train_dataset="qasrl",
# train_epochs=20,
# batch_size=12,
# gradient_accumulation_steps=8,
# learning_rate=0.005, # ACTUALLY 0.0062
# dropout_rate=0.1,
# seed=44,
# source_prefix="parse: ",
# preprocess_input_func="input_predicate_marker",
# use_bilateral_predicate_marker=True,
# overwrite_output_dir=True,
# num_beams=5,
# logging_steps=500,
# eval_steps=500,
# save_steps=500,
# wandb_run_name=wandb_run_name,
# dir_switch="small_train",
# limit_train_data=0.07,
# description="qasrl baseline trained on 0.07 of the data, approx. as qanom data",
# )
# #%% best joint model so far
# for learn_predicate_type in [None, "pre", "post"]:
# model_type = "t5-base"
# epochs=20
# wandb_run_name=f"{now()}_{epochs}ep_{model_type}_joint-qanom answer-order dev"
# full_experiment(model_type=model_type,
# train_dataset="joint_qanom",
# train_epochs=epochs,
# batch_size=4,
# gradient_checkpointing=True,
# # learn_predicate_type=learn_predicate_type,
# gradient_accumulation_steps=42,
# learning_rate=0.001,
# dropout_rate=0.1,
# seed=44,
# append_verb_form=True,
# source_prefix="parse: ",
# preprocess_input_func="input_predicate_marker",
# use_bilateral_predicate_marker=True,
# overwrite_output_dir=True,
# num_beams=3,
# logging_steps=500,
# eval_steps=500,
# save_steps=500,
# wandb_run_name=wandb_run_name,
# preprocess_output_func="all_by_answer_ordering", # "permutate_sample_fixed", "permutate_sample_num_of_qas", "permutate_all", "all_shuffled", "all_random_order", "all_by_answer_ordering"
# do_eval_on="validation",
# # dir_switch="j",
# qanom_joint_factor=14,
# description="""t5-base using best joint of t5-small hparams, answer-ordering""",
# )
"""
*** Saved Configs ***
best QASRL baseline configuration (sweep baseline finer1):
wandb_run_name=f"{now()}_t5_baseline_qasrl"
full_experiment(model_type="t5",
train_dataset="qasrl",
train_epochs=5,
batch_size=12,
gradient_accumulation_steps=8,
learning_rate=0.005, # ACTUALLY 0.0062
dropout_rate=0.1,
seed=44,
source_prefix="parse: ",
preprocess_input_func="input_predicate_marker",
use_bilateral_predicate_marker=True,
overwrite_output_dir=True,
num_beams=5,
logging_steps=500,
eval_steps=500,
save_steps=500,
wandb_run_name=wandb_run_name,
dir_switch="qasrl/baseline",
description="optimal qasrl baseline config based on finer sweep1",
)
best qanom baseline configuration (sweep baseline finer1):
full_experiment(model_type="t5",
train_dataset="qanom",
train_epochs=30,
batch_size=12,
gradient_accumulation_steps=8,
learning_rate=0.001,
dropout_rate=0.15,
seed=44,
source_prefix="parse: ",
preprocess_input_func="input_predicate_marker",
use_bilateral_predicate_marker=True,
overwrite_output_dir=True,
num_beams=3,
logging_steps=500,
eval_steps=500,
save_steps=500,
wandb_run_name=wandb_run_name,
dir_switch="baseline",
description="optimal qanom baseline config from finer sweep1",
)
best joint configuration (sweep joint finer1):
full_experiment(model_type="t5",
train_dataset="joint_qanom",
train_epochs=20,
batch_size=12,
gradient_accumulation_steps=14,
learning_rate=0.001,
dropout_rate=0.1,
seed=44,
source_prefix="parse: ",
preprocess_input_func="input_predicate_marker",
use_bilateral_predicate_marker=True,
overwrite_output_dir=True,
num_beams=5,
logging_steps=500,
eval_steps=500,
save_steps=500,
wandb_run_name=wandb_run_name,
dir_switch="joint_optimal",
qanom_joint_factor=14,
description="optimal joint config from finer sweep1, mainly for qanom",
)
"""