Repolode
microsoft

microsoft/hummingbird

A Python library that compiles trained scikit-learn, LightGBM and XGBoost models into tensor computations to run inference on PyTorch, TorchScript, ONNX or TVM.

Stars
3,553
Forks
293
Open issues
78
Last commit
2 months ago

What is it?

Hummingbird converts trained traditional machine learning models into tensor computations so they can run on neural network frameworks. Developers can take scikit-learn decision trees, random forests, and LightGBM or XGBoost classifiers and regressors, then target PyTorch, TorchScript, ONNX, or TVM without rewriting the model.

The conversion reshapes tree-based and other classical operators into matrix operations that suit vectorized and GPU execution. Hummingbird provides a uniform predict-style API modeled on scikit-learn, so inference code can stay the same after swapping in a converted model. Converted PyTorch and TorchScript models can be served with TorchServe.

Installation is via pip as hummingbird-ml, with an optional extra for LightGBM and XGBoost. It supports Python 3.9 to 3.11 on Linux, Windows and macOS, and requires PyTorch 1.6.0 or later.

Key features

  • 01Converts scikit-learn trees, random forests, LightGBM and XGBoost models
  • 02Targets PyTorch, TorchScript, ONNX and TVM backends
  • 03Provides a scikit-learn-style predict API for converted models
  • 04Runs predictions on CPU or GPU, including via model.to('cuda')
  • 05Supports saving and loading converted models

Use cases

  • Speeding up batch inference of a trained random forest on GPU hardware
  • Deploying a classical ML model alongside neural networks in one PyTorch-based serving stack
  • Exporting tree-based models to ONNX or TVM for execution outside Python

Quick start

  1. 1

    Install PyTorch (version 1.6.0 or newer) for your platform from pytorch.org

  2. 2

    Install Hummingbird from pip

    python -m pip install hummingbird-ml
  3. 3

    Convert a trained scikit-learn model with convert(model, 'pytorch') after importing hummingbird.ml

Things to know

  • PyTorch must be installed separately before Hummingbird can be used.
  • The TVM backend only works on Python 3.10.
  • It supports a defined subset of scikit-learn, LightGBM and XGBoost models and featurizers, not all of them.

In collections

Topics

FAQ

What is hummingbird?
A Python library that compiles trained scikit-learn, LightGBM and XGBoost models into tensor computations to run inference on PyTorch, TorchScript, ONNX or TVM. Hummingbird converts trained traditional machine learning models into tensor computations so they can run on neural network frameworks. Developers can take scikit-learn decision trees, random forests, and LightGBM or XGBoost classifiers and regressors, then target PyTorch, TorchScript, ONNX, or TVM without rewriting the model.
Is hummingbird free to use? What license does it have?
hummingbird is open source under the MIT license. Check the license terms before using it in commercial products.
Is hummingbird still maintained?
Updated within 6 months. The last commit to hummingbird was on Sep 14, 2026.
What can I use hummingbird for?
Speeding up batch inference of a trained random forest on GPU hardware Deploying a classical ML model alongside neural networks in one PyTorch-based serving stack Exporting tree-based models to ONNX or TVM for execution outside Python
How do I install hummingbird?
Install PyTorch (version 1.6.0 or newer) for your platform from pytorch.org Install Hummingbird from pip: python -m pip install hummingbird-ml Convert a trained scikit-learn model with convert(model, 'pytorch') after importing hummingbird.ml
Where can I get hummingbird?
The source code and installation instructions are on GitHub: https://github.com/microsoft/hummingbird

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects