setfit icon indicating copy to clipboard operation
setfit copied to clipboard

AttributeError: 'TrainingArguments' object has no attribute 'eval_strategy'

Open HeAndres opened this issue 1 year ago • 1 comments

Edit: I just saw there are other issues related to this: #535, #528, #512 and a PR #538

When running training as in the example in the README, I get the following error:

File "path_to_my_project/my_folder/my_script.py", line 81, in trainer.train() File "path_to_my_project/.venv/lib/python3.10/site-packages/setfit/trainer.py", line 410, in train self.train_embeddings(*full_parameters, args=args) File "path_to_my_project/.venv/lib/python3.10/site-packages/setfit/trainer.py", line 462, in train_embeddings self._train_sentence_transformer( File "path_to_my_project/.venv/lib/python3.10/site-packages/setfit/trainer.py", line 656, in _train_sentence_transformer self.control = self.callback_handler.on_step_end(args, self.state, self.control) File "path_to_my_project/.venv/lib/python3.10/site-packages/transformers/trainer_callback.py", line 486, in on_step_end return self.call_event("on_step_end", args, state, control) File "path_to_my_project/.venv/lib/python3.10/site-packages/transformers/trainer_callback.py", line 508, in call_event result = getattr(callback, event)( File "path_to_my_project/.venv/lib/python3.10/site-packages/transformers/trainer_callback.py", line 540, in on_step_end args.eval_strategy == IntervalStrategy.STEPS AttributeError: 'TrainingArguments' object has no attribute 'eval_strategy'. Did you mean: 'save_strategy'?

According to the release notes for version 4.41.0 of the transformers library (https://github.com/huggingface/transformers/releases/tag/v4.41.0), the variable "eval_strategy" is renamed to "evaluation_strategy": image I'm copying the paragraph:

  • 🚨🚨🚨Deprecate evaluation_strategy to eval_strategy🚨🚨🚨 by @muellerzr in https://github.com/huggingface/transformers/pull/30190

In my case, the error disappears if I add the following line before line 653 of setfit/src/setfit/trainer.py:

args.eval_strategy = args.evaluation_strategy

My current setfit version is 1.0.3. For transformers, it is 4.42.4.

HeAndres avatar Jul 18 '24 09:07 HeAndres