Instructions to use GizzmoShifu/glm-4-9b-chat-hf-fp8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use GizzmoShifu/glm-4-9b-chat-hf-fp8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="GizzmoShifu/glm-4-9b-chat-hf-fp8") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("GizzmoShifu/glm-4-9b-chat-hf-fp8") model = AutoModelForCausalLM.from_pretrained("GizzmoShifu/glm-4-9b-chat-hf-fp8") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use GizzmoShifu/glm-4-9b-chat-hf-fp8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "GizzmoShifu/glm-4-9b-chat-hf-fp8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GizzmoShifu/glm-4-9b-chat-hf-fp8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/GizzmoShifu/glm-4-9b-chat-hf-fp8
- SGLang
How to use GizzmoShifu/glm-4-9b-chat-hf-fp8 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 "GizzmoShifu/glm-4-9b-chat-hf-fp8" \ --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": "GizzmoShifu/glm-4-9b-chat-hf-fp8", "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 "GizzmoShifu/glm-4-9b-chat-hf-fp8" \ --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": "GizzmoShifu/glm-4-9b-chat-hf-fp8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use GizzmoShifu/glm-4-9b-chat-hf-fp8 with Docker Model Runner:
docker model run hf.co/GizzmoShifu/glm-4-9b-chat-hf-fp8
Built with glm-4
This repository provides a quantised version of the GLM-4-9b-Chat-HF model.
Licensing and Usage
This model is distributed under the glm-4-9b License.
- Attribution: This model is "Built with glm-4".
- Naming: The model name includes the required "glm-4" prefix.
- Commercial Use: Users wishing to use this model for commercial purposes must complete the registration here.
- Restrictions: Usage for military or illegal purposes is strictly prohibited.
Quantisation Overview
This model was quantised to FP8_DYNAMIC (Dynamic 8-bit Floating Point) to optimize performance while maintaining chat capabilities.
- Methodology: Quantised using the
llmcompressorlibrary with a one-shot calibration process. - Calibration Data: A custom-curated dataset was used, pulling from
ultrachat_200kandLongAlign-10kto ensure the model handles both short-form and long-form context effectively. - Architecture: The process preserved the original 40-layer dense structure (layers 0-39) required for the 9B model architecture.
Quantisation Details
- Scheme: FP8_DYNAMIC (Dynamic 8-bit Floating Point).
- Format: compressed-tensors.
- Calibration: One-shot calibration using llmcompressor.
- Calibration Data: Custom distribution weighted toward production-typical prompt lengths:
- 256–1024 tokens: 90%
- 1024–2048 tokens: 10%
- Precision: FP8_DYNAMIC (Dynamic 8-bit Floating Point)
Usage
This model is designed for runtimes compatible with the FP8_DYNAMIC format, such as vLLM.
An example docker-compose is as follows assuming the model is stored in /models/glm-4-9b-chat-hf-fp8:
services:
glm4-9b-fp8:
image: nvcr.io/nvidia/vllm:26.01-py3
container_name: glm4-9b-fp8
ipc: host
shm_size: "32gb"
ports:
- "8080:8080"
volumes:
- /models:/mnt/models:ro
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
command: >
python3 -m vllm.entrypoints.openai.api_server
--model /mnt/models/glm-4-9b-chat-hf-fp8
--served-model-name glm-4-9b-chat
--port 8080
--quantization compressed-tensors
--kv-cache-dtype fp8
--max-model-len 32768
--max-num-seqs 64
--gpu-memory-utilization 0.75
For questions regarding the original model license, contact license@zhipuai.cn.
- Downloads last month
- 1