Text Generation
Transformers
Safetensors
English
Chinese
qwen2
reinforcement-learning
writing
Long Context
conversational
text-generation-inference
Instructions to use THU-KEG/LongWriter-Zero-32B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use THU-KEG/LongWriter-Zero-32B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="THU-KEG/LongWriter-Zero-32B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("THU-KEG/LongWriter-Zero-32B") model = AutoModelForCausalLM.from_pretrained("THU-KEG/LongWriter-Zero-32B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use THU-KEG/LongWriter-Zero-32B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "THU-KEG/LongWriter-Zero-32B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "THU-KEG/LongWriter-Zero-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/THU-KEG/LongWriter-Zero-32B
- SGLang
How to use THU-KEG/LongWriter-Zero-32B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "THU-KEG/LongWriter-Zero-32B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "THU-KEG/LongWriter-Zero-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "THU-KEG/LongWriter-Zero-32B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "THU-KEG/LongWriter-Zero-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use THU-KEG/LongWriter-Zero-32B with Docker Model Runner:
docker model run hf.co/THU-KEG/LongWriter-Zero-32B
Add link to Github repository
#3
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,24 +1,24 @@
|
|
| 1 |
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
datasets:
|
| 4 |
-
- THU-KEG/LongWriter-Zero-RLData
|
| 5 |
base_model:
|
| 6 |
- Qwen/Qwen2.5-32B
|
| 7 |
-
|
| 8 |
-
-
|
| 9 |
-
- writing
|
| 10 |
-
- Long Context
|
| 11 |
language:
|
| 12 |
- en
|
| 13 |
- zh
|
| 14 |
-
pipeline_tag: text-generation
|
| 15 |
library_name: transformers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
---
|
| 17 |
|
| 18 |
# LongWriter-Zero ✍️ — Mastering Ultra-Long Text Generation via Reinforcement Learning
|
| 19 |
|
| 20 |
<p align="center">
|
| 21 |
-
🤗 <a href="https://huggingface.co/datasets/THU-KEG/LongWriter-Zero-RLData" target="_blank">HF Dataset</a> • 📃 <a href="https://arxiv.org/abs/2506.18841" target="_blank">Paper</a>
|
| 22 |
</p>
|
| 23 |
|
| 24 |

|
|
@@ -178,4 +178,5 @@ for chunk in response.iter_lines():
|
|
| 178 |
archivePrefix={arXiv},
|
| 179 |
primaryClass={cs.CL},
|
| 180 |
url={https://arxiv.org/abs/2506.18841},
|
| 181 |
-
}
|
|
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
base_model:
|
| 3 |
- Qwen/Qwen2.5-32B
|
| 4 |
+
datasets:
|
| 5 |
+
- THU-KEG/LongWriter-Zero-RLData
|
|
|
|
|
|
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
- zh
|
|
|
|
| 9 |
library_name: transformers
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
pipeline_tag: text-generation
|
| 12 |
+
tags:
|
| 13 |
+
- reinforcement-learning
|
| 14 |
+
- writing
|
| 15 |
+
- Long Context
|
| 16 |
---
|
| 17 |
|
| 18 |
# LongWriter-Zero ✍️ — Mastering Ultra-Long Text Generation via Reinforcement Learning
|
| 19 |
|
| 20 |
<p align="center">
|
| 21 |
+
🤗 <a href="https://huggingface.co/datasets/THU-KEG/LongWriter-Zero-RLData" target="_blank">HF Dataset</a> • 📃 <a href="https://arxiv.org/abs/2506.18841" target="_blank">Paper</a> • 💻 <a href="https://github.com/THU-KEG/LongWriter-Zero" target="_blank">Code</a>
|
| 22 |
</p>
|
| 23 |
|
| 24 |

|
|
|
|
| 178 |
archivePrefix={arXiv},
|
| 179 |
primaryClass={cs.CL},
|
| 180 |
url={https://arxiv.org/abs/2506.18841},
|
| 181 |
+
}
|
| 182 |
+
```
|