-
Notifications
You must be signed in to change notification settings - Fork 25
/
arguments.py
172 lines (135 loc) · 5.39 KB
/
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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# Copyright 2020 The HuggingFace Team. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Uses some code from
# https://github.com/huggingface/transformers/blob/master/examples/seq2seq/finetune_trainer.py
from dataclasses import dataclass, field
from typing import Optional
import transformers
@dataclass
class TrainingArguments(transformers.TrainingArguments):
"""
Arguments for the Trainer.
"""
output_dir: str = field(
default='experiments',
metadata={"help": "The output directory where the results and model weights will be written."}
)
zero_shot: bool = field(
default=False,
metadata={"help": "Zero-shot setting"}
)
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
"""
model_name_or_path: Optional[str] = field(
default=None, 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"}
)
@dataclass
class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
datasets: Optional[str] = field(
default=None,
metadata={"help": "Comma separated list of dataset names, for training."}
)
data_dir: Optional[str] = field(
default=None,
metadata={"help": "Path to data directory"}
)
eval_datasets: Optional[str] = field(
default=None,
metadata={"help": "Comma separated list of dataset names. Defaults to the train datasets."}
)
train_split: str = field(
default='train',
metadata={"help": "The datasplit for training. Can be 'train', 'dev', 'test', etc."}
)
max_seq_length: int = field(
default=128,
metadata={
"help": "The maximum total input sequence length after tokenization. Sequences longer "
"than this will be truncated, shorter sequences will be padded."
},
)
max_output_seq_length: Optional[int] = field(
default=None,
metadata={
"help": "The maximum output sequence length (default is the same as input)"
},
)
overwrite_cache: bool = field(
default=True, metadata={"help": "Overwrite the cached training and evaluation sets"}
)
train_subset: float = field(
default=1, metadata={"help": "The portion of training data to use"}
)
episodes: str = field(
default='0', metadata={"help": "Episode indices -- a single number such as 3 or an interval such as 1-4\n"
"The index is also used as random seeds and this setting is therefore used to "
"repeat multiple experiments."}
)
num_beams: int = field(
default=None,
metadata={"help": "Number of beams for beam search during generation (only affects evaluation)"}
)
max_seq_length_eval: int = field(
default=None,
metadata={
"help": "Maximum input sequence length at evaluation time (default is equal to max_seq_length)"
},
)
max_output_seq_length_eval: int = field(
default=None,
metadata={
"help": "The maximum output sequence length at evaluation time (default is the same as input)"
},
)
input_format: str = field(
default=None, metadata={"help": "Input format"}
)
output_format: str = field(
default=None, metadata={"help": "Output format"}
)
multitask: bool = field(
default=False, metadata={"help": "If true, each input sentence is prepended with the dataset name"}
)
# few-shot arguments
num_shots: int = field(
default=None, metadata={"help": "number of shots (few-shot argument for the FewRel dataset)"}
)
num_ways: int = field(
default=None, metadata={"help": "number of ways (few-shot argument for the FewRel dataset)"}
)
num_query: int = field(
default=5, metadata={"help": "number of query examples (few-shot argument for the FewRel dataset)"}
)
# chunk arguments (used for the CoNLL2012 coreference resolution dataset)
chunk_size: int = field(
default=128, metadata={"help": "Size of document chunks"}
)
chunk_overlap: int = field(
default=64, metadata={"help": "Size of overlap between consecutive chunks"}
)
chunk_size_eval: int = field(
default=None, metadata={"help": "Size of document chunks during evaluation (default is equal to chunk_size)"}
)
chunk_overlap_eval: int = field(
default=None, metadata={"help": "Size of overlap between consecutive chunks during evaluation "
"(default is equal to chunk_overlap)"}
)
eval_nll: bool = field(
default=False, metadata={"help": "Evaluate using NLL (only applicable to certain datasets)"}
)