TL;DR
Researchers have discovered that the "short-output" limitation of current Large Language Models (LLMs) is a data problem, not a model architecture issue. Models are effectively capped by the maximum length of examples in their fine-tuning sets. By introducing AgentWrite, a pipeline that uses a "plan-then-write" strategy to generate ultra-long training data, the authors successfully trained a 9B model to generate coherent outputs exceeding 10,000 words, outperforming much larger proprietary models.
The Problem: The 2,000-Word Wall
We are currently in the era of "Long Context" LLMs, with models like Gemini and Claude boasting input windows of 100,000 to over 1,000,000 tokens. However, there is a glaring asymmetry: while these models can read a library, they struggle to write more than a few pages.
Most state-of-the-art models hit a wall at approximately 2,000 words. If you ask for a 10,000-word history of the Roman Empire, the model will likely provide a high-level summary that falls significantly short of the requested length. This paper investigates the root cause of this "bounded generation length" and provides a scalable solution to unlock the latent long-form writing potential already present in these models.
Methods: Unlocking Length with AgentWrite
The authors' approach tackles the problem through a systematic, three-phase methodology:
- Probing the Cause: Through controlled experiments, the researchers found that a model's maximum output length is strictly correlated with the maximum length of the samples it saw during Supervised Fine-Tuning (SFT). Because most SFT datasets (often distilled from other LLMs) rarely exceed 2,000 words, models "learn" this as an implicit constraint.
- The AgentWrite Pipeline: To create the missing ultra-long training data, they developed an agentic workflow:
- Step I (Plan): The LLM breaks a long prompt into a detailed outline, assigning specific word count requirements to each subsection.
- Step II (Write): The model generates each section serially. Crucially, it receives the previously generated sections as context to ensure narrative flow and coherence.
- Model Training: Using AgentWrite, the team constructed LongWriter-6k, a dataset of 6,000 high-quality, ultra-long outputs ranging from 2,000 to 32,000 words. They fine-tuned GLM-4-9B and Llama-3.1-8B on a mixture of this data and general SFT data.
- Alignment (DPO): Finally, they applied Direct Preference Optimization (DPO) to help the model better follow specific length constraints and improve overall writing quality.
Datasets and Evaluation
- LongWriter-6k: A new SFT dataset containing 6,000 examples with outputs ranging from 2,000 to 32,000 words, generated via the AgentWrite pipeline.
- LongBench-Write: A comprehensive evaluation benchmark consisting of 120 diverse prompts (half English, half Chinese) with explicit length requirements ranging from 500 to over 20,000 words.
- LongWrite-Ruler: A diagnostic tool used to test the absolute maximum output length a model can provide across varying length requirements.
Key Insights
- The "SFT Cap": The most significant finding is that the generation limit is an alignment artifact. Even if a model is pre-trained on massive sequences, the SFT phase "shrinks" its output window to match the training distribution.
- Serial > Parallel: In the AgentWrite pipeline, generating sections serially (using previous sections as context) is vital. Parallel generation (writing sections independently) leads to a 6% drop in coherence, as the model loses the "connective tissue" between paragraphs.
- Data Over Scale: A 9B parameter model trained on LongWriter-6k can generate longer and more coherent text than a 70B model or even massive proprietary models that lack long-form SFT data.
- DPO for Length Adherence: While SFT enables long generation, DPO is what makes the model "obedient" to specific word count requests (e.g., hitting exactly 5,000 words when asked).
Key Results
- 10,000+ Word Generation: The resulting LongWriter-9B model successfully scaled output length from the standard 2k limit to over 10k words while maintaining high quality.
- State-of-the-Art Performance: On the LongBench-Write benchmark, the LongWriter-9B-DPO model achieved a score of 84.0, surpassing GPT-4o (78.6) and Claude 3.5 Sonnet (80.7), particularly in the 4k–20k word range where proprietary models often failed to meet length requirements.
- Coherence Validation: Using Negative Log-Likelihood (NLL) tests, the authors proved that the long outputs were logically connected and exhibited long-range dependencies, rather than degrading into rambling or repetitive text.
Limitations and Future Work
- Inference Efficiency: Generating 10,000 words is computationally expensive and slow. Each new paragraph requires re-processing the entire preceding text, leading to high latency.
- Mechanical Tone: Human evaluations noted that AgentWrite-generated text can sometimes feel "mechanical," such as ending every paragraph with a repetitive summary or transition.
- Extreme Lengths: While 10k–20k words is a massive leap, the authors suggest that with even more data, models could eventually reach 100k-word generation (novel-length) in a single pass.
- Task Expansion: Future work could apply this method to other long-form tasks, such as generating entire software codebases or massive technical documentation.
Summary updated