huggingface / setfit

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

Warning from sentence-transformer, version 2.3.1 #493

Closed kgourgou closed 9 months ago

kgourgou commented 9 months ago

When I use trainer.train(), sentence-transformer complains because of the calls to _target_device.

https://github.com/huggingface/setfit/blob/1e3ce937e2e430c549b5b43ffb48b43d714efc24/src/setfit/modeling.py#L624

The warning is "SentenceTransformer._target_device has been removed, please use SentenceTransformer.device instead.`", so it should be an easy fix.

I did note the part:

   # SentenceTransformers.device is reliable from 2.3.0 onwards
        if parse(sentence_transformers_version) >= Version("2.3.0"):
            return self.model_body.device

Maybe I have a mismatch of versions of SetFit and Sentence-Transformers cause I see a ton of warnings from ST.

I'm using setfit==1.0.1 and sentence-transformers==2.3.1, so the above should have used device instead of target_device.

kgourgou commented 9 months ago

Upgrading to 1.0.3 fixed this; closing.