Q
Qwen/Qwen3-Coder-480B-A35B-Instruct
模型介绍模型推理文件和版本分析
下载使用量0

Qwen3-Coder-480B-A35B-Instruct

Chat

核心亮点

今日,我们隆重推出迄今最具智能体特性的代码模型——Qwen3-Coder。该系列提供多种规格选择,而我们将首先为您呈现其最强版本:Qwen3-Coder-480B-A35B-Instruct,具备以下关键升级:

  • 卓越性能 在开源模型中,于智能编程、浏览器自动化等基础编码任务上表现突出,效果堪比Claude Sonnet。
  • 超长上下文 原生支持256K tokens,通过Yarn技术可扩展至1M tokens,专为代码库级理解优化。
  • 智能编程 兼容Qwen Code、CLINE等主流平台,采用特制函数调用格式。

image/jpeg

模型概览

Qwen3-480B-A35B-Instruct 具备以下特性:

  • 类型:因果语言模型
  • 训练阶段:预训练与后训练
  • 参数量:总计480B,激活35B
  • 层数:62
  • 注意力头数(GQA):查询头96个,键值头8个
  • 专家数量:160
  • 激活专家数:8
  • 上下文长度:原生支持262,144 tokens。

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

欲了解更多细节,包括基准测试、硬件需求及推理性能,请参阅我们的博客、GitHub及文档。

快速开始

建议使用最新版transformers。

若使用transformers<4.51.0版本,您将遇到以下错误:

KeyError: 'qwen3_moe'

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

from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "Qwen/Qwen3-480B-A35B-Instruct"

# 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。

智能编程

Qwen3-Coder 在工具调用能力上表现卓越。

你可以像下面这个例子一样简单地定义或使用任何工具。

# 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'
                        }
                },
            }
        }
    }
]

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-480B-A35B-Instruct",
    max_tokens=65536,
    tools=tools,
)

print(completion.choice[0])

最佳实践

为获得最佳性能,我们推荐以下设置:

  1. 采样参数:

    • 建议使用 temperature=0.7、top_p=0.8、top_k=20 和 repetition_penalty=1.05。
  2. 适当的输出长度:对于大多数查询,我们推荐使用 65,536 个 token 的输出长度,这对指令模型来说已经足够。

引用

如果您觉得我们的工作有帮助,欢迎引用。

@misc{qwen3technicalreport,
      title={Qwen3 Technical Report}, 
      author={Qwen Team},
      year={2025},
      eprint={2505.09388},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2505.09388}, 
}