Skip to content

TextEmbedder only handles ModernBertForMaskedLM, not ModernBertModel embedding checkpoints #214

Description

@amgix-dev

Problem

TextEmbedder::from_pretrained_hf in rust/src/embeddings/embed/text.rs only routes ModernBertForMaskedLM to ModernBertEmbedder:

"ModernBertForMaskedLM" => Ok(Self::ModernBert(Box::new(ModernBertEmbedder::new(...)?))),

Many embedding models on Hugging Face use architecture ModernBertModel, not ModernBertForMaskedLM, for example:

  • ibm-granite/granite-embedding-97m-multilingual-r2
  • Alibaba-NLP/gte-modernbert-base
  • nomic-ai/modernbert-embed-base

Calling TextEmbedder::from_pretrained_hf with these models fails with "Model not supported", even though ModernBertEmbedder::new(model_id, ...) works when used directly.

Expected behavior

Also match ModernBertModel and construct ModernBertEmbedder the same way.

Workaround

Instantiate ModernBertEmbedder directly instead of going through TextEmbedder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions