( dataset_name: str dataset_config: typing.Optional[str] = None dataset_train_split: str = 'train' dataset_test_split: str = 'test' gradient_checkpointing_use_reentrant: bool = False ignore_bias_buffers: bool = False )
Parameters
str
) —
Dataset name. str
or None
, optional, defaults to None
) —
Dataset configuration name. Corresponds to the name
argument of the load_dataset function. str
, optional, defaults to "train"
) —
Dataset split to use for training. str
, optional, defaults to "test"
) —
Dataset split to use for evaluation. bool
, optional, defaults to False
) —
Whether to apply use_reentrant
for gradient_checkpointing. bool
, optional, defaults to False
) —
Debug argument for distributed training. Fix for DDP issues with LM bias/mask buffers - invalid scalar
type, inplace operation. See https://github.com/huggingface/transformers/issues/22482#issuecomment-1595790992. Arguments common to all scripts.
( dataclass_types: typing.Union[transformers.hf_argparser.DataClassType, typing.Iterable[transformers.hf_argparser.DataClassType], NoneType] = None ignore_extra_args: typing.Optional[bool] = None **kwargs )
Parameters
Union[DataClassType, Iterable[DataClassType]]
or None
, optional, defaults to None
) —
Dataclass types to use for argument parsing. A subclass of transformers.HfArgumentParser designed for parsing command-line arguments with dataclass-backed configurations, while also supporting configuration file loading and environment variable management.
# main.py
import os
from dataclasses import dataclass
from trl import TrlParser
@dataclass
class MyArguments:
arg1: int
arg2: str = "alpha"
parser = TrlParser(dataclass_types=[MyArguments])
training_args = parser.parse_args_and_config()
print(training_args, os.environ.get("VAR1"))
$ python main.py --config config.yaml
(MyArguments(arg1=23, arg2='alpha'),) value1
$ python main.py --arg1 5 --arg2 beta
(MyArguments(arg1=5, arg2='beta'),) None
( args: typing.Optional[typing.Iterable[str]] = None return_remaining_strings: bool = False )
Parse command-line args and config file into instances of the specified dataclass types.
This method wraps transformers.HfArgumentParser.parse_args_into_dataclasses and also parses the config file
specified with the --config
flag. The config file (in YAML format) provides argument values that replace the
default values in the dataclasses. Command line arguments can override values set by the config file. The
method also sets any environment variables specified in the env
field of the config file.
( args = None return_remaining_strings = False look_for_args_file = True args_filename = None args_file_flag = None ) → Tuple consisting of
Parameters
Returns
Tuple consisting of
Parse command-line args into instances of the specified dataclass types.
This relies on argparse’s ArgumentParser.parse_known_args
. See the doc at:
docs.python.org/3.7/library/argparse.html#argparse.ArgumentParser.parse_args
Overrides the parser’s default values with those provided via keyword arguments.
Any argument with an updated default will also be marked as not required if it was previously required.
Returns a list of strings that were not consumed by the parser.