Instructions to use QuantTrio/GLM-4.7-AWQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use QuantTrio/GLM-4.7-AWQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="QuantTrio/GLM-4.7-AWQ") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("QuantTrio/GLM-4.7-AWQ") model = AutoModelForCausalLM.from_pretrained("QuantTrio/GLM-4.7-AWQ", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use QuantTrio/GLM-4.7-AWQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantTrio/GLM-4.7-AWQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantTrio/GLM-4.7-AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/QuantTrio/GLM-4.7-AWQ
- SGLang
How to use QuantTrio/GLM-4.7-AWQ 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 "QuantTrio/GLM-4.7-AWQ" \ --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": "QuantTrio/GLM-4.7-AWQ", "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 "QuantTrio/GLM-4.7-AWQ" \ --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": "QuantTrio/GLM-4.7-AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use QuantTrio/GLM-4.7-AWQ with Docker Model Runner:
docker model run hf.co/QuantTrio/GLM-4.7-AWQ
Revert remplate
Browse filesReverting back the changes of the jinja template from this PR -https://huggingface.co/QuantTrio/GLM-4.7-AWQ/discussions/7
Sadly the model is breaking when structured output is requested and thinking is enabled. Making the model to only produce thinking block.
If structured output is needed, best will be to put it in the system prompt - this is also what GLM suggest as well.
Sorry for the confusion.
- chat_template.jinja +2 -27
chat_template.jinja
CHANGED
|
@@ -1,17 +1,14 @@
|
|
| 1 |
[gMASK]<sop>
|
| 2 |
-
{%- if tools
|
| 3 |
<|system|>
|
| 4 |
# Tools
|
| 5 |
-
|
| 6 |
You may call one or more functions to assist with the user query.
|
| 7 |
-
|
| 8 |
You are provided with function signatures within <tools></tools> XML tags:
|
| 9 |
<tools>
|
| 10 |
{% for tool in tools %}
|
| 11 |
{{ tool | tojson(ensure_ascii=False) }}
|
| 12 |
{% endfor %}
|
| 13 |
</tools>
|
| 14 |
-
|
| 15 |
For each function call, output the function name and arguments within the following XML format:
|
| 16 |
<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 -%}
|
| 17 |
{%- macro visible_text(content) -%}
|
|
@@ -78,29 +75,7 @@ For each function call, output the function name and arguments within the follow
|
|
| 78 |
<tool_response>{{ tr.output if tr.output is defined else tr }}</tool_response>{% endfor -%}
|
| 79 |
{% endif -%}
|
| 80 |
{%- elif m.role == 'system' -%}
|
| 81 |
-
<|system|>
|
| 82 |
-
{%- if structured_output is defined and structured_output.enabled and loop.index0 == 0 -%}
|
| 83 |
-
# Structured Output
|
| 84 |
-
|
| 85 |
-
You are a structured output engine.
|
| 86 |
-
|
| 87 |
-
Output ONLY valid JSON. Follow the JSON schema exactly.
|
| 88 |
-
|
| 89 |
-
Do not output:
|
| 90 |
-
- markdown
|
| 91 |
-
- prose
|
| 92 |
-
- explanations
|
| 93 |
-
- XML
|
| 94 |
-
- comments
|
| 95 |
-
- chain-of-thought
|
| 96 |
-
|
| 97 |
-
JSON Schema:
|
| 98 |
-
{{ structured_output.schema | tojson(indent=2) }}
|
| 99 |
-
|
| 100 |
-
{{ visible_text(m.content) }}
|
| 101 |
-
{%- else -%}
|
| 102 |
-
{{ visible_text(m.content) }}
|
| 103 |
-
{%- endif -%}
|
| 104 |
{%- endif -%}
|
| 105 |
{%- endfor -%}
|
| 106 |
{%- if add_generation_prompt -%}
|
|
|
|
| 1 |
[gMASK]<sop>
|
| 2 |
+
{%- if tools -%}
|
| 3 |
<|system|>
|
| 4 |
# Tools
|
|
|
|
| 5 |
You may call one or more functions to assist with the user query.
|
|
|
|
| 6 |
You are provided with function signatures within <tools></tools> XML tags:
|
| 7 |
<tools>
|
| 8 |
{% for tool in tools %}
|
| 9 |
{{ tool | tojson(ensure_ascii=False) }}
|
| 10 |
{% endfor %}
|
| 11 |
</tools>
|
|
|
|
| 12 |
For each function call, output the function name and arguments within the following XML format:
|
| 13 |
<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 -%}
|
| 14 |
{%- macro visible_text(content) -%}
|
|
|
|
| 75 |
<tool_response>{{ tr.output if tr.output is defined else tr }}</tool_response>{% endfor -%}
|
| 76 |
{% endif -%}
|
| 77 |
{%- elif m.role == 'system' -%}
|
| 78 |
+
<|system|>{{ visible_text(m.content) }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
{%- endif -%}
|
| 80 |
{%- endfor -%}
|
| 81 |
{%- if add_generation_prompt -%}
|