Views
No views yet
pip install model2vec1from model2vec import StaticModel
2
3model = StaticModel.from_pretrained("minishlab/potion-code-16M")
4
5# Embed natural language queries
6query_embeddings = model.encode(["How to read a file in Python?"])
7
8# Embed code documents
9code_embeddings = model.encode(["def read_file(path):\n with open(path) as f:\n return f.read()"])| Model | Params | AVG | AppsRetrieval | COIRCodeSearchNet | CodeFeedbackMT | CodeFeedbackST | CodeSearchNetCC | CodeTransContest | CodeTransDL | CosQA | StackOverflow | Text2SQL |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CodeRankEmbed | 137M | 59.14 | 23.46 | 94.70 | 42.61 | 78.11 | 76.39 | 66.43 | 34.84 | 35.92 | 80.53 | 58.37 |
| BM25 | — | 42.31 | 4.76 | 40.86 | 59.19 | 68.15 | 53.97 | 47.78 | 34.42 | 18.75 | 70.26 | 24.94 |
| potion-code-16M | 16M | 37.05 | 3.97 | 42.99 | 36.26 | 50.27 | 43.40 | 39.76 | 31.72 | 21.37 | 57.47 | 43.34 |
| potion-retrieval-32M | 32M | 32.10 | 4.22 | 31.80 | 36.71 | 45.11 | 38.64 | 29.97 | 32.62 | 8.70 | 56.26 | 36.93 |
| potion-base-32M | 32M | 31.42 | 3.37 | 29.58 | 34.77 | 42.69 | 37.88 | 28.51 | 30.55 | 14.61 | 53.36 | 38.88 |
| Property | Value |
|---|---|
| Parameters | ~16M |
| Embedding dimensions | 256 |
| Vocabulary size | ~62,500 |
| Teacher model | nomic-ai/CodeRankEmbed |
| Training corpus | CornStack (6 languages: Python, Java, JavaScript, Go, PHP, Ruby) |
| Max sequence length | 1,000,000 tokens (static, no limit in practice) |
train.py. It requires minishlab/tokenlearn-cornstack-docs-coderankembed and minishlab/tokenlearn-cornstack-queries-coderankembed (20k samples per language used).pip install model2vec tokenlearn sentence-transformers datasets skeletoken einops
python train.py1@software{minishlab2024model2vec,
2 author = {Stephan Tulkens and {van Dongen}, Thomas},
3 title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
4 year = {2024},
5 publisher = {Zenodo},
6 doi = {10.5281/zenodo.17270888},
7 url = {https://github.com/MinishLab/model2vec},
8 license = {MIT}
9}