This repository contains model weights and configuration files for the post-trained model in the Hugging Face Transformers format.
These artifacts are compatible with Hugging Face Transformers, vLLM, SGLang, TokenSpeed, etc.
For users seeking managed, scalable inference without infrastructure maintenance, the official Qwen API service is provided by Qwen Cloud.
In particular, Qwen4-35B-A3B is served under the model name
qwen4-35b-a3b, with more production features, e.g., official built-in tools. For more information, please refer to the Qwen4-35B-A3B Overview.
Since the release of Qwen3.8-Flash-Next, the community has embraced the Qwen4 architecture with remarkable creativity. Built for efficient inference, the Qwen4 architecture has already found its way into a wide range of new use cases through community-driven work, especially in local, self-hosted deployment.
Meanwhile, we've been pushing hard to unlock the full potential of this next-generation architecture, culminating in Qwen4-Max, the flagship of the Qwen4 series: an ultra-sparse model designed for long-horizon agentic applications, with cost-effectiveness optimized across the board.
Building on the same architecture and training techniques, the Qwen4 open model series is now on its way, making the latest advances in Qwen's frontier AI available to an ever-wider community.
Qwen4 features the following enhancement:
Efficient model architecture design: Built on a hybrid of linear attention and sparse attention, the Qwen4 architecture delivers outstanding efficiency in long-sequence scenarios — with faster inference and a drastically reduced cache footprint, enabling a native 1,000,000-token context window. Combined with n-gram embeddings, the architecture improves model quality without extra compute or accelerator memory overhead.
Significantly enhanced long-horizon agentic capabilities: Real-world productivity spans virtually every industry and profession. Throughout Qwen4's development, we went deep into the workflows of knowledge work, continually expanding the model's knowledge and capability boundaries, and achieved substantial progress in scenarios that demand sustained, long-term task delivery, with the goal of becoming a truly capable work assistant. Qwen4 also delivers stronger performance in coding for visual and creative deliverables, such as frontend development, 3D modeling, and game development with professional software & tools.
Improved token efficiency: Qwen4 substantially lowers the overall cost of task completion. Tasks require fewer interaction rounds, and within each round, thinking is markedly more concise across all effort levels, with the levels now clearly better separated. Paired with the architectural gains in inference efficiency, tasks complete faster and at lower cost.
1. Terminal Bench 4.1, FrontierCode-AA 2.0, AA-Briefcase v1.1 and AutomationBench-AA: Scores are cited from Artificial Analysis.
For streamlined integration, we recommend using Qwen4-35B-A3B via APIs.
Inference efficiency and throughput vary significantly across frameworks. We recommend using the latest framework versions to ensure optimal performance and compatibility. For production workloads or high-throughput scenarios, dedicated serving engines such as SGLang, vLLM, and TokenSpeed are strongly recommended.
Qwen4-35B-A3B can be deployed with popular inference frameworks for production-level serving, e.g.:
For local deployment, model repositories in compatible formats can be found in the model tree on the right. The Qwen4 architecture is supported by general-purpose inference engines such as llama.cpp, ollama, unsloth, mlx-vlm, and LiteRT-LM as well as by specialized inference engines for Qwen4.
Along with the model weights, we release a reference implementation of the Qwen4 Tokenizer/Processor. It ships with the original BPE vocabulary and provides methods for formatting messages into token sequences and parsing messages from generated token sequences. The implementation additionally depends on tiktoken, and trust_remote_code=True is required when creating the tokenizer instance. We recommend using this implementation.
For ecosystems that rely on Jinja chat templates, we include one in tokenizer-compat/ for backward compatibility only. Please note that although it produces the same formatted text, the resulting token IDs can be different, since the reference implementation distinguishes control tokens from regular tokens at the ID level.
See README-tokenizer.md for details.
We recommend using the following sets of sampling parameters for generation:
- Thinking Mode:
temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,presence_penalty=0.0,repetition_penalty=1.0- Non-thinking Mode:
temperature=0.7,top_p=0.80,top_k=20,min_p=0.0,presence_penalty=1.5,repetition_penalty=1.0Please note that the support for sampling parameters varies according to inference frameworks.
Qwen4 supports controlling thinking behavior via reasoning_effort and preserve_thinking. By default, Qwen4 operates in thinking mode reasoning_effort="high" and preserve_thinking enabled.
The supported reasoning effort levels are:
xhigh: for complex tasks where quality matters mosthigh: for common tasks (default)low: for fast responses with minimal thinkingoff: disables thinking entirelyThe enable_thinking switch can still be used and enable_thinking=False is equivalent to reasoning_effort="off". Please also note that the model may judge a task simple enough to answer directly without thinking, even at non-off reasoning effort levels.
In multi-turn agentic tasks, lower reasoning effort does not always reduce overall task completion time. Although it may produce faster per-turn responses, it can also lead to insufficient analysis, more failures, and repeated retries, which may increase total latency and token consumption.
The Chat Completions API is available in most inference frameworks, as well as on Qwen Cloud. You can call the API directly from your application, or connect it to agentic tools such as Qoder CLI and Qwen Code.
Below we show an example of calling the API directly. For connecting agentic applications, please refer to the respective guides for each tool.
Before starting, make sure it is installed and the API key and the API base URL is configured, e.g.:
pip install -U openai
# Set the following accordingly
export OPENAI_BASE_URL="http://localhost:8000/v1"
export OPENAI_API_KEY="EMPTY"
from openai import OpenAI
client = OpenAI()
messages = [
{"role": "user", "content": "Write a Python function to merge two sorted linked lists."},
]
completion = client.chat.completions.create(
model="Qwen/Qwen4-35B-A3B",
messages=messages,
extra_body={
"chat_template_kwargs": {
"preserve_thinking": True,
"reasoning_effort": "high",
},
},
stream=True,
stream_options={"include_usage": True},
)
reasoning_content = ""
answer_content = ""
is_answering = False
print("\n" + "=" * 20 + "Reasoning" + "=" * 20 + "\n")
for chunk in completion:
if not chunk.choices:
print("\nUsage:")
print(chunk.usage)
continue
delta = chunk.choices[0].delta
if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
if not is_answering:
print(delta.reasoning_content, end="", flush=True)
reasoning_content += delta.reasoning_content
elif hasattr(delta, "reasoning") and delta.reasoning is not None:
if not is_answering:
print(delta.reasoning, end="", flush=True)
reasoning_content += delta.reasoning
if hasattr(delta, "content") and delta.content:
if not is_answering:
print("\n" + "=" * 20 + "Answer" + "=" * 20 + "\n")
is_answering = True
print(delta.content, end="", flush=True)
answer_content += delta.content
messages.append({
"role": "assistant",
"content": answer_content,
"reasoning_content": reasoning_content,
})
To achieve optimal performance, we recommend the following settings:
Sampling Parameters: We suggest using the following sets of sampling parameters:
temperature=1.0, top_p=0.95, top_k=20, min_p=0.0, presence_penalty=0.0, repetition_penalty=1.0temperature=0.7, top_p=0.80, top_k=20, min_p=0.0, presence_penalty=1.5, repetition_penalty=1.0 For supported frameworks, you can adjust the presence_penalty parameter between 0 and 2 to reduce endless repetition. However, using a higher value may occasionally result in language mixing and a slight decrease in model performance.
Adequate Output Length: To optimize performance on agentic tasks, we recommend allocating sufficient output length to allow the model to generate detailed and comprehensive responses. For frameworks that support separate token limits for internal reasoning and final outputs, we suggest the following configuration within the 1M context length:
These settings provide the necessary capacity for complex reasoning while ensuring ample space for high-quality final deliverables.
Long Video Understanding: To optimize inference efficiency for plain text and images, the size parameter in the released video_preprocessor_config.json is conservatively configured. It is recommended to set the longest_edge parameter in the video_preprocessor_config file to 469,762,048 (corresponding to 224k video tokens) to enable higher frame-rate sampling for hour-scale videos and thereby achieve superior performance. For example,
{"longest_edge": 469762048, "shortest_edge": 4096}
Alternatively, override the default values via engine startup parameters. For implementation details, refer to: vLLM / SGLang.
Video Frame Sampling: When vLLM is launched with --media-io-kwargs '{"video": {"num_frames": -1}}', video frame sampling can be configured via extra_body (e.g., by setting fps). This feature is currently supported only in vLLM. By default, fps=2 and do_sample_frames=True.
chat_response = client.chat.completions.create(
model="Qwen/Qwen4-35B-A3B",
messages=messages,
extra_body={
"mm_processor_kwargs": {"fps": 2, "do_sample_frames": True},
},
)
If you find our work helpful, feel free to give us a cite.
@techreport{qwen2026design,
title = {On the Design of {Qwen3.8-Next} Architecture: Evaluation, Efficiency, and Training Stability},
author = {{Qwen Team}},
institution = {Alibaba Group},
month = {August},
year = {2026}
}
@misc{qwen4-35ba3b,
title = {{Qwen4-35B-A3B}},
author = {{Qwen Team}},
month = {December},
year = {2026},
url = {https://huggingface.co/Qwen/Qwen4-35B-A3B}
}