Skip to content

Add GTE-Reranker-ModernBERT-Base support with reranking example and tests#62

Open
afanjul wants to merge 2 commits into
Blaizzy:mainfrom
afanjul:main
Open

Add GTE-Reranker-ModernBERT-Base support with reranking example and tests#62
afanjul wants to merge 2 commits into
Blaizzy:mainfrom
afanjul:main

Conversation

@afanjul

@afanjul afanjul commented Apr 30, 2026

Copy link
Copy Markdown

Summary

Adds full support for the Alibaba-NLP/gte-reranker-modernbert-base cross-encoder reranker model.

The existing modernbert.py already handled ModernBertForSequenceClassification architecture, but it lacked tests, documentation, and the generate() function didn't accept text pairs needed for reranking.

Changes:

  • mlx_embeddings/utils.py:

    • Updated generate() type signature to accept List[List[str]] (text pairs for reranking)
    • Added reranker-specific example in upload_to_hub() for ModernBertForSequenceClassification
    • Fixed bug: architectures comparison for ModernBertForMaskedLM was comparing a list to a string instead of a list
  • mlx_embeddings/tests/test_models.py:

    • Added test_modernbert_model_sequence_classification test that validates the model works correctly with sigmoid output range verification
  • README.md:

    • Added "Text Reranking" section with a complete usage example for Alibaba-NLP/gte-reranker-modernbert-base

devin-ai-integration Bot and others added 2 commits April 30, 2026 10:27
…ests

Co-Authored-By: Alex Fan <afanjul@palbin.com>
…modernbert-support

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Alex Fan <afanjul@palbin.com>

@Blaizzy Blaizzy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants