This repository contains example weights and configuration records for the post-trained example in the Hugging Face Transformers format.
These artifacts are compatible alongside Hugging Face Transformers, vLLM, SGLang, TokenSpeed, etc.
For users seeking managed, scalable conclusion without infrastructure maintenance, the authoritative Qwen API assistance is provided by Qwen Cloud.
In particular, Qwen4-35B-A3B is served under the example name qwen4-35b-a3b, alongside additional manufacturing features, e.g., authoritative built-in tools. The APIs volition be avaible at Qwen Cloud soon.
Since the publish of Qwen3.8-Flash-Next, the community has embraced the Qwen4 architecture alongside notable creativity. Built for productive inference, the Qwen4 architecture has already established its way into a broad range of new use cases through community-driven work, particularly in local, self-hosted deployment.
Meanwhile, we've been pushing difficult to unlock the complete possible of this next-generation architecture, culminating in Qwen4-Max, the flagship of the Qwen4 series: an ultra-sparse example designed for long-horizon agentic applications, alongside cost-effectiveness optimized throughout the board.
Building on the identical architecture and training techniques, the Qwen4 open example sequence is now on its way, making the latest advances in Qwen's frontier AI accessible to an ever-wider community.
Qwen4 Highlights
Qwen4 features the following enhancement:
Efficient example architecture design: Built on a hybrid of linear notice and sparse attention, the Qwen4 architecture delivers outstanding effectiveness in long-sequence scenarios — alongside faster conclusion and a drastically reduced cache footprint, enabling a native 1,000,000-token environment window. Combined alongside n-gram embeddings, the architecture improves example norm without additional compute or accelerator recollection overhead.
Significantly enhanced long-horizon agentic capabilities: Real-world efficiency spans practically all industry and profession. Throughout Qwen4's development, we went profound into the workflows of cognition work, continually expanding the model's cognition and capability boundaries, and achieved significant advancement in scenarios that petition sustained, long-term project delivery, alongside the goal of becoming a really capable activity assistant. Qwen4 additionally delivers stronger achievement in coding for ocular and imaginative deliverables, specified as frontend development, 3D modeling, and equivalent betterment alongside expert application & tools.
Improved token efficiency: Qwen4 substantially lowers the general disbursal of project completion. Tasks necessitate small communication rounds, and inside all round, thinking is markedly additional concise throughout all attempt levels, alongside the levels now plainly improved separated. Paired alongside the architectural gains in conclusion efficiency, tasks complete faster and at lesser cost.
Model Overview
- Type: Causal Language Model alongside Vision Encoder
- Training Stage: Pre-training & Post-training
- Language Model
- Number of Parameters: 35B alongside 3B activated, affirmative 20B n-gram embedding and 2B MTP
- Hidden Dimension: 2048
- Token Embedding: 248320 (Padded)
- N-gram Embedding: 10,000,000 (bigrams/trigrams at tier 2)
- Number of Layers: 40
- Hidden Layout: 10 × (3 × (Gated DeltaNet → MoE) → 1 × (Qwen Sparse Attention → MoE))
- Gated DeltaNet:
- Number of Linear Attention Heads: 32 for V and 16 for QK
- Head Dimension: 128
- Qwen Sparse Attention:
- Number of Attention Heads: 16 for Q and 2 for KV
- Head Dimension: 256
- Rotary Position Embedding Dimension: 64
- Indexer Structure: MQA alongside 4 Query Heads and 1 Shared Key Head
- Indexer Head Dimension: 128
- Budget: 512 blocks or 2048 tokens
- Mixture Of Experts
- Number of Experts: 256
- Number of Activated Experts: 8 Routed + 1 Shared
- Expert Intermediate Dimension: 512
- Gated Residual:
- Number of Branches: 4
- Bottleneck Rank: 256
- LM Output: 248320 (Padded)
- MTP: 1 layer, trained alongside multi-steps
- Context Length: 1,048,576 natively.
Benchmark Results
1. Terminal Bench 4.1, FrontierCode-AA 2.0, AA-Briefcase v1.1 and AutomationBench-AA: Scores are cited from Artificial Analysis.
2. APEX-Agents v1.1: Scores are cited from the Mercor leaderboard.
3. Work360: Our built-in benchmark for evaluating models' capabilities throughout manufacturing and expert workflows.
4. ChartoGraphy: The scores of our models were obtained alongside min_pixels set to 4096×32×32.
Quickstart
For streamlined integration, we propose using Qwen4-35B-A3B via APIs.
Serving Qwen4-35B-A3B
Inference effectiveness and throughput change considerably throughout frameworks. We propose using the latest example versions to justify optimal achievement and compatibility. For manufacturing workloads or high-throughput scenarios, dedicated serving engines specified as SGLang, vLLM, and TokenSpeed are powerfully recommended.
Qwen4-35B-A3B can be deployed alongside famous conclusion frameworks for production-level serving, e.g.:
For local deployment, example repositories in compatible formats can be established in the example tree on the right. The Qwen4 architecture is supported by general-purpose conclusion engines specified as llama.cpp, ollama, unsloth, mlx-vlm, and LiteRT-LM as fine as by specialized conclusion engines for Qwen4.
Qwen4 Tokenizer
Along alongside the example weights, we publish a citation implementation of the Qwen4 Tokenizer/Processor. It ships alongside the first 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 whenever creating the tokenizer instance. We propose using this implementation.
For ecosystems that depend on Jinja conversation templates, we contain one in tokenizer-compat/ for backward compatibility only. Please note that although it produces the identical formatted text, the resulting token IDs can be different, since the citation implementation distinguishes authority tokens from regular tokens at the ID level.
See README-tokenizer.md for details.
API Usage
We propose 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.0
Please note that the assistance for sampling parameters varies according to conclusion frameworks.
Thinking Control
Qwen4 supports controlling thinking behavior via reasoning_effort and preserve_thinking. By default, Qwen4 operates in thinking manner reasoning_effort="high" and preserve_thinking enabled.
The supported reasoning attempt levels are:
- xhigh: for complex tasks anywhere norm matters most
- high: for average tasks (default)
- low: for accelerated responses alongside minimal thinking
- off: disables thinking entirely
The enable_thinking toggle can motionless be used and enable_thinking=False is equal to reasoning_effort="off". Please additionally note that the example may fairness a project uncomplicated adequate to answer immediately without thinking, equal at non-off reasoning attempt levels.
In multi-turn agentic tasks, lesser reasoning attempt does not continually decrease general project completion time. Although it may create faster per-turn responses, it can additionally guide to insufficient analysis, additional failures, and repeated retries, which may addition total latency and token consumption.
Chat Completions API
The Chat Completions API is accessible in most conclusion frameworks, as fine as on Qwen Cloud. You can call the API immediately from your application, or nexus it to agentic tools specified as Qoder CLI and Qwen Code.
Below we display an example of calling the API directly. For connecting agentic applications, delight mention to the corresponding guides for all tool.
Before starting, create certain it is installed and the API key and the API basis URL is configured, e.g.:
pip instal -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 connected 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, })
Best Practices
To accomplish optimal performance, we propose the following settings:
Sampling Parameters: We propose using the following sets of sampling parameters:
- 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.0
For supported frameworks, you can modify the presence_penalty indicator between 0 and 2 to decrease endless repetition. However, using a higher value may occasionally outcome in tongue mixing and a minor decrease in example performance.
Adequate Output Length: To optimize achievement on agentic tasks, we propose allocating adequate output dimension to authorize the example to create detailed and thorough responses. For frameworks that assistance distinct token limits for inner reasoning and final outputs, we propose the following configuration inside the 1M environment length:
- Reasoning Content: Set the maximum output dimension to 262,144 tokens.
- Final Response: Set the maximum output dimension to 131,072 tokens.
These settings provision the necessary capability for complex reasoning during ensuring roomy area for high-quality final deliverables.
Long Video Understanding: To optimize conclusion effectiveness for plain content and images, the size indicator in the released video_preprocessor_config.json is conservatively configured. It is recommended to set the longest_edge indicator in the video_preprocessor_config document to 469,762,048 (corresponding to 224k video tokens) to allow higher frame-rate sampling for hour-scale videos and thereby accomplish better performance. For example,
{"longest_edge": 469762048, "shortest_edge": 4096}
Alternatively, override the default values via motor startup parameters. For implementation details, mention to: vLLM / SGLang.
Video Frame Sampling: When vLLM is launched alongside --media-io-kwargs '{"video": {"num_frames": -1}}', video example sampling can be configured via extra_body (e.g., by environment fps). This characteristic is currently supported lone 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 discover our activity helpful, awareness liberated to provision us a cite.
@techreport{qwen2026design, heading = {On the Design of {Qwen3.8-Next} Architecture: Evaluation, Efficiency, and Training Stability}, author = {{Qwen Team}}, institution = {Alibaba Group}, duration = {August}, twelvemonth = {2026} } @misc{qwen4-35ba3b, heading = {{Qwen4-35B-A3B}}, author = {{Qwen Team}}, duration = {December}, twelvemonth = {2026}, url = {https://huggingface.co/Qwen/Qwen4-35B-A3B} }
