Use custom serde
deserializer for JinaBERT models
#559
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Note
This PR is still being tested and is missing the tests to be included within this PR.
This PR "improves" the handling for the JinaBERT configurations as those share the same
model_type
as the default BERT models i.e.model_type=bert
meaning that those need a specific handling for telling apart JinaBERT and BERT. Apparently, when fine-tuning or re-uploading JinaBERT models with Sentence Transformers, the_name_or_path
value is overwritten with the actual path to the origin Hugging Face Hub repository, which means that the serde-based tag strategy to tell those apart will no longer work, as the value won't match the former check. This PR then, adds a customserde
deserializer to make sure that theconfig.json
is deserialized for the correct model not only based on the_name_or_path
value but also on theauto_map.AutoConfig
value, which in any case will still point to the remote repository with the JinaBERT implementation.Fixes #556
Before submitting
Who can review?
@Narsil or @McPatate