-
Notifications
You must be signed in to change notification settings - Fork 1
/
param.py
85 lines (61 loc) · 2.9 KB
/
param.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
import argparse
import random
from ast import literal_eval
import numpy as np
import torch
def parse_args():
parser = argparse.ArgumentParser()
# Data Splits
parser.add_argument('--test_only', action='store_true')
# Quick experiments
parser.add_argument('--train_topk', type=int, default=-1)
parser.add_argument('--valid_topk', type=int, default=-1)
# Training Hyper-parameters
parser.add_argument('--batch_size', type=int, default=10)
parser.add_argument('--valid_batch_size', type=int, default=None)
parser.add_argument('--lr', type=float, default=1e-5)
parser.add_argument('--epochs', type=int, default=10)
parser.add_argument('--patient', type=int, default=4)
parser.add_argument('--dropout', type=float, default=0.1)
parser.add_argument('--seed', type=int, default=42, help='random seed')
parser.add_argument('--neg_num', default=5, type=int,
help='number of context entities used for negatives')
parser.add_argument('--wandb', action='store_true')
# Debugging
parser.add_argument('--output', type=str, default='boxbart_checkpoint')
# Model Loading
parser.add_argument('--load', type=str, default=None,
help='Load the model (usually the fine-tuned model).')
parser.add_argument('--load_cons', type=str, default=None,
help='Load the construction model (usually the fine-tuned model).')
# Optimization
parser.add_argument('--min_lr', type=float, default=1e-6)
parser.add_argument('--lr_mul', type=int, default=1)
parser.add_argument('--lr-scheduler', default='cosine', type=str,
help='Lr scheduler to use')
parser.add_argument("--warmup_steps", default=400, type=int)
# Pre-training Config
parser.add_argument("--dataset_dir", default='chemner_filter_cleaned_data', type=str)
# CPU/GPU
parser.add_argument('--fp16', action='store_true')
parser.add_argument("--distributed", action='store_true')
parser.add_argument('--local_rank', type=int, default=-1)
parser.add_argument('-j', '--workers', default=8, type=int,
help='number of data loading workers')
# Inference
parser.add_argument('--num_beams', type=int, default=5)
# Training configuration
parser.add_argument("--weight_decay", default=0.01, type=float, help="Weight decay if we apply some.")
parser.add_argument("--adam_eps", default=1e-6, type=float, help="Epsilon for Adam optimizer.")
parser.add_argument('--clip_grad_norm', type=float, default=1.0)
parser.add_argument("--start_epoch", default=0, type=int)
parser.add_argument("--pos_num", default = 25, type = int)
# Parse the arguments.
args = parser.parse_args()
# Set seeds
torch.manual_seed(args.seed)
random.seed(args.seed)
np.random.seed(args.seed)
return args
if __name__ == '__main__':
args = parse_args()