Skip to content

lignum

Fast inference for LightGBM, XGBoost and CatBoost models, with predictions that equal the library that trained them, bit for bit.
Terminal window
pip install pylignum
0rows that differ from the library’s own predictions, in every test and benchmark
8-24×faster than LightGBM on a million rows, 4-8× faster than XGBoost (x86, all threads)
4-6×faster than LightGBM on single rows, a different row every call
11 µsmedian for one row of a 500-tree LightGBM model (California housing) on one x86 core; 7 µs on an Apple M4
LightGBM models: times faster than LightGBM500 rounds, 63 leaves, 1,000,000 rows on all threads, AMD EPYC-Milan, 8 vCPU (Hetzner CCX33). Higher is better.

lignum's predictions equal LightGBM's on every row; lleaves differs on 55-100% of them. Diabetes 130-US and synthetic-cat have categorical features with hundreds to thousands of values.

LightGBM models: times faster than LightGBM: 500 rounds, 63 leaves, 1,000,000 rows on all threads, AMD EPYC-Milan, 8 vCPU (Hetzner CCX33). Higher is better.
Data setlignum (compiled)lleavesTL2cgen
California housing11.1×7.5×1.8×
Covertype23.8×17.0×1.1×
Adult13.1×9.1×1.9×
Bank marketing13.3×10.8×2.0×
Diabetes 130-US12.4×2.2×0.3×
synthetic8.4×6.1×1.2×
synthetic-cat10.4×1.3×0.3×
One row: times faster than LightGBMMedian of up to 100,000 calls on one thread, a different row every call, AMD EPYC-Milan, 8 vCPU (Hetzner CCX33). Higher is better.
One row: times faster than LightGBM: Median of up to 100,000 calls on one thread, a different row every call, AMD EPYC-Milan, 8 vCPU (Hetzner CCX33). Higher is better.
Data setlignum (interpreter)lignum (compiled)lleaves
California housing5.2×5.0×2.3×
Covertype3.9×2.5×1.9×
Adult4.8×5.8×3.6×
Bank marketing4.7×5.8×3.5×
Diabetes 130-US4.7×6.2×1.1×
synthetic5.4×5.1×3.3×
synthetic-cat3.8×6.3×1.0×
CatBoost models: times faster than CatBoost500 trees of depth 6, 1,000,000 rows on one thread from a pandas DataFrame, AMD EPYC-Milan, 8 vCPU (Hetzner CCX33). Higher is better.

On an Apple M4 lignum is 2.3-2.7× faster; on single rows from a DataFrame 7-27× (up to 216× with high-cardinality categories).

CatBoost models: times faster than CatBoost: 500 trees of depth 6, 1,000,000 rows on one thread from a pandas DataFrame, AMD EPYC-Milan, 8 vCPU (Hetzner CCX33). Higher is better.
Data setlignum
California housing1.2×
Covertype3.0×
Adult1.8×
Bank marketing1.7×
Diabetes 130-US1.8×
synthetic1.1×
synthetic-cat1.5×

Exact

Raw scores and probabilities equal the library’s predict bit for bit: NaN and zero-as-missing, categorical splits, XGBoost’s float32 arithmetic and CatBoost’s CTRs included. What the notebook showed is what production returns.

Fast to predict

A binned interpreter for any batch size, and a compiled mode that turns LightGBM and XGBoost trees into native code in a few seconds for 500 trees. autotune picks the faster one for your data.

CatBoost with categories

Categorical features, one-hot and CTRs with their combinations, straight from strings in pandas, Arrow or plain lists. No preprocessing, no compilation.

Fast to start

model.save(“model.bin”) writes a file that maps into memory in well under a millisecond; compiled trees ship next to it, so production needs no compiler.

Arrow in, no copies

predict reads pyarrow, polars and any Arrow PyCapsule data directly. C and C++ services pass Arrow record batches through the C API.

Small and portable

One C++20 library with no dependencies beyond simdjson and OpenMP. Wheels for Linux, macOS and Windows on x86-64 and ARM.