Skip to content

feat: make onnx export a function - #347

Merged
stephantul merged 5 commits into
mainfrom
make-onnx-util
Aug 26, 2026
Merged

feat: make onnx export a function#347
stephantul merged 5 commits into
mainfrom
make-onnx-util

Conversation

@stephantul

Copy link
Copy Markdown
Contributor

This PR makes the ONNX export we offered a part of the model2vec package. I added extra things to the onnx extra to support new torch versions and made the script work on an in-memory version of a model, not one stored on disk.

from model2vec import StaticModel
from model2vec.onnx import export_model_to_onnx

s = StaticModel.from_pretrained("minishlab/potion-base-8m")
export_model_to_onnx(s, "my_model")

This writes an onnx model to disk, which can then be uploaded to Hugging Face manually and used wherever. I chose to write some additional config options which were needed by fastembed. Most of these are not necessary, which I reported here.

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.38710% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
model2vec/onnx.py 98.36% 2 Missing ⚠️
Files with missing lines Coverage Δ
model2vec/tokenizer/tokenizer.py 100.00% <100.00%> (ø)
model2vec/onnx.py 98.36% <98.36%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stephantul
stephantul merged commit 280b341 into main Aug 26, 2026
11 checks passed
@stephantul
stephantul deleted the make-onnx-util branch August 26, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant