Core ML2017intermediate9 min read

LightGBM: A Highly Efficient Gradient Boosting Decision Tree

LightGBM: تعزيز تدرُّجي فائق الكفاءة لأشجار القرار

Ke, G. · Meng, Q. · Finley, T. · Wang, T. · Chen, W. · Ma, W. · Ye, Q. · Liu, T.-Y. — NeurIPS

The problem

Decision Trees (GBDT) are among the most effective algorithms for tabular data, but existing implementations like hit a wall on large-scale datasets. The bottleneck: for each , the algorithm scans every data instance to find the best point. With millions of rows and thousands of features, this exhaustive search becomes prohibitively slow, consuming hours of time and enormous memory.

The contribution

introduces two novel techniques: -based One-Side (GOSS), which keeps all instances with large gradients and randomly samples from the rest — focusing computation on the data that matters most; and Exclusive Feature Bundling (EFB), which identifies mutually exclusive sparse features and bundles them into single features, reducing dimensionality without information . Combined with -based split finding and leaf-wise tree growth, LightGBM achieves up to 20× speedup over conventional GBDT with nearly identical .

The impact

LightGBM became the dominant tool for large-scale tabular machine learning. It powers winning solutions in the majority of Kaggle competitions involving structured data, and is widely deployed in industry for ranking, recommendation, fraud detection, and click-through-rate prediction. Together with XGBoost and CatBoost, it forms the modern triad, and its histogram and GOSS ideas have influenced subsequent gradient boosting frameworks.

Imagine a school principal hiring substitute teachers. The old system (XGBoost) interviews every candidate for every subject, even the hundreds who applied for jobs that are already filled. The process takes weeks.

LightGBM's approach: first, group similar candidates into quick buckets instead of evaluating each one precisely (histogram-based splits). Second, focus your interview time on the candidates who performed worst in the screening test — they have the most to reveal (GOSS). Third, notice that the "Spanish teacher" and "French teacher" slots are never both open at the same time, so merge them into one "language teacher" position (EFB).

Result: the same quality hires, in a fraction of the time.

The bottleneck: scanning every row for every split

Gradient Boosting builds an of decision trees sequentially. Each new tree is trained on the residual errors (gradients) of all previous trees. To find the best split at each , the algorithm must evaluate every possible split point for every feature — and that means scanning the entire dataset per candidate split.

XGBoost uses a pre-sorted algorithm: it sorts each feature's values and walks through them to calculate . This is exact, but for nn data points and dd features, the cost is O(n⋅d)O(n \cdot d) per tree node — and a typical model has thousands of nodes across hundreds of trees.

When nn reaches millions and dd reaches thousands, the training time becomes a serious practical barrier.

Open in Lab
Compare pre-sorted split finding (scans every value) with histogram-based split finding (scans only bin boundaries). Watch the speedup as data size grows.
The demo wakes as you arrive…

Solution 1: Histogram-based split finding

Instead of examining every unique feature value, LightGBM buckets continuous features into a fixed number of discrete bins (typically 255). Building a histogram — a count and gradient sum per bin — costs O(n)O(n), but finding the best split then costs only O(bins)O(\text{bins}) instead of O(n)O(n).

Think of it like grading exams: instead of ranking every student's exact score, you bin them into letter grades (A, B, C, D, F). You lose a tiny bit of precision, but you can spot the best split point between grades almost instantly. And with 255 bins, the precision loss is negligible.

An additional trick: the histogram subtraction optimization. If a parent node's histogram is known, the histogram of one child can be obtained by subtracting the other child's histogram from it. This halves the histogram construction cost.

Open in Lab
Drag the number of bins and watch how the histogram approximates the continuous distribution. More bins = more precision but more computation.
The demo wakes as you arrive…
Gain=12[GL2HL+λ+GR2HR+λ−(GL+GR)2HL+HR+λ]−γ\text{Gain} = \frac{1}{2}\left[\frac{G_L^2}{H_L + \lambda} + \frac{G_R^2}{H_R + \lambda} - \frac{(G_L + G_R)^2}{H_L + H_R + \lambda}\right] - \gamma
Split gain formula — the decision criterion for each split — G_L, G_R = sum of gradients in left/right child · H_L, H_R = sum of Hessians · λ = regularization on leaf weights · γ = penalty for adding a new leaf. The histogram stores G and H sums per bin, so evaluating all bin boundaries is fast.

