Class Hierarchies for Memory-Bounded Multiclass Boosting

Gradient-boosted decision trees are sums of many small yes/no trees. They are among the most accurate models for tabular and hand-crafted sensor features, and recent work shows they can be squeezed onto microcontrollers with only a few kilobytes of storage. That compression mostly works for binary problems. With $C$ classes, the standard recipe trains a separate tree ensemble for every class, so storage grows linearly with $C$, and every prediction evaluates all of those ensembles. We propose replacing the per-class ensembles with a binary class hierarchy: a tree of yes/no decisions over groups of classes, where each internal node holds its own small boosted ensemble. Three design choices make this work under a memory budget. All nodes draw features and split thresholds from one shared lookup table. The storage budget is spent unevenly, so easy coarse splits get a handful of trees and hard fine splits get more. The hierarchy itself is chosen so that the easy splits come first.

The claim is that under a fixed flash budget of a few kilobytes, this design reaches a better accuracy–memory–latency trade-off than flat multiclass boosting. Two mechanisms produce the gain. First, a prediction only evaluates the roughly $\log_2 C$ ensembles on its root-to-leaf path. Second, most coarse decisions are cheap enough that the stored bits migrate to the few genuinely confusable class pairs. If this holds, it removes the main limitation that compact-tree work currently names for itself. It also partly recovers the inference slowdown that bit-packed storage introduces.

What the two directions contribute, and where the gap is

The memory side supplies both the method and the problem. Boosted Trees on a Diet (ToaD) changes the boosting split criterion so that reusing an already-used feature or threshold costs nothing while introducing a new one is penalized. It then stores shallow trees as pointer-less bit arrays that index into global parameter tables. This gives 4x to 16x compression over LightGBM, and on Covertype it matches a 16 KB float32 LightGBM model with 2 KB. The same paper names two costs. Multiclass memory scales as $O(C)$ because of per-class ensembling, and bit-unpacking makes inference about 0.51 ms per prediction on an Arduino Nano 33 BLE, roughly 5x slower than uncompressed. We reuse ToaD's reuse penalty and storage layout unchanged and attack both costs through the structure of the class space.

The hierarchical-classification side supplies the decomposition and a known failure mode. HD-CNN builds a two-level coarse-to-fine network. It discovers the coarse groups by spectral clustering on a flat model's confusion matrix and uses overlapping groups to soften routing errors. It still needs product quantization because its expert heads each carry their own weights. Multilabel Classification by Hierarchical Partitioning and Data-dependent Grouping shows that partitioning a huge label space gives logarithmic-time decoding, 0.8 ms per instance on WikiLSHTC. That approach relies on matrix factorization at a scale unrelated to embedded devices. Older hierarchical binary systems, such as per-split feature selection with hierarchical SVMs and the clustered hierarchical tandem acoustic system, motivate the idea that each split benefits from its own small feature set. That is exactly what a shared reuse table can exploit cheaply.

No paper in our search combines a class hierarchy with parameter-reuse compression in boosted trees. The closest work, HD-CNN, gives every branch separate weights and treats memory as an afterthought to compress. Our proposal differs in two ways: all branches share one parameter table, and the memory budget is the objective that shapes both the hierarchy and how bits are split among nodes. The neural single-backbone approaches, LayerSkip and the Dynamic Encoder Transducer, make the same argument for sharing in a different model class. They collapse what would be multiple models into one set of weights rather than storing several.

One honest correction to the obvious version of this idea is needed. A balanced binary hierarchy has $C-1$ internal nodes, not $\log_2 C$. Simply swapping per-class ensembles for per-node ensembles therefore does not shrink the number of stored ensembles. The savings must come from three sources, each of which we test separately. Only the path is evaluated, which affects latency. Node budgets are uneven, which affects memory. Thresholds are shared across nodes, which also affects memory.

Core Claim

We use the following notation. A class hierarchy $H$ is a binary tree whose leaves are the $C$ classes. Each internal node $v$ holds a binary ensemble of $R_v$ trees. All trees index into a shared table of $F$ feature/threshold entries. Stored bytes are approximately

$$ B(H,\{R_v\}) \approx \beta_{\text{tab}} F + \beta_{\text{tree}} \sum_{v} R_v , $$

where $\beta_{\text{tab}}$ is the bytes per table entry and $\beta_{\text{tree}}$ is the bytes per shallow bit-packed tree. Expected inference cost is $\mathbb{E}_x \sum_{v \in \text{path}(x)} R_v$. Flat one-ensemble-per-class boosting instead stores and evaluates $C \cdot R$ trees.

The hypothesis is about what the hierarchy and budgets learn. When both are chosen well, the optimal $R_v$ is highly skewed: most internal nodes need very few trees and a few confusable nodes absorb most of the budget. Under that skew, the sum over nodes falls well below $C \cdot R$ at matched accuracy, and the path sum falls further.

Research Program

We will build the method in three pieces.

The first piece is hierarchy construction. We train a cheap flat model, compute its confusion matrix, and recursively bisect the classes. HD-CNN uses spectral clustering to form groups. We adapt it to binary bisection with a cost-aware criterion: each cut should separate classes that the flat model rarely confuses, so the expensive distinctions are pushed toward the leaves. We compare this against three alternatives: a random balanced bisection, a semantic taxonomy where one exists, and a bisection chosen greedily to minimize the bytes needed to reach a target node accuracy.

