Skip to content

Fix VarBuilder handling for custom code GTE variants #473

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

Closed
Prev Previous commit
Next Next commit
Handle AlibabaNLP/gte-multilingual-base edge case
alvarobartt committed Jan 17, 2025

Verified

This commit was signed with the committer’s verified signature.
alvarobartt Alvaro Bartolome
commit 62ab160f91fcdc5674ae95b46d9944a1e2d0eb59
9 changes: 9 additions & 0 deletions router/src/lib.rs
Original file line number Diff line number Diff line change
@@ -352,6 +352,15 @@ fn get_backend_model_type(
pooling: Option<text_embeddings_backend::Pool>,
) -> Result<text_embeddings_backend::ModelType> {
for arch in &config.architectures {
// Edge case affecting `Alibaba-NLP/gte-multilingual-base` and possibly other fine-tunes of
// the same base model. More context at https://huggingface.co/Alibaba-NLP/gte-multilingual-base/discussions/7
if arch == "NewForTokenClassification"
&& (config.id2label.is_none() | config.label2id.is_none())
{
tracing::warn!("Provided `--model-id` is likely an AlibabaNLP GTE model, but the `config.json` contains the architecture `NewForTokenClassification` but it doesn't contain the `id2label` and `label2id` mapping, so `NewForTokenClassification` architecture will be ignored.");
continue;
}

if Some(text_embeddings_backend::Pool::Splade) == pooling && arch.ends_with("MaskedLM") {
return Ok(text_embeddings_backend::ModelType::Embedding(
text_embeddings_backend::Pool::Splade,