HuggingFace镜像/Qwen3-Coder-Next
模型介绍文件和版本分析
下载使用量0

Qwen3-Coder-Next

亮点特性

今日,我们正式发布Qwen3-Coder-Next——一款专为编码智能体和本地开发场景设计的开源语言模型。该模型在以下关键方面实现了显著提升:

  • 极致高效与卓越性能:仅需激活30亿参数(总参数量800亿),性能便可媲美激活参数规模为其10-20倍的模型,为智能体部署提供了极高的成本效益。
  • 强大智能体能力:通过精心设计的训练方案,模型在长程推理、复杂工具调用以及执行故障恢复等方面表现出色,确保在动态编码任务中实现稳健性能。
  • 灵活适配真实IDE环境:256k的上下文长度结合对多种脚手架模板的良好适配性,使其能够无缝集成各类CLI/IDE平台(如Claude Code、Qwen Code、Qoder、Kilo、Trae、Cline等),支持多样化的开发环境。

image/jpeg

image/jpeg

模型概览

Qwen3-Coder-Next具备以下特性:

  • 类型:因果语言模型
  • 训练阶段:预训练与后训练
  • 参数数量:总参数800亿,激活参数30亿
  • 非嵌入层参数数量:790亿
  • 隐藏层维度:2048
  • 网络层数:48层
    • 混合结构:12 * (3 * (Gated DeltaNet -> MoE) -> 1 * (Gated Attention -> MoE))
  • 门控注意力(Gated Attention):
    • 注意力头数量:Q头16个,KV头2个
    • 头维度:256
    • 旋转位置嵌入维度:64
  • 门控DeltaNet(Gated DeltaNet):
    • 线性注意力头数量:V头32个,QK头16个
    • 头维度:128
  • 混合专家(Mixture of Experts):
    • 专家数量:512个
    • 激活专家数量:10个
    • 共享专家数量:1个
    • 专家中间层维度:512
  • 上下文长度:原生支持262,144 tokens

注意:本模型仅支持非思考模式,其输出不会生成</think>superscript:代码块。同时,不再需要指定enable_thinking=False参数。

有关基准测试评估、硬件要求及推理性能等更多详细信息,请参阅我们的博客、GitHub和文档。

快速入门

建议您使用最新版本的 transformers。

以下代码片段展示了如何基于给定输入使用模型生成内容。

from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "Qwen/Qwen3-Coder-Next"

# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
  model_name,
  torch_dtype="auto",
  device_map="auto"
)

# prepare the model input
prompt = "Write a quick sort algorithm."
messages = [
  {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
  messages,
  tokenize=False,
  add_generation_prompt=True,
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

# conduct text completion
generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=65536
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() 

content = tokenizer.decode(output_ids, skip_special_tokens=True)

print("content:", content)

注意:如果遇到内存不足(OOM)问题,请考虑将上下文长度减少到更短的值,例如 32,768。

对于本地使用,Ollama、LMStudio、MLX-LM、llama.cpp 和 KTransformers 等应用程序也已支持 Qwen3。

部署

进行部署时,您可以使用最新的 sglang 或 vllm 来创建兼容 OpenAI 的 API 端点。

SGLang

SGLang 是一个用于大型语言模型和视觉语言模型的快速服务框架。 SGLang 可用于启动具有兼容 OpenAI API 服务的服务器。

Qwen3-Coder-Next 需要 sglang>=v0.5.8,可通过以下方式安装:

pip install 'sglang[all]>=v0.5.8'

有关更多详情,请参见其文档。

以下命令可用于在4块GPU上通过张量并行创建一个API端点,地址为http://localhost:30000/v1,最大上下文长度为256K tokens。

python -m sglang.launch_server --model Qwen/Qwen3-Coder-Next --port 30000 --tp-size 2 --tool-call-parser qwen3_coder

[!Note] 默认上下文长度为 256K。如果服务器启动失败,请考虑将上下文长度减小,例如设为 32768。

vLLM

vLLM 是一个用于大语言模型(LLMs)的高吞吐量且内存高效的推理和服务引擎。 vLLM 可用于启动具有 OpenAI 兼容 API 服务的服务器。

Qwen3-Coder-Next 需要 vllm>=0.15.0,可通过以下命令安装:

pip install 'vllm>=0.15.0'

有关更多详细信息,请参见其文档。

以下命令可用于在 http://localhost:8000/v1 创建一个 API 端点,该端点使用 4 块 GPU 进行张量并行,最大上下文长度为 256K tokens。

vllm serve Qwen/Qwen3-Coder-Next --port 8000 --tensor-parallel-size 2 --enable-auto-tool-choice --tool-call-parser qwen3_coder

[!Note] 默认上下文长度为 256K。如果服务器启动失败,请考虑将上下文长度减小,例如设置为 32768。

智能体编码

Qwen3-Coder-Next 在工具调用能力方面表现卓越。

您可以按照以下示例轻松定义或使用任何工具。

# Your tool implementation
def square_the_number(num: float) -> dict:
    return num ** 2

# Define Tools
tools=[
    {
        "type":"function",
        "function":{
            "name": "square_the_number",
            "description": "output the square of the number.",
            "parameters": {
                "type": "object",
                "required": ["input_num"],
                "properties": {
                    'input_num': {
                        'type': 'number', 
                        'description': 'input_num is a number that will be squared'
                        }
                },
            }
        }
    }
]

from openai import OpenAI
# Define LLM
client = OpenAI(
    # Use a custom endpoint compatible with OpenAI API
    base_url='http://localhost:8000/v1',  # api_base
    api_key="EMPTY"
)
 
messages = [{'role': 'user', 'content': 'square the number 1024'}]

completion = client.chat.completions.create(
    messages=messages,
    model="Qwen3-Coder-Next",
    max_tokens=65536,
    tools=tools,
)

print(completion.choices[0])

最佳实践

为实现最佳性能,我们建议使用以下采样参数:temperature=1.0、top_p=0.95、top_k=40。

引用

如果您发现我们的研究工作对您有所帮助,欢迎引用我们的成果。

@techreport{qwen_qwen3_coder_next_tech_report,
  title        = {Qwen3-Coder-Next Technical Report},
  author       = {{Qwen Team}},
  url          = {https://github.com/QwenLM/Qwen3-Coder/blob/main/qwen3_coder_next_tech_report.pdf},
  note         = {Accessed: 2026-02-03}
}