{"data":{"slug":"thudm-longwriter","name":"LongWriter","tagline":"LongWriter enables generation of texts longer than 10,000 words using long-context LLMs","github_url":"https://github.com/THUDM/LongWriter","owner":"THUDM","repo":"LongWriter","owner_avatar_url":"https://avatars.githubusercontent.com/u/48590610?v=4","primary_language":"Python","stars":1872,"forks":182,"topics":["fine-tuning","llm","long-context","long-text"],"archived":false,"github_pushed_at":"2025-06-24T06:41:41+00:00","maintenance_label":"Dormant","stars_delta_30d":4,"url":"https://www.graphcanon.com/tools/thudm-longwriter","markdown_url":"https://www.graphcanon.com/tools/thudm-longwriter.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/thudm-longwriter","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=thudm-longwriter","description":"[ICLR 2025] LongWriter: Unleashing 10,000+ Word Generation from Long Context LLMs","homepage_url":null,"license":"Apache-2.0","open_issues":32,"watchers":22,"ai_summary":"[ICLR 2025] LongWriter: Unleashing 10,000+ Word Generation from Long Context LLMs, implemented in Python with focus on fine-tuning and llm functionalities","readme_excerpt":"## ⚙️ LongWriter Deployment\n\n**Environmental Setup**:\nWe recommend using `transformers>=4.43.0` to successfully deploy our models.\n\nWe 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:\n```python\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\nimport torch\ntokenizer = AutoTokenizer.from_pretrained(\"THUDM/LongWriter-glm4-9b\", trust_remote_code=True)\nmodel = AutoModelForCausalLM.from_pretrained(\"THUDM/LongWriter-glm4-9b\", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map=\"auto\")\nmodel = model.eval()\nquery = \"Write a 10000-word China travel guide\"\nresponse, history = model.chat(tokenizer, query, history=[], max_new_tokens=32768, temperature=0.5)\nprint(response)\n```\nYou may deploy your own LongWriter chatbot (like the one we show in the teasor video) by running\n```\nCUDA_VISIBLE_DEVICES=0 python trans_web_demo.py\n```\nAlternatively, 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).\n\n<a name=\"agentwrite\"></a>","github_created_at":"2024-08-12T16:00:19+00:00","created_at":"2026-07-11T11:38:43.857781+00:00","updated_at":"2026-08-24T00:02:01.232824+00:00","categories":[{"slug":"llm-frameworks","name":"LLM Frameworks","url":"https://www.graphcanon.com/categories/llm-frameworks","markdown_url":"https://www.graphcanon.com/categories/llm-frameworks.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/llm-frameworks"},{"slug":"model-training","name":"Model Training","url":"https://www.graphcanon.com/categories/model-training","markdown_url":"https://www.graphcanon.com/categories/model-training.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/model-training"}],"tags":[{"slug":"fine-tuning","name":"fine-tuning"},{"slug":"llm","name":"llm"},{"slug":"long-context","name":"long-context"},{"slug":"long-text","name":"long-text"}],"trust":{"provenance":{"is_fork":false,"github_id":841541826,"owner_type":"Organization","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-08-24T00:02:00.482Z","maintenance":{"label":"Dormant","score":18,"methodology":"github_public_v1","releases_90d":0,"days_since_push":425,"last_release_at":null,"stars_delta_30d":4,"open_issues_delta_30d":0},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-07-11T11:38:45.129Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-08-24T00:02:00.953Z"},"languages":{"value":["python"],"source":"github.language","observed_at":"2026-08-24T00:02:00.953Z"},"license_spdx":{"value":"Apache-2.0","source":"github.license","observed_at":"2026-08-24T00:02:00.953Z"}},"decision_facts":{"hosting":null,"pricing":null,"requirements":null,"constraints":null,"when_to_use":["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"],"when_not_to_use":["Avoid for short-form content generation where LLM context is less relevant","Not ideal when the requirement is to maintain conciseness in output texts"],"source":"enrich:decision_facts","observed_at":"2026-07-16T22:09:32.943Z"},"constraint_facets":null,"decision_summary":[{"label":"Adopt for","value":"LongWriter specializes in exceeding the text generation limit to over 10,000 words using long-context LLMs for Python-based development."}]}}