granite embedding small english r2

Provideribm-granite
Categoryfeature-extraction
Licenseapache-2.0
Downloads138
Stars0

Overview

The granite-embedding-small-english-r2 is a lightweight, English-centric feature extraction model designed for high-efficiency vectorization. Unlike larger LLMs, this model focuses specifically on transforming text into dense embeddings, making it an ideal choice for developers building RAG (Retrieval-Augmented Generation) pipelines, semantic search engines, or clustering applications where latency and memory overhead are critical constraints. It balances performance with a small footprint, allowing for faster indexing and lower inference costs compared to heavyweight embedding models. Integration is straightforward via standard embedding APIs, and its Apache-2.0 license provides the flexibility needed for commercial deployment without restrictive vendor lock-in.

Highlights

  • Optimized for low-latency semantic search and RAG pipelines
  • Lightweight architecture reduces memory and infrastructure costs
  • Apache-2.0 license enables flexible commercial integration
  • High-efficiency text-to-vector conversion for English datasets

Usage

Install
# Install Hugging Face transformers
pip install transformers torch
SDK Usage
# Load model with transformers
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("ibm-granite/granite-embedding-small-english-r2")
tokenizer = AutoTokenizer.from_pretrained("ibm-granite/granite-embedding-small-english-r2")

Hugging Face Download

We recommend downloading the model via the Hugging Face CLI or Hub SDK.

Guidance:Before downloading, install huggingface_hub with:

Guidance
pip install -U huggingface_hub

CLI Download

Download the full repository

Download the full repository
huggingface-cli download ibm-granite/granite-embedding-small-english-r2

Download a single file to a local folder (e.g. config.json into ./dir)

Download a single file to a local folder (e.g. config.json into ./dir)
huggingface-cli download ibm-granite/granite-embedding-small-english-r2 config.json --local-dir ./dir

See the official docs for more CLI options

SDK Download

SDK Download
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('ibm-granite/granite-embedding-small-english-r2')

Git Download

Make sure git-lfs is installed first

Git Download
git lfs install
git clone https://huggingface.co/ibm-granite/granite-embedding-small-english-r2

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/ibm-granite/granite-embedding-small-english-r2

Model files are hosted on the Hugging Face Hub — download directly via HF CLI / SDK / Git, not through this site.

PyTorch / Transformers Usage

Install Transformers

Install Transformers
pip install -U transformers torch

Load the model and run inference

Load the model and run inference
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('ibm-granite/granite-embedding-small-english-r2')
tokenizer = AutoTokenizer.from_pretrained('ibm-granite/granite-embedding-small-english-r2')

Model Download

We recommend downloading the model via the ModelScope CLI or SDK.

Guidance:Before downloading, install ModelScope with:

Guidance
pip install modelscope

CLI Download

Download the full repository

Download the full repository
modelscope download --model ibm-granite/granite-embedding-small-english-r2

Download a single file to a local folder (e.g. README.md into ./dir)

Download a single file to a local folder (e.g. README.md into ./dir)
modelscope download --model ibm-granite/granite-embedding-small-english-r2 README.md --local_dir ./dir

See the docs for more CLI options

SDK Download

SDK Download
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('ibm-granite/granite-embedding-small-english-r2')

Git Download

Make sure git-lfs is installed first

Git Download
git lfs install
git clone https://www.modelscope.cn/ibm-granite/granite-embedding-small-english-r2.git

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/ibm-granite/granite-embedding-small-english-r2.git

ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。

Notebook Quickstart

Install the ModelScope library

Install the ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

Load the model and run inference

Load the model and run inference
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

p = pipeline('text-generation', 'ibm-granite/granite-embedding-small-english-r2')

Full Documentation

来源: HuggingFace

---
language:

  • en

library_name: sentence-transformers
license: apache-2.0
pipeline_tag: feature-extraction
tags:
  • granite

  • embeddings

  • transformers

  • mteb

  • feature-extraction

---

Granite-Embedding-Small-English-R2

<!-- Provide a quick summary of what the model is/does. -->

Model Summary: Granite-embedding-small-english-r2 is a 47M parameter dense biencoder embedding model from the Granite Embeddings collection that can be used to generate high quality text embeddings. This model produces embedding vectors of size 384 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 r2 models show strong performance across standard and IBM-built information retrieval benchmarks (BEIR, ClapNQ),
code retrieval (COIR), long-document search benchmarks (MLDR, LongEmbed), conversational multi-turn (MTRAG),
table retrieval (NQTables, OTT-QA, AIT-QA, MultiHierTT, OpenWikiTables), and on many enterprise use cases.

These models use a bi-encoder architecture to generate high-quality embeddings from text inputs such as queries, passages, and documents, enabling seamless comparison through cosine similarity. Built using retrieval oriented pretraining, contrastive finetuning, knowledge distillation, and model merging, granite-embedding-small-english-r2 is optimized to ensure strong alignment between query and passage embeddings.

The latest granite embedding r2 release introduces two English embedding models, both based on the ModernBERT architecture:

  • _granite-embedding-english-r2_ (149M parameters): with an output embedding size of _768_, replacing _granite-embedding-125m-english_.

  • _granite-embedding-small-english-r2_ (47M parameters): A _first-of-its-kind_ reduced-size model, with 8192 context length support, fewer layers and a smaller output embedding size (_384_), replacing _granite-embedding-30m-english_.

