Instructions to use zai-org/glm-4-9b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/glm-4-9b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zai-org/glm-4-9b", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("zai-org/glm-4-9b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zai-org/glm-4-9b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/glm-4-9b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/glm-4-9b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/zai-org/glm-4-9b
- SGLang
How to use zai-org/glm-4-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/glm-4-9b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/glm-4-9b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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/glm-4-9b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/glm-4-9b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use zai-org/glm-4-9b with Docker Model Runner:
docker model run hf.co/zai-org/glm-4-9b
Commit History
-
Update tokenization_chatglm.py
zRVerified signature8cd2b58
-
Update README.md
Verified signature3b61032
-
support transformers 4.44
zRfb328f2 -
support transformers 4.44
zR04e0173
-
fix
zR5dd1ab7
-
fix
zR99a1409 -
fix import error of flash attn
zR86df0b7
-
add flash-attn
zRbd16ff6
-
Add output_attentions for ChatGLMForSequenceClassification
duzx164ec3b65
-
fix with convert_tokens_to_string
zR7025474 -
技术报告更新
zRf5616c0
-
Fix apply_chat_template
duzx16e1c8748 -
Merge branch 'main' of https://huggingface.co/THUDM/glm-4-9b
duzx1610d4977 -
Fix default dtype of classifier head
duzx1644011aa
-
Fix tensor shape error (#7)
zR +1: hiyouga Verified signature- Fix tensor shape error (3d222b84ea089f5c9463cb7e7327b81a221fa4ec) Co-authored-by: Yaowei Zheng <hiyouga@users.noreply.huggingface.co>ef8e833
-
Update LICENSE
zRVerified signaturebb3417f -
Update readme to make it more discoverable (#3)
zR +1: xianbao
Verified signature- Update readme to make it more discoverable (0f2492086d18f5cbc74377c6648066c60db72fe9) Co-authored-by: Tiezhen WANG <xianbao@users.noreply.huggingface.co>3dfdf07
-
Fix classification model
duzx16911e84c -
english readme
Ubuntub7588ac -
Update README_en.md
zRVerified signatureb36f158 -
english readme
Ubuntu397fc1e
-
Update README.md
zRVerified signatured613393
-
Update tokenizer_config.json
zRVerified signaturee6efe95 -
first commit
Ubuntu3c58857 -
first commit
Ubuntuaeb03e3 -
initial commit
zRVerified signaturec7f4438