guilherme-miranda/m2v-bge-m3-ptbr-en
m2v-bge-m3-ptbr-en
A compact Portuguese + English Model2Vec static embedding model, distilled from BAAI/bge-m3.
It keeps essentially the retrieval quality of bge-m3 for Portuguese (pt-BR) and English (including code identifiers) while being ~10x smaller than the multilingual static model, by dropping non-Latin-script tokens from the vocabulary. Built for fast local semantic code/text search — e.g. as a drop-in model for semble.
Why this exists
The only ready-made multilingual Model2Vec model (potion-multilingual-128M) is ~1 GB because it carries the vocabulary of 100+ languages. For a project that only needs English + Portuguese, most of that is dead weight. This model removes non-Latin scripts (CJK, Cyrillic, Arabic, etc.) while preserving Latin letters, Portuguese accents and subword tokens — so multi-word code identifiers still work.
Details
In blind retrieval queries it matched potion-multilingual-128M (1 GB) at a fraction of the size, including correctly handling Portuguese homonyms that the English-only code model got wrong.
Usage
With Model2Vec
from model2vec import StaticModel
model = StaticModel.from_pretrained("guilherme-miranda/m2v-bge-m3-ptbr-en")
embeddings = model.encode(["autenticação de usuário", "user authentication controller"])With semble (fast code search)
Point semble at this model via an environment variable:
export SEMBLE_MODEL_NAME="guilherme-miranda/m2v-bge-m3-ptbr-en"
semble search "rate limiting middleware" ./my-projectHow Model2Vec works
It passes a vocabulary through a Sentence Transformer, reduces dimensionality with PCA, and applies SIF weighting. At inference it averages the static token embeddings in a sentence — no transformer forward pass — making it orders of magnitude faster on CPU.
Credits
- Teacher model: BAAI/bge-m3
- Distillation toolkit: Model2Vec by Minish Lab (Stephan Tulkens & Thomas van Dongen)
Citation
@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}
}