# LightGBM

LightGBM 是一个开源的[梯度提升](https://www.edgepedia.org/zh/gradient-boosting)框架，它构建决策树集成模型，用于排序、分类、回归及其他表格型机器学习任务，在大规模数据集上训练速度快、内存占用低。<sup>[1](https://github.com/lightgbm-org/LightGBM/)</sup> 它实现了梯度提升决策树（GBDT），采用基于[直方图](https://www.edgepedia.org/zh/histogram)的分裂查找和按叶生长（leaf-wise）的树生长方式，并支持低通信成本的分布式训练以及 GPU 训练。<sup>[2](https://www.microsoft.com/en-us/research/project/lightgbm/)</sup>

| 关键事实 | 详情 |
|---|---|
| 产出物 | 用于排序、分类、回归及其他任务的树集成模型<sup>[1](https://github.com/lightgbm-org/LightGBM/)</sup> |
| 首次介绍该框架的论文 | 柯国霖等，2017，第 3149–3157 页<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf)</sup> |
| 核心效率技术 | 基于直方图的分裂、按叶生长、GOSS 采样、EFB 捆绑<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf)</sup><sup> • </sup><sup>[4](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup> |
| 报告的加速比 | 在几乎相同精度下，相比传统 GBDT 最高超过 20 倍<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf)</sup> |
| 内存示例 | Higgs（1050 万行，28 个特征）：峰值 0.897 GB，而 XGBoost 精确算法为 4.853 GB<sup>[5](https://lightgbm.readthedocs.io/en/latest/Experiments.html)</sup> |
| 分布式扩展性 | Criteo（17 亿条记录）：单机每棵树 627.8 秒，16 台机器降至 42 秒<sup>[5](https://lightgbm.readthedocs.io/en/latest/Experiments.html)</sup> |
| 当前版本 | v4.7.0（2026-07-18）；仓库于 2026 年 3 月迁至 lightgbm-org<sup>[1](https://github.com/lightgbm-org/LightGBM/)</sup> |

## 工作原理

梯度提升决策树构建一个加性模型，其中每一棵新树都拟合损失函数相对于当前预测值的梯度；该框架迭代地生长能够降低该损失的树。2017 年的论文将 XGBoost 和 pGBRT 列为现有的有效 GBDT 实现，但指出当特征维度高、数据规模大时，它们的效率和可扩展性并不令人满意。<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf)</sup> XGBoost 本身是陈天奇（Tianqi Chen）和卡洛斯·格斯特林（Carlos Guestrin）提出的可扩展树提升系统，于 2016 年发表。<sup>[6](https://doi.org/10.48550/arxiv.1603.02754)</sup>

基于直方图的分裂是第一大效率支柱。连续特征值被分入离散的桶中；构建每个直方图是一次快速的 \( O(\#data) \) 求和遍历，之后查找最佳分裂的代价为 \( O(\#bins) \)，远小于 \( \#data \)，而基于预排序的算法每次分裂搜索都要付出 \( O(\#data) \) 的代价。<sup>[4](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup> 论文将同一复杂度分两部分表述：直方图构建为 \( O(\#data \cdot \#feature) \)，分裂点查找为 \( O(\#bin \cdot \#feature) \)，因此直方图构建占主导，减少 #data 或 #feature 能大幅加速训练。<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf)</sup> 直方图相减还能以 \( O(\#bins) \) 的代价获得某个叶节点的相邻直方图。<sup>[4](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup>

按叶（最佳优先）生长是第二大支柱。LightGBM 不是在一层上生长所有节点，而是选择损失降幅最大的叶节点进行下一次分裂。在叶节点数量固定的情况下，按叶生长的树往往比按层生长的树达到更低的损失，这就是为什么用更少、选择更优的分裂就能达到相同精度。<sup>[4](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup>

论文中还有两项技术直接减少数据量和特征数。基于梯度的单边采样（GOSS）排除相当比例的小梯度实例，用其余实例估计信息增益；它保留选定比例的大梯度实例，对剩余小梯度实例采样选定比例，并对这些被采样的实例重新加权，以保持信息增益估计无偏；在 LETOR 上，相同采样比例下其精度始终优于随机梯度提升。<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf)</sup> 完全丢弃小梯度样本会降低性能，因此 GOSS 以受控比例保留它们。<sup>[7](https://export.arxiv.org/pdf/2305.17094v1.pdf)</sup> 互斥特征捆绑（EFB）捆绑互斥特征，即很少同时取非零值的特征，使直方图构建复杂度从 \( O(\#data \cdot \#feature) \) 降至 \( O(\#data \cdot \#bundle) \)。寻找最优捆绑是 NP 难的，可由图着色问题归约证明，但贪心算法能达到良好的近似比。<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf)</sup>

## 实现方式

实践者通过选择目标函数、树生长预算和正则化约束来训练 LightGBM 模型。支持的目标函数包括 L2 损失回归、二分类和多分类、交叉熵（logloss），以及带 NDCG 的 LambdaRank；支持的指标包括 AUC、NDCG、MAP、Huber、Poisson、Quantile 和 Tweedie。<sup>[4](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup>

由于生长是按叶进行的，模型复杂度由 `num_leaves` 而非仅由深度控制。在官方与 XGBoost 的对比中，LightGBM 使用 `num_leaves=255`，而 xgboost 以 `max_depth=8`（至多 255 个叶节点）按深度生长树。<sup>[5](https://lightgbm.readthedocs.io/en/latest/Experiments.html)</sup> 由于按叶生长的树可能以很少的叶节点长得非常深，LightGBM 包含 `max_depth` 参数来限制树深，作为过拟合控制。<sup>[4](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup> 基于采样的正则化通过数据采样策略配置；自 v4.0.0 起，用 `data_sample_strategy='goss'` 选择 GOSS，默认值为 `'bagging'`。<sup>[8](https://github.com/lightgbm-org/LightGBM/releases/tag/v4.0.0)</sup>

类别特征无需独热编码即可处理。对于有 k 个类别的类别特征，存在 \( 2^{k-1} - 1 \) 种可能的二子集划分；LightGBM 按累积的 `sum_gradient / sum_hessian` 值对该特征的直方图排序，并在排序后的直方图上以约 \( O(k \log k) \) 的代价找到最佳分裂。<sup>[4](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup>

API 与集成覆盖常见工作流，包括用于 Spark 上 LightGBM 的 SynapseML、用于 Ray 的 lightgbm_ray、Dask、ML.NET、ONNXMLTools、SHAP、Treelite、cuML GPU 推理，以及 FLAML/Optuna 自动调参。<sup>[1](https://github.com/lightgbm-org/LightGBM/)</sup>

## 起源

LightGBM 由柯国霖（Guolin Ke）及其同事于 2017 年在《LightGBM: A Highly Efficient Gradient Boosting Decision Tree》中提出，发表于 NeurIPS 2017 会议论文集。<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf)</sup> GitHub 仓库创建于 2016-08-05。<sup>[1](https://github.com/lightgbm-org/LightGBM/)</sup> 由 LightGBM 贡献者撰写的一篇微软基准博客称 LightGBM“始于 2016 年 3 月，于 2016 年 8 月开源”，<sup>[9](https://learn.microsoft.com/en-us/archive/blogs/machinelearning/lessons-learned-benchmarking-fast-machine-learning-algorithms)</sup> 而[微软研究院](https://www.edgepedia.org/zh/microsoft-research)项目页面称其成立于 2016 年 10 月 1 日。<sup>[2](https://www.microsoft.com/en-us/research/project/lightgbm/)</sup> LightGBM 中使用的投票并行[分布式算法](https://www.edgepedia.org/zh/distributed-algorithm)建立在孟奇（Qi Meng）及其同事于 2016 年在 arXiv（康奈尔大学）上发表的通信高效决策树并行算法之上。<sup>[10](https://doi.org/10.48550/arxiv.1611.01276)</sup>

## 变体

分布式学习提供特征并行、数据并行和投票并行模式。LightGBM 中的数据并行使用 Reduce Scatter 和直方图相减，时间复杂度为 \( O(0.5 \cdot \#feature \cdot \#bin) \)，投票并行通过针对特征直方图的两阶段投票，将通信成本降至常数。<sup>[4](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup> GPU 变体在张焕（Huan Zhang）、司思（Si Si）和谢卓睿（Cho-Jui Hsieh）的《GPU-acceleration for Large-scale Tree Boosting》中描述，2017 年以 arXiv 预印本发布，2018 年在 SysML 会议上展示。<sup>[11](https://doi.org/10.48550/arxiv.1706.08359)</sup> 量化训练是后来大幅提升 CPU 训练速度的变体，出自石宇（Yu Shi）及其同事的《Quantized Training of Gradient Boosting Decision Trees》，2022 年发表于 arXiv（康奈尔大学）。<sup>[12](https://doi.org/10.48550/arxiv.2207.09682)</sup> 4.0.0 版本带来了完全重写的 CUDA 实现，更多操作在 GPU 上执行，还有量化训练，以及带自动 OpenCL GPU 支持的 manylinux_2_28 wheel，因此 `pip install lightgbm` 后跟 `{"device": "gpu"}` 无需自定义构建即可工作。<sup>[8](https://github.com/lightgbm-org/LightGBM/releases/tag/v4.0.0)</sup> Python 包附带一个兼容 scikit-learn 的估计器；自 v4.0.0 起，scikit-learn 不再是必需依赖。<sup>[8](https://github.com/lightgbm-org/LightGBM/releases/tag/v4.0.0)</sup>

## 应用

2017 年的论文报告，在五个公开数据集（LETOR、Allstate Insurance Claim、Flight Delay、KDD CUP 2010、KDD CUP 2012）上，LightGBM 将传统 GBDT 训练加速最高超过 20 倍，同时达到几乎相同的精度。<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf)</sup> 官方实验页面报告，对于 Higgs（1050 万行 × 28 个特征），训练耗时 130.094 秒，而 xgboost 精确算法为 3794.34 秒，精度基本相等或更好，峰值内存为 0.897 GB 对 4.853 GB。<sup>[5](https://lightgbm.readthedocs.io/en/latest/Experiments.html)</sup> 微软 Azure 在六个数据集上的基准发现，LightGBM 在 CPU 和 GPU 上都比 XGBoost 和 XGBoost hist 更快，F1 精度相近。<sup>[9](https://learn.microsoft.com/en-us/archive/blogs/machinelearning/lessons-learned-benchmarking-fast-machine-learning-algorithms)</sup> 对于分布式训练，在 Criteo 万亿字节点击日志数据集（17 亿条记录，67 个特征）上，数据并行的 LightGBM 从单机每棵树 627.8 秒降至 16 台机器上的 42 秒，每台机器内存从 176 GB 降至 11 GB，呈线性加速。<sup>[5](https://lightgbm.readthedocs.io/en/latest/Experiments.html)</sup> 除了在机器学习竞赛的获胜方案中被广泛使用外，<sup>[1](https://github.com/lightgbm-org/LightGBM/)</sup> 此处引用的已发表文献中没有记录具体的行业或科学部署案例研究。

## 局限性与替代方案

小数据上的过拟合是按叶生长的主要失效模式。由于按叶生长的树可能以很少的叶节点长得深，它们容易过拟合，尤其在训练样本数少或树生长得很深时；文档因此建议用 `max_depth` 限制深度。<sup>[4](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup><sup> • </sup><sup>[7](https://export.arxiv.org/pdf/2305.17094v1.pdf)</sup> GPU 加速有其自身的阈值：在小数据集上，RAM 与 GPU 内存之间的数据传输开销超过计算收益，因此 GPU 训练主要在大数据集、多轮次时才有价值。<sup>[9](https://learn.microsoft.com/en-us/archive/blogs/machinelearning/lessons-learned-benchmarking-fast-machine-learning-algorithms)</sup>

与 XGBoost 相比，官方基准显示在测试数据集上以相等或更好的精度取得大幅速度和内存优势，<sup>[5](https://lightgbm.readthedocs.io/en/latest/Experiments.html)</sup> 但在 GPU 上情况并不一致：一项独立的网格搜索基准发现 XGBoost 的平均 GPU 加速比最高（平均 7.26 倍，中位数 3.32 倍），CatBoost 平均 3.7 倍，LightGBM 最低，平均 2.35 倍（中位数 0.75 倍，排除 goss 提升类型后升至平均 3.57 倍、中位数 1.32 倍）。<sup>[13](https://arxiv.org/pdf/1809.04559)</sup> 同一基准指出，LightGBM 的 GPU 实现仅用 GPU 构建特征直方图，而 XGBoost 的 gpu_hist 因 GPU 内存限制在 Epsilon 数据集上失败，LightGBM 则完成了。<sup>[13](https://arxiv.org/pdf/1809.04559)</sup> CatBoost 由 [Yandex](https://www.edgepedia.org/zh/yandex) 于 2017 年开源，在安娜·维罗妮卡·多罗古什（Anna Veronika Dorogush）、瓦西里·叶尔绍夫（Vasily Ershov）和安德烈·古林（Andrey Gulin）的技术报告中描述，该报告在 NIPS 2017 学习系统研讨会上展示；CatBoost 使用对称树，不能恰当处理稀疏数据，用特征最小值或最大值填补缺失值，且不支持 L1 正则化，与 XGBoost 或 LightGBM 不同。<sup>[14](https://doi.org/10.48550/arxiv.1810.11363)</sup><sup> • </sup><sup>[7](https://export.arxiv.org/pdf/2305.17094v1.pdf)</sup> 经过 TPE 超参数调优后，在该比较研究中四个库（GBM、XGBoost、LightGBM、CatBoost）表现非常相似，LightGBM 最佳且最稳定，调优收益最大，例如在信用卡欺诈数据集上平均 AUC 提升近 24%。<sup>[7](https://export.arxiv.org/pdf/2305.17094v1.pdf)</sup> 此处未引用 LightGBM 与表格数据上深度学习模型的已发表直接对比基准，因此无法陈述与神经表格模型的比较。

## References

1. [lightgbm-org/LightGBM, official GitHub repository (Microsoft/LightGBM page merged)](https://github.com/lightgbm-org/LightGBM/)
2. [LightGBM, Microsoft Research project page](https://www.microsoft.com/en-us/research/project/lightgbm/)
3. [LightGBM: A Highly Efficient Gradient Boosting Decision Tree (NeurIPS 2017, full paper; abstract page merged)](https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf)
4. [Features, LightGBM official documentation (latest; earlier versions merged)](https://lightgbm.readthedocs.io/en/latest/Features.html)
5. [Experiments, LightGBM official documentation (benchmark records; first version 27 Feb 2017, updated March 2020)](https://lightgbm.readthedocs.io/en/latest/Experiments.html)
6. [Chen, Tianqi, Guestrin, Carlos (2016). XGBoost: A Scalable Tree Boosting System. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1603.02754)
7. [Comparison study of gradient boosting variants (GBM, XGBoost, LightGBM, CatBoost) with hyperparameter tuning](https://export.arxiv.org/pdf/2305.17094v1.pdf)
8. [Release v4.0.0 · lightgbm-org/LightGBM](https://github.com/lightgbm-org/LightGBM/releases/tag/v4.0.0)
9. [Lessons Learned From Benchmarking Fast Machine Learning Algorithms (Microsoft, July 2017)](https://learn.microsoft.com/en-us/archive/blogs/machinelearning/lessons-learned-benchmarking-fast-machine-learning-algorithms)
10. [Meng, Qi and colleagues (2016). A Communication-Efficient Parallel Algorithm for Decision Tree. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1611.01276)
11. [Zhang, Huan, Si, Si, Hsieh, Cho-Jui (2017). GPU-acceleration for Large-scale Tree Boosting. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1706.08359)
12. [Shi, Yu and colleagues (2022). Quantized Training of Gradient Boosting Decision Trees. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2207.09682)
13. [Benchmarking and Optimization of Gradient Boosting Decision Tree Libraries](https://arxiv.org/pdf/1809.04559)
14. [Dorogush, Anna Veronika, Ershov, Vasily, Gulin, Andrey (2018). CatBoost: gradient boosting with categorical features support. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1810.11363)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Ensemble, boosting, and transfer methods › Boosting algorithms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/lightgbm

English original: https://www.edgepedia.org/lightgbm
