Text Generation
Transformers
Safetensors
English
Chinese
chatglm
feature-extraction
Long Context
llama
conversational
custom_code
Instructions to use zai-org/LongWriter-glm4-9b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/LongWriter-glm4-9b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zai-org/LongWriter-glm4-9b", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("zai-org/LongWriter-glm4-9b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zai-org/LongWriter-glm4-9b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/LongWriter-glm4-9b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/LongWriter-glm4-9b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/zai-org/LongWriter-glm4-9b
- SGLang
How to use zai-org/LongWriter-glm4-9b 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 "zai-org/LongWriter-glm4-9b" \ --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": "zai-org/LongWriter-glm4-9b", "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 "zai-org/LongWriter-glm4-9b" \ --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": "zai-org/LongWriter-glm4-9b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use zai-org/LongWriter-glm4-9b with Docker Model Runner:
docker model run hf.co/zai-org/LongWriter-glm4-9b
Commit History
-
Fix TypeError in _pad method by adding missing padding_side field (#9)
zR +1: ayyylol Verified signature- Fix TypeError in _pad method by adding missing padding_side field (778b5712634889f5123d6c463ca383bc6dd5c621) Co-authored-by: Ayyylol <ayyylol@users.noreply.huggingface.co>2e7f691 -
Update transformers typo (#10)
zR +1: ayyylol Verified signature- Update transformers typo (4f733b52c6d826a5ccfbfd07868cbea277f98bdd) Co-authored-by: Ayyylol <ayyylol@users.noreply.huggingface.co>9896eb9
-
Update config.json
Verified signature16e280f
-
Update tokenizer_config.json
Verified signaturefdfab97
-
Update README.md
Verified signature0fab950 -
Update README.md
Verified signatured8cde7a
-
Modify to original glm-4-9b code
Verified signature6884326 -
Modify to original GLM-4-9B code
Verified signature6eff855
-
Update README.md
Verified signature81b025e -
Support transformers==4.43.0
Verified signature23fa792 -
Update README.md
Verified signature8291eb8 -
Update README.md
Verified signature806416d
-
Update README.md
Verified signature31a9b86
-
Update README.md
Verified signature38c0c3f -
Update README.md
Verified signature6e3ba60 -
add readme
18b5dbf -
Upload folder using huggingface_hub
Verified signature2210ed7 -
initial commit
Verified signature6c70f72