|
|
--- |
|
|
license: mit |
|
|
language: |
|
|
- en |
|
|
tags: |
|
|
- onnx |
|
|
--- |
|
|
This is the ONNX variant of the [gte-small](https://huggingface.co/thenlper/gte-small) embeddings model created with the [DeepSparse Optimum](https://github.com/neuralmagic/optimum-deepsparse) integration. |
|
|
|
|
|
To replicate ONNX export, run: |
|
|
|
|
|
```bash |
|
|
pip install git+https://github.com/neuralmagic/optimum-deepsparse.git |
|
|
``` |
|
|
|
|
|
```python |
|
|
from optimum.deepsparse import DeepSparseModelForFeatureExtraction |
|
|
from transformers.onnx.utils import get_preprocessor |
|
|
from pathlib import Path |
|
|
|
|
|
model_id = "thenlper/gte-small" |
|
|
|
|
|
# load model and convert to onnx |
|
|
model = DeepSparseModelForFeatureExtraction.from_pretrained(model_id, export=True) |
|
|
tokenizer = get_preprocessor(model_id) |
|
|
|
|
|
# save onnx checkpoint and tokenizer |
|
|
onnx_path = Path("gte-small-dense") |
|
|
model.save_pretrained(onnx_path) |
|
|
tokenizer.save_pretrained(onnx_path) |
|
|
``` |