RepoIBM (Granite)IBM (Granite)published Dec 10, 2024seen 5d

ibm-granite/granite-embedding-models

Jupyter Notebook

Open original ↗

Captured source

source ↗

ibm-granite/granite-embedding-models

Language: Jupyter Notebook

License: Apache-2.0

Stars: 71

Forks: 4

Open issues: 4

Created: 2024-12-10T16:14:10Z

Pushed: 2026-05-14T02:40:11Z

Default branch: main

Fork: no

Archived: no

README: ---

Introduction to Granite Embedding Models

The Granite Embedding collection delivers innovative sentence-transformer models purpose-built for retrieval-based applications. Featuring a bi-encoder architecture, these models generate high-quality embeddings for textual 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, the Granite Embedding lineup is optimized to ensure strong alignment between query and passage embeddings.

Built on a foundation of carefully curated, permissibly licensed public datasets, the Granite Embedding models set a high standard for performance, maintaining competitive scores not only on academic benchmarks such as BEIR, but also out-perfoming models of the same size on many enterprise use cases. Developed to meet enterprise-grade expectations, they are crafted transparently in accordance with IBM's AI Ethics principles and offered under the Apache 2.0 license for both research and commercial innovation.

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. For details on improvements over R1, see [What's New in R2](whats_new_in_r2.md).

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, the Granite Embedding R2 models are optimized to ensure strong alignment between query and passage embeddings.

The Granite Embedding R2 release introduces English and Multilingual models, all based on the ModernBERT architecture:

English:

  • 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 reduced-size model, with fewer layers and a smaller output embedding size (_384_), replacing _granite-embedding-30m-english_.

Multilingual:

Model Details

  • Developed by: Granite Embedding Team, IBM
  • Repository: ibm-granite/granite-embedding-models
  • Paper: [Techincal Report](papers/GraniteEmbeddingR2.pdf)
  • Language(s) (NLP): English (all models), 200+ languages with enhanced retrieval for 52 languages (multilingual models)
  • Release Date: Aug 15, 2025 (English) / April 29, 2026 (Multilingual)
  • Model Size: 47M & 149M (English) / 97M & 311M (Multilingual)
  • License: Apache 2.0

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.

pip install flash_attn

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 encode pairs of text and find the similarity between their representations

from sentence_transformers import SentenceTransformer, util

model_path = "ibm-granite/granite-embedding-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-english-r2 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 AutoModel, AutoTokenizer

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

# Load the model and tokenizer
model = AutoModel.from_pretrained(model_path)…

Excerpt shown — open the source for the full document.

Notability

notability 5.0/10

Solid new repo with moderate traction