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

Example from quick start fails with 'TrainingArguments' object has no attribute 'eval_strategy' #528

Closed salvador-dali closed 2 months ago

salvador-dali commented 6 months ago

Tried to follow https://huggingface.co/docs/setfit/main/en/quickstart#end-to-end

This notebook is just a copypaste from quickstart: https://colab.research.google.com/drive/1N9HPmqhaqBm_rL13nTuV3wC7rdIJseve#scrollTo=0NybX59O5o98

The train fails with

/usr/local/lib/python3.10/dist-packages/transformers/utils/notebook.py in on_train_begin(self, args, state, control, **kwargs)
    293 
    294     def on_train_begin(self, args, state, control, **kwargs):
--> 295         self.first_column = "Epoch" if args.eval_strategy == IntervalStrategy.EPOCH else "Step"
    296         self.training_loss = 0
    297         self.last_log = 0

AttributeError: 'TrainingArguments' object has no attribute 'eval_strategy'
tomaarsen commented 6 months ago

The most recent version of transformers has renamed evaluation_strategy into eval_strategy. I'd recommend downgrading transformers to a slightly older version. You can see your current version with pip show transformers.

salvador-dali commented 6 months ago

Thanks, I was able to fix this with !pip install transformers==4.39.0

tomaarsen commented 6 months ago

Excellent, thanks for sharing! I intend to fix this more properly in early June.

giorgionicoli commented 5 months ago

It seems to work up to transformers==4.40.2, but it fails with transformers>=4.41.0, in case useful :)

splevine commented 5 months ago

I was facing this issue yesterday, I will try that particular downgrade to transformers this week. Thank you!

XeniaZerweck commented 5 months ago

Hello, I am facing the same issue and downgrading to transformers==4.39.0 did not fix the problem. Neither did the workaround args.eval_strategy = args.evaluation_strategy. Are there any updates or any other insights? Thanks in advance!

splevine commented 5 months ago

The transformers downgrade worked for me

If in notebook you can run:

pip install setfit transformers==4.39.0
XeniaZerweck commented 5 months ago

Yes it worked for me too now, I forgot to restart my kernel. Apologies and thanks!

zhiyiyeo commented 3 months ago

+1 on this - any plans for a fix to be released?