--- id: onnxslim version: "0.1.95" license: MIT license_treatment: permissive maintenance: active --- # onnxslim — OnnxSlim: A Toolkit to Help Optimize Onnx Model License: permissive · Maintenance: active · Downloads: 1.3M/mo ## 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 above — 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 pip install onnxslim uv add onnxslim poetry add onnxslim ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 1.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags onnx model optimization, reduce onnx model size, onnx inference speed, model compression onnx, slim onnx models, onnx operator reduction, lightweight onnx inference, model-optimization, onnx, inference-performance [View on SkillFed](https://skillfed.io/packages/onnxslim) · [View on PyPI](https://pypi.org/project/onnxslim/)