---
license: apache-2.0
language:
Model Summary:
granite-embedding-reranker-english-r2 is a 149M parameter dense cross-encoder model from the Granite Embeddings collection that can be used to generate high quality text embeddings. This model produces embedding vectors of size 768 based on context length of upto 8192 tokens. Compared to most other open-source models, this model was only trained using open-source relevance-pair datasets with permissive, enterprise-friendly license, plus IBM collected and generated datasets.The
granite-embedding-reranker-english-r2 model uses a cross-encoder architecture to compute high-quality relevance scores between queries and documents by jointly encoding their text, enabling precise reranking based on contextual alignment.The latest granite embedding r2 release introduces two English embedding models, and one English reranking all based on the ModernBERT architecture:
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
The model is designed to compute relevance scores for query-document pairs, making it well-suited for reranking tasks in information retrieval and search applications.
Usage with Sentence Transformers:
The model is compatible with SentenceTransformer library and is very easy to use:
First, install the sentence transformers library
pip install sentence_transformers
The model can then be used to jointly encode pairs of text to compute a relevance score.
from sentence_transformers import CrossEncoder, util
model_path = "ibm-granite/granite-embedding-reranker-english-r2"
# Load the Sentence Transformer model
model = CrossEncoder(model_path)
passages = [
"Romeo and Juliet is a play by William Shakespeare.",
"Climate change refers to long-term shifts in temperatures.",
"Shakespeare also wrote Hamlet and Macbeth.",
"Water is an inorganic compound with the chemical formula H2O.",
"In liquid form, H2O is also called 'water' at standard temperature and pressure."
]
query = "what is the chemical formula of water?"
# encodes query and passages jointly and computes relevance score.
ranks = model.rank(query, passages, return_documents=True)
# Print document rank and relevance score
for rank in ranks:
print(f"- #{rank['corpus_id']} ({rank['score']:.2f}): {rank['text']}")
Usage with Huggingface Transformers:
This is a simple example of how to use the reranking model with the Transformers library and PyTorch.
First, install the required libraries
pip install transformers torch
The model can then be used to encode pairs of text
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_path = "ibm-granite/granite-embedding-reranker-english-r2"
# Load the model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained(model_path).eval()
tokenizer = AutoTokenizer.from_pretrained(model_path)
pairs = [
["what is the chemical formula of water?", "Water is an inorganic compound with the chemical formula H2O."],
["what is the chemical formula of water?", "In liquid form, H2O is also called 'water' at standard temperature and pressure."],
["how to implement quick sort in python?", "The weather is nice today"],
]
# tokenize inputs
tokenized_pairs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt')
# encode and compute scores
with torch.no_grad():
scores = model(**tokenized_pairs, return_dict=True).logits.view(-1, ).float()
print(scores)
Usage with Huggingface Transformers (Retriever + Reranker E2E):
This is a simple example of how to use the Granite retriever and reranker together end-to-end with the Transformers library and PyTorch. The retriever first finds the most relevant candidate documents for a query, and then the reranker re-orders those candidates to produce the final ranked list.
import torch
from transformers import AutoModel, AutoTokenizer, AutoModelForSequenceClassification
# --------------------------
# 1. Load retriever (149M)
# --------------------------
retriever_model_path = "ibm-granite/granite-embedding-english-r2"
retriever = AutoModel.from_pretrained(retriever_model_path).eval()
retriever_tokenizer = AutoTokenizer.from_pretrained(retriever_model_path)
# Example query + candidate documents
query = "what is the chemical formula of water?"
documents = [
"Water is an inorganic compound with the chemical formula H2O.",
"In liquid form, H2O is also called 'water' at standard temperature and pressure.",
"The weather is nice today",
"Quick sort is a divide and conquer algorithm that sorts by partitioning."
]
# Encode query and documents
with torch.no_grad():
query_emb = retriever(
**retriever_tokenizer(query, return_tensors="pt", truncation=True, padding=True)
).last_hidden_state[:, 0, :] # CLS embedding
doc_embs = retriever(
**retriever_tokenizer(documents, return_tensors="pt", truncation=True, padding=True)
).last_hidden_state[:, 0, :]
# Compute cosine similarity
query_emb = torch.nn.functional.normalize(query_emb, dim=-1)
doc_embs = torch.nn.functional.normalize(doc_embs, dim=-1)
similarities = torch.matmul(query_emb, doc_embs.T).squeeze(0)
# Rank docs by retriever
retriever_ranked = sorted(
zip(documents, similarities.tolist()),
key=lambda x: x[1],
reverse=True
)
print("Retriever ranking:")
for doc, score in retriever_ranked:
print(f"{score:.4f} | {doc}")
# --------------------------
# 2. Load reranker (149M)
# --------------------------
reranker_model_path = "ibm-granite/granite-embedding-reranker-english-r2"
reranker = AutoModelForSequenceClassification.from_pretrained(reranker_model_path).eval()
reranker_tokenizer = AutoTokenizer.from_pretrained(reranker_model_path)
# Prepare top-k candidates (say top 3 from retriever)
top_k = 3
candidate_pairs = [[query, doc] for doc, _ in retriever_ranked[:top_k]]
# Tokenize and rerank
with torch.no_grad():
tokenized_pairs = reranker_tokenizer(
candidate_pairs, padding=True, truncation=True, return_tensors="pt"
)
rerank_scores = reranker(**tokenized_pairs).logits.view(-1, ).float()
# Rank docs by reranker
reranker_ranked = sorted(
zip([doc for doc, _ in retriever_ranked[:top_k]], rerank_scores.tolist()),
key=lambda x: x[1],
reverse=True
)
print("\nReranker final ranking:")
for doc, score in reranker_ranked:
print(f"{score:.4f} | {doc}")
Usage with Hugging Face Text Embeddings Inference (TEI):
This is a simple example of how to deploy the reranking model with Text Embeddings Inference (TEI), a blazing fast inference solution for text embedding models, via Docker.
docker run -p 8080:80 -v hf_cache:/data --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-latest --model-id ibm-granite/granite-embedding-reranker-english-r2
docker run --gpus all -p 8080:80 -v hf_cache:/data --pull always ghcr.io/huggingface/text-embeddings-inference:cuda-latest --model-id ibm-granite/granite-embedding-reranker-english-r2
Then you can send requests to the deployed API via the /rerank route (see the Text Embeddings Inference OpenAPI Specification for more details):
curl http://0.0.0.0:8080/rerank \
-H "Content-Type: application/json" \
-d '{
"query": "what is the chemical formula of water?",
"texts": [
"Water is an inorganic compound with the chemical formula H2O.",
"In liquid form, H2O is also called '\''water'\'' at standard temperature and pressure.",
"The weather is nice today",
"Quick sort is a divide and conquer algorithm that sorts by partitioning."
],
"raw_scores": false,
"return_text": false,
"truncate": true,
"truncation_direction": "Right"
}'
The performance of the Granite Embedding English reranking model on BEIR, MLDR, and Miracl benchmarks is reported below. All models are evaluated on the top-20 documents retrieved from the granite-embedding-english-small-r2 or granite-embedding-english-r2 retrievers respectively.
Each reranking model is evaluated with its maximum supported sequence length, while queries are truncated to 64 tokens.
| Model | Parameters (M) | Seq. Length | BEIR Avg. | MLDR (en) | Miracl (en) |
|---|---|---|---|---|---|
| Retriever: granite-embedding-small-english-r2 | 47 | 8192 | 50.9 | 40.1 | 42.4 |
| ms-marco-MiniLM-L12-v2 | 33 | 512 | 52.0 | 34.8 | 54.5 |
| bge-reranker-base | 278 | 512 | 51.6 | 36.7 | 40.7 |
| bge-reranker-large | 560 | 512 | 53.0 | 37.9 | 42.2 |
| gte-reranker-modernbert-base | 149 | 8192 | 54.8 | 50.4 | 54.3 |
| granite-embedding-reranker-english-r2 | 149 | 8192 | 55.0 | 44.9 | 54.2 |
| Retriever: granite-embedding-english-r2 | 149 | 8192 | 53.1 | 41.6 | 43.6 |
| ms-marco-MiniLM-L12-v2 | 33 | 512 | 53.2 | 34.5 | 55.4 |
| bge-reranker-base | 278 | 512 | 53.0 | 36.6 | 40.9 |
| bge-reranker-large | 560 | 512 | 54.3 | 38.0 | 42.3 |
| gte-reranker-modernbert-base | 149 | 8192 | 56.1 | 51.2 | 54.8 |
| granite-embedding-reranker-english-r2 | 149 | 8192 | 55.8 | 45.8 | 55.2 |
The latest Granite Reranking r2 release introduces an English ranking model, based on the ModernBERT architecture:
The following table shows the structure of the two R2 models:
| Model | granite-embedding-reranker-english-r2 |
|---|---|
| Embedding size | 768 |
| Number of layers | 22 |
| Number of attention heads | 12 |
| Intermediate size | 1152 |
| Activation Function | GeGLU |
| Vocabulary Size | 50368 |
| Max. Sequence Length | 8192 |
| # Parameters | 149M |
The r2 models incorporate key enhancements from the ModernBERT architecture, including:
Notably, we do not use the popular MS-MARCO retrieval dataset in our training corpus due to its non-commercial license (many open-source models use this dataset due to its high quality).
The underlying encoder models using GneissWeb, an IBM-curated dataset composed exclusively of open, commercial-friendly sources.
For governance, all our data undergoes a data clearance process subject to technical, business, and governance review.
This comprehensive process captures critical information about the data, including but not limited to their content description ownership, intended use, data classification, licensing information, usage restrictions, how the data will be acquired, as well as an assessment of sensitive information (i.e, personal information).
@misc{awasthy2025graniteembeddingr2models,
title={Granite Embedding R2 Models},
author={Parul Awasthy and Aashka Trivedi and Yulong Li and Meet Doshi and Riyaz Bhat and Vignesh P and Vishwajeet Kumar and Yushu Yang and Bhavani Iyer and Abraham Daniels and Rudra Murthy and Ken Barker and Martin Franz and Madison Lee and Todd Ward and Salim Roukos and David Cox and Luis Lastras and Jaydeep Sen and Radu Florian},
year={2025},
eprint={2508.21085},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2508.21085},
}