rxdtech's picture
move files
bd30301
|
Raw History Blame Contribute Delete
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.