通过优化训练数据与策略,让小模型高效处理超长文本。
How to Train Long-Context Language Models (Effectively)
- 用代码和书籍构建长文本数据,搭配短文本提升效果
- 训练序列长度超过评估长度,显著增强长文本理解能力
- 仅用短指令数据微调即可在长文本任务上表现优异
我们研究了语言模型的持续预训练与监督微调(SFT),以有效利用长上下文信息。建立了一套可靠的评估协议,采用多样化的长上下文下游任务,并在SFT后评估模型,更准确揭示其长文本能力。基于稳健评估,我们系统实验了持续预训练数据组合、指令微调数据集等设计选择,包括位置外推。结果表明:(1) 代码仓库和书籍是优质长文本来源,但需与高质量短文本数据结合;(2) 训练时使用超过评估长度的序列可提升长文本性能;(3) 仅用短指令数据集进行SFT,也能在长文本任务上取得优异表现。最终模型ProLong-8B(基于Llama-3,训练400亿token)在128K上下文长度下达到同类模型最优水平,且在多数长文本任务中优于使用5%更多训练令牌的Llama-3.1-8B-Instruct。ProLong还能有效处理高达512K tokens,是公开可用模型中上下文最长之一。
原文摘要 · Abstract (English)
We study continued training and supervised fine-tuning (SFT) of a language model (LM) to make effective use of long-context information. We first establish a reliable evaluation protocol to guide model development -- instead of perplexity or simple needle-in-a-haystack (NIAH) tests, we use a broad set of long-context downstream tasks, and we evaluate models after SFT as this better reveals long-context abilities. Supported by our robust evaluations, we run thorough experiments to decide the data mix for continued pre-training, the instruction tuning dataset, and many other design choices such as position extrapolation. We find that (1) code repositories and books are excellent sources of long data, but it is crucial to combine them with high-quality short-context data; (2) training with a sequence length beyond the evaluation length boosts long-context performance; (3) for SFT, using only short instruction datasets yields strong performance on long-context tasks. Our final model, ProLong-8B, which is initialized from Llama-3 and trained on 40B tokens, demonstrates state-of-the-art long-context performance among similarly sized models at a length of 128K. ProLong outperforms Llama-3.1-8B-Instruct on the majority of long-context tasks despite using only 5% as many tokens during long-context training. Additionally, ProLong can effectively process up to 512K tokens, one of the longest context windows of publicly available LMs.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。