Instructions to use rxdtech/potion-code-16M-v2-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Model2Vec
How to use rxdtech/potion-code-16M-v2-onnx with Model2Vec:
from model2vec import StaticModel model = StaticModel.from_pretrained("rxdtech/potion-code-16M-v2-onnx") embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."]) print(embeddings.shape) - sentence-transformers
How to use rxdtech/potion-code-16M-v2-onnx with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("rxdtech/potion-code-16M-v2-onnx") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
|
Download README.md from rxdtech/potion-code-16M-v2-onnx: direct link, hf CLI and curl.
- Browser
- Download file 2.82 kB
-
https://huggingface.co/rxdtech/potion-code-16M-v2-onnx/resolve/main/README.md
- Command line
-
hf download hf://rxdtech/potion-code-16M-v2-onnx/README.md
-
curl -L -o README.md https://huggingface.co/rxdtech/potion-code-16M-v2-onnx/resolve/main/README.md
2.82 kB
| base_model: unknown | |
| language: | |
| - code | |
| library_name: model2vec | |
| license: mit | |
| model_name: potion-code-16M-v2-onnx | |
| tags: | |
| - embeddings | |
| - static-embeddings | |
| - sentence-transformers | |
| - onnx | |
| # potion-code-16M-v2-onnx | |
| This is an ONNX export of the [minishlab/potion-code-16M-v2](https://huggingface.co/minishlab/potion-code-16M-v2) Model2Vec model, produced with the [ONNX](https://onnx.ai/) runtime. [Model2Vec](https://github.com/MinishLab/model2vec) models use static embeddings, allowing text embeddings to be computed orders of magnitude faster on both GPU and CPU. This ONNX export lets you run the model with `onnxruntime` or `transformers.js`, without depending on the `model2vec` package. | |
| `model_quantized.onnx` is int8 quantized for CPU, `model.onnx` is FP32. | |
| ## Usage | |
| ### Using ONNX Runtime | |
| ```python | |
| import onnxruntime as ort | |
| from transformers import AutoTokenizer | |
| tokenizer = AutoTokenizer.from_pretrained("potion-code-16M-v2-onnx") | |
| session = ort.InferenceSession("onnx/model_quantized.onnx") # or onnx/model.onnx | |
| encodings = tokenizer(["Example sentence"], padding=True, return_tensors="np") | |
| embeddings = session.run(None, dict(encodings))[0] | |
| ``` | |
| ## Overview | |
| **potion-code-16M-v2** is a fast static code embedding model optimized for code retrieval tasks. It powers [Semble](https://github.com/MinishLab/semble), a code search library for agents. It is distilled from [nomic-ai/CodeRankEmbed](https://huggingface.co/nomic-ai/CodeRankEmbed) and trained on the [CornStack](https://huggingface.co/datasets/nomic-ai/cornstack-python-v1) code corpus using [Tokenlearn](https://github.com/MinishLab/tokenlearn) and contrastive fine-tuning. | |
| It is the successor to [potion-code-16M](https://huggingface.co/minishlab/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. | |
| ## Model Details | |
| | Property | Value | | |
| | -------------------- | ---------------------------------------------------------------- | | |
| | Parameters | \~16M | | |
| | Embedding dimensions | 256 | | |
| | Vocabulary size | \~63,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) | | |
| ### Further details | |
| See the original model [minishlab/potion-code-16M-v2](https://huggingface.co/minishlab/potion-code-16M-v2) for complete details. | |