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

Qwen3-480B-A35B-Instruct 具备以下特性:
注意:本模型仅支持非思考模式,输出中不会生成<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])为获得最佳性能,我们推荐以下设置:
采样参数:
temperature=0.7、top_p=0.8、top_k=20 和 repetition_penalty=1.05。适当的输出长度:对于大多数查询,我们推荐使用 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},
}