让小模型通过自我学习,搞定长文本任务而不丢短文本能力。
LongPO: Long Context Self-Evolution of Large Language Models through Short-to-Long Preference Optimization
- 用自生成的长短上下文对比数据,让模型自己学长文本处理。
- 在128K→512K上下文长度下,短文本性能不降,长文本超越GPT-4-128K。
- 适合想低成本提升模型长文本能力的研究者和开发者。
大语言模型(LLMs)在预训练和对齐后展现出强大能力,但优秀短上下文模型在长上下文场景中表现可能下降,因缺乏长上下文对齐。由于人工标注长上下文不现实,且难以平衡长短上下文性能,该问题仍具挑战性。为此,我们提出LongPO,使短上下文模型通过内部迁移能力,自演化以精通长上下文任务。LongPO利用大模型自生成短-长上下文偏好数据:对相同指令,分别生成长上下文输入与压缩后的短上下文对应响应。这种偏好揭示了短上下文对齐中培养的能力在长上下文对齐不足时被削弱的潜力。同时,引入短到长的KL约束,防止长上下文对齐过程中短文本性能下降。在将Mistral-7B-Instruct-v0.2从128K扩展至512K上下文长度时,LongPO完全保留短文本性能,并在长、短任务上显著优于朴素SFT和DPO。具体而言,其长文本表现可媲美甚至超越依赖大量长文本标注和更大参数量的先进模型(如GPT-4-128K)。代码已开源:https://github.com/DAMO-NLP-SG/LongPO。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have demonstrated remarkable capabilities through pretraining and alignment. However, superior short-context LLMs may underperform in long-context scenarios due to insufficient long-context alignment. This alignment process remains challenging due to the impracticality of human annotation for extended contexts and the difficulty in balancing short- and long-context performance. To address these challenges, we introduce LongPO, that enables short-context LLMs to self-evolve to excel on long-context tasks by internally transferring short-context capabilities. LongPO harnesses LLMs to learn from self-generated short-to-long preference data, comprising paired responses generated for identical instructions with long-context inputs and their compressed short-context counterparts, respectively. This preference reveals capabilities and potentials of LLMs cultivated during short-context alignment that may be diminished in under-aligned long-context scenarios. Additionally, LongPO incorporates a short-to-long KL constraint to mitigate short-context performance decline during long-context alignment. When applied to Mistral-7B-Instruct-v0.2 from 128K to 512K context lengths, LongPO fully retains short-context performance and largely outperforms naive SFT and DPO in both long- and short-context tasks. Specifically, LongPO-trained models can achieve results on long-context benchmarks comparable to, or even surpassing, those of superior LLMs (e.g., GPT-4-128K) that involve extensive long-context annotation and larger parameter scales. Our code is available at https://github.com/DAMO-NLP-SG/LongPO.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。