forked from PaddlePaddle/PaddleNLP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
finetune_args.py
177 lines (170 loc) Β· 5.61 KB
/
finetune_args.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
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Optional
from dataclasses import dataclass, field
@dataclass
class DataArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
task_name: Optional[str] = field(
default="ner", metadata={"help": "The name of the task (ner, pos...)."})
dataset_name: Optional[str] = field(
default=None,
metadata={
"help": "The name of the dataset to use (via the datasets library)."
})
dataset_config_name: Optional[str] = field(
default=None,
metadata={
"help":
"The configuration name of the dataset to use (via the datasets library)."
})
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."
},
)
max_seq_length: int = field(
default=512,
metadata={
"help":
"The maximum total input sequence length after tokenization. Sequences longer "
"than this will be truncated, sequences shorter will be padded."
},
)
doc_stride: int = field(
default=128,
metadata={
"help":
"When splitting up a long document into chunks, how much stride to take between chunks."
},
)
target_size: int = field(
default=1024,
metadata={"help": "The maximum 2d pos size"},
)
pad_to_max_length: bool = field(
default=True,
metadata={
"help":
"Whether to pad all samples to model maximum sentence length. "
"If False, will pad the samples dynamically when batching to the maximum length in the batch. More "
"efficient on GPU but very bad for TPU."
},
)
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_val_samples: Optional[int] = field(
default=None,
metadata={
"help":
"For debugging purposes or quicker training, truncate the number of validation examples to this "
"value if set."
},
)
max_test_samples: Optional[int] = field(
default=None,
metadata={
"help":
"For debugging purposes or quicker training, truncate the number of test examples to this "
"value if set."
},
)
label_all_tokens: bool = field(
default=False,
metadata={
"help":
"Whether to put the label for one word on all tokens of generated by that word or just on the "
"one (in which case the other tokens will have a padding index)."
},
)
return_entity_level_metrics: bool = field(
default=False,
metadata={
"help":
"Whether to return all the entity levels during evaluation or just the overall ones."
},
)
train_log_file: Optional[str] = field(
default=None,
metadata={"help": "train log file"},
)
train_nshard: Optional[int] = field(
default=1,
metadata={
"help": "For big dataset, DocVQA/CORD when using ner3 pattern"
},
)
use_segment_box: bool = field(
default=False,
metadata={"help": "Whether use segment box"},
)
task_type: str = field(
default="ner",
metadata={"help": "The task type"},
)
pattern: Optional[str] = field(
default="ner1",
metadata={
"help": "The way to process input, choose from ner1, ner2, ner3"
},
)
rst_converter: Optional[str] = field(
default=None,
metadata={"help": "The way to convert the predict result"},
)
lang: Optional[str] = field(
default="en",
metadata={"help": "Languge type of the dataset"},
)
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: str = field(
metadata={
"help":
"Path to pretrained model or model identifier from huggingface.co/models"
})
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=None,
metadata={
"help":
"Where do you want to store the pretrained models downloaded from huggingface.co"
},
)