Model Details

  • Developed by: Granite Embedding Team, IBM
  • Language(s): English
  • Release Date: Aug 15, 2025

Usage

Intended Use: The model is designed to produce fixed length vector representations for a given text, which can be used for text similarity, retrieval, and search applications.

For efficient decoding, these models use Flash Attention 2. Installing it is optional, but can lead to faster inference.

shell
pip install flash_attn==2.6.1

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->

Usage with Sentence Transformers:

The model is compatible with SentenceTransformer library and is very easy to use:

First, install the sentence transformers library

shell
pip install sentence_transformers

The model can then be used to encode pairs of text and find the similarity between their representations

python
from sentence_transformers import SentenceTransformer, util

model_path = "ibm-granite/granite-embedding-small-english-r2"

Load the Sentence Transformer model


model = SentenceTransformer(model_path)

input_queries = [
' Who made the song My achy breaky heart? ',
'summit define'
]

input_passages = [
"Achy Breaky Heart is a country song written by Don Von Tress. Originally titled Don't Tell My Heart and performed by The Marcy Brothers in 1991. ",
"Definition of summit for English Language Learners. : 1 the highest point of a mountain : the top of a mountain. : 2 the highest level. : 3 a meeting or series of meetings between the leaders of two or more governments."
]

encode queries and passages. The model produces unnormalized vectors. If your task requires normalized embeddings pass normalize_embeddings=True to encode as below.

query_embeddings = model.encode(input_queries) passage_embeddings = model.encode(input_passages)

calculate cosine similarity

print(util.cos_sim(query_embeddings, passage_embeddings))

Usage with Huggingface Transformers:

This is a simple example of how to use the granite-embedding-small-english-r2 model with the Transformers library and PyTorch.

First, install the required libraries

shell
pip install transformers torch

The model can then be used to encode pairs of text

python
import torch
from transformers import AutoModel, AutoTokenizer

model_path = "ibm-granite/granite-embedding-small-english-r2"

Load the model and tokenizer

model = AutoModel.from_pretrained(model_path) tokenizer = AutoTokenizer.from_pretrained(model_path) model.eval()

input_queries = [
' Who made the song My achy breaky heart? ',
'summit define'
]

tokenize inputs

tokenized_queries = tokenizer(input_queries, padding=True, truncation=True, return_tensors='pt')

encode queries

with torch.no_grad(): # Queries model_output = model(tokenized_queries) # Perform pooling. granite-embedding-278m-multilingual uses CLS Pooling query_embeddings = model_output[0][:, 0]

normalize the embeddings

query_embeddings = torch.nn.functional.normalize(query_embeddings, dim=1)

Evaluation Results

Granite embedding r2 models show a strong performance across tasks diverse tasks.

Performance of the granite models on MTEB Retrieval (i.e., BEIR), MTEB-v2, code retrieval (CoIR), long-document search benchmarks (MLDR, LongEmbed), conversational multi-turn (MTRAG),
table retrieval (NQTables, OTT-QA, AIT-QA, MultiHierTT, OpenWikiTables), benchmarks is reported in the below tables.

The average speed to encode documents on a single H100 GPU using a sliding window with 512 context length chunks is also reported.
Nearing encoding speed of 200 documents per second granite-embedding-small-english-r2 demonstrates speed and efficiency, while mainintaining competitive performance.

| Model | Parameters (M) | Embedding Size | BEIR Retrieval (15) | MTEB-v2 (41)| CoIR (10) | MLDR (En) | MTRAG (4) | Encoding Speed (dosc/sec) |
|------------------------------------|:--------------:|:--------------:|:-------------------:|:-----------:|:---------:|:---------:|:---------:|:-------------------------------:|
| granite-embedding-125m-english | 125 | 768 | 52.3 | 62.1 | 50.3 | 35.0 | 49.4 | 149 |
| granite-embedding-30m-english | 30 | 384 | 49.1 | 60.2 | 47.0 | 32.6 | 48.6 | 198 |
| granite-embedding-english-r2 | 149 | 768 | 53.1 | 62.8 | 55.3 | 40.7 | 56.7 | 144 |
| granite-embedding-small-english-r2 | 47 | 384 | 50.9 | 61.1 | 53.8 | 39.8 | 48.1 | 199 |

|Model | Parameters (M)| Embedding Size|AVERAGE**|MTEB-v2 Retrieval (10)| CoIR (10)| MLDR (En)| LongEmbed (6)| Table IR (5)| MTRAG (4) | Encoding Speed (docs/sec)|
|-----------------------------------|:-------------:|:-------------:|:---------:|:--------------------:|:--------:|:--------:|:------------:|:-----------:|:--------:|-----------:|
|e5-small-v2 |33|384|45.39|48.5|47.1|29.9|40.7|72.31|33.8| 138|
|bge-small-en-v1.5 |33|384|45.22|53.9|45.8|31.4|32.1|69.91|38.2| 138|
|||||||||||
|granite-embedding-english-r2 |149|768|59.5|56.4|54.8|41.6|67.8|78.53|57.6| 144|
|granite-embedding-small-english-r2 | 47|384|55.6|53.

Join our Telegram