Instructions to use zai-org/GLM-5.3-Flash-BF16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-5.3-Flash-BF16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="zai-org/GLM-5.3-Flash-BF16") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("zai-org/GLM-5.3-Flash-BF16") model = AutoModelForMultimodalLM.from_pretrained("zai-org/GLM-5.3-Flash-BF16", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zai-org/GLM-5.3-Flash-BF16 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.3-Flash-BF16" # 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.3-Flash-BF16", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/zai-org/GLM-5.3-Flash-BF16
- SGLang
How to use zai-org/GLM-5.3-Flash-BF16 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.3-Flash-BF16" \ --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.3-Flash-BF16", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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.3-Flash-BF16" \ --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.3-Flash-BF16", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use zai-org/GLM-5.3-Flash-BF16 with Docker Model Runner:
docker model run hf.co/zai-org/GLM-5.3-Flash-BF16
chat template: speed up tool-result validation and reordering (GLM-5.3-Flash)
#2
by ShijinZhang - opened
177 unmodified lines178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250177 unmodified lines{%- if block_start > 0 and messages[block_start - 1].role == 'assistant' and messages[block_start - 1].tool_calls -%}{%- set ns_a.tool_calls = messages[block_start - 1].tool_calls -%}{%- endif -%}{%- set ns_chk = namespace(can_sort=true) -%}{%- if not ns_a.tool_calls -%}{%- set ns_chk.can_sort = false -%}{%- else -%}{%- for k in range(block_start, ns_blk.end + 1) -%}{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}{%- set m = messages[k] -%}{%- if is_list_of_outputs(m) -%}{%- for entry in m.content -%}{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}{%- set eid = id_of(entry) -%}{%- if not eid -%}{%- set ns_chk.can_sort = false -%}{%- elif has_dup_tool_result_id(block_start, ns_blk.end, eid) -%}{%- set ns_chk.can_sort = false -%}{%- elif not tc_id_exists(ns_a.tool_calls, eid) -%}{%- set ns_chk.can_sort = false -%}{%- endif -%}{%- endfor -%}{%- else -%}{%- set tk_id = id_of(m) -%}{%- if not tk_id -%}{%- set ns_chk.can_sort = false -%}{%- elif has_dup_tool_result_id(block_start, ns_blk.end, tk_id) -%}{%- set ns_chk.can_sort = false -%}{%- elif not tc_id_exists(ns_a.tool_calls, tk_id) -%}{%- set ns_chk.can_sort = false -%}{%- endif -%}{%- endif -%}{%- endfor -%}{%- for i in range(ns_a.tool_calls | length) -%}{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}{%- set tc_id = id_of(ns_a.tool_calls[i]) -%}{%- if not tc_id -%}{%- set ns_chk.can_sort = false -%}{%- endif -%}{%- for j in range(i + 1, ns_a.tool_calls | length) -%}{%- if id_of(ns_a.tool_calls[j]) == tc_id -%}{%- set ns_chk.can_sort = false -%}{%- break -%}{%- endif -%}{%- endfor -%}{%- endfor -%}{%- endif -%}{%- if ns_chk.can_sort -%}{%- for tc in ns_a.tool_calls -%}{%- set tc_id = id_of(tc) -%}{%- for k in range(block_start, ns_blk.end + 1) -%}{%- set m = messages[k] -%}{%- if is_list_of_outputs(m) -%}{%- for entry in m.content -%}{%- set eid = id_of(entry) -%}{%- if eid == tc_id -%}{%- if entry.output is iterable and entry.output is not string and entry.output is not mapping and entry.output and entry.output.0.type == "tool_reference" -%}{{- tool_references_to_response(entry.output) -}}{%- else -%}{{- tool_response(visible_text(entry.output)) -}}{%- endif -%}{%- endif -%}{%- endfor -%}{%- else -%}{%- set tk_id = id_of(m) -%}{%- if tk_id == tc_id -%}{{- render_tool_response(m) -}}{%- endif -%}{%- endif -%}{%- endfor -%}{%- endfor -%}{%- else -%}{%- for k in range(block_start, ns_blk.end + 1) -%}177 unmodified lines178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246177 unmodified lines{%- if block_start > 0 and messages[block_start - 1].role == 'assistant' and messages[block_start - 1].tool_calls -%}{%- set ns_a.tool_calls = messages[block_start - 1].tool_calls -%}{%- endif -%}{%- set ns_chk = namespace(can_sort=true, res=[], mk=[], ek=[], tcs=[]) -%}{%- for k in range(block_start, ns_blk.end + 1) -%}{%- set m = messages[k] -%}{%- if is_list_of_outputs(m) -%}{%- for entry in m.content -%}{%- set ns_chk.res = ns_chk.res + [id_of(entry)] -%}{%- set ns_chk.mk = ns_chk.mk + [k] -%}{%- set ns_chk.ek = ns_chk.ek + [loop.index0] -%}{%- endfor -%}{%- else -%}{%- set ns_chk.res = ns_chk.res + [id_of(m)] -%}{%- set ns_chk.mk = ns_chk.mk + [k] -%}{%- set ns_chk.ek = ns_chk.ek + [-1] -%}{%- endif -%}{%- endfor -%}{%- if not ns_a.tool_calls -%}{%- set ns_chk.can_sort = false -%}{%- else -%}{%- for tc in ns_a.tool_calls -%}{%- set ns_chk.tcs = ns_chk.tcs + [id_of(tc)] -%}{%- endfor -%}{%- if '' in ns_chk.res or '' in ns_chk.tcs -%}{%- set ns_chk.can_sort = false -%}{%- elif ns_chk.res | unique(case_sensitive=true) | list | length != ns_chk.res | length -%}{%- set ns_chk.can_sort = false -%}{%- elif ns_chk.tcs | unique(case_sensitive=true) | list | length != ns_chk.tcs | length -%}{%- set ns_chk.can_sort = false -%}{%- else -%}{%- for eid in ns_chk.res -%}{%- if eid not in ns_chk.tcs -%}{%- set ns_chk.can_sort = false -%}{%- break -%}{%- endif -%}{%- endfor -%}{%- endif -%}{%- endif -%}{%- if ns_chk.can_sort -%}{%- set ns_ord = namespace(res=[], tcs=[], j=0, pairs=[]) -%}{%- for eid in ns_chk.res -%}{%- set ns_ord.res = ns_ord.res + [{'id': eid, 'p': loop.index0}] -%}{%- endfor -%}{%- for tc_id in ns_chk.tcs -%}{%- set ns_ord.tcs = ns_ord.tcs + [{'id': tc_id, 'i': loop.index0}] -%}{%- endfor -%}{%- set ns_ord.res = ns_ord.res | sort(attribute='id', case_sensitive=true) -%}{%- for tc in ns_ord.tcs | sort(attribute='id', case_sensitive=true) -%}{%- if ns_ord.j < ns_ord.res | length and ns_ord.res[ns_ord.j].id == tc.id -%}{%- set ns_ord.pairs = ns_ord.pairs + [{'i': tc.i, 'p': ns_ord.res[ns_ord.j].p}] -%}{%- set ns_ord.j = ns_ord.j + 1 -%}{%- endif -%}{%- endfor -%}{%- for pair in ns_ord.pairs | sort(attribute='i') -%}{%- set m = messages[ns_chk.mk[pair.p]] -%}{%- if ns_chk.ek[pair.p] >= 0 -%}{%- set entry = m.content[ns_chk.ek[pair.p]] -%}{%- if entry.output is iterable and entry.output is not string and entry.output is not mapping and entry.output and entry.output.0.type == "tool_reference" -%}{{- tool_references_to_response(entry.output) -}}{%- else -%}{{- tool_response(visible_text(entry.output)) -}}{%- endif -%}{%- else -%}{{- render_tool_response(m) -}}{%- endif -%}{%- endfor -%}{%- else -%}{%- for k in range(block_start, ns_blk.end + 1) -%}
chat_template.jinja+51-55