Growing smarter: leaf-wise vs level-wise

Most boosting frameworks (including XGBoost's default) grow trees level-wise: they split all nodes at the current depth before moving deeper, producing balanced trees. This is safe but inefficient — it wastes splits on nodes that contribute little to the loss reduction.

LightGBM grows trees leaf-wise: at each step, it finds the leaf with the largest potential loss reduction across the entire tree and splits that one. This produces asymmetric, deeper trees that converge faster — achieving the same loss with fewer total splits.

The risk is : a leaf-wise tree can grow very deep on one side, memorizing noise in small partitions. LightGBM controls this with max_depth and num_leaves parameters — think of num_leaves as a budget: the tree can spend its splits wherever the gain is highest, but it cannot exceed the budget.

Open in Lab
Watch both strategies grow a tree on the same data. Leaf-wise reaches lower loss with fewer splits, but grows asymmetrically.
The demo wakes as you arrive…

GOSS: focus on the data that matters

Not all data instances contribute equally to learning. Instances with large gradients are the ones the model currently gets most wrong — they carry the most information for improving the next tree. Instances with small gradients are already well-predicted and contribute less.

GOSS exploits this insight: it keeps all instances with large gradients (the top aa fraction) and randomly samples from the remaining small-gradient instances (keeping a fraction bb). To avoid biasing the learned model, it multiplies the sampled small-gradient instances by a constant factor 1−ab\frac{1-a}{b} to compensate for the under-sampling.

The result: the histogram is built from a much smaller subset of the data, but the distribution of information gain is approximately preserved. Typical settings (a=0.2a = 0.2, b=0.1b = 0.1) mean the tree is built on only 30% of the data, yielding roughly a 2× speedup on top of histograms alone.

Open in Lab
Instances sorted by gradient magnitude. Orange = kept (large gradient), blue = randomly sampled (small gradient), gray = dropped. Adjust a and b to see the tradeoff.
The demo wakes as you arrive…
V~j(d)=1n(∑xi∈Algi+1−ab∑xi∈Blgi)2/  nl(j)(d)\tilde{V}_j(d) = \frac{1}{n}\left( \sum_{x_i \in A_l} g_i + \frac{1-a}{b}\sum_{x_i \in B_l} g_i \right)^2 \bigg/ \; n_l^{(j)}(d)
GOSS variance gain estimate — A = top-a% instances (large gradients, all kept) · B = randomly sampled b% from the rest · the factor (1−a)/b re-weights the sampled instances so the gain estimate stays approximately unbiased.

EFB: bundling sparse features together

Real-world datasets — especially after — are often highly sparse: most feature values are zero. Many of these features are mutually exclusive — they rarely take non-zero values simultaneously. For example, in one-hot encoded text data, the column for "apple" and the column for "orange" never both equal 1 in the same row.

EFB identifies such mutually exclusive features and merges them into a single bundle feature. If feature A ranges from 0–10 and feature B ranges from 0–20, the bundle stores A's values as-is and offsets B's values by adding 10. The tree can then split on the bundle instead of two separate features, cutting the effective feature count dramatically.

Finding the optimal bundling is NP-hard (it reduces to ), so EFB uses a greedy algorithm: build a conflict graph where edges connect features that are not mutually exclusive, then greedily assign features to bundles while allowing a small conflict rate.

Open in Lab
See how mutually exclusive features get merged into bundles. Toggle features to see the conflict graph and resulting bundles.
The demo wakes as you arrive…

The full pipeline: how LightGBM trains

Each boosting round proceeds as follows:

  1. Compute gradients for all instances using the current model's predictions.
  2. GOSS sampling — keep all large-gradient instances, randomly sample from the rest.
  3. EFB — bundle mutually exclusive features (done once at initialization).
  4. Build histograms for each feature (or bundle) on the sampled data.
  5. Find best splits by scanning histogram bins (not raw values).
  6. Grow the tree leaf-wise — always split the leaf with the highest gain.
  7. Add the new tree to the ensemble with a shrinkage.

Steps 4 and 5 are where the histogram trick saves time. Step 2 reduces the data going into step 4. Step 3 reduces the features. Together, they compound into the 20× speedup.

Open in Lab
Click through each stage of the LightGBM training pipeline. Watch data shrink at each step.
The demo wakes as you arrive…

The idea in code

Histogram-based split finding, simplifiedpython

Simplified to show the idea — not the real implementation.

import numpy as np

def build_histogram(feature_bins, gradients, hessians, n_bins=255):
    """Build gradient/hessian histogram for one feature."""
    grad_hist = np.zeros(n_bins)
    hess_hist = np.zeros(n_bins)
    for i in range(len(feature_bins)):
        b = feature_bins[i]
        grad_hist[b] += gradients[i]
        hess_hist[b] += hessians[i]
    return grad_hist, hess_hist

def find_best_split(grad_hist, hess_hist, reg_lambda=1.0):
    """Scan histogram bins to find the split with the highest gain."""
    G_total = grad_hist.sum()
    H_total = hess_hist.sum()
    best_gain, best_bin = -np.inf, -1
    G_left, H_left = 0.0, 0.0

    for b in range(len(grad_hist) - 1):
        G_left += grad_hist[b]
        H_left += hess_hist[b]
        G_right = G_total - G_left
        H_right = H_total - H_left

        gain = 0.5 * (
            G_left**2 / (H_left + reg_lambda)
            + G_right**2 / (H_right + reg_lambda)
            - G_total**2 / (H_total + reg_lambda)
        )
        if gain > best_gain:
            best_gain, best_bin = gain, b

    return best_bin, best_gain
# Key insight: we scan 255 bins, not millions of rows.
# That's where the speed comes from.

Experiments: speed and accuracy

The paper evaluated LightGBM on five public datasets ranging from 0.5M to 10M instances. Compared to XGBoost's pre-sorted algorithm, LightGBM achieved speedups of 6× to 21× while maintaining nearly identical accuracy (measured by for classification and NDCG@10 for ranking).

Breaking down the contributions: GOSS alone provides roughly a 2× speedup by training on 10–20% of the data. EFB provides additional speedup proportional to the feature — on one-hot encoded features, it can reduce the effective feature count by an order of magnitude. The histogram-based approach provides the foundation that both build on.

Open in Lab
Speedup of LightGBM over XGBoost (pre-sorted) on five benchmark datasets. Hover for details.
The demo wakes as you arrive…

Why LightGBM changed the landscape

  1. 2014

    XGBoost released

    Chen & Guestrin release XGBoost, which popularizes gradient boosting with regularization and becomes the dominant algorithm for Kaggle competitions.

  2. 2017

    LightGBM (this paper)

    Microsoft introduces GOSS + EFB + leaf-wise growth, achieving 20× speedup over conventional GBDT with near-identical accuracy.

  3. 2018

    CatBoost

    Yandex releases CatBoost with ordered boosting and native categorical feature handling, completing the modern boosting triad.

  4. 2020

    SHAP for interpretability

    Lundberg develops TreeSHAP — an exact, efficient algorithm for computing SHAP values on tree ensembles. LightGBM integrates it natively, making model interpretability a first-class feature.

  5. 2022

    Tabular ML dominance

    Studies confirm that gradient boosting (XGBoost, LightGBM, CatBoost) still outperforms deep learning on most tabular tasks, especially on medium-sized datasets.

CitationKe, Meng, Finley, Wang, Chen, Ma, Ye, Liu. LightGBM: A Highly Efficient Gradient Boosting Decision Tree. NeurIPS, 2017.

Terms in this paper