-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfigs.py
169 lines (164 loc) · 4.49 KB
/
configs.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
from dataclasses import dataclass, field
from typing import List, Optional, Tuple
@dataclass
class GlobalArguments:
seed: int = field(
default=42,
metadata={"help": "Random seed for initialization"}
)
no_cuda: bool = field(
default=False,
metadata={"help": "Avoid using CUDA when available"}
)
debug: bool = field(
default=False
)
stop: bool = field(
default=False
)
exp_name: str = field(
default='debug',
metadata={"help": "Unique name of experiment"}
)
knowledge_base: str = field(
default='kg',
)
edit_output: bool = field(
default=False
)
num_edits: int = field(
default=1,
)
@dataclass
class DataArguments:
data_name: str = field(
default='WebQuestions',
metadata={"help": "Name of dataset"}
)
data_path: str = field(
default='./datasets',
metadata={"help": "Path of dataset"}
)
data_type: str = field(
default='KGQA'
)
batch_size: int = field(
default=16,
metadata={"help": "Batch size of dataset loaders"}
)
aliases: bool = field(
default=True,
metadata={"help": "Whether to consider aliases of answer entities"}
)
@dataclass
class LanguageModelArguments:
model_type: str = field(
default='flan',
metadata={"help": "Type of pretrained model"}
)
model_name_or_path: str = field(
default='google/flan-t5-base',
metadata={"help": "Path to pretrained model or model identifier from huggingface.co/models"}
)
max_source_length: int = field(
default=1024,
metadata={"help": "The maximum total input sequence length"}
)
max_target_length: int = field(
default=128,
metadata={"help": "The maximum total sequence length for target text"}
)
cache_dir: Optional[str] = field(
default='./cache',
metadata={"help": "Path to directory to store the pretrained models downloaded from huggingface.co"}
)
fp16: bool = field(
default=False,
metadata={"help": "Whether to use 16-bit (mixed) precision (through NVIDIA apex) instead of 32-bit"}
)
device_map: str = field(
default="auto"
)
question_prefix: str = field(
default="Question: ",
metadata={"help": "Text added prior to input question"}
)
question_postfix: str = field(
default="Answer:",
metadata={"help": "Text added next to input question"}
)
@dataclass
class RetrieverArguments:
use_retrieval: bool = field(
default=True
)
retriever_name: str = field(
default='mpnet',
metadata={"help": "Name of retrieval model"}
)
retriever_top_k: int = field(
default=10
)
retriever_batch_size: int = field(
default=8192
)
retriever_sep_token: str = field(
default=' '
)
index_dir: Optional[str] = field(
default='./cache/pyserini'
)
@dataclass
class VerifierArguments:
use_verification: bool = field(
default=True
)
verifier_name: str = field(
default='google/flan-t5-base',
metadata={"help": "Name of verifier model"}
)
verifier_generation_metric: str = field(
default='accuracy',
metadata={"help": "Name of verifier metric for generated answer"}
)
verifier_generation_threshold: float = field(
default=0.5
)
verifier_retrieval_threshold: float = field(
default=0.0
)
verifier_max_source_length: int = field(
default=1024,
metadata={"help": "The maximum total input sequence length"}
)
verifier_max_target_length: int = field(
default=1,
metadata={"help": "The maximum total sequence length for target text"}
)
fact_sep_token: str = field(
default=' '
)
verifier_sample: bool = field(
default=False
)
verifier_num_epochs: int = field(
default=3
)
verifier_batch_size: int = field(
default=32,
metadata={"help": "Batch size of verifier dataset loaders"}
)
verifier_learning_rate: float = field(
default=5e-5,
metadata={"help": "Initial learning rate (after the potential warmup period) to use"}
)
verifier_weight_decay: float = field(
default=0.0,
metadata={"help": "Weight decay to use"}
)
ensemble: bool = field(
default=False
)
verifier_num_instructions: int = field(
default=5
)