forked from taishan1994/pytorch_bert_entity_linking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
el_config.py
74 lines (56 loc) · 2.84 KB
/
el_config.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
import argparse
class Args:
@staticmethod
def parse():
parser = argparse.ArgumentParser()
return parser
@staticmethod
def initialize(parser):
# args for path
parser.add_argument('--output_dir', default='./checkpoints/',
help='the output dir for model checkpoints')
parser.add_argument('--bert_dir', default='../model_hub/chinese-bert-wwm-ext/',
help='bert dir for uer')
parser.add_argument('--data_dir', default='./data/ccks2019/',
help='data dir for uer')
parser.add_argument('--log_dir', default='./logs/',
help='log dir for uer')
# other args
parser.add_argument('--num_tags', default=2, type=int,
help='number of tags')
parser.add_argument('--seed', type=int, default=123, help='random seed')
parser.add_argument('--gpu_ids', type=str, default='0',
help='gpu ids to use, -1 for cpu, "0,1" for multi gpu')
parser.add_argument('--max_seq_len', default=256, type=int)
parser.add_argument('--eval_batch_size', default=12, type=int)
parser.add_argument('--swa_start', default=3, type=int,
help='the epoch when swa start')
# train args
parser.add_argument('--train_epochs', default=15, type=int,
help='Max training epoch')
parser.add_argument('--dropout_prob', default=0.1, type=float,
help='drop out probability')
# 2e-5
parser.add_argument('--lr', default=2e-5, type=float,
help='learning rate for the bert module')
# 2e-3
parser.add_argument('--other_lr', default=2e-4, type=float,
help='learning rate for the module except bert')
# 0.5
parser.add_argument('--max_grad_norm', default=1, type=float,
help='max grad clip')
parser.add_argument('--warmup_proporation', default=0.1, type=float)
parser.add_argument('--weight_decay', default=0.01, type=float)
parser.add_argument('--adam_epsilon', default=1e-8, type=float)
parser.add_argument('--train_batch_size', default=32, type=int)
parser.add_argument('--ip', type=str,
help='service_ip',
default='0.0.0.0')
parser.add_argument('--port', type=str,
help='service_port',
default=1080)
return parser
def get_parser(self):
parser = self.parse()
parser = self.initialize(parser)
return parser.parse_args()