-
Notifications
You must be signed in to change notification settings - Fork 487
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
[Sentence Transformers] Complete the update of model_type
#1645
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the notice, would this suggestion work?
model.config = model[0].auto_model.config | ||
model.config.model_type = "sentence-transformers-transformer" | ||
model.config.__class__.model_type = "sentence-transformers-transformer" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model.config = model[0].auto_model.config | |
model.config.model_type = "sentence-transformers-transformer" | |
model.config.__class__.model_type = "sentence-transformers-transformer" | |
model.config = PretrainedConfig.from_dict(model[0].auto_model.config.to_dict()) | |
model.config.model_type = "sentence-transformers-transformer" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model.config = model[0].model.config | ||
model.config.model_type = "sentence-transformers-clip" | ||
model.config.__class__.model_type = "sentence-transformers-clip" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model.config = model[0].model.config | |
model.config.model_type = "sentence-transformers-clip" | |
model.config.__class__.model_type = "sentence-transformers-clip" | |
model.config = PretrainedConfig.from_dict(model[0].model.config.to_dict()) | |
model.config.model_type = "sentence-transformers-clip" |
Right, the issue comes from https://github.com/huggingface/transformers/blob/881e966aced6f0f208f43d7b7e7e55bc680f8fa5/src/transformers/configuration_utils.py#L901-L902. This sounds like a bug in Transformers to me, In the meantime we rather fix with: class SentenceTransformersTransformerPretrainedConfig(PretrainedConfig):
model_type = "sentence-transformers-transformer"
class SentenceTransformersClipPretrainedConfig(PretrainedConfig):
model_type = "sentence-transformers-clip" to avoid modifying class attributes? |
close as this will be tackled in #1647 |
What does this PR do?
model_type
, with the previous update, themodel_type
remains as the previous one (eg.bert
) when displaying the config (which is relatively ok):But if we apply
config.to_dict()
, themodel_type
is not changed, so I would suggest to complete the change ofmodel_type
thoroughly.