Installation

To distill, make sure you install the distill extra:

pip install model2vec[distill]

Distilling a Model from a Sentence Transformer

To distill a model from a Sentence Transformer, you can use the distill function. This function allows you to create a lightweight static model from any Sentence Transformer. This can be done on a CPU in a few minutes.

from model2vec.distill import distill

# Distill a Sentence Transformer model
m2v_model = distill(model_name="BAAI/bge-base-en-v1.5")

# Save the model
m2v_model.save_pretrained("m2v_model")