MCPcopy Create free account
hub / github.com/RingBDStack/GDAP / main

Function main

run_seq2seq.py:279–782  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

277
278
279def main():
280 # See all possible arguments in src/transformers/training_args.py
281 # or by passing the --help flag to this script.
282 # We now keep distinct sets of args, for a cleaner separation of concerns.
283
284 parser = HfArgumentParser(
285 (ModelArguments, DataTrainingArguments, ConstraintSeq2SeqTrainingArguments))
286 if len(sys.argv) == 2 and sys.argv[1].endswith(".json"):
287 # If we pass only one argument to the script and it's the path to a json file,
288 # let's parse it to get our arguments.
289 model_args, data_args, training_args = parser.parse_json_file(
290 json_file=os.path.abspath(sys.argv[1]))
291 else:
292 model_args, data_args, training_args = parser.parse_args_into_dataclasses()
293
294 print(model_args)
295 print(data_args)
296 print(training_args)
297
298 # Detecting last checkpoint.
299 last_checkpoint = None
300 if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
301 last_checkpoint = get_last_checkpoint(training_args.output_dir)
302 if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
303 raise ValueError(
304 f"Output directory ({training_args.output_dir}) already exists and is not empty. "
305 "Use --overwrite_output_dir to overcome."
306 )
307 elif last_checkpoint is not None:
308 logger.info(
309 f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
310 "the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
311 )
312
313 # Setup logging
314 logging.basicConfig(
315 format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
316 datefmt="%m/%d/%Y %H:%M:%S",
317 handlers=[logging.StreamHandler(sys.stdout)],
318 )
319 logger.setLevel(logging.INFO if is_main_process(
320 training_args.local_rank) else logging.WARN)
321
322 # Log on each process the small summary:
323 logger.warning(
324 f"Process rank: {training_args.local_rank}, device: {training_args.device}, n_gpu: {training_args.n_gpu}"
325 + f"distributed training: {bool(training_args.local_rank != -1)}, 16-bits training: {training_args.fp16}"
326 )
327 # Set the verbosity to info of the Transformers logger (on main process only):
328 if is_main_process(training_args.local_rank):
329 transformers.utils.logging.set_verbosity_info()
330 logger.info("Training/evaluation parameters %s", training_args)
331
332 # Set seed before initializing model.
333 set_seed(training_args.seed)
334
335 # Get the datasets: you can either provide your own CSV/JSON training and evaluation files (see below)
336 # or just provide the name of one of the public datasets available on the hub at https://huggingface.co/datasets/

Callers 2

_mp_fnFunction · 0.70
run_seq2seq.pyFile · 0.70

Calls 2

read_from_fileMethod · 0.80

Tested by

no test coverage detected