Views
No views yet
pip install model2vecfrom_pretrained method:1from model2vec import StaticModel
2
3# Load a pretrained Model2Vec model
4model = StaticModel.from_pretrained("stephantulkens/NIFE-mxbai-embed-large-v1_model2vec")
5
6# Compute text embeddings
7embeddings = model.encode(["Example sentence"])1from sentence_transformers import SentenceTransformer
2
3# Load a pretrained Sentence Transformer model
4model = SentenceTransformer("stephantulkens/NIFE-mxbai-embed-large-v1_model2vec")
5
6# Compute text embeddings
7embeddings = model.encode(["Example sentence"])distill method. First, install the distill extra with pip install model2vec[distill]. Then, run the following code:1from model2vec.distill import distill
2
3# Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
4m2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)
5
6# Save the model
7m2v_model.save_pretrained("m2v_model")@software{minishlab2024model2vec,
author = {Stephan Tulkens and {van Dongen}, Thomas},
title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
year = {2024},
publisher = {Zenodo},
doi = {10.5281/zenodo.17270888},
url = {https://github.com/MinishLab/model2vec},
license = {MIT}
}