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 Settings
- 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
这模型推理陷入死循环的概率非常高
问题稍微复杂一点,就陷入循环推理了,一个例子:
已知有4个逻辑单元
Ges,Tes,Gus,Tus。
设定3个逻辑符号
△ ◮ ◪
Ges △ Tes = es
Tes △ Tus = Ts
Ges ◮ Tes = GT
Tes ◮ Tus = eu
Tes ◪ Gus = tEgU
Ges ◪ Gus = EU
- Ges ◮ Gus = ?
- Tes △ Tus ◪ Tus = ?
模型的推理片段:
不过回到题目中的第一个问题:Ges ◮ Gus
我们可以尝试从已知例子中寻找模式。首先看◮运算的两个例子:
Ges ◮ Tes = GT
Tes ◮ Tus = eu
现在分析这两个例子中的操作数和结果的关系:
在例1中,操作数为Ges(G开头)和Tes(T开头),结果GT是两个首字母的组合。
在例1中,操作数Ges和Tes的首字母分别是G和T,结果GT是这两个首字母的顺序排列(因为Ges在前,Tes在后)。
在例2中,操作数为Tes和Tus。首先确定它们的单元类型:Tes是“Tes”,Tus是“Tus”。现在看结果eu。我们可以尝试将操作数中的部分映射到结果。
另外,观察符号△的例子:Ges △ Tes = es。这里es可能是两个单元中的“e”和“s”?或者是对应的部分。
不过可能更有效的是寻找运算的代数性质,比如对于◮运算,假设其规则是对两个单元进行某种组合或提取,类似于“取首字母”但可能涉及其他部分。
不过回到题目中的第一个问题:Ges ◮ Gus
我们可以尝试从已知例子中寻找模式。首先看◮运算的两个例子:
Ges ◮ Tes = GT
Tes ◮ Tus = eu
现在分析这两个例子中的操作数和结果的关系:
在例1中,操作数为Ges(G开头)和Tes(T开头),结果GT是两个首字母的组合。
在例1中,操作数Ges和Tes的首字母分别是G和T,结果GT是这两个首字母的顺序排列(因为Ges在前,Tes在后)。
在例2中,操作数为Tes和Tus。首先确定它们的单元类型:Tes是“Tes”,Tus是“Tus”。现在看结果eu。我们可以尝试将操作数中的部分映射到结果。
另外,观察符号△的例子:Ges △ Tes = es。这里es可能是两个单元中的“e”和“s”?或者是对应的部分。
不过可能更有效的是寻找运算的代数性质,比如对于◮运算,假设其规则是对两个单元进行某种组合或提取,类似于“取首字母”但可能涉及其他部分。
不过回到题目中的第一个问题:Ges ◮ Gus
我们可以尝试从已知例子中寻找模式。首先看◮运算的两个例子:
Ges ◮ Tes = GT
Tes ◮ Tus = eu
现在分析这两个例子中的操作数和结果的关系:
在例1中,操作数为Ges(G开头)和Tes(T开头),结果GT是两个首字母的组合。
在例1中,操作数Ges和Tes的首字母分别是G和T,结果GT是这两个首字母的顺序排列(因为Ges在前,Tes在后)。
在例2中,操作数为Tes和Tus。首先确定它们的单元类型:Tes是“Tes”,Tus是“Tus”。现在看结果eu。我们可以尝试将操作数中的部分映射到结果。
另外,观察符号△的例子:Ges △ Tes = es。这里es可能是两个单元中的“e”和“s”?或者是对应的部分。
不过可能更有效的是寻找运算的代数性质,比如对于◮运算,假设其规则是对两个单元进行某种组合或提取,类似于“取首字母”但可能涉及其他部分。
不过回到题目中的第一个问题:Ges ◮ Gus
可以看到一直在重复一个推理路径
其实GLM4.6有的时候也有这个问题,感觉就是训练流程或者数据集有点问题
me too
确实是的, 死循环概率很大