C++ inference for tabular ML models — GGUF-native, zero Python dependency.
Embed XGBoost, LightGBM, TabPFN, and FT-Transformer into any C++ application — IoT firmware, PLC controllers, mobile apps, trading systems — without pulling in a Python runtime or separate ML library.
| Model | Type | Edge? | tabular.cpp | sklearn/xgb |
|---|---|---|---|---|
| XGBoost | Gradient boosted trees | ✅ | ✅ | Heavy dep |
| LightGBM | Gradient boosted trees | ✅ | ✅ | Heavy dep |
| TabPFN v2 | In-context transformer | — | ✅ | ❌ |
| FT-Transformer | Feature tokenizer + attn | ✅ | ✅ | ❌ |
Built on ggml — same backend as llama.cpp and whisper.cpp. One GGUF format for all model types.
git clone https://github.com/liodon-ai/tabular.cpp
cd tabular.cpp
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)Convert your existing models in seconds. No accuracy loss — exact same tree traversal.
# Convert
python convert/convert_xgboost.py --model model.json --output model.gguf
python convert/convert_lightgbm.py --model model.txt --output model.gguf
# Predict
./build/tb-predict -m model.gguf -i features.csv -o predictions.csv
# From C
struct tb_context * ctx = tb_init("model.gguf", tb_default_params());
int n_out;
float * pred = tb_predict(ctx, X, n_rows, &n_out); // [n_rows, n_out]Why not just use xgboost's C++ library?
- xgboost.so is 30 MB; tabularcpp + ggml is smaller and already linked if you use llama.cpp
- GGUF format is consistent with your other models
- NaN/missing value handling baked in via
default_leftper split node - Multiclass softmax, binary sigmoid, regression — all handled
Flat-array tree representation (cache-friendly, no pointer chasing):
trees.feature int32[n_nodes] -1 = leaf
trees.threshold f32[n_nodes]
trees.left_child int32[n_nodes] node index
trees.right_child int32[n_nodes]
trees.default_left int8[n_nodes] 1 = NaN goes left
trees.leaf_value f32[n_nodes]
trees.roots int32[n_trees]
Zero training. Pass your labeled examples as context; get predictions immediately. Beats XGBoost on datasets with < 10k rows on most benchmarks.
python convert/convert_tabpfn.py --model priorlabs/tabpfn-v2 --output tabpfn-v2.gguf
./build/tb-predict \
-m tabpfn-v2.gguf \
--train train.csv --label-col 0 \
-i test.csv -o predictions.csvstruct tb_context * ctx = tb_init("tabpfn-v2.gguf", tb_default_params());
float * proba = tb_predict_pfn(ctx,
X_train, y_train, n_train,
X_test, n_test,
n_features, n_classes);
// proba: [n_test, n_classes] softmax probabilitiesArchitecture: Feature tokenizer → 12-layer transformer encoder → classification head. In-context: training samples and test samples attend to each other in one forward pass.
Feature Tokenizer + Transformer. Handles mixed numeric + categorical features natively.
python convert/convert_fttransformer.py \
--checkpoint ft_transformer.pt \
--output ft_transformer.gguf
./build/tb-predict -m ft_transformer.gguf -i features.csv -o preds.csvEach feature gets its own linear projection to d-dimensional token space. The transformer then reads all feature tokens, and a CLS token's output drives the prediction head.
Predictive maintenance — XGBoost/LightGBM models running on ARM PLCs in factories with no internet connectivity. No Python, no xgboost library, just a static binary.
Medical wearables — Risk scoring on heart rate + accelerometer data. FDA class II devices require on-device inference. tabular.cpp compiles to bare-metal ARM Cortex-M.
POS fraud detection — Transaction feature scoring in < 5ms, fully offline. Card data never leaves the terminal.
Automotive ECUs — OBD-II sensor anomaly detection in the vehicle. C++ only, strict memory budgets.
| Key | Type | Description |
|---|---|---|
tb.arch |
str | xgboost / lightgbm / tabpfn / ft_transformer |
tb.model_type |
i32 | Enum (1=XGBoost, 2=LGBM, 3=TabPFN, 4=FTT) |
tb.objective |
str | regression / binary / multiclass |
tb.n_trees |
i32 | Total tree count (trees) |
tb.n_features |
i32 | Input feature count |
tb.n_classes |
i32 | Output class count |
tb.n_nodes |
i32 | Total node count across all trees |
tb.base_score |
f32 | Initial prediction (XGBoost) |
tb.d_model |
i32 | Transformer hidden dim (TabPFN/FTT) |
tb.n_layers |
i32 | Transformer layer count |
tb.max_features |
i32 | Max features supported (TabPFN) |
tb.max_context |
i32 | Max training samples in context (TabPFN) |
- CatBoost converter (native categorical support)
- NODE (Neural Oblivious Decision Ensembles)
- ONNX import for any sklearn-compatible model
- AVX-512 tree traversal for x86 edge servers
- Quantized trees (int8 thresholds, int16 leaf values)
- Python bindings (ctypes wrapper)
MIT. Built on ggml (MIT).