CoolFace
Modelpublic

guilherme-miranda/m2v-bge-m3-ptbr-en

sourceHugging Facemitupdated 3mo agoView on Hugging Face
0likes17downloads
Model Card

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

Teacher / sourceBAAI/bge-m3 (MIT)
MethodModel2Vec distillation, non-Latin scripts removed, PCA, float16
Vocabulary185,417 Latin-script subword tokens
Dimensions256
Size on disk~97 MB
LanguagesPortuguese (pt-BR), English
Good forcode search, retrieval, semantic similarity on pt/en text

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

python
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:

bash
export SEMBLE_MODEL_NAME="guilherme-miranda/m2v-bge-m3-ptbr-en"
semble search "rate limiting middleware" ./my-project

How 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}
}