This
Model2Vec model is a distilled version of the ibm-granite/granite-embedding-30m-english(
https://huggingface.co/ibm-granite/granite-embedding-30m-english) Sentence Transformer. It uses static embeddings, allowing text embeddings to be computed orders of magnitude faster on both GPU and CPU. It is designed for applications where computational resources are limited or where real-time performance is critical. Model2Vec models are the smallest, fastest, and most performant static embedders available. The distilled models are up to 50 times smaller and 500 times faster than traditional Sentence Transformers.
The
Model2Vec library is the fastest and most lightweight way to run Model2Vec models.
1from model2vec import StaticModel
2
3# Load a pretrained Model2Vec model
4model = StaticModel.from_pretrained("cnmoro/granite-30m-distilled")
5
6# Compute text embeddings
7embeddings = model.encode(["Example sentence"])
You can also use the
Sentence Transformers library to load and use the model:
1from sentence_transformers import SentenceTransformer
2
3# Load a pretrained Sentence Transformer model
4model = SentenceTransformer("cnmoro/granite-30m-distilled")
5
6# Compute text embeddings
7embeddings = model.encode(["Example sentence"])