2023-08-03 11:16:51 +08:00

63 lines
2.2 KiB
Python

from dataclasses import dataclass, field
from typing import Optional
from transformers import TrainingArguments
@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 s3"}
)
sentence_pooling_method: str = field(default='cls')
normlized: bool = field(default=True)
@dataclass
class DataArguments:
train_data: str = field(
default=None, metadata={"help": "Path to train data"}
)
max_example_num_per_dataset: int = field(
default=1000000, metadata={"help": "sample negatives from top-k"}
)
train_group_size: int = field(default=8)
query_max_len: int = field(
default=32,
metadata={
"help": "The maximum total input sequence length after tokenization for passage. Sequences longer "
"than this will be truncated, sequences shorter will be padded."
},
)
passage_max_len: int = field(
default=128,
metadata={
"help": "The maximum total input sequence length after tokenization for passage. Sequences longer "
"than this will be truncated, sequences shorter will be padded."
},
)
@dataclass
class RetrieverTrainingArguments(TrainingArguments):
negatives_x_device: bool = field(default=False, metadata={"help": "share negatives across devices"})
temperature: Optional[float] = field(default=1.0)
fix_position_embedding: bool = field(default=False,
metadata={"help": "Freeze the parameters of position embeddings"})