TrainingArguments error : TypeError: __init__() got an unexpected keyword argument 'evaluation_strategy'
Author: Fourha
Pull request: no
Labels: name: wontfix

# ❓ Questions & Help

<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to the Hugging Face forum: https://discuss.huggingface.co/ .
     You can also try Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. In this case, make sure to tag your
     question with the right deep learning framework as well as the
     huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     -->

## Details
<!-- Description of your issue -->

when I use TrainingArguments (transformer 3,3,1) , it emerge the error TypeError: __init__() got an unexpected keyword argument 'evaluation_strategy'.  I wonder why I 've got this error. 

these are my code:

> training_args = TrainingArguments(
>     output_dir="./no_num_pretrain_model",
>     overwrite_output_dir=True,
>     num_train_epochs=epochs,
>     per_device_train_batch_size=16,
>     per_device_eval_batch_size=32,   
>     do_train = True,
>     do_eval = True,
>     evaluation_strategy="steps",
>     logging_steps = 10,
>     save_steps=2000,
>     eval_steps=10,
> )
> 
> 
> trainer = Trainer(
>     model=model,
>     args=training_args,
>     data_collator=data_collator, 
>     train_dataset=train_dataset,
>     eval_dataset=val_dataset,            # evaluation dataset
>     optimizers =(optimizer,scheduler)
> )



<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on the forum/Stack Overflow**:

Comments:
It was recently added, so you may need to upgrade your version of transformers.

> It was recently added, so you may need to upgrade your version of transformers.

Thanks,it works!
I use transformers in 

> kaggle notebook

 , maybe there is some bug in such online applications. I once tried to update transformer to see whether this error would not appear, but it was not work. 

This time I close my  browser and restart the kaggle notebook. Everything going well ! 

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


I've just successfully solved this problem using this command.

`pip install transformers --upgrade`


facing this error while applying Glora

training_arguments = TrainingArguments(
      5     # change the path of dir to save
      6     output_dir= output_dir,

TypeError: TrainingArguments.__init__() got an unexpected keyword argument 'num_ochs'


surely you must mean num_epochs and not num_ochs @asadurrehman10 

yes , it has solved, but at the last when I run trainer.train() it give this error:
RuntimeError: The size of tensor a (8388608) must match the size of tensor b (4096) at non-singleton dimension 0
where can I find a solution for this

@asadurrehman10 This issue is related to how you treat your data, not related with the topic of this question. Check the expected dimensions of the training samples and the actual dimensions you are using.

> I've just successfully solved this problem using this command.
> 
> `pip install transformers --upgrade`

didn't work for me.....

having this issue too, upgrading doesn't work

switching evaluation_strategy to eval_strategy worked

seems to be from this https://github.com/huggingface/transformers/commit/2b550c47b208fc1a57feca46307349ab575cba2c

> having this issue too, upgrading doesn't work
> 
> switching evaluation_strategy to eval_strategy worked
> 
> seems to be from this [2b550c4](https://github.com/huggingface/transformers/commit/2b550c47b208fc1a57feca46307349ab575cba2c)

Yaaa correct .. eval_startagy worked for me too yesterday... Apparently they have updated it...

> having this issue too, upgrading doesn't work
> 
> switching evaluation_strategy to eval_strategy worked
> 
> seems to be from this [2b550c4](https://github.com/huggingface/transformers/commit/2b550c47b208fc1a57feca46307349ab575cba2c)

Thank you , this works !

So I just signed up for Github specifically to comment that after literal hours of uninstalling and reinstalling anaconda, miniconda, going to Colab and trying to get this to work with ChatGPT and Gemini and Copilot all taking different approaches.... this simple thread got it working. I just had to change evaluation_strategy to eval_strategy. So thank you from the bottom of my heart and soul. Can't believe it took a 5 years old Github issue tracker with people somehow still sharing their experience to do it.

> having this issue too, upgrading doesn't work
> 
> switching evaluation_strategy to eval_strategy worked
> 
> seems to be from this [2b550c4](https://github.com/huggingface/transformers/commit/2b550c47b208fc1a57feca46307349ab575cba2c)

Love you

> having this issue too, upgrading doesn't work
> 
> switching evaluation_strategy to eval_strategy worked
> 
> seems to be from this [2b550c4](https://github.com/huggingface/transformers/commit/2b550c47b208fc1a57feca46307349ab575cba2c)

this is the recent solution

> having this issue too, upgrading doesn't work
> 
> switching evaluation_strategy to eval_strategy worked
> 
> seems to be from this [2b550c4](https://github.com/huggingface/transformers/commit/2b550c47b208fc1a57feca46307349ab575cba2c)

thanks!! 

> 也存在此问题，升级不起作用
> 
> 将 evaluation_strategy 切换到 eval_strategy 有效
> 
> 似乎来自这个 [2b550c4](https://github.com/huggingface/transformers/commit/2b550c47b208fc1a57feca46307349ab575cba2c)

you're sooooooooooo right

> having this issue too, upgrading doesn't work
> 
> switching evaluation_strategy to eval_strategy worked
> 
> seems to be from this [2b550c4](https://github.com/huggingface/transformers/commit/2b550c47b208fc1a57feca46307349ab575cba2c)

Helpful!

您发给温灼健的信件已收到，祝您身体健康，工作顺利，生活愉快~
 

> having this issue too, upgrading doesn't work
> 
> switching evaluation_strategy to eval_strategy worked
> 
> seems to be from this [2b550c4](https://github.com/huggingface/transformers/commit/2b550c47b208fc1a57feca46307349ab575cba2c)

That's also what worked for me, thanks!

您发给温灼健的信件已收到，祝您身体健康，工作顺利，生活愉快~
 

> > having this issue too, upgrading doesn't work
> > switching evaluation_strategy to eval_strategy worked
> > seems to be from this [2b550c4](https://github.com/huggingface/transformers/commit/2b550c47b208fc1a57feca46307349ab575cba2c)
> 
> Thank you , this works !

thanks so muc


Ошибка, с которой вы столкнулись, связана с изменениями в библиотеке Hugging Face Transformers. В новых версиях библиотеки параметр evaluation_strategy был переименован в eval_strategy. 

Это не проблема с обновлением библиотек, как вы предполагали, а намеренное изменение в API библиотеки. В результате обновления transformers параметр evaluation_strategy заменен на eval_strategy в новой версии.

您发给温灼健的信件已收到，祝您身体健康，工作顺利，生活愉快~
 

> eval_strategy

It works! Thx

Agree, to Solve `SFTConfig.__init__() got an unexpected keyword argument 'evaluation_strategy'`, rename parameter:
```diff
SFTConfig(
      ...
-     evaluation_strategy="epoch"
+     eval_strategy="epoch"
)
```

您发给温灼健的信件已收到，祝您身体健康，工作顺利，生活愉快~