Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
HeAndres opened this issue Jul 18, 2024 · 1 comment · Fixed by #538
Closed

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

HeAndres opened this issue Jul 18, 2024 · 1 comment · Fixed by #538

Comments

@HeAndres
Copy link

HeAndres commented Jul 18, 2024

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:

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 HeAndres changed the title Training is broken by "possibly breaking changes" in transformers library from v4.41.0 AttributeError: 'TrainingArguments' object has no attribute 'eval_strategy' Jul 18, 2024
@HeAndres HeAndres reopened this Jul 18, 2024
@hamishdickson
Copy link

Hi @HeAndres - it looks like this is down to a change which happened in transformers

#528

@tomaarsen tomaarsen linked a pull request Sep 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants