Make training args fully immutable (#25435)
* Make training args fully immutable * Working tests, PyTorch * In test_trainer * during testing * Use proper dataclass way * Fix test * Another one * Fix tf * Lingering slow * Exception * Clean
This commit is contained in:
@@ -18,6 +18,7 @@ Fine-tuning the library models for sequence to sequence.
|
||||
"""
|
||||
# You can also adapt this script on your own sequence to sequence task. Pointers for this are left as comments.
|
||||
|
||||
import dataclasses
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
@@ -674,14 +675,10 @@ def main():
|
||||
return result
|
||||
|
||||
# Override the decoding parameters of Seq2SeqTrainer
|
||||
training_args.generation_max_length = (
|
||||
training_args.generation_max_length
|
||||
if training_args.generation_max_length is not None
|
||||
else data_args.val_max_target_length
|
||||
)
|
||||
training_args.generation_num_beams = (
|
||||
data_args.num_beams if data_args.num_beams is not None else training_args.generation_num_beams
|
||||
)
|
||||
if training_args.generation_max_length is None:
|
||||
training_args = dataclasses.replace(training_args, generation_max_length=data_args.val_max_target_length)
|
||||
if training_args.generation_num_beams is None:
|
||||
training_args = dataclasses.replace(training_args, generation_num_beams=data_args.num_beams)
|
||||
|
||||
# Initialize our Trainer
|
||||
trainer = Seq2SeqTrainer(
|
||||
|
||||
Reference in New Issue
Block a user