Instructions to use Qwen/Qwen3.8-2.4T-A95B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen3.8-2.4T-A95B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Qwen/Qwen3.8-2.4T-A95B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3.8-2.4T-A95B") model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.8-2.4T-A95B", 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]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Qwen/Qwen3.8-2.4T-A95B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/Qwen3.8-2.4T-A95B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qwen/Qwen3.8-2.4T-A95B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Qwen/Qwen3.8-2.4T-A95B
- SGLang
How to use Qwen/Qwen3.8-2.4T-A95B 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 "Qwen/Qwen3.8-2.4T-A95B" \ --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": "Qwen/Qwen3.8-2.4T-A95B", "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 "Qwen/Qwen3.8-2.4T-A95B" \ --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": "Qwen/Qwen3.8-2.4T-A95B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Qwen/Qwen3.8-2.4T-A95B with Docker Model Runner:
docker model run hf.co/Qwen/Qwen3.8-2.4T-A95B
Update chat template
Browse files- chat_template.jinja +18 -46
- tokenizer_config.json +1 -1
chat_template.jinja
CHANGED
|
@@ -1,33 +1,9 @@
|
|
| 1 |
-
{%-
|
| 2 |
-
{%- set video_count = namespace(value=0) %}
|
| 3 |
-
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
| 4 |
{%- if content is string %}
|
| 5 |
{{- content }}
|
| 6 |
{%- elif content is iterable and content is not mapping %}
|
| 7 |
{%- for item in content %}
|
| 8 |
-
{%- if '
|
| 9 |
-
{%- if is_system_content %}
|
| 10 |
-
{{- raise_exception('System message cannot contain images.') }}
|
| 11 |
-
{%- endif %}
|
| 12 |
-
{%- if do_vision_count %}
|
| 13 |
-
{%- set image_count.value = image_count.value + 1 %}
|
| 14 |
-
{%- endif %}
|
| 15 |
-
{%- if add_vision_id %}
|
| 16 |
-
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
| 17 |
-
{%- endif %}
|
| 18 |
-
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 19 |
-
{%- elif 'video' in item or item.type == 'video' %}
|
| 20 |
-
{%- if is_system_content %}
|
| 21 |
-
{{- raise_exception('System message cannot contain videos.') }}
|
| 22 |
-
{%- endif %}
|
| 23 |
-
{%- if do_vision_count %}
|
| 24 |
-
{%- set video_count.value = video_count.value + 1 %}
|
| 25 |
-
{%- endif %}
|
| 26 |
-
{%- if add_vision_id %}
|
| 27 |
-
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
| 28 |
-
{%- endif %}
|
| 29 |
-
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
|
| 30 |
-
{%- elif 'text' in item %}
|
| 31 |
{{- item.text }}
|
| 32 |
{%- else %}
|
| 33 |
{{- raise_exception('Unexpected item type in content.') }}
|
|
@@ -42,17 +18,18 @@
|
|
| 42 |
{%- if not messages %}
|
| 43 |
{{- raise_exception('No messages provided.') }}
|
| 44 |
{%- endif %}
|
|
|
|
|
|
|
|
|
|
| 45 |
{%- set reasoning_instructions = '' %}
|
| 46 |
-
{%-
|
| 47 |
-
|
| 48 |
-
{
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
{%-
|
| 52 |
-
|
| 53 |
-
{%-
|
| 54 |
-
{%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}
|
| 55 |
-
{%- endif %}
|
| 56 |
{%- endif %}
|
| 57 |
{%- if tools and tools is iterable and tools is not mapping %}
|
| 58 |
{{- '<|im_start|>system\n' }}
|
|
@@ -67,7 +44,7 @@
|
|
| 67 |
{{- "\n</tools>" }}
|
| 68 |
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 69 |
{%- if messages[0].role == 'system' %}
|
| 70 |
-
{%- set content = render_content(messages[0].content
|
| 71 |
{%- if content %}
|
| 72 |
{{- '\n\n' + content }}
|
| 73 |
{%- endif %}
|
|
@@ -75,7 +52,7 @@
|
|
| 75 |
{{- '<|im_end|>\n' }}
|
| 76 |
{%- else %}
|
| 77 |
{%- if messages[0].role == 'system' %}
|
| 78 |
-
{%- set content = render_content(messages[0].content
|
| 79 |
{%- if content %}
|
| 80 |
{{- '<|im_start|>system\n' + (reasoning_instructions + '\n\n' if reasoning_instructions else '') + content + '<|im_end|>\n' }}
|
| 81 |
{%- elif reasoning_instructions %}
|
|
@@ -89,7 +66,7 @@
|
|
| 89 |
{%- for message in messages[::-1] %}
|
| 90 |
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 91 |
{%- if ns.multi_step_tool and message.role == "user" %}
|
| 92 |
-
{%- set content = render_content(message.content
|
| 93 |
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
|
| 94 |
{%- set ns.multi_step_tool = false %}
|
| 95 |
{%- set ns.last_query_index = index %}
|
|
@@ -100,7 +77,7 @@
|
|
| 100 |
{{- raise_exception('No user query found in messages.') }}
|
| 101 |
{%- endif %}
|
| 102 |
{%- for message in messages %}
|
| 103 |
-
{%- set content = render_content(message.content
|
| 104 |
{%- if message.role == "system" %}
|
| 105 |
{%- if not loop.first %}
|
| 106 |
{{- raise_exception('System message must be at the beginning.') }}
|
|
@@ -161,10 +138,5 @@
|
|
| 161 |
{%- endif %}
|
| 162 |
{%- endfor %}
|
| 163 |
{%- if add_generation_prompt %}
|
| 164 |
-
{{- '<|im_start|>assistant\n' }}
|
| 165 |
-
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 166 |
-
{{- '<think>\n\n</think>\n\n' }}
|
| 167 |
-
{%- else %}
|
| 168 |
-
{{- '<think>\n' }}
|
| 169 |
-
{%- endif %}
|
| 170 |
{%- endif %}
|
|
|
|
| 1 |
+
{%- macro render_content(content) %}
|
|
|
|
|
|
|
| 2 |
{%- if content is string %}
|
| 3 |
{{- content }}
|
| 4 |
{%- elif content is iterable and content is not mapping %}
|
| 5 |
{%- for item in content %}
|
| 6 |
+
{%- if 'text' in item %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
{{- item.text }}
|
| 8 |
{%- else %}
|
| 9 |
{{- raise_exception('Unexpected item type in content.') }}
|
|
|
|
| 18 |
{%- if not messages %}
|
| 19 |
{{- raise_exception('No messages provided.') }}
|
| 20 |
{%- endif %}
|
| 21 |
+
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 22 |
+
{{- raise_exception('Disabling thinking is not supported.') }}
|
| 23 |
+
{%- endif %}
|
| 24 |
{%- set reasoning_instructions = '' %}
|
| 25 |
+
{%- set resolved_reasoning_effort = reasoning_effort|default('xhigh') %}
|
| 26 |
+
{%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}
|
| 27 |
+
{{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh (default), medium, and low.') }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{%- if resolved_reasoning_effort == 'xhigh' %}
|
| 30 |
+
{%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}
|
| 31 |
+
{%- elif resolved_reasoning_effort == 'low' %}
|
| 32 |
+
{%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}
|
|
|
|
|
|
|
| 33 |
{%- endif %}
|
| 34 |
{%- if tools and tools is iterable and tools is not mapping %}
|
| 35 |
{{- '<|im_start|>system\n' }}
|
|
|
|
| 44 |
{{- "\n</tools>" }}
|
| 45 |
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 46 |
{%- if messages[0].role == 'system' %}
|
| 47 |
+
{%- set content = render_content(messages[0].content)|trim %}
|
| 48 |
{%- if content %}
|
| 49 |
{{- '\n\n' + content }}
|
| 50 |
{%- endif %}
|
|
|
|
| 52 |
{{- '<|im_end|>\n' }}
|
| 53 |
{%- else %}
|
| 54 |
{%- if messages[0].role == 'system' %}
|
| 55 |
+
{%- set content = render_content(messages[0].content)|trim %}
|
| 56 |
{%- if content %}
|
| 57 |
{{- '<|im_start|>system\n' + (reasoning_instructions + '\n\n' if reasoning_instructions else '') + content + '<|im_end|>\n' }}
|
| 58 |
{%- elif reasoning_instructions %}
|
|
|
|
| 66 |
{%- for message in messages[::-1] %}
|
| 67 |
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 68 |
{%- if ns.multi_step_tool and message.role == "user" %}
|
| 69 |
+
{%- set content = render_content(message.content)|trim %}
|
| 70 |
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
|
| 71 |
{%- set ns.multi_step_tool = false %}
|
| 72 |
{%- set ns.last_query_index = index %}
|
|
|
|
| 77 |
{{- raise_exception('No user query found in messages.') }}
|
| 78 |
{%- endif %}
|
| 79 |
{%- for message in messages %}
|
| 80 |
+
{%- set content = render_content(message.content)|trim %}
|
| 81 |
{%- if message.role == "system" %}
|
| 82 |
{%- if not loop.first %}
|
| 83 |
{{- raise_exception('System message must be at the beginning.') }}
|
|
|
|
| 138 |
{%- endif %}
|
| 139 |
{%- endfor %}
|
| 140 |
{%- if add_generation_prompt %}
|
| 141 |
+
{{- '<|im_start|>assistant\n<think>\n' }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
{%- endif %}
|
tokenizer_config.json
CHANGED
|
@@ -282,7 +282,7 @@
|
|
| 282 |
"<|video_pad|>"
|
| 283 |
],
|
| 284 |
"bos_token": null,
|
| 285 |
-
"chat_template": "{%-
|
| 286 |
"clean_up_tokenization_spaces": false,
|
| 287 |
"eos_token": "<|im_end|>",
|
| 288 |
"errors": "replace",
|
|
|
|
| 282 |
"<|video_pad|>"
|
| 283 |
],
|
| 284 |
"bos_token": null,
|
| 285 |
+
"chat_template": "{%- macro render_content(content) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- if enable_thinking is defined and enable_thinking is false %}\n {{- raise_exception('Disabling thinking is not supported.') }}\n{%- endif %}\n{%- set reasoning_instructions = '' %}\n{%- set resolved_reasoning_effort = reasoning_effort|default('xhigh') %}\n{%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}\n {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh (default), medium, and low.') }}\n{%- endif %}\n{%- if resolved_reasoning_effort == 'xhigh' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}\n{%- elif resolved_reasoning_effort == 'low' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}\n{%- endif %}\n{%- if tools and tools is iterable and tools is not mapping %}\n {{- '<|im_start|>system\\n' }}\n {%- if reasoning_instructions %}\n {{- reasoning_instructions + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>\\nvalue_1\\n</parameter>\\n<parameter=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- Required parameters MUST be specified\\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\\n</IMPORTANT>' }}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content)|trim %}\n {%- if content %}\n {{- '\\n\\n' + content }}\n {%- endif %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content)|trim %}\n {%- if content %}\n {{- '<|im_start|>system\\n' + (reasoning_instructions + '\\n\\n' if reasoning_instructions else '') + content + '<|im_end|>\\n' }}\n {%- elif reasoning_instructions %}\n {{- '<|im_start|>system\\n' + reasoning_instructions + '<|im_end|>\\n' }}\n {%- endif %}\n {%- elif reasoning_instructions %}\n {{- '<|im_start|>system\\n' + reasoning_instructions + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" %}\n {%- set content = render_content(message.content)|trim %}\n {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if ns.multi_step_tool %}\n {{- raise_exception('No user query found in messages.') }}\n{%- endif %}\n{%- for message in messages %}\n {%- set content = render_content(message.content)|trim %}\n {%- if message.role == \"system\" %}\n {%- if not loop.first %}\n {{- raise_exception('System message must be at the beginning.') }}\n {%- endif %}\n {%- elif message.role == \"user\" %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content|trim %}\n {%- if preserve_thinking is undefined or preserve_thinking is true or loop.index0 > ns.last_query_index %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {%- if loop.first %}\n {%- if content|trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- if tool_call.arguments is defined and tool_call.arguments != '' %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}\n {{- args_value }}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>\\n' }}\n {%- elif loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- raise_exception('Unexpected message role.') }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n<think>\\n' }}\n{%- endif %}",
|
| 286 |
"clean_up_tokenization_spaces": false,
|
| 287 |
"eos_token": "<|im_end|>",
|
| 288 |
"errors": "replace",
|