Skip to main content

Model Collection

View the full Granite Embedding collection on Hugging Face

Run locally with Ollama

Download and run Granite Embedding with Ollama

Replicate

Deploy Granite Embedding on Replicate

Overview

The Granite Embedding model collection consists of embedding models to generate high-quality text embeddings and a reranker model to improve the relevance and quality of search results or recommendations. The embedding models output vector representations (aka embeddings) of textual inputs such as queries, passages, and documents to capture the semantic meaning of the input text. The primary use cases for these embeddings are in semantic search and retrieval-augmented generation (RAG) applications. The Granite Embedding Reranker model is optional, but useful to further improve the relevance and quality of search results or recommendations. After the initial retrieval of items based on their embeddings, the reranker refines the ranking by considering additional factors and more complex criteria. Built on a foundation of carefully curated, permissibly licensed public datasets, the Granite Embedding models achieve state-of-the-art results in their respective weight classes. On the MTEB Leaderboard, granite-embedding-97m-multilingual-r2 ranks #1 for multilingual embedding models under 100M parameters, and granite-embedding-311m-multilingual-r2 ranks #2 for multilingual embedding models under 500M parameters. Granite Embedding models are released under the Apache 2.0 license, making them freely available for both research and commercial purposes, with full transparency into their training data. Granite Embedding Paper

Getting Started

Intended Use

The Granite Embedding 311m multilingual model is designed to produce fixed-length vector representations for a given text, which can be used for text similarity, retrieval, and search applications across multiple languages. It supports 200+ languages with enhanced support for 52 languages. For efficient inference, these models support Flash Attention 2. Installing it is optional but can lead to faster encoding:

Usage with Sentence Transformers

The model is compatible with the SentenceTransformer library and is very easy to use: First, install the sentence transformers library:
The model can then be used to encode pairs of text and find the similarity between their representations:

Matryoshka Representation Learning

This model supports Matryoshka Representation Learning (MRL), which allows you to truncate embeddings to smaller dimensions (e.g., 512, 256, 128) with graceful performance degradation. This is useful for reducing storage and memory requirements.

Usage with Hugging Face Transformers

This is a simple example of how to use the granite-embedding-311m-multilingual-r2 model with the Transformers library and PyTorch. For a complete retrieval workflow including passage encoding and cosine similarity, see the Sentence Transformers example above. First, install the required libraries:
The model can then be used to encode text:

Optimized Inference and Deployment

ONNX and OpenVINO

Pre-converted ONNX and OpenVINO models are released alongside the PyTorch weights for production deployment. These can be loaded through the Optimum library:
The ONNX model is compatible with any ONNX Runtime backend (CPU, CUDA, TensorRT, DirectML). The OpenVINO model is optimized for Intel hardware including CPUs and integrated GPUs.

vLLM

The model can be served as an embedding endpoint using vLLM: