Fix VarBuilder
handling for custom code GTE variants
#473
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?
This PR fixes how the VarBuilder loading is being handled for
GTEModel
since some models such asAlibaba-NLP/gte-multilingual-base
require custom code (available at https://huggingface.co/Alibaba-NLP/new-impl) using thebase_model_prefix="new"
as per this line, meaning that thesafetensors
weights are not stored as e.g.embeddings.word_embeddings
like in other variants of GTE as e.g.Alibaba-NLP/gte-base-en-v1.5
, but asnew.embeddings.word_embeddings
.Fixes #460
Fixes #471
Note
Some of the changes proposed in this PR are pretty specific to some of the Alibaba NLP model variants and should or could be fixed within the repositories, but since those are widely used e.g.
Alibaba-NLP/gte-multilingual-base
has over 500k monthly downloads on the Hub, being on the top 100 models on the MTEB Leaderboard, and showing astext-embeddings-inference
compatible on the Hub; we could ship this as a tiny QoL improvement causing less friction when deploying TEI models from the Hub (it can now be deployed but settingrefs/pr/7
as the revision as e.g.text-embeddings-router --model-id Alibaba-NLP/gte-multilingual-base --port 8081
).WDYT @OlivierDehaene? Thanks in advance!
See below the following deployments:
Alibaba-NLP/gte-multilingual-base
:Alibaba-NLP/gte-multilingual-reranker-base
:Before submitting
Who can review?
@OlivierDehaene