⚠️ A Word of Warning: This Might Not Be the Model You're Looking For
This model is an experimental distillation of NVIDIA's powerful llama-embed-nemotron-8b (4096 dimensions), aggressively compressed into a mere 3 dimensions.
When to Use This Model:
For visualizing how sentences cluster in a 3D space.
For educational purposes to understand the information loss from extreme dimensionality reduction.
For a good laugh, and to ask yourself, "Why would anyone do this?"
When NOT to Use This Model:
Semantic Search
Retrieval-Augmented Generation (RAG)
Sentence Similarity
Clustering
Basically, any real-world production task.
Attempting to use this for any serious embedding task will result in abysmal performance. If you value your time and sanity, please use this model for its intended (mostly humorous) purpose.
You have been warned.
llama-embed-nemotron-8b-model2vec-pca3 Model Card
This Model2Vec model is a distilled version of the nvidia/llama-embed-nemotron-8b(https://huggingface.co/nvidia/llama-embed-nemotron-8b) 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.
Installation
Install model2vec using pip:
pip install model2vec
Usage
Using Model2Vec
The Model2Vec library is the fastest and most lightweight way to run Model2Vec models.
Load this model using the from_pretrained method:
python
1from model2vec import StaticModel
23# Load a pretrained Model2Vec model4model = StaticModel.from_pretrained("enzoescipy/llama-embed-nemotron-8b-model2vec-pca3")56# Compute text embeddings7embeddings = model.encode(["Example sentence"])
1from sentence_transformers import SentenceTransformer
23# Load a pretrained Sentence Transformer model4model = SentenceTransformer("enzoescipy/llama-embed-nemotron-8b-model2vec-pca3")56# Compute text embeddings7embeddings = model.encode(["Example sentence"])
Distilling a Model2Vec model
You can distill a Model2Vec model from a Sentence Transformer model using the distill method. First, install the distill extra with pip install model2vec[distill]. Then, run the following code:
python
1from model2vec.distill import distill
23# Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model4m2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)56# Save the model7m2v_model.save_pretrained("m2v_model")
How it works
Model2vec creates a small, fast, and powerful model that outperforms other static embedding models by a large margin on all tasks we could find, while being much faster to create than traditional static embedding models such as GloVe. Best of all, you don't need any data to distill a model using Model2Vec.
It works by passing a vocabulary through a sentence transformer model, then reducing the dimensionality of the resulting embeddings using PCA, and finally weighting the embeddings using SIF weighting. During inference, we simply take the mean of all token embeddings occurring in a sentence.
@article{minishlab2024model2vec,
author = {Tulkens, Stephan and {van Dongen}, Thomas},
title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
year = {2024},
url = {https://github.com/MinishLab/model2vec}
}