Home/LLM Frameworks/LongWriter
LongWriter logo

LongWriter

THUDM/LongWriter

LongWriter enables generation of texts longer than 10,000 words using long-context LLMs

GraphCanon updated 1d · GitHub synced 1d

1.9k stars182 forksLast push 1y Python Apache-2.0

Decision brief

LongWriter specializes in exceeding the text generation limit to over 10,000 words using long-context LLMs for Python-based development.

Good fit when

  • For projects requiring texts longer than 10,000 words with fine-tuned llm models
  • When working on tasks that demand high-context retention across very large text outputs

Avoid when

  • Avoid for short-form content generation where LLM context is less relevant
  • Not ideal when the requirement is to maintain conciseness in output texts

Observed Jul 16, 2026 · Source: enrich:decision_facts

Verify the decision

Maintenance and security

Full trust report
Maintenance
Dormant (425d since push)
As of 1d
Provenance
Not a fork · Organization account
As of 1d
Security (OSV)
No lockfile
As of 1mo

Public GitHub metadata and optional OSV scans. Signals, not a guarantee. Trust methodology.

Install

pip install LongWriter
PyPI

Similar tools

Same-category neighbours. No typed graph edges are catalogued for this tool yet.

Evidence and technical details

Sourced facts, taxonomy, compatibility claims, README excerpt, and machine-readable endpoints.

Overview

[ICLR 2025] LongWriter: Unleashing 10,000+ Word Generation from Long Context LLMs, implemented in Python with focus on fine-tuning and llm functionalities

Capability facts

Languages
python

Source: github.language · Aug 24, 2026

Categories

Compatibility

Sourced claims from the README excerpt - not unsourced marketing copy.

Python runtimePython

Source: README excerpt (regex_v1, Aug 24, 2026)

```python from transformers import AutoTokenizer, AutoModelForCausalLM
Source link

Tags

README

⚙️ LongWriter Deployment

Environmental Setup: We recommend using transformers>=4.43.0 to successfully deploy our models.

We open-source two models: LongWriter-glm4-9b and LongWriter-llama3.1-8b, trained based on GLM-4-9B and 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:

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, which allows generating 10,000+ words within a minute! See the code example in vllm_inference.py.

For agents

This page has a .md twin and JSON over the API.

Was this helpful?

Anonymous feedback helps us improve pages and translations.