forked from rycolab/probing-via-prompting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdp_arguments.py
204 lines (200 loc) · 5.85 KB
/
dp_arguments.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
# -*- coding: utf-8 -*-
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
"""
gpt2_name_or_path: Optional[str] = field(
default=None,
metadata={
"help": "The model checkpoint for weights initialization."
"Don't set if you want to train a model from scratch."
},
)
chinese: bool = field(
default=False,
metadata={
"help": "Whether to use GPT2-Chinese model."
},
)
model_path: Optional[str] = field(
default=None,
metadata={
"help": "Path to trained model."
"Don't set if you want to train a model from scratch."
},
)
config_overrides: Optional[str] = field(
default=None,
metadata={
"help": "Override some existing default config settings when a model is trained from scratch. Example: "
"n_embd=10,resid_pdrop=0.2,scale_attn_weights=false,summary_type=cls_index"
},
)
config_name: Optional[str] = field(
default=None, metadata={"help": "Pretrained config name or path if not the same as model_name"}
)
tokenizer_name: Optional[str] = field(
default=None, metadata={"help": "Pretrained tokenizer name or path if not the same as model_name"}
)
cache_dir: Optional[str] = field(
default='cache/',
metadata={"help": "Where do you want to store the pretrained models downloaded from huggingface.co"},
)
use_fast_tokenizer: bool = field(
default=True,
metadata={"help": "Whether to use one of the fast tokenizer (backed by the tokenizers library) or not."},
)
model_revision: str = field(
default="main",
metadata={"help": "The specific model version to use (can be a branch name, tag name or commit id)."},
)
use_auth_token: bool = field(
default=False,
metadata={
"help": "Will use the token generated when running `transformers-cli login` (necessary to use this script "
"with private models)."
},
)
use_mlp: bool = field(
default=True,
metadata={
"help": "use mlp or linear regression"
},
)
mlp_dropout: Optional[float] = field(
default=0.2,
metadata={"help": "Dropout in MLP model."},
)
mlp_dim: Optional[int] = field(
default=512,
metadata={"help": "Dimension of hidden states of MLP model."},
)
mlp_layers: Optional[int] = field(
default=1,
metadata={"help": "The number of layers of MLP model."},
)
num_of_heads: Optional[int] = field(
default=96,
metadata={"help": "Number of heads left unpruned."},
)
pruning_lr: Optional[float] = field(
default=0.1,
metadata={"help": "Learning rate for head importance variables."},
)
do_prune: Optional[bool] = field(
default=False,
metadata={"help": "Whether heads are pruned."},
)
randomized: bool = field(
default=False,
metadata={
"help": "If true, load the architecture of the model only, without pretrained weights. "
"By default (randomized=False), load the whole pretrained model."
},
)
dev: bool = field(
default=False,
metadata={
"help": "If true, use development dataset to do evaluation. Otherwise use test dataset."
},
)
mod_randomized: bool = field(
default=False,
metadata={
"help": "If true, load the architecture of the model only, without pretrained weights. "
"Artificially specify how to initialize the weights, e.g., init_mean, init_std, etc."
},
)
agg_mod_rand: bool = field(
default=False,
metadata={
"help": "If true, load the architecture of the model only, without pretrained weights."
"Initialize the weights head by head with predetermined parameters, e.g., abs_mean, abs_std, etc."
},
)
fine_mod_rand: bool = field(
default=False,
metadata={
"help": "If true, load the architecture of the model only, without pretrained weights."
"Initialize the weights module by module with predetermined parameters, e.g., abs_mean, abs_std, etc."
},
)
norm_mod_rand: bool = field(
default=False,
metadata={
"help": "If true, load the architecture of the model only, without pretrained weights."
"Initialize the weights module by module with specified norm."
},
)
init_mean: float = field(
default=0.0,
metadata={
"help": "Randomized model weight initialization mean"
},
)
init_std: float = field(
default=0.02,
metadata={
"help": "Randomized model weight initialization std"
},
)
verbose: int = field(
default=0,
metadata={
"help": "How to group wandb experiments."
},
)
saturated: bool = field(
default=False,
metadata={
"help": "Saturated attention mode."
},
)
onehot: bool = field(
default=False,
metadata={
"help": "If true, extract the embeddings from GPT2 and then pass them as input to the probe."
},
)
n_gpu: int = field(
default=1,
metadata={
"help": "Number of GPUs to use."
},
)
@dataclass
class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
data_dir: Optional[str] = field(
default=None, metadata={"help": "Where data is stored"}
)
task: Optional[str] = field(
default='ner',
metadata={"help": "Tasks, one or more of {pos, const, coref, ner, srl}."},
)
max_train_samples: Optional[int] = field(
default=None,
metadata={
"help": "For debugging purposes or quicker training, truncate the number of training examples to this "
"value if set."
},
)
max_eval_samples: Optional[int] = field(
default=None,
metadata={
"help": "For debugging purposes or quicker training, truncate the number of evaluation examples to this "
"value if set."
},
)
overwrite_cache: bool = field(
default=False, metadata={"help": "Overwrite the cached training and evaluation sets"}
)
preprocessing_num_workers: Optional[int] = field(
default=None,
metadata={"help": "The number of processes to use for the preprocessing."},
)