Information
This is a temporary fork based on the transformers 5.x PR by xadupre. Packaged result published by National Archives of Finland to be used until transformers 5.x support lands in the official optimum-onnx.
Installation
Before you begin, make sure you install all necessary libraries by running:
pip install "optimum-onnx[onnxruntime]"
If you want to use the GPU version of ONNX Runtime, make sure the CUDA and cuDNN requirements are satisfied, and install the additional dependencies by running :
pip install "optimum-onnx[onnxruntime-gpu]"
To avoid conflicts between onnxruntime and onnxruntime-gpu, make sure the package onnxruntime is not installed by running pip uninstall onnxruntime prior to installing Optimum.
ONNX export
It is possible to export 🤗 Transformers, Diffusers, Timm and Sentence Transformers models to the ONNX format and perform graph optimization as well as quantization easily:
optimum-cli export onnx --model meta-llama/Llama-3.2-1B onnx_llama/
The model can also be optimized and quantized with onnxruntime.
For more information on the ONNX export, please check the documentation.
Inference
Once the model is exported to the ONNX format, we provide Python classes enabling you to run the exported ONNX model in a seamless manner using ONNX Runtime in the backend:
from transformers import AutoTokenizer, pipeline
- from transformers import AutoModelForCausalLM
+ from optimum.onnxruntime import ORTModelForCausalLM
- model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B") # PyTorch checkpoint
+ model = ORTModelForCausalLM.from_pretrained("onnx-community/Llama-3.2-1B", subfolder="onnx") # ONNX checkpoint
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B")
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
result = pipe("He never went out without a book under his arm")
More details on how to run ONNX models with ORTModelForXXX classes here.
Examples
Check out the examples folder for more usage examples including optimization, quantization, and model-specific demonstrations.
Metadata
Release files for optimum-onnx-naf 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| optimum_onnx_naf-0.1.1.tar.gz | 169.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| optimum_onnx_naf-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 368.4 kB
Release files / optimum_onnx_naf-0.1.1.tar.gz
| Download URL | optimum_onnx_naf-0.1.1.tar.gz |
|---|---|
| Size | 169.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ecc668b1a991dff49fc7211bdc5298b9e8c865daef597fe4e88aa2beac10eae7
|
|
BLAKE2b-256 checksum How to use checksums |
8f9c6b8d470c0a55f10726e6463307ec952665f65d1e8f44fec7b8b87403641d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / optimum_onnx_naf-0.1.1-py3-none-any.whl
| Download URL | optimum_onnx_naf-0.1.1-py3-none-any.whl |
|---|---|
| Size | 199.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8270689027589c7688fb01fd07a4175e781dbc3a1adcd77af7c1d982792df5e
|
|
BLAKE2b-256 checksum How to use checksums |
4a6c02c427851955ea26a3b8a4d1df14ab2097e33de9e14b16d8d454234a5cf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for optimum-onnx-naf 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for optimum_onnx_naf-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.