Practical overview
When it fits
Use Lleaves when an existing trained LightGBM tree model needs a compiled prediction path, especially when single-row latency, batch throughput or native binary integration matters.
Who it is for
- Machine-learning engineers running trained LightGBM models in prediction-heavy workloads.
- Python developers seeking compiled inference for single predictions or batches.
- Developers integrating generated model binaries with native callers such as C benchmarks.
Documented uses
- Compile a saved LightGBM model for prediction.
- Run single-row or batch predictions with the compiled model.
- Cache generated native binaries to avoid repeating compilation.
- Link generated model binaries from native code to avoid Python inference overhead.
Requirements & limits
The README documents installation with pip or uv on Linux and macOS. The repository specifies an MIT license.
- Lleaves depends on llvmlite and numpy; LLVM is statically linked.
- The
lleaves.Modelinterface is a subset ofLightGBM.Booster, rather than a claim of full interface equivalence. - Caching stores ELF binaries on Linux and Mach-O binaries on macOS.
- Generated binaries can be linked from native callers, but the function signature may change between major versions.
- Published benchmark results use specified datasets and an Intel i7-4770 Haswell; measured performance may differ for other workloads and hardware.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Compile a trained LightGBM model
Create an optimized machine-code model from a saved LightGBM model file.
Before you start
- A trained LightGBM model saved to a model file.
- Python on Linux or macOS.
- Lleaves, with llvmlite and numpy dependencies.
Steps
Install lleaves with the command below or the command below.
pip install lleavesuv add lleavesLoad the saved model with
lleaves.Model(model_file=...).Call
compile()on the model.
Expected outcome
A compiled model that can be used for prediction through lleaves.
Guide limitations
- Installation is documented for Linux and macOS.
- The documented example does not specify model-format or feature compatibility beyond trained LightGBM models.
Cache a compiled model binary
Reuse a generated native binary on subsequent compilation calls.
Before you start
- A trained LightGBM model and lleaves installed on Linux or macOS.
- A filepath for the generated binary.
Steps
Create a
lleaves.Modelfor the trained model.Call
compile(cache=)using the chosen filepath.On a later call, use
compile(cache=)to load the stored binary instead of compiling again.
Expected outcome
The first call stores an ELF file on Linux or a Mach-O file on macOS; later calls using the same filepath skip compilation and load that binary.
Guide limitations
- The documented cache behavior is tied to the same filepath.
- The project notes that the generated-binary function signature may change between major versions.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 12 November 2026
- Original website title
- siboehm/lleaves · Official homepage title · retained in its source language

