setfit icon indicating copy to clipboard operation
setfit copied to clipboard

Address deprecated ModelCardCallback from sentence_transformers

Open blawney opened this issue 11 months ago • 0 comments

Addresses a minor issue related to the deprecation of sentence_transformers.model_card.ModelCardCallback. This has since been changed to sentence_transformers.model_card.SentenceTransformerModelCardCallback and the PR will catch either object type.

I initially encounted a bug when I had setfit==1.1.1 with sentence-transformers==4.1.0 (which resulted from an "unversioned" mamba-based build). Prior to #595 (as is the case for v1.1.1), there was an instance of sentence_transformers.model_card.SentenceTransformerModelCardCallback which was added by the add_model_card_callback method in the sentence_transformers.SentenceTransformerTrainer class. Since the object type did not match sentence_transformers.model_card.ModelCardCallback (aliased as STModelCardCallback in setfit/trainer.py), the callback was not removed and a call to the setfit.Trainer constructor resulted in this:

TypeError: SentenceTransformerModelCardCallback.on_init_end() missing 1 required positional argument: 'trainer'

Note that this is no longer an issue with setfit==1.1.2, yet this PR addresses the potential where either the current or deprecated callback makes its way into setfit.trainer.BCSentenceTransformersTrainer

blawney avatar May 15 '25 20:05 blawney