arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2612.03183cs.LGcs.AI
收藏

关键序列长度:关于文档结构如何限制梯度噪声降低的注记

Critical Sequence Length: A Note on How Document Structure Bounds Gradient-Noise Reduction

Oracle(甲骨文公司)

Sunny Guha

AI总结:

本文研究LLM预训练中梯度噪声缩放规则的失效问题,提出关键序列长度S*概念,通过GPT模型实验验证数据、模型规模等对S*的影响,得出批量大小与序列长度的权衡规则。

摘要:

大语言模型(LLM)预训练通常将训练序列中的每个 token 视为梯度的独立样本。在该假设下,梯度噪声的缩放关系为1/(B×S),其中B为批量大小,S为序列长度,因此当S加倍时B需减半。本文表明该规则在超过某一特定长度后会失效,且可测量该失效点。基于对下一个 token 训练中梯度噪声产生的简单模型,我们将噪声拆分为两部分:随1/S平均消失的每 token 项,以及由同一文档内 token 间相关性导致的、不会消失的基底项。两者在关键序列长度S*处交汇:低于该长度时,更长的序列可降低梯度噪声;高于该长度时,序列虽增加上下文但几乎无法降低噪声。我们在参数规模1.25亿至10亿的GPT模型上验证了该结论,模型分别在短网页文档(FineWeb-Edu)和整本书籍(古腾堡项目)上训练,结果显示该结论拟合良好,仅在书籍和人工切分数据上存在有意义的例外。主要发现有三点:第一,S*由数据决定,取决于文档及其打包方式,将文档切分为短片段会使基底项减半;第二,在AdamW实际应用的更新中测得的关键长度,在不同模型规模和训练时间下基本稳定(10亿参数模型在不同语料库间也稳定),仅随训练长度增长,而原始梯度版本的关键长度变化极大;第三,在接近该长度训练时验证损失最低,且超过该长度后损失变化很小,但下游性能更脆弱:将更多文档打包进每个序列时性能会小幅下降,而将文档切分为短片段时性能会崩溃。文档内注意力掩码可在大量打包时保持关键长度稳定并降低损失。这些结果形成了一种简单的、感知不同 regime 的批量大小与序列长度的权衡规则。

英文摘要:

LLM pre-training commonly treats every token in a training sequence as an independent sample of the gradient. Under this assumption, gradient noise scales as 1/(BS) for batch size B and sequence length S, so B is halved whenever S is doubled. We show that this rule breaks down beyond a certain length, and that the point where it breaks down can be measured. Guided by a simple model of how gradient noise arises in next-token training, we split the noise into two parts: a per-token term that averages away as 1/S, and a floor, caused by correlations between tokens of the same document, that does not. The two meet at a critical sequence length S*. Below it, longer sequences reduce gradient noise; above it, they add context but barely reduce the noise. We test this picture on GPT models from 125M to 1B parameters, trained on short web documents (FineWeb-Edu) and on whole books (Project Gutenberg), and find that it fits well, with informative exceptions on books and on artificially chopped data. Three findings stand out. First, S* is set by the data: it depends on the documents and on how they are packed into sequences, and chopping documents into short pieces halves the floor. Second, the critical length measured on the updates that AdamW actually applies is largely stable across model sizes and training time (and, at 1B, across corpora) and grows only with the training length, whereas the raw-gradient version varies widely. Third, validation loss is lowest when training near this length and changes little beyond it, but downstream performance is more fragile: it drops modestly as more documents are packed into each sequence and collapses when documents are chopped into short pieces. Intra-document attention masking keeps the critical length stable under heavy packing and lowers the loss. These results lead to a simple, regime-aware rule for trading batch size against sequence length.

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

↑