nlp-with-transformers / notebooks

Jupyter notebooks for the Natural Language Processing with Transformers book
https://transformersbook.com/
Apache License 2.0
3.85k stars 1.19k forks source link

TrainingArguments are now Immutable #118

Closed canberk17 closed 1 year ago

canberk17 commented 1 year ago

We have to change the way TrainingArguments are modified due to a recent update that made them immutable, as discussed in this thread.

Previously, we could directly modify the TrainingArguments like this:

training_args.logging_steps = len(corpora_encoded["train"]) // batch_size
training_args.output_dir = "xlm-roberta-base-finetuned-panx-all"

However, since TrainingArguments are now immutable(#25435), we have to use the replace function from the dataclasses module to modify its fields. The replace function creates a new object of the same type as the original, replacing fields with new values specified, as mentioned here

So, the modification of TrainingArguments will now look like this:

training_args = replace(training_args, logging_steps=len(corpora_encoded['train'])//batch_size)
training_args = replace(training_args, output_dir="xlm-roberta-base-finetuned-panx-all")
review-notebook-app[bot] commented 1 year ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

canberk17 commented 1 year ago

@lvwerra @lewtun

lvwerra commented 1 year ago

The book has the transformers version pinned, so I believe that should not be an issue?

canberk17 commented 1 year ago

Aah, fair point. I probably missed that detail while going through the chapter. I'll close this PR. Thanks for pointing it out. Also amazing content!