minishlab/potion-code-16M-v2

Model

13

stars

10

commits

9

repos using this model

5

linked in READMEs

Jul 13, 2026

updated

code
embeddings
model2vec
retrieval
safetensors
static-embeddings

README

potion-code-16M-v2 Model Card

Overview

potion-code-16M-v2 is a fast static code embedding model optimized for code retrieval tasks. It powers Semble, a code search library for agents. It is distilled from nomic-ai/CodeRankEmbed and trained on the CornStack code corpus using Tokenlearn and contrastive fine-tuning. It is the successor to potion-code-16M. It uses static embeddings, allowing text and code embeddings to be computed orders of magnitude faster than transformer-based models on both GPU and CPU.

Installation

pip install model2vec

Usage

from model2vec import StaticModel

model = StaticModel.from_pretrained("minishlab/potion-code-16M-v2")

# Embed natural language queries
query_embeddings = model.encode(["How to read a file in Python?"])

# Embed code documents
code_embeddings = model.encode(["def read_file(path):\n    with open(path) as f:\n        return f.read()"])

How it works

potion-code-16M-v2 is created using the following pipeline:

  1. Vocabulary mining: code-specific tokens are mined from CornStack and added to the base CodeRankEmbed tokenizer (43k extra tokens → ~63.5k total)
  2. Distillation: the extended vocabulary is distilled from CodeRankEmbed using Model2Vec (256-dimensional embeddings, PCA)
  3. Tokenlearn: the distilled model is fine-tuned on 1.2 million (query, document) pairs from CornStack using cosine similarity loss
  4. Contrastive fine-tuning: the model is further fine-tuned using MultipleNegativesRankingLoss on 1.2 million CornStack query-document pairs

Results

Results on the CoIR benchmark on MTEB (NDCG@10, mteb>=2.10):

ModelParamsAVGAppsRetrievalCOIRCodeSearchNetCodeFeedbackMTCodeFeedbackSTCodeSearchNetCCCodeTransContestCodeTransDLCosQAStackOverflowText2SQL
CodeRankEmbed137M59.1423.4694.7042.6178.1176.3966.4334.8435.9280.5358.37
potion-code-16M-v2 + BM25 (hybrid)16M43.366.0847.7145.3861.1051.6853.8033.4221.3966.7346.29
BM2542.314.7640.8659.1968.1553.9747.7834.4218.7570.2624.94
potion-code-16M-v216M39.085.1946.3738.0253.2243.6643.6632.6424.3659.5744.07
potion-code-16M16M37.053.9742.9936.2650.2743.4039.7631.7221.3757.4743.34
potion-retrieval-32M32M32.104.2231.8036.7145.1138.6429.9732.628.7056.2636.93
potion-base-32M32M31.423.3729.5834.7742.6937.8828.5130.5514.6153.3638.88

CoIR covers a broad range of code retrieval scenarios. For the use case of finding code given a natural language query, CosQA and CodeFeedback (ST/MT) are the most relevant tasks. Others are less so: COIRCodeSearchNetRetrieval retrieves text given a code query (the reverse direction), and the CodeTransOcean tasks target cross-language code translation. The hybrid row combines dense retrieval with BM25 using Reciprocal Rank Fusion (k=60).

Model Details

PropertyValue
Parameters~16M
Embedding dimensions256
Vocabulary size~63,500
Teacher modelnomic-ai/CodeRankEmbed
Training corpusCornStack (6 languages: Python, Java, JavaScript, Go, PHP, Ruby)
Max sequence length1,000,000 tokens (static, no limit in practice)

Additional Resources

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

Contributors

Pringled

1 commits

minishlab/potion-code-16M-v2

Model

13

stars

10

commits

9

repos using this model

5

linked in READMEs

Jul 13, 2026

updated

code
embeddings
model2vec
retrieval
safetensors
static-embeddings

README

potion-code-16M-v2 Model Card

Overview

potion-code-16M-v2 is a fast static code embedding model optimized for code retrieval tasks. It powers Semble, a code search library for agents. It is distilled from nomic-ai/CodeRankEmbed and trained on the CornStack code corpus using Tokenlearn and contrastive fine-tuning. It is the successor to potion-code-16M. It uses static embeddings, allowing text and code embeddings to be computed orders of magnitude faster than transformer-based models on both GPU and CPU.

Installation

pip install model2vec

Usage

from model2vec import StaticModel

model = StaticModel.from_pretrained("minishlab/potion-code-16M-v2")

# Embed natural language queries
query_embeddings = model.encode(["How to read a file in Python?"])

# Embed code documents
code_embeddings = model.encode(["def read_file(path):\n    with open(path) as f:\n        return f.read()"])

How it works

potion-code-16M-v2 is created using the following pipeline:

  1. Vocabulary mining: code-specific tokens are mined from CornStack and added to the base CodeRankEmbed tokenizer (43k extra tokens → ~63.5k total)
  2. Distillation: the extended vocabulary is distilled from CodeRankEmbed using Model2Vec (256-dimensional embeddings, PCA)
  3. Tokenlearn: the distilled model is fine-tuned on 1.2 million (query, document) pairs from CornStack using cosine similarity loss
  4. Contrastive fine-tuning: the model is further fine-tuned using MultipleNegativesRankingLoss on 1.2 million CornStack query-document pairs

Results

Results on the CoIR benchmark on MTEB (NDCG@10, mteb>=2.10):

ModelParamsAVGAppsRetrievalCOIRCodeSearchNetCodeFeedbackMTCodeFeedbackSTCodeSearchNetCCCodeTransContestCodeTransDLCosQAStackOverflowText2SQL
CodeRankEmbed137M59.1423.4694.7042.6178.1176.3966.4334.8435.9280.5358.37
potion-code-16M-v2 + BM25 (hybrid)16M43.366.0847.7145.3861.1051.6853.8033.4221.3966.7346.29
BM2542.314.7640.8659.1968.1553.9747.7834.4218.7570.2624.94
potion-code-16M-v216M39.085.1946.3738.0253.2243.6643.6632.6424.3659.5744.07
potion-code-16M16M37.053.9742.9936.2650.2743.4039.7631.7221.3757.4743.34
potion-retrieval-32M32M32.104.2231.8036.7145.1138.6429.9732.628.7056.2636.93
potion-base-32M32M31.423.3729.5834.7742.6937.8828.5130.5514.6153.3638.88

CoIR covers a broad range of code retrieval scenarios. For the use case of finding code given a natural language query, CosQA and CodeFeedback (ST/MT) are the most relevant tasks. Others are less so: COIRCodeSearchNetRetrieval retrieves text given a code query (the reverse direction), and the CodeTransOcean tasks target cross-language code translation. The hybrid row combines dense retrieval with BM25 using Reciprocal Rank Fusion (k=60).

Model Details

PropertyValue
Parameters~16M
Embedding dimensions256
Vocabulary size~63,500
Teacher modelnomic-ai/CodeRankEmbed
Training corpusCornStack (6 languages: Python, Java, JavaScript, Go, PHP, Ruby)
Max sequence length1,000,000 tokens (static, no limit in practice)

Additional Resources

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

Contributors

Pringled

1 commits