The second piece is joint budget allocation. All node ensembles grow together, one tree at a time, under ToaD's reuse-penalized split gain. The feature/threshold table is global, so a threshold introduced at the root is free for every descendant node. At each step, the next tree goes to the node with the largest validation-loss reduction per added byte, where loss is the leaf-level multiclass log-loss. Growth stops when $B$ reaches the flash budget.

The third piece addresses error propagation. Root mistakes are unrecoverable in a hard cascade, as HD-CNN's overlapping clusters acknowledge. We therefore score leaves by the product of node probabilities along the path. When a node's margin falls below a calibrated threshold, we also follow the second branch, a beam of width two. This trades a measured amount of extra path cost for robustness, and we report that trade-off explicitly.

Baselines

The naive reference is flat multiclass LightGBM with one ensemble per class, stored in float32 and shrunk to each memory budget by reducing the number of rounds. It shows what happens with no compression idea at all. A second naive point is the same model with post-hoc FP16 quantization, which ToaD already reports losing to reuse regularization.

The strongest existing method is ToaD applied in its standard multiclass form, with per-class ensembles, reuse-penalized splits and a bit-packed layout. It is the strongest competitor because it is the current memory-efficient boosting method and shares every low-level storage trick with our proposal. Any gain over it must therefore come from the hierarchy. The reported reference point is ToaD matching a 16 KB float32 LightGBM on Covertype at 2 KB, with about 0.51 ms per prediction on an Arduino Nano 33 BLE, from Boosted Trees on a Diet. We found no reported ToaD result on Lacuna for Speech Commands or MSWC.

We will also run vector-leaf multiclass boosting, where each tree stores $C$ leaf values, with ToaD's reuse penalty added. This is the most dangerous competitor and is discussed below.

All methods get the same features, the same flash budgets (1, 2, 4, 8, 16 KB), the same tree depth cap (below 5, as in ToaD), and the same hyperparameter search of equal trial count on a shared validation split. Latency is measured on the same Arduino Nano 33 BLE build. Beating ToaD means higher accuracy at equal bytes at two or more budgets, or equal accuracy at half the bytes, with on-device latency no worse than ToaD's.

Three ablations isolate the key ingredients. The first gives each node a private table instead of the shared one. The second gives every node the same number of trees instead of greedy allocation. The third replaces the confusion-based hierarchy with a random one. If the private-table or uniform-budget variants match the full method, the corresponding mechanism is not doing the work.

Why not just…?

Why not just quantize a flat model? ToaD already compared against post-hoc FP16 quantization and beat it across nearly all memory envelopes. Quantization also leaves the $O(C)$ evaluation cost untouched. We still include it as a baseline, and the hierarchy should be complementary to it.

Why not just share trees across classes with vector-valued leaves? This is a real threat. It removes the per-class ensemble count directly, with one tree per round, and needs no routing, so it cannot propagate errors. Its cost moves into leaves: $C$ values per leaf, a part of the model ToaD explicitly does not regularize. Every prediction still touches every tree. We run it with ToaD's regularization and with 8-bit leaf quantization. If it matches our method on the accuracy–bytes curve, the hierarchy's remaining claim reduces to latency. In that case we will report the result as such rather than as a memory win.

Why not use error-correcting output codes, with about $\log_2 C$ binary ensembles total? These store fewer ensembles than a hierarchy. However, each bit splits the classes into arbitrary halves that are often hard to separate, so each bit's ensemble needs many trees, and every bit must be evaluated per input. We include a random-code and a confusion-aware-code variant under the same budgets. Our hypothesis predicts that coding wins only at the very smallest budgets on low-$C$ data.

Why not a tiny neural network or binary early-exit network? Binary Early-Exit Network reports about 95% accuracy on Speech Commands, with latencies of 2.62 to 8 ms on a Snapdragon 855. That is a phone-class processor, not a 256 KB-flash microcontroller, so the number is a reference point rather than a matched competitor. We include a small integer-quantized MLP on the same features and budget to place boosted trees fairly.

Proposed Experiments

Benchmarks come from the file and span a range of $C$. Covertype has 7 classes and allows direct comparison with ToaD's reported numbers. Speech Commands has 12 keyword classes and MSWC Micro-EN has 31; for both we use fixed MFCC summary statistics as tabular features, which is a feature choice we make, not one taken from those papers. Mushroom is binary and serves only as a sanity check that the hierarchical code path reduces exactly to ToaD when $C=2$. The $C=31$ setting is where the hypothesis has the most room, so it is the decisive test.

We report five metrics: accuracy versus stored bytes curves, median and 95th-percentile on-device latency, the distribution of $R_v$ across nodes, and root-level routing error with and without the width-two beam.

Three findings would confirm the proposal. The first is a skewed $R_v$ distribution in which the top quarter of nodes hold most of the trees. The second is that the full method beats both per-class ToaD and vector-leaf ToaD at matched bytes on MSWC. The third is that latency falls below ToaD's at matched accuracy, with the gap widening from 7 to 31 classes.

Three findings would refute it. The first is that uniform per-node budgets perform as well as greedy allocation. The second is that private tables match the shared table. The third is that vector-leaf boosting dominates at every budget. Any of these would mean the class hierarchy contributes routing overhead but no memory benefit.