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 data points and features, the cost is per tree node — and a typical model has thousands of nodes across hundreds of trees.
When reaches millions and reaches thousands, the training time becomes a serious practical barrier.
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 , but finding the best split then costs only instead of .
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.
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.
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 fraction) and randomly samples from the remaining small-gradient instances (keeping a fraction ). To avoid biasing the learned model, it multiplies the sampled small-gradient instances by a constant factor 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 (, ) mean the tree is built on only 30% of the data, yielding roughly a 2× speedup on top of histograms alone.
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.
The full pipeline: how LightGBM trains
Each boosting round proceeds as follows:
- Compute gradients for all instances using the current model's predictions.
- GOSS sampling — keep all large-gradient instances, randomly sample from the rest.
- EFB — bundle mutually exclusive features (done once at initialization).
- Build histograms for each feature (or bundle) on the sampled data.
- Find best splits by scanning histogram bins (not raw values).
- Grow the tree leaf-wise — always split the leaf with the highest gain.
- 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.
The idea in code
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.
Why LightGBM changed the landscape
2014
XGBoost released
Chen & Guestrin release XGBoost, which popularizes gradient boosting with regularization and becomes the dominant algorithm for Kaggle competitions.
2017
LightGBM (this paper)
Microsoft introduces GOSS + EFB + leaf-wise growth, achieving 20× speedup over conventional GBDT with near-identical accuracy.
2018
CatBoost
Yandex releases CatBoost with ordered boosting and native categorical feature handling, completing the modern boosting triad.
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.
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
- Gradient Boostingتعزيز التدرج
- Decision Treeشجرة القرار الإحصائية
- Histogramالمُدرَّج التكراري
- Feature Importanceأهمية السمات
- Overfittingفرط التخصيص
- Learning Rateمعدل التعلم
- Ensembleالنماذج التجميعية الهجينة
- Boostingالتجميع المتتالي التراكمي للنماذج
- XGBoostإكس جي بوست
- LightGBMلايت جي بي إم
- Feature Extractionاستخلاص السمات
- Sparsityالتناثر البنيوي للمصفوفات