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)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("zai-org/LongWriter-glm4-9b", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- 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
Fix TypeError in _pad method by adding missing padding_side field (#9)
Browse files- Fix TypeError in _pad method by adding missing padding_side field (778b5712634889f5123d6c463ca383bc6dd5c621)
Co-authored-by: Ayyylol <ayyylol@users.noreply.huggingface.co>
- tokenization_chatglm.py +1 -0
tokenization_chatglm.py
CHANGED
|
@@ -207,6 +207,7 @@ class ChatGLM4Tokenizer(PreTrainedTokenizer):
|
|
| 207 |
padding_strategy: PaddingStrategy = PaddingStrategy.DO_NOT_PAD,
|
| 208 |
pad_to_multiple_of: Optional[int] = None,
|
| 209 |
return_attention_mask: Optional[bool] = None,
|
|
|
|
| 210 |
) -> dict:
|
| 211 |
"""
|
| 212 |
Pad encoded inputs (on left/right and up to predefined length or max length in the batch)
|
|
|
|
| 207 |
padding_strategy: PaddingStrategy = PaddingStrategy.DO_NOT_PAD,
|
| 208 |
pad_to_multiple_of: Optional[int] = None,
|
| 209 |
return_attention_mask: Optional[bool] = None,
|
| 210 |
+
padding_side: Optional[str] = None,
|
| 211 |
) -> dict:
|
| 212 |
"""
|
| 213 |
Pad encoded inputs (on left/right and up to predefined length or max length in the batch)
|