Instructions to use zai-org/GLM-5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zai-org/GLM-5") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-5") model = AutoModelForCausalLM.from_pretrained("zai-org/GLM-5", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zai-org/GLM-5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/GLM-5" # 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/GLM-5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/zai-org/GLM-5
- SGLang
How to use zai-org/GLM-5 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-5" \ --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/GLM-5", "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/GLM-5" \ --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/GLM-5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use zai-org/GLM-5 with Docker Model Runner:
docker model run hf.co/zai-org/GLM-5
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+1
- chat_template.jinjaAdded+86
- config.jsonAdded+59
- generation_config.jsonAdded+12
- model-00001-of-00282.safetensorsAdded+3
- model-00002-of-00282.safetensorsAdded+3
- model-00003-of-00282.safetensorsAdded+3
- model-00004-of-00282.safetensorsAdded+3
- model-00005-of-00282.safetensorsAdded+3
- model-00006-of-00282.safetensorsAdded+3
- model-00007-of-00282.safetensorsAdded+3
- model-00008-of-00282.safetensorsAdded+3
- model-00009-of-00282.safetensorsAdded+3
- model-00010-of-00282.safetensorsAdded+3
- model-00011-of-00282.safetensorsAdded+3
- model-00012-of-00282.safetensorsAdded+3
- model-00013-of-00282.safetensorsAdded+3
- model-00014-of-00282.safetensorsAdded+3
- model-00015-of-00282.safetensorsAdded+3
- model-00016-of-00282.safetensorsAdded+3
- model-00017-of-00282.safetensorsAdded+3
- model-00018-of-00282.safetensorsAdded+3
- model-00257-of-00282.safetensorsAdded+3
- model-00258-of-00282.safetensorsAdded+3
- model-00259-of-00282.safetensorsAdded+3
- model-00260-of-00282.safetensorsAdded+3
- model-00261-of-00282.safetensorsAdded+3
- model-00262-of-00282.safetensorsAdded+3
- model-00263-of-00282.safetensorsAdded+3
- model-00264-of-00282.safetensorsAdded+3
- model-00265-of-00282.safetensorsAdded+3
- model-00266-of-00282.safetensorsAdded+3
- model-00267-of-00282.safetensorsAdded+3
- model-00268-of-00282.safetensorsAdded+3
- model-00269-of-00282.safetensorsAdded+3
- model-00270-of-00282.safetensorsAdded+3
- model-00271-of-00282.safetensorsAdded+3
- model-00272-of-00282.safetensorsAdded+3
- model-00273-of-00282.safetensorsAdded+3
- model-00274-of-00282.safetensorsAdded+3
- model-00275-of-00282.safetensorsAdded+3
- model-00276-of-00282.safetensorsAdded+3
- model-00277-of-00282.safetensorsAdded+3
- model-00278-of-00282.safetensorsAdded+3
- model-00279-of-00282.safetensorsAdded+3
- model-00280-of-00282.safetensorsAdded+3
- model-00281-of-00282.safetensorsAdded+3
- model-00282-of-00282.safetensorsAdded+3
- model.safetensors.index.jsonAdded
- tokenizer.jsonAdded+3
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -texttokenizer.json filter=lfs diff=lfs merge=lfs -text
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586[gMASK]<sop>{%- if tools -%}<|system|># Tools
You may call one or more functions to assist with the user query.
You are provided with function signatures within <tools></tools> XML tags:<tools>{% for tool in tools %}{{ tool | tojson(ensure_ascii=False) }}{% endfor %}</tools>
For each function call, output the function name and arguments within the following XML format:<tool_call>{function-name}<arg_key>{arg-key-1}</arg_key><arg_value>{arg-value-1}</arg_value><arg_key>{arg-key-2}</arg_key><arg_value>{arg-value-2}</arg_value>...</tool_call>{%- endif -%}{%- macro visible_text(content) -%} {%- if content is string -%} {{- content }} {%- elif content is iterable and content is not mapping -%} {%- for item in content -%} {%- if item is mapping and item.type == 'text' -%} {{- item.text }} {%- elif item is string -%} {{- item }} {%- endif -%} {%- endfor -%} {%- else -%} {{- content }} {%- endif -%}{%- endmacro -%}{%- set ns = namespace(last_user_index=-1) %}{%- for m in messages %} {%- if m.role == 'user' %} {% set ns.last_user_index = loop.index0 -%} {%- endif %}{%- endfor %}{% for m in messages %}{%- if m.role == 'user' -%}<|user|>{{ visible_text(m.content) }}{%- elif m.role == 'assistant' -%}<|assistant|>{%- set reasoning_content = '' %}{%- set content = visible_text(m.content) %}{%- if m.reasoning_content is string %} {%- set reasoning_content = m.reasoning_content %}{%- else %} {%- if '</think>' in content %} {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %} {%- set content = content.split('</think>')[-1].lstrip('\n') %} {%- endif %}{%- endif %}{%- if ((clear_thinking is defined and not clear_thinking) or loop.index0 > ns.last_user_index) and reasoning_content -%}{{ '<think>' + reasoning_content.strip() + '</think>'}}{%- else -%}{{ '</think>' }}{%- endif -%}{%- if content.strip() -%}{{ content.strip() }}{%- endif -%}{% if m.tool_calls %}{% for tc in m.tool_calls %}{%- if tc.function %} {%- set tc = tc.function %}{%- endif %}{{- '<tool_call>' + tc.name -}}{% set _args = tc.arguments %}{% for k, v in _args.items() %}<arg_key>{{ k }}</arg_key><arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>{% endfor %}</tool_call>{% endfor %}{% endif %}{%- elif m.role == 'tool' -%}{%- if m.content is string -%}{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} {{- '<|observation|>' }}{%- endif %}{{- '<tool_response>' }}{{- m.content }}{{- '</tool_response>' }}{%- else -%}<|observation|>{% for tr in m.content %}<tool_response>{{ tr.output if tr.output is defined else tr }}</tool_response>{% endfor -%}{% endif -%}{%- elif m.role == 'system' -%}<|system|>{{ visible_text(m.content) }}{%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%} <|assistant|>{{- '</think>' if (enable_thinking is defined and not enable_thinking) else '<think>' -}}{%- endif -%}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859{ "architectures": [ "GlmMoeDsaForCausalLM" ], "attention_bias": false, "attention_dropout": 0.0, "dtype": "bfloat16", "eos_token_id": [ 154820, 154827, 154829 ], "ep_size": 1, "first_k_dense_replace": 3, "hidden_act": "silu", "head_dim": 64, "hidden_size": 6144, "index_head_dim": 128, "index_n_heads": 32, "index_topk": 2048, "indexer_rope_interleave": true, "initializer_range": 0.02, "intermediate_size": 12288, "kv_lora_rank": 512, "max_position_embeddings": 202752, "moe_intermediate_size": 2048, "moe_layer_freq": 1, "model_type": "glm_moe_dsa", "n_group": 1, "n_routed_experts": 256, "n_shared_experts": 1, "norm_topk_prob": true, "num_attention_heads": 64, "num_experts_per_tok": 8, "num_hidden_layers": 78, "num_key_value_heads": 64, "num_nextn_predict_layers": 1, "pad_token_id": 154820, "pretraining_tp": 1, "q_lora_rank": 2048, "qk_head_dim": 256, "qk_nope_head_dim": 192, "qk_rope_head_dim": 64, "rms_norm_eps": 1e-05, "rope_interleave": true, "rope_parameters": { "rope_theta": 1000000, "rope_type": "default" }, "routed_scaling_factor": 2.5, "scoring_func": "sigmoid", "tie_word_embeddings": false, "topk_group": 1, "topk_method": "noaux_tc", "transformers_version": "5.0.2.dev0", "use_cache": true, "v_head_dim": 256, "vocab_size": 154880}123456789101112{ "_from_model_config": true, "eos_token_id": [ 154820, 154827, 154829 ], "pad_token_id": 154820, "temperature": 1.0, "top_p": 0.95, "transformers_version": "5.0.2.dev0"}123version https://git-lfs.github.com/spec/v1oid sha256:198ef923a7ca4effc5ead8ebf799fee10beb8ce081352fb099636f805d1deda9size 5342821416123version https://git-lfs.github.com/spec/v1oid sha256:f41e14a00f8f65b5ddae90afc9aee29745bbe38821090b78dfc18f8b2be25738size 5351970840123version https://git-lfs.github.com/spec/v1oid sha256:f5f696f543a4473b272bb38068bec2a5fa2ce6b00306b99e7b7264ac9a4784easize 5360347320123version https://git-lfs.github.com/spec/v1oid sha256:21ea9316694ec51d00be3a54f4c90c6b8c927e9f9852aa673234ce10ea46b092size 5360347208123version https://git-lfs.github.com/spec/v1oid sha256:447d3150fda6a4a95063c52402cc32a5e185e94ccb8ab1162463a6dec34d1130size 5359985352123version https://git-lfs.github.com/spec/v1oid sha256:5bd92a8fb83f562439f97700404160da10f43d0c18b0e2ac900128c921ddd8d7size 5360347320123version https://git-lfs.github.com/spec/v1oid sha256:ca57320e2c33917441d7ade047ea155fc630d0fa1f7933946e209486174aa12bsize 5360347320123version https://git-lfs.github.com/spec/v1oid sha256:e848c982bf3fdcb5b7d8704e20e4b30aaff0d85f7314713dc82f3e069fb2d2cdsize 5360347144123version https://git-lfs.github.com/spec/v1oid sha256:67d50e69f80e4f0959e6af2ed383aad04d3e930c5788b148b692df10652e8953size 5359985416123version https://git-lfs.github.com/spec/v1oid sha256:9a18aa0bb8201311c1c31e462e3885f26299e6d025d9ff9cef40c899df3384e0size 5360347312123version https://git-lfs.github.com/spec/v1oid sha256:86ae5f0fe4ca9bd26926ff5feb2f8eea2524ff851bac18920180a74d5829f01bsize 5360347288123version https://git-lfs.github.com/spec/v1oid sha256:1da09cf92af76c5271f500bb204b581e8fa79d086ea0b980f739c00e75a13d83size 5363494088123version https://git-lfs.github.com/spec/v1oid sha256:4c06dc21e2bd376abdcf28dea362f00511f50a449bbcec299fe6cd1842d248cesize 5356838488123version https://git-lfs.github.com/spec/v1oid sha256:213d05d35132ab6c76771ccc87d9798b3417505f1456900fc111d1aa2dafafb5size 5360347312123version https://git-lfs.github.com/spec/v1oid sha256:b04e317d274bed49d942c5d6f99565ab80149a588528ce9208d9cc3c9000177fsize 5360347224123version https://git-lfs.github.com/spec/v1oid sha256:25f73b1e9e9fde8f9588253b0c2a9884ff115ccacf4114ad37be355ce2361454size 5359985336123version https://git-lfs.github.com/spec/v1oid sha256:18d47fcb369b742e775ddc25ca499858533255ec50e0e76f2405b1f3d92b7b70size 5360347320123version https://git-lfs.github.com/spec/v1oid sha256:62e23e54f40709fc762c172444a5dee41e78111df151fdbe7b48d75386a36debsize 5360347312123version https://git-lfs.github.com/spec/v1oid sha256:d1fe12d26eaeae93d22414d5acc450f356282179780df26a6d6de296dc78d4ebsize 5360347320123version https://git-lfs.github.com/spec/v1oid sha256:6b28016187f348860783283038b5becc4fcfe0a4d5c37b14e186aea9ea5774d2size 5360347320123version https://git-lfs.github.com/spec/v1oid sha256:5a9324a618091a61ad9b43cbb31b9a263da5d63f2baf37866161fc11de9a1219size 5360347112123version https://git-lfs.github.com/spec/v1oid sha256:91a83234694e86107f62968ee781c82e00393f22f0f158de989d6b8a1bada8ebsize 5359985440123version https://git-lfs.github.com/spec/v1oid sha256:5a1fc30d04fe2c3f0121d1e2b871cbc3c4d68890faf78412a3468ee33ec0f737size 5360347312123version https://git-lfs.github.com/spec/v1oid sha256:51883c4c3b40ff465191a6989bc6494c223e1883fe6d8a8a1f77f4cff36a28eesize 5360347256123version https://git-lfs.github.com/spec/v1oid sha256:584d74da20536d9185c6beb02f862c4aad3aab20f427d7d0ef4de58198704c0dsize 5359985304123version https://git-lfs.github.com/spec/v1oid sha256:c5ad0a00031b7bb329cd9becfdee135e60e9fed9591110dda806d62984f53201size 5360347320123version https://git-lfs.github.com/spec/v1oid sha256:bd96386529b77e87a3a6b6822e992314dbce4233059791a23fb64a7f3792fa12size 5360347312123version https://git-lfs.github.com/spec/v1oid sha256:8a5bbc412ec51915341e839658721cade56b8dba27df2d30e8bc889f6b7f5509size 5360347192123version https://git-lfs.github.com/spec/v1oid sha256:76967c52be6e31a361cc356f2e598080d4969491984d094d581bade3cbee85d9size 5359985368123version https://git-lfs.github.com/spec/v1oid sha256:0e441b6e96606c0a457e598cacf747940da8d2b6aab656a7b65c9ec21d5fbabfsize 5360347320123version https://git-lfs.github.com/spec/v1oid sha256:98a0e6ec1229a85bbf487717921d8a0e5652729869f8d760e65da0cf3b95cdf6size 5360347312123version https://git-lfs.github.com/spec/v1oid sha256:118a793dee7bf28df6946cbddb72d98d16f70d8e60cfe050e8a8806927d09d22size 5360347120123version https://git-lfs.github.com/spec/v1oid sha256:26fa04bb05b6f1950b419e5f5e22db38366d64086bbf71010ed0b4f8d8c88d63size 5360009568123version https://git-lfs.github.com/spec/v1oid sha256:2b5eaa13153916f8066a4e74e67162481c274290705af5502d1e0c209e2109b9size 5360347320123version https://git-lfs.github.com/spec/v1oid sha256:6cf5baae0dafafcd844beaf3ff8a0c42f79fd6ecdabdda5bf0fe38601b626141size 5360347272123version https://git-lfs.github.com/spec/v1oid sha256:c8cb0442be6333dad19948f545f2d22adeef3f836c548994685f86cc6470f7aesize 5359997696123version https://git-lfs.github.com/spec/v1oid sha256:2b4e3e71965278a68c1f7637c249338ef8205ec262a4c6c7a071543ee45fa423size 5360347096123version https://git-lfs.github.com/spec/v1oid sha256:b8e1a2cbb4b3686fad9cd050e98eb834c435861d84d16976aa3bc553d4260856size 5360347104123version https://git-lfs.github.com/spec/v1oid sha256:c8f3f97c2f70b7d2bc42b6bb7db26a831bc40be37d515b77e5eddf1872391a6dsize 5360346992123version https://git-lfs.github.com/spec/v1oid sha256:d2bb9fd0a7e43ba1a06409e0817076a7e9a54beaeb2e8d6b3d478adb91d28a75size 5359985144123version https://git-lfs.github.com/spec/v1oid sha256:eedc492419e146e693a12d7c66fd850126b603ef3046ac23a662ceb3086e7848size 5360347104123version https://git-lfs.github.com/spec/v1oid sha256:4bd753fa46862e8f16dc16aff3e944c9fcc02c6581e7348edc026f40678c935asize 5360347104123version https://git-lfs.github.com/spec/v1oid sha256:546caec63dc6bd4caa8a425ff1f4821aceed22f452bdca93f22f61bcb90524a1size 5360346928123version https://git-lfs.github.com/spec/v1oid sha256:c1178850422a694ae634d7aab74184f083f738b0307bec6c248d60b33b6eaec1size 1962582048123version https://git-lfs.github.com/spec/v1oid sha256:19e773648cb4e65de8660ea6365e10acca112d42a854923df93db4a6f333a82dsize 20217442.gitattributes+1
chat_template.jinjaAdded+86
config.jsonAdded+59
generation_config.jsonAdded+12
model-00001-of-00282.safetensorsAdded+3
model-00002-of-00282.safetensorsAdded+3
model-00003-of-00282.safetensorsAdded+3
model-00004-of-00282.safetensorsAdded+3
model-00005-of-00282.safetensorsAdded+3
model-00006-of-00282.safetensorsAdded+3
model-00007-of-00282.safetensorsAdded+3
model-00008-of-00282.safetensorsAdded+3
model-00009-of-00282.safetensorsAdded+3
model-00010-of-00282.safetensorsAdded+3
model-00011-of-00282.safetensorsAdded+3
model-00012-of-00282.safetensorsAdded+3
model-00013-of-00282.safetensorsAdded+3
model-00014-of-00282.safetensorsAdded+3
model-00015-of-00282.safetensorsAdded+3
model-00016-of-00282.safetensorsAdded+3
model-00017-of-00282.safetensorsAdded+3
model-00018-of-00282.safetensorsAdded+3
model-00257-of-00282.safetensorsAdded+3
model-00258-of-00282.safetensorsAdded+3
model-00259-of-00282.safetensorsAdded+3
model-00260-of-00282.safetensorsAdded+3
model-00261-of-00282.safetensorsAdded+3
model-00262-of-00282.safetensorsAdded+3
model-00263-of-00282.safetensorsAdded+3
model-00264-of-00282.safetensorsAdded+3
model-00265-of-00282.safetensorsAdded+3
model-00266-of-00282.safetensorsAdded+3
model-00267-of-00282.safetensorsAdded+3
model-00268-of-00282.safetensorsAdded+3
model-00269-of-00282.safetensorsAdded+3
model-00270-of-00282.safetensorsAdded+3
model-00271-of-00282.safetensorsAdded+3
model-00272-of-00282.safetensorsAdded+3
model-00273-of-00282.safetensorsAdded+3
model-00274-of-00282.safetensorsAdded+3
model-00275-of-00282.safetensorsAdded+3
model-00276-of-00282.safetensorsAdded+3
model-00277-of-00282.safetensorsAdded+3
model-00278-of-00282.safetensorsAdded+3
model-00279-of-00282.safetensorsAdded+3
model-00280-of-00282.safetensorsAdded+3
model-00281-of-00282.safetensorsAdded+3
model-00282-of-00282.safetensorsAdded+3
model.safetensors.index.jsonAdded
tokenizer.jsonAdded+3