Registry / ai-ml / model2vec

model2vec

JSON →
library0.9.0pypypi✓ verified 22d ago

Model2Vec is a Python library designed for training and using state-of-the-art static embeddings for various NLP tasks like classification, clustering, and semantic search. Built on top of Hugging Face's `transformers` library, it aims for fast and efficient embedding generation. The current version is 0.8.1, and it maintains an active release cadence with updates typically occurring monthly or bi-monthly.

pip install model2vec
INSTALL
IMPORT
SIG · MODEL2VEC
M
model2vec
ai-mlpythonv0.9.0
Install
7.1s avg
Import
768ms
Disk
148MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.808s · 152.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 7.1s · import 0.728s · 131MB
148MB installed
● package 148MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

StaticModel
from model2vec import StaticModel
from model2vec import Model2Vec

Initialize a Model2Vec instance with a pre-trained model from Hugging Face Hub and use it to encode a list of sentences into embeddings.

from model2vec import Model2Vec import os # Load a pre-trained model. Specify 'device' for CPU/GPU. # Example uses a dummy device for quickstart portability. model = Model2Vec("minishlab/m2v_base", device=os.environ.get('MODEL2VEC_DEVICE', 'cpu')) # Get embeddings for some text sentences = [ "This is a test sentence for model2vec.", "Another example sentence to demonstrate embedding." ] embeddings = model.encode(sentences) print(f"Embeddings shape: {embeddings.shape}") # Expected output for base model: Embeddings shape: (2, 768)
model2vec --version
Debug
Known issues
breakingThe `v0.5.0` release included a significant 'rewrite backend' which likely introduced breaking changes to the API, particularly around model initialization and internal component access. Users upgrading from versions prior to 0.5.0 may need to refactor their code.
fix
Refer to the GitHub changelog for v0.5.0 and the updated documentation/examples for `Model2Vec` initialization and usage patterns.
affects: <0.5.0 to 0.5.0
gotchaPrior to `v0.8.1`, Windows users might encounter path-related issues when loading models or processing data due to non-POSIX path handling. This was addressed in v0.8.1.
fix
Upgrade to `model2vec==0.8.1` or newer for improved Windows compatibility.
affects: <0.8.1
gotchaModel2Vec relies heavily on Hugging Face `transformers`. Mismatches or outdated versions of `transformers` can lead to issues with tokenizers, padding, or model loading. Version `v0.7.0` specifically included a fix for padding token recognition and an update to `transformers` usage.
fix
Ensure your `transformers` library is kept up-to-date, preferably to a version compatible with your `model2vec` installation. Consult the `model2vec` `pyproject.toml` or `setup.py` for exact `transformers` version constraints.
affects: <0.7.0
Upgrade
Version history
0.9.0latest on PyPI · released Aug 12, 2026
Audit
Dependencies
transformersrequiredCore dependency for underlying model architectures and tokenizers.
torchrequiredPrimary deep learning framework for model operations.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
model2vec — pip install model2vec · libregistry