talira

Model2Vec

Fast state-of-the-art static embeddings, and lightweight classifiers trained on top of them

open sourceMITself-hostablefree

Model2Vec turns a sentence transformer into a small static embedding model: it runs every token of the vocabulary through the model once, stores one vector per token, and makes a sentence embedding by averaging token vectors, so inference is a table lookup that runs on CPU with numpy as the only major dependency. Minish's pre-trained Potion models (1.8M to 128M parameters, most distilled from bge-base-en-v1.5 or bge-m3) load from Hugging Face, and you can distill your own from any Sentence Transformer in about 30 seconds without a dataset. With the train extra it fine-tunes single- or multi-label text classifiers on top of a static model and saves them as scikit-learn pipelines that run without torch; in Minish's own benchmark of 26 datasets these averaged a slightly higher F1 than SetFit while classifying about 80 times faster. An official Rust crate, model2vec-rs, loads the same models.

Problems it solves

  • sort short search queries into a handful of intents in microseconds on a CPU, with no GPU and no API calls
  • my sentence-transformer embeddings are too slow and heavy to run inside a small web service
  • train a text classifier on a few thousand labelled rows in minutes on my laptop
  • hand-written keyword rules beat the zero-shot model at routing queries; I want a learned classifier that's just as cheap to run
  • an embedding model of a few tens of megabytes that I can ship inside a CLI or a serverless function
  • deploy a trained text classifier to production without installing PyTorch
  • shrink an existing embedding model into a much faster one without collecting a training dataset
  • embed millions of short texts for clustering or deduplication in minutes on CPU
  • multi-label tagging of support messages at tens of thousands of texts per second
  • run the same embedding model from Python and from a Rust service
  • multilingual sentence embeddings that load instantly and don't need a GPU

Features

  • distills any Sentence Transformer into a static model in about 30 seconds on CPU, without a dataset
  • pre-trained Potion models on Hugging Face: English, multilingual, retrieval and code
  • up to 50x smaller and up to 500x faster than the source model on CPU (maker's figures)
  • mean embeddings and per-token sequence embeddings
  • fine-tuning for single- and multi-label classification, similarity, regression and pair similarity
  • trained classifiers export to scikit-learn pipelines that run without torch
  • push and load models and classifiers on the Hugging Face Hub
  • optional float16 or int8 quantization and vocabulary quantization
  • loads directly in Sentence Transformers and LangChain
  • official Rust implementation (model2vec-rs)

Alternatives

The same job

These do what Model2Vec does.

  1. GLiNER2.5-Decide The 340M English classification model in the GLiNER2.5 family: any label set at call time, no generated tokens
  2. SetFit Efficient few-shot learning with Sentence Transformers
  3. FastEmbed Fast, light, accurate library built for retrieval embedding generation
  4. model2vec-rs Fast State-of-the-Art Static Embeddings in Rust

Compare Model2Vec with the top 3