onnxslim
OnnxSlim: A Toolkit to Help Optimize Onnx Model
What it is and what it does
OnnxSlim is a toolkit for optimizing ONNX neural network models by reducing operator count and model size while maintaining inference accuracy. It provides both a command-line interface and a Python API for model optimization. The package depends on onnx for model handling, sympy for symbolic computation, ml-dtypes for numeric types, packaging for version management, and colorama for terminal output formatting.
The tool is designed for developers deploying neural networks who need faster inference without sacrificing model accuracy. It integrates into major ML frameworks and deployment pipelines, having been adopted by NVIDIA TensorRT-Model-Optimizer, HuggingFace optimum and transformers.js, ultralytics, and others. Installation is straightforward via pip with no compiled dependencies.
Use it for:
- Optimize ONNX models for edge deployment where model size and inference latency are critical constraints.
- Reduce inference latency in production serving pipelines while maintaining model accuracy.
- Prepare pre-trained models for mobile or embedded inference with lower computational overhead.
- Integrate model optimization into automated ML pipelines as a preprocessing step before deployment.
- Benchmark and compare inference performance before and after optimization on target hardware.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
OnnxSlim reduces the size and operator count of ONNX models while preserving accuracy and improving inference speed through optimization techniques.
Yes. OnnxSlim is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and installs with low friction. It is widely adopted in production ML frameworks (NVIDIA, HuggingFace, ultralytics) and has strong community adoption. Install if you work with ONNX models and need to optimize for speed or size.
Install
onnxslim on PyPI
pip
pip install onnxslimuv
uv add onnxslimpoetry
poetry add onnxslimInstalling onnxslim
Before you install
Low friction installation with a pure Python wheel. Actively maintained with a release in the last two weeks and a recent commit history. Five runtime dependencies are all stable, widely-used packages.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install onnxslim
import onnx
import onnxslim
model = onnx.load("model.onnx")
slimmed_model = onnxslim.slim(model)
if slimmed_model:
onnx.save(slimmed_model, "slimmed_model.onnx")
Requires Python 3.8 or later. Input must be a valid ONNX model file.
Verify before relying
- Specific optimization techniques used (pruning, quantization, graph simplification, or others)
- Whether accuracy preservation is measured quantitatively or qualitatively
- Inference speed improvements are claimed but not quantified in the excerpt
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — colorama, ml-dtypes, onnx, packaging, sympy |
| Maintenance | actively maintained — 13 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,281,234/month — #4,117 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: onnxslim-0.1.95-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
nudenetDetects nudity in images using lightweight ONNX…
permissive · top 15,000 on PyPI
nvidia-modeloptApplies state-of-the-art model optimization…
permissive · top 15,000 on PyPI
optimum-onnxExports Hugging Face transformer models to ONNX…
permissive · top 15,000 on PyPI
optimumOptimum provides optimization tools to export…
permissive · top 5,000 on PyPI
onnxruntime_extensionsExtends ONNX Runtime with custom operators for…
permissive · top 15,000 on PyPI
onnxoptimizerApplies graph-level optimizations to ONNX…
permissive · top 15,000 on PyPI
mnnMNN is a lightweight deep learning inference…
permissive · top 15,000 on PyPI
ssi4onnxInfers and fills missing tensor shape…
permissive · top 15,000 on PyPI
onnxruntime-gpuExecutes ONNX machine learning models on GPU…
permissive · top 5,000 on PyPI
sit4onnxRuns inference tests on ONNX models using…
permissive · top 15,000 on PyPI