Instructions to use zai-org/GLM-4.6V-Flash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-4.6V-Flash with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="zai-org/GLM-4.6V-Flash") 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)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("zai-org/GLM-4.6V-Flash") model = AutoModelForImageTextToText.from_pretrained("zai-org/GLM-4.6V-Flash") 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use zai-org/GLM-4.6V-Flash 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.6V-Flash" # 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-4.6V-Flash", "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-4.6V-Flash
- SGLang
How to use zai-org/GLM-4.6V-Flash 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.6V-Flash" \ --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-4.6V-Flash", "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-4.6V-Flash" \ --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-4.6V-Flash", "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-4.6V-Flash with Docker Model Runner:
docker model run hf.co/zai-org/GLM-4.6V-Flash
VLLM 启动报错了
(EngineCore_DP0 pid=1717473) File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/transformers_utils/processor.py", line 154, in get_processor
(EngineCore_DP0 pid=1717473) raise TypeError(
(EngineCore_DP0 pid=1717473) TypeError: Invalid type of HuggingFace processor. Expected type: <class 'transformers.processing_utils.ProcessorMixin'>, but found type: <class 'transformers.tokenization_utils_fast.PreTrainedTokenizerFast'>
Traceback (most recent call last):
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/entrypoints/api_server.py", line 184, in
asyncio.run(run_server(args))
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/entrypoints/api_server.py", line 132, in run_server
app = await init_app(args, llm_engine)
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/entrypoints/api_server.py", line 116, in init_app
else AsyncLLMEngine.from_engine_args(
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/v1/engine/async_llm.py", line 232, in from_engine_args
return cls(
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/v1/engine/async_llm.py", line 133, in init
self.engine_core = EngineCoreClient.make_async_mp_client(
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/v1/engine/core_client.py", line 121, in make_async_mp_client
return AsyncMPClient(*client_args)
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/v1/engine/core_client.py", line 808, in init
super().init(
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/v1/engine/core_client.py", line 469, in init
with launch_core_engines(vllm_config, executor_class, log_stats) as (
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/contextlib.py", line 142, in exit
next(self.gen)
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/v1/engine/utils.py", line 907, in launch_core_engines
wait_for_engine_startup(
File "/home/xiandai/miniconda3/envs/glm_vl/lib/python3.10/site-packages/vllm/v1/engine/utils.py", line 964, in wait_for_engine_startup
raise RuntimeError(
RuntimeError: Engine core initialization failed. See root cause above. Failed core proc(s): {}
transformer 版本换成 5.0.0rc0 可以起服务,但是对于多模态的请求不能正常响应