LongPO: Long Context Self-Evolution of Large Language Models through Short-to-Long Preference Optimization

Guanzheng Chen, Xin Li, Michael Qizhe Shieh, Lidong Bing
2/19/2025
cs.CLcs.LG

Official code: DAMO-NLP-SG/LongPO (44 stars, last commit 2025-02-27).

Abstract

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.

View on arXivView PDF

Code Implementations(1)

DAMO-NLP-SG/LongPOOfficial100%

[ICLR 2025] LongPO: Long Context Self-Evolution of Large Language Models through Short-to-Long Preference Optimization

445Shell, PythonOct 17, 20241 years ago

Cite this paper

@article{chen2025longpo,
  title  = {LongPO: Long Context Self-Evolution of Large Language Models through Short-to-Long Preference Optimization},
  author = {Guanzheng Chen and Xin Li and Michael Qizhe Shieh and Lidong Bing},
  year   = {2025},
  eprint = {2502.13922},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.13922v3},
  journal = {ICLR 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.13922.svg)](https://codeofpaper.com/paper/2502.13922)

Discussion