-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrun_classifier_roberta_exe.py
72 lines (67 loc) · 2.57 KB
/
run_classifier_roberta_exe.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
import sys
import os
task_name = sys.argv[1]
ROBERTA_DIR = sys.argv[2]
per_gpu_train_batch_size = sys.argv[3]
gradient_accumulation_steps = sys.argv[4]
# set up some hypers
if task_name == 'dream':
learning_rate = 2e-5
num_train_epochs = 8.
max_grad_norm = 1.
elif task_name == 'dream,race':
learning_rate = 2e-5
num_train_epochs = 10
max_grad_norm = 1.
elif 'mctest' in task_name or 'mcscript' in task_name:
learning_rate = 5e-6
num_train_epochs = 10.
max_grad_norm = 0.
elif 'toefl' in task_name:
learning_rate = 1e-5
num_train_epochs = 10
max_grad_norm = 0.
elif 'race' in task_name:
learning_rate = 2e-5
num_train_epochs = 5
max_grad_norm = 0.
elif 'nli' in task_name:
learning_rate = 2e-5
num_train_epochs = 4.
max_grad_norm = 0.
else:
raise NotImplementedError
# set up data directories
data_dir = []
for task_name_ in task_name.split(','):
if task_name_ == 'race':
data_dir.append('data/RACE')
elif task_name_ == 'dream':
data_dir.append('data/dream')
elif task_name_ in ['toefl', 'mctest', 'mcscript']:
data_dir.append('data/{}'.format(task_name_.upper()))
elif task_name_ in ['mctest160', 'mctest500']:
data_dir.append('data/{}'.format(task_name_.upper()[:6]))
else:
data_dir.append('data/{}'.format(task_name_.upper()))
data_dir = ','.join(data_dir)
command = 'python run_classifier_roberta.py --model_type roberta ' \
'--task_name {task_name} ' \
'--do_train --do_eval ' \
'--data_dir {data_dir} ' \
'--model_name_or_path {ROBERTA_DIR} ' \
'--per_gpu_train_batch_size {per_gpu_train_batch_size} ' \
'--adam_epsilon 1e-6 --warmup_proportion 0.1 ' \
'--learning_rate {learning_rate} --num_train_epochs {num_train_epochs} ' \
'--seed 1 --max_grad_norm {max_grad_norm} ' \
'--output_dir tmp/{task_name}_{ROBERTA_DIR} ' \
'--do_not_summary ' \
'--gradient_accumulation_steps {gradient_accumulation_steps} ' \
'--same_linear_layer 1'.format(ROBERTA_DIR=ROBERTA_DIR,
data_dir=data_dir, task_name=task_name,
per_gpu_train_batch_size=per_gpu_train_batch_size,
learning_rate=learning_rate,
num_train_epochs=num_train_epochs,
max_grad_norm=max_grad_norm,
gradient_accumulation_steps=gradient_accumulation_steps)
os.system(command)