Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
[ICLR 2025] LongWriter: Unleashing 10,000+ Word Generation from Long Context LLMs
| Date | Stars |
|---|---|
| 2026-07-31 | 1870 |
| 2026-08-06 | 1870 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
<p align="center" width="100%">
<img src="https://github.com/user-attachments/assets/d931d4a7-fb5d-4b9c-af54-12bdc875f8e1" width="80%" alt="longwriter">
</p>
# LongWriter: Unleashing 10,000+ Word Generation From Long Context LLMs
<p align="center">
🤗 <a href="https://huggingface.co/datasets/THUDM/LongWriter-6k" target="_blank">LongWriter</a> • 📃 <a href="https://arxiv.org/abs/2408.07055" target="_blank">LongWriter Paper</a>
</p>
<p align="center">
🤗 <a href="https://huggingface.co/THU-KEG/LongWriter-Zero-32B" target="_blank">LongWriter-Zero</a> • 📜 <a href="https://arxiv.org/abs/2506.18841" target="_blank">LongWriter-Zero Paper</a>
</p>
[English](./README.md) | [中文](./README_zh.md) | [日本語](./README_jp.md)
https://github.com/user-attachments/assets/c7eedeca-98ed-43ec-8619-25137987bcde
Left: LongWriter-glm4-9b; Right: GLM-4-9B-chat
## 🔥 Updates
**[2025/06/23]** Introducing [**LongWriter-Zero**](https://huggingface.co/THU-KEG/LongWriter-Zero-32B), trained with pure RL for ultra-long text generation—no synthetic or annotated data required. It beats LongWriter by a large margin, and even 100B+ models such as DeepSeek-R1, Qwen3 on long-form writing tasks! Click to see our [technical report](https://arxiv.org/abs/2506.18841).
**[2024/08/18]** You can now deploy the LongWriter model using [vllm](https://github.com/vllm-project/vllm). Refer to the code in [vllm_inference.py](https://github.com/THUDM/LongWriter/blob/main/vllm_inference.py) and experience lightning-fast generation. It can **generate over 10,000+ words in just one minute**!
## 🔍 Table of Contents
- [⚙️ LongWriter Deployment](#deployment)
- [🤖️ AgentWrite](#agentwrite)
- [🖥️ Model Training](#longwriter-training)
- [📊 Evaluation](#evaluation)
- [👀 Cases](#case)
- [📝 Citation](#citation)
<a name="deployment"></a>
## ⚙️ LongWriter Deployment
**Environmental Setup**:
We recommend using `transformers>=4.43.0` to successfully deploy our models.
We open-source two models: [LongWriter-glm4-9b](https://huggingface.co/THUDM/LongWriter-glm4-9b) and [LongWriter-llama3.1-8b](https://huggingface.co/THUDM/LongWriter-llama3.1-8b), trained based on [GLM-4-9B](https://huggingface.co/THUDM/glm-4-9b) and [Meta-Llama-3.1-8B](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B), respectively. These two models point to the "LongWriter-9B-DPO" and "LongWriter-8B" models in our paper. Try the model:
```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("THUDM/LongWriter-glm4-9b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("THUDM/LongWriter-glm4-9b", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto")
model = model.eval()
query = "Write a 10000-word China travel guide"
response, history = model.chat(tokenizer, query, history=[], max_new_tokens=32768, temperature=0.5)
print(response)
```
You may deploy your own LongWriter chatbot (like the one we show in the teasor video) by running
```
CUDA_VISIBLE_DEVICES=0 python trans_web_demo.py
```
Alternatively, you can deploy the model with [vllm](https://github.com/vllm-project/vllm), which allows generating 10,000+ words within a minute! See the code example in [vllm_inference.py](https://github.com/THUDM/LongWriter/blob/main/vllm_inference.py).
<a name="agentwrite"></a>
## 🤖️ AgentWrite

We are also open-sourcing AgentWrite under `agentwrite/`, our automated ultra-long output data construction pipeline. Run `plan.py` and then `write.py` to obtain the final data. Please configure your API key in the files.
<a name="longwriter-training"></a>
## 🖥️ Model Training
You can download and save the **LongWriter-6k** data through the Hugging Face datasets ([🤗 HF Repo](https://huggingface.co/datasets/THUDM/LongWriter-6k)):
```python
dataset = load_dataset('THUDM/LongWriter-6k')
for split, split_dataset in dataset.items()Excerpt of 53,869 characters
Read on GitHubYushi Bai · Tsinghua University
30
ambivalent · Vietnam
3
Yuxuan Zhang · Z.ai · China
1
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:22e55a4efa0e30a2, topic:fine-tuning
matched fp:22e55a4efa0e30a2, topic:llm