Papers › LongWriter-Zero: Mastering Ultra-Long Text Generation via Reinforcement Learning

LongWriter-Zero: Mastering Ultra-Long Text Generation via Reinforcement Learning

23 Jun 2025arXiv:2506.18841archive 2025-07-28

Yuhao Wu, Yushi Bai, Zhiqiang Hu, Roy Ka-Wei Lee, Juanzi Li

Ultra-long generation by large language models (LLMs) is a widely demanded scenario, yet it remains a significant challenge due to their maximum generation length limit and overall quality degradation as sequence length increases. Previous approaches, exemplified by LongWriter, typically rely on ''teaching'', which involves supervised fine-tuning (SFT) on synthetic long-form outputs. However, this strategy heavily depends on synthetic SFT data, which is difficult and costly to construct, often lacks coherence and consistency, and tends to be overly artificial and structurally monotonous. In this work, we propose an incentivization-based approach that, starting entirely from scratch and without relying on any annotated or synthetic data, leverages reinforcement learning (RL) to foster the emergence of ultra-long, high-quality text generation capabilities in LLMs. We perform RL training starting from a base model, similar to R1-Zero, guiding it to engage in reasoning that facilitates planning and refinement during the writing process. To support this, we employ specialized reward models that steer the LLM towards improved length control, writing quality, and structural formatting. Experimental evaluations show that our LongWriter-Zero model, trained from Qwen2.5-32B, consistently outperforms traditional SFT methods on long-form writing tasks, achieving state-of-the-art results across all metrics on WritingBench and Arena-Write, and even surpassing 100B+ models such as DeepSeek R1 and Qwen3-235B. We open-source our data and model checkpoints under https://huggingface.co/THU-KEG/LongWriter-Zero-32B

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2506.18841")

Code

Syntology Ran 6 of 14 code samples harvested from 1 repository linked to this paper; 8 have no recorded run. Of those that ran: 4 ran · our draft was wrong; 2 ran · fixture could not drive it.

By repository: community (archive-listed): 14 samples from 1 repository, 6 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

thudm/longwriter mentioned on GitHubpytorchApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

14 samples harvested; 6 ran; 0 honoured the contract we drafted; 8 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

4ran · our draft was wrong
2ran · fixture could not drive it
8unverified

Licence: 0 of the 14 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from thudm/longwriter. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

repeat_kv thudm/longwriter/train/patch/modeling_llama.py community (archive-listed) ran · fixture could not drive it fingerprinted Apache-2.0 (permissive) · 30d7eec482ebf6b1 · report
apply_rotary_pos_emb thudm/longwriter/train/patch/modeling_llama.py community (archive-listed) ran · our draft was wrong Apache-2.0 (permissive) · bac65c3dafaec040 · report
apply_rotary_pos_emb thudm/longwriter/train/patch/modeling_chatglm.py community (archive-listed) ran · fixture could not drive it Apache-2.0 (permissive) · 5cfeaee89a75c5ff · report
extract_info thudm/longwriter/evaluation/eval_quality.py community (archive-listed) ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 05ae45b3b7e836be · report
rotate_half thudm/longwriter/train/patch/modeling_llama.py community (archive-listed) ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · b99eea6376d1e212 · report
split_tensor_along_last_dim thudm/longwriter/train/patch/modeling_chatglm.py community (archive-listed) ran · our draft was wrong Apache-2.0 (permissive) · d7e378ee7899fbde · report
count_words thudm/longwriter/evaluation/pred.py community (archive-listed) unverified Apache-2.0 (permissive) · 2bb5c6316f656bec · report
default_init thudm/longwriter/train/patch/modeling_chatglm.py community (archive-listed) unverified Apache-2.0 (permissive) · 237019e36b9481d9 · report
get_response_gpt4 thudm/longwriter/agentwrite/plan.py community (archive-listed) unverified Apache-2.0 (permissive) · 72494291664f9618 · report
get_response_gpt4 thudm/longwriter/evaluation/eval_quality.py community (archive-listed) unverified Apache-2.0 (permissive) · 8017d011436ee94c · report
load_model_and_tokenizer thudm/longwriter/trans_web_demo.py community (archive-listed) unverified Apache-2.0 (permissive) · b966ffef888e5413 · report
parse_args thudm/longwriter/train/pre_tokenize_glm4.py community (archive-listed) unverified Apache-2.0 (permissive) · 5399d42525c76303 · report
parse_args thudm/longwriter/train/pre_tokenize_llama3.py community (archive-listed) unverified Apache-2.0 (permissive) · 3686c5e8cbb5882e · report
score thudm/longwriter/evaluation/eval_length.py community (archive-listed) unverified Apache-2.0 (permissive) · 653c358686bbb406 · report

Tasks

Reinforcement Learning (RL)Text Generation

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

BASESFT

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections