()
| 190 | |
| 191 | |
| 192 | def main(): |
| 193 | # See all possible arguments in src/transformers/training_args.py |
| 194 | # or by passing the --help flag to this script. |
| 195 | # We now keep distinct sets of args, for a cleaner separation of concerns. |
| 196 | |
| 197 | parser = HfArgumentParser((ModelArguments, DataTrainingArguments, TrainingArguments)) |
| 198 | model_args, data_args, training_args = parser.parse_args_into_dataclasses() |
| 199 | |
| 200 | # Setup logging |
| 201 | logging.basicConfig( |
| 202 | format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", |
| 203 | datefmt="%m/%d/%Y %H:%M:%S", |
| 204 | handlers=[logging.StreamHandler(sys.stdout)], |
| 205 | ) |
| 206 | |
| 207 | if training_args.should_log: |
| 208 | # The default of training_args.log_level is passive, so we set log level at info here to have that default. |
| 209 | transformers.utils.logging.set_verbosity_info() |
| 210 | |
| 211 | log_level = training_args.get_process_log_level() |
| 212 | logger.setLevel(log_level) |
| 213 | datasets.utils.logging.set_verbosity(log_level) |
| 214 | transformers.utils.logging.set_verbosity(log_level) |
| 215 | transformers.utils.logging.enable_default_handler() |
| 216 | transformers.utils.logging.enable_explicit_format() |
| 217 | |
| 218 | # Log on each process the small summary: |
| 219 | logger.warning( |
| 220 | f"Process rank: {training_args.local_process_index}, device: {training_args.device}, n_gpu: {training_args.n_gpu}, " |
| 221 | + f"distributed training: {training_args.parallel_mode.value == 'distributed'}, 16-bits training: {training_args.fp16}" |
| 222 | ) |
| 223 | logger.info(f"Training/evaluation parameters {training_args}") |
| 224 | |
| 225 | # Set seed before initializing model. |
| 226 | set_seed(training_args.seed) |
| 227 | |
| 228 | # In distributed training, the load_dataset function guarantees that only one local process can concurrently |
| 229 | # download the dataset. |
| 230 | # Downloading and loading xnli dataset from the hub. |
| 231 | if training_args.do_train: |
| 232 | if model_args.train_language is None: |
| 233 | train_dataset = load_dataset( |
| 234 | "xnli", |
| 235 | model_args.language, |
| 236 | split="train", |
| 237 | cache_dir=model_args.cache_dir, |
| 238 | token=model_args.token, |
| 239 | ) |
| 240 | else: |
| 241 | train_dataset = load_dataset( |
| 242 | "xnli", |
| 243 | model_args.train_language, |
| 244 | split="train", |
| 245 | cache_dir=model_args.cache_dir, |
| 246 | token=model_args.token, |
| 247 | ) |
| 248 | label_list = train_dataset.features["label"].names |
| 249 |
no test coverage detected