刚刚,阿里开源了其最强代码模型:Qwen3-Coder-480B-A35B-Instruct,性能媲美 Claude Sonnet4
刚刚,阿里开源了其最强代码模型:Qwen3-Coder-480B-A35B-Instruct,性能媲美 Claude Sonnet4
阿里最新开源的代码模型 Qwen3-Coder-480B-A35B-Instruct,拥有 480B 参数量,35B 激活参数,采用 Mixture-of-Experts 机制(MoE)。模型原生支持 256K 上下文长度,通过 YaRN 可扩展到 1M,在代码理解、生成与 Agent 能力上对标目前最强的 Claude Sonnet4。
此外,阿里还提供了基于 Gemini CLI 修改的 Qwen Code CLI 工具,进一步增强了 Qwen3-Coder 系列模型的解析器和工具支持。
文章目录
- 刚刚,阿里开源了其最强代码模型:Qwen3-Coder-480B-A35B-Instruct,性能媲美 Claude Sonnet4
-
- 一、快速体验
- 二、通义千问代码模型概览
-
- 商业版模型对比
-
- qwen3-coder-plus 阶梯计费明细
- 三、使用方法
-
- 1. 简单示例:寻找质数函数
- 2. 工具调用:Coding Agent 能力
- 四、代码补全功能
-
- 1. 前缀补全(Completions 接口)
- 2. 前缀+后缀补全(Partial Mode)
- 五、总结
一、快速体验
-
Qwen Chat 在线体验:chat.qwen.ai
-
阿里云百炼:
https://bailian.console.aliyun.com/tab=model#/model-market/detail/qwen3-coder-480b-a35b-instruct -
GitHub 仓库:
https://github.com/QwenLM/Qwen3-Coder -
Hugging Face:
https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct -
魔搭社区:
https://www.modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct
二、通义千问代码模型概览
下表列出了阿里云百炼平台上可用的主要代码模型及其参数和定价情况。
商业版模型对比
qwen3-coder-plus 阶梯计费明细
提示: qwen3-coder-plus 支持 上下文缓存,可显著降低输入 Token 成本。
更多限流信息请参见限流。
三、使用方法
以下示例展示了如何通过 OpenAI 兼容接口在 Python 和 curl 中调用通义千问代码模型。
1. 简单示例:寻找质数函数
import osfrom openai import OpenAIclient = OpenAI( api_key=os.getenv(\"DASHSCOPE_API_KEY\"), # 或直接填写 API Key base_url=\"https://dashscope.aliyuncs.com/compatible-mode/v1\",)completion = client.chat.completions.create( model=\"qwen3-coder-plus\", messages=[ {\'role\': \'system\', \'content\': \'You are a helpful assistant.\'}, {\'role\': \'user\', \'content\': ( \'请编写一个Python函数 find_prime_numbers,该函数接受一个整数 n 作为参数,\' \'并返回一个包含所有小于 n 的质数(素数)的列表。\' \'质数是指仅能被1和其自身整除的正整数,如2, 3, 5, 7等。\' \'不要输出非代码的内容。\' )} ],)print(completion.choices[0].message.content)
返回结果:
```pythondef find_prime_numbers(n): if n <= 2: return [] primes = [] for num in range(2, n): is_prime = True for i in range(2, int(num ** 0.5) + 1): if num % i == 0: is_prime = False break if is_prime: primes.append(num) return primes```
2. 工具调用:Coding Agent 能力
Qwen3-Coder 系列模型支持 Function Calling,可通过配置读写文件、列目录等工具,实现直接修改和生成文件。
import osfrom openai import OpenAIclient = OpenAI( api_key=os.getenv(\"DASHSCOPE_API_KEY\"), # 若未配置环境变量,可直接替换为您的 API Key base_url=\"https://dashscope.aliyuncs.com/compatible-mode/v1\",)tools = [ { \"type\": \"function\", \"function\": { \"name\": \"read_file\", \"description\": \"读取指定路径的文件内容。\", \"parameters\": { \"type\": \"object\", \"properties\": { \"path\": {\"type\": \"string\", \"description\": \"目标文件路径\"} }, \"required\": [\"path\"] } } }, { \"type\": \"function\", \"function\": { \"name\": \"write_file\", \"description\": \"将内容写入指定文件,若文件不存在则创建。\", \"parameters\": { \"type\": \"object\", \"properties\": { \"path\": {\"type\": \"string\", \"description\": \"目标文件路径\"}, \"content\": {\"type\": \"string\", \"description\": \"写入内容\"} }, \"required\": [\"path\", \"content\"] } } }, { \"type\": \"function\", \"function\": { \"name\": \"list_directory\", \"description\": \"列出指定目录中的文件和子目录。\", \"parameters\": { \"type\": \"object\", \"properties\": { \"path\": {\"type\": \"string\", \"description\": \"目标目录路径\"} }, \"required\": [\"path\"] } } }]messages = [{\"role\": \"user\", \"content\": \"写一个python代码,快速排序,命名为quick_sort.py\"}]completion = client.chat.completions.create( model=\"qwen3-coder-plus\", messages=messages, tools=tools)print(completion.model_dump_json())
示例返回(摘录):
{ \"choices\": [ { \"message\": { \"tool_calls\": [ { \"function\": { \"name\": \"write_file\", \"arguments\": \"{\\\"content\\\": \\\"def quick_sort(arr):...\\\", \\\"path\\\": \\\"quick_sort.py\\\"}\" } } ] } } ]}
模型通过 tool_calls
参数输出函数调用信息,运行相应工具即可完成代码文件的创建或更新。
四、代码补全功能
通义千问代码模型还提供基于 Completions 接口 和 Partial Mode 的多种补全方案。
1. 前缀补全(Completions 接口)
import osfrom openai import OpenAIclient = OpenAI( base_url=\"https://dashscope.aliyuncs.com/compatible-mode/v1\", api_key=os.getenv(\"DASHSCOPE_API_KEY\"))completion = client.completions.create( model=\"qwen2.5-coder-32b-instruct\", prompt=\"写一个python的快速排序函数,def quick_sort(arr):\",)print(completion.choices[0].text)
2. 前缀+后缀补全(Partial Mode)
import osfrom openai import OpenAIclient = OpenAI( base_url=\"https://dashscope.aliyuncs.com/compatible-mode/v1\", api_key=os.getenv(\"DASHSCOPE_API_KEY\"))prefix_content = f\"\"\"def reverse_words_with_special_chars(s):\'\'\'反转字符串中的每个单词(保留非字母字符的位置),并保持单词顺序。示例:reverse_words_with_special_chars(\"Hello, world!\") -> \"olleH, dlrow!\"参数: s (str): 输入字符串(可能包含标点符号)返回: str: 处理后的字符串,单词反转但非字母字符位置不变\'\'\'\"\"\"suffix_content = \"return result\"completion = client.completions.create( model=\"qwen2.5-coder-32b-instruct\", prompt=f\"{prefix_content}{suffix_content}\",)print(completion.choices[0].text)
五、总结
阿里开源的 Qwen3-Coder-480B-A35B-Instruct,凭借超大参数量、Mixture-of-Experts 架构及超长上下文能力,已经跃居行业前列。无论是交互式开发、Agent 驱动还是大规模代码补全,均能提供媲美或超越同级别竞品的性能。马上访问以上链接,一起体验这款最强代码模型吧!