arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2505.23971cs.LG
收藏

临界批量大小再探:一种面向大批量语言模型训练的简单经验方法

Critical Batch Size Revisited: A Simple Empirical Approach to Large-Batch Language Model Training

Allen Institute for AI(人工智能研究所)

William Merrill, Shane Arora, Dirk Groeneveld, Hannaneh Hajishirzi

AI总结:

本文提出一种直接测量临界批量大小(CBS)的简单经验方法,发现 CBS 随训练先升后稳,并据此验证批量大小预热可在减少 43% 梯度步数的情况下训练 OLMo 1B 达到更优损失。

摘要:

在规模化训练语言模型时,选择合适的批量大小非常重要:大批量对于快速训练是必要的,但过大的批量会损害 token 效率。为了权衡这一矛盾,McCandlish 等人(2018)提出可以根据训练过程中的梯度噪声尺度来估计临界批量大小(CBS),低于该批量时训练不会显著降低损失。尽管他们的方法已在实践中被采用,例如在训练 GPT-3 时,但要用梯度噪声作为 CBS 的代理指标需要很强的假设,这使得他们的方法在实践中是否值得信赖并不明确,从而限制了其适用性。在本文中,我们引入一种简单的经验方法来直接测量 CBS,并展示 CBS 在训练过程中如何演变。将我们的方法应用于 OLMo 模型后,我们发现 CBS 在初始化时接近 0,随后迅速增大,并在训练推进过程中趋于平稳。此外,我们发现这一趋势在不同模型规模(1B 和 7B)下都成立,这表明从小规模训练运行中得到的 CBS 可以为更大规模的训练运行提供参考。我们关于 CBS 在训练过程中如何变化的发现,促使我们将批量大小预热(batch size warmup)作为一种在大批量下可靠训练语言模型的自然方式:从较小的批量开始,并随着 CBS 的增长而增大批量。为了验证这一主张,我们使用批量大小预热来训练 OLMo 1B,在梯度步数减少 43% 的情况下,取得了比原始训练运行略好的损失。这表明我们的框架可以应用于以更大批量可靠地训练语言模型,在不牺牲性能的情况下提高数据并行度。

英文摘要:

The right batch size is important when training language models at scale: a large batch size is necessary for fast training, but a batch size that is too large will harm token efficiency. To navigate this tradeoff, McCandlish et al. (2018) suggest that a critical batch size (CBS), below which training will not substantially degrade loss, can be estimated based on the gradient noise scale during training. While their method has been adopted in practice, e.g., when training GPT-3, strong assumptions are required to justify gradient noise as a proxy for the CBS, which makes it unclear whether their approach should be trusted in practice, limiting its applicability. In this paper, we introduce a simple, empirical approach to directly measure the CBS and show how the CBS evolves over training. Applying our approach to the OLMo models, we find that CBS is near 0 at initialization, increases rapidly at first, and then plateaus as training progresses. Furthermore, we find that this trend holds across different model sizes (1B and 7B), suggesting CBS from small training runs can inform larger-scale training runs. Our findings about how the CBS changes over training motivate batch size warmup as a natural way to reliably train language models at large batch size: start the batch size small and increase it as the CBS grows. To validate this claim, we use batch size warmup to train OLMo 1B to slightly better loss than the original training run with 43% fewer gradient steps. This shows how our framework can be applied to reliably train language models at larger batch sizes, increasing data parallelism without compromising performance.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