LongWriter: Unleashing 10,000+ Word Generation from Long Context LLMs

Yushi Bai, Jiajie Zhang, Xin Lv, Linzhi Zheng, Siqi Zhu, Lei Hou, Yuxiao Dong, Jie Tang, Juanzi Li

arXiv:2408.07055 · 2026-07-27 공개 · arXiv · PDF

llm long-context model-alignment dpo agentwrite longwriter-6k longbench-write ultra-long-generation

Abstract

Current long context large language models (LLMs) can process inputs up to 100,000 tokens, yet struggle to generate outputs exceeding even a modest length of 2,000 words. Through controlled experiments, we find that the model's effective generation length is inherently bounded by the sample it has seen during supervised fine-tuning (SFT). In other words, their output limitation is due to the scarcity of long-output examples in existing SFT datasets. To address this, we introduce AgentWrite, an agent-based pipeline that decomposes ultra-long generation tasks into subtasks, enabling off-the-shelf LLMs to generate coherent outputs exceeding 20,000 words. Leveraging AgentWrite, we construct LongWriter-6k, a dataset containing 6,000 SFT data with output lengths ranging from 2k to 32k words. By incorporating this dataset into model training, we successfully scale the output length of existing models to over 10,000 words while maintaining output quality. We also develop LongBench-Write, a comprehensive benchmark for evaluating ultra-long generation capabilities. Our 9B parameter model, further improved through DPO, achieves state-of-the-art performance on this benchmark, surpassing even much larger proprietary models. In general, our work demonstrates that existing long context LLM already possesses the potential for a larger output window--all you need is data with extended output during model alignment to unlock this capability. Our code&models are at: https://github.com/THUDM/LongWriter.

한국어 요약

한 줄 요약

LongWriter는 AgentWrite 파이프라인과 LongWriter-6k 데이터셋을 통해 기존 LLM의 출력 길이를 10,000단어 이상으로 확장하는 기법을 제시한다.

핵심 기여도

핵심 아이디어

기존 LLM이 2,000단어 이상의 출력을 생성하지 못하는 이유는 SFT 데이터에 긴 출력 예시가 부족하기 때문이라는 점을 발견했다. 이는 모델이 학습 과정에서 긴 출력을 생성하는 능력을 습득하지 못했음을 의미한다. 이를 해결하기 위해 AgentWrite라는 에이전트 기반 파이프라인을 설계했다. AgentWrite는 사용자 입력에 따라 글쓰기 계획을 수립하고, 이를 바탕으로 단락별로 순차적으로 출력을 생성함으로써 20,000단어 이상의 일관된 텍스트를 생성한다. 이 파이프라인을 활용해 LongWriter-6k 데이터셋을 구축하고, 이를 기존 모델에 학습시켜 출력 길이를 확장했다. 또한, DPO를 통해 모델의 긴 텍스트 생성 능력을 향상시켰다.

기술적 접근법

주요 결과

의의 및 한계

이 연구는 기존 LLM이 긴 출력을 생성할 잠재력을 가지고 있으며, 이를 활성화하려면 SFT 데이터에 긴 출력 예시가 포함되어야 함을 입증한다. AgentWrite와 LongWriter-6k는 기존 모델을 최소한의 수정 없이 확장할 수 있는 실용적인 방법을 제시한다. 그러나 LongWriter-6k는 GPT-4o에 의존하여 생성된 데이터로, 독립적인 데이터 생성 능력은 제한적이다. 또한, 10,000단어 이상의 출력은 추론 효율성에 영향을 줄 수 있으며, 이에 대한 최적화는 추가 연구가 필요하다.

실용적 활용

LongWriter는 긴 텍스트 생성이 필요한 산업, 예를 들어, 콘텐츠 제작, 학술 논문 작성, 법적 문서 작성 등에 적용 가능하다. 또한, 대규모 모델이 아닌 소규모 모델에서도 긴 출력을 생성할 수 있도록 기술적 접근법을 제공하여, 비용 효율적인 AI 활용이 가능하다.