huggingface / setfit

Efficient few-shot learning with Sentence Transformers
https://hf.co/docs/setfit
Apache License 2.0
2.24k stars 222 forks source link

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

Closed HeAndres closed 2 months ago

HeAndres commented 4 months ago

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.

hamishdickson commented 3 months ago

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

https://github.com/huggingface/setfit/issues/528