Model reference · open weights
gte-reranker-modernbert is an open-weight embedding model from Alibaba. gte-reranker-modernbert-base (FP32) weighs 299 MB; the smallest configuration that runs it is RTX 3060 12 GB.
Summary of the Alibaba-NLP/gte-reranker-modernbert-base model card, 2026-10-01
What it is
| Released by | Alibaba |
|---|---|
| Released | 2025-01-20 |
| Parameters | 150M |
| VRAM | 299 MB for the weights |
What it runs on
| Card | Runs | Memory |
|---|---|---|
| RTX 3060 12 GB | fits | 11.6 GB |
| RTX 4060 Ti 16 GB | fits | 15.4 GB |
| RTX 3090 24 GB | fits | 23.4 GB |
| RTX 4090 24 GB | fits | 23.4 GB |
| RTX 5090 32 GB | fits | 31.0 GB |
| L40S 48 GB | fits | 44.0 GB |
| A100 80 GB | fits | 78.2 GB |
| H100 80 GB | fits | 78.1 GB |
| RTX PRO 6000 Blackwell 96 GB | fits | 93.8 GB |
| DGX Spark (GB10) 128 GB unified | fits | 107 GB |
| H200 141 GB | fits | 138 GB |
| B200 180 GB | fits | 176 GB |
From the model card
We are excited to introduce the gte-modernbert series of models, which are built upon the latest modernBERT pre-trained encoder-only foundation models. The gte-modernbert series models include both text embedding models and rerank models.
The gte-modernbert models demonstrates competitive performance in several text embedding and text retrieval evaluation tasks when compared to similar-scale models from the current open-source community. This includes assessments such as MTEB, LoCO, and COIR evaluation.
| Models | Language | Model Type | Model Size | Max Seq. Length | Dimension | MTEB-en | BEIR | LoCo | CoIR |
|---|---|---|---|---|---|---|---|---|---|
gte-modernbert-base | English | text embedding | 149M | 8192 | 768 | 64.38 | 55.33 | 87.57 | 79.31 |
gte-reranker-modernbert-base | English | text reranker | 149M | 8192 | - | - | 56.19 | 90.68 | 79.99 |
[!TIP] For
transformersandsentence-transformers, if your GPU supports it, the efficient Flash Attention 2 will be used automatically if you haveflash_attninstalled. It is not mandatory.pip install flash_attn
Use with transformers
# Requires transformers>=4.48.0
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_name_or_path = "Alibaba-NLP/gte-reranker-modernbert-base"
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
model = AutoModelForSequenceClassification.from_pretrained(
model_name_or_path,
torch_dtype=torch.float16,
)
model.eval()
pairs = [
["what is the capital of China?", "Beijing"],
["how to implement quick sort in python?", "Introduction of quick sort"],
["how to implement quick sort in python?", "The weather is nice today"],
]
with torch.no_grad():
inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=512)
scores = model(**inputs, return_dict=True).logits.view(-1, ).float()
print(scores)
# tensor([ 2.1387, 2.4609, -1.6729])
Use with sentence-transformers:
Before you start, install the sentence-transformers libraries:
pip install sentence-transformers
# Requires transformers>=4.48.0
from sentence_transformers import CrossEncoder
model = CrossEncoder(
"Alibaba-NLP/gte-reranker-modernbert-base",
automodel_args={"torch_dtype": "auto"},
)
pairs = [
["what is the capital of China?", "Beijing"],
["how to implement quick sort in python?","Introduction of quick sort"],
["how to implement quick sort in python?", "The weather is nice today"],
]
scores = model.predict(pairs)
print(scores)
# [0.8945664 0.9213594 0.15742092]
# NOTE: Sentence Transformers calls Softmax over the outputs by default, hence the scores are in [0, 1] range.
Use with transformers.js
import {
AutoTokenizer,
AutoModelForSequenceClassification,
} from "@huggingface/transformers";
const model_id = "Alibaba-NLP/gte-reranker-modernbert-base";
const model = await AutoModelForSequenceClassification.from_pretrained(
model_id,
{ dtype: "fp32" }, // Supported options: "fp32", "fp16", "q8", "q4", "q4f16"
);
const tokenizer = await AutoTokenizer.from_pretrained(model_id);
const pairs = [
["what is the capital of China?", "Beijing"],
["how to implement quick sort in python?", "Introduction of quick sort"],
["how to implement quick sort in python?", "The weather is nice today"],
];
const inputs = tokenizer(
pairs.map((x) => x[0]),
{
text_pair: pairs.map((x) => x[1]),
padding: true,
truncation: true,
},
);
const { logits } = await model(inputs);
console.log(logits.tolist()); // [[2.138258218765259], [2.4609625339508057], [-1.6775450706481934]]
Additionally, you can also deploy Alibaba-NLP/gte-reranker-modernbert-base with Text Embeddings Inference (TEI) as follows:
docker run --platform linux/amd64 \
-p 8080:80 \
-v $PWD/data:/data \
--pull always \
ghcr.io/huggingface/text-embeddings-inference:cpu-1.7 \
--model-id Alibaba-NLP/gte-reranker-modernbert-base
docker run --gpus all \
-p 8080:80 \
-v $PWD/data:/data \
--pull always \
ghcr.io/huggingface/text-embeddings-inference:1.7 \
--model-id Alibaba-NLP/gte-reranker-modernbert-base
Then you can send requests to the deployed API via the /rerank route (see the Text Embeddings Inference OpenAPI Specification for more details):
curl https://0.0.0.0:8080/rerank \
-H "Content-Type: application/json" \
-d '{
"query": "What is the capital of China?",
"raw_scores": false,
"return_text": false,
"texts": [ "Beijing" ],
"truncate": true,
"truncation_direction": "right"
}'
The gte-modernbert series of models follows the training scheme of the previous GTE models, with the only difference being that the pre-training language model base has been replaced from GTE-MLM to ModernBert. For more training details, please refer to our paper: [mGTE: Generalized Long-Context Text Representation and
Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.