
前言今天通義千問Qwen團隊正式開源推出 Qwen3這是 Qwen 系列大型語言模型的最新成員。最新的Qwen3系列模型具備雙模推理能力深入思考/快速響應、支持119種語言及方言并強化了Agent功能與代碼執行能力全面滿足復雜問題處理與全球化應用需求。其中旗艦模型 Qwen3-235B-A22B 在代碼、數學、通用能力等基準測試中與 DeepSeek-R1、o1、o3-mini、Grok-3 和 Gemini-2.5-Pro 等頂級模型相比表現出極具競爭力的結果。此外小型 MoE 模型 Qwen3-30B-A3B 的激活參數數量是 QwQ-32B 的 10%表現更勝一籌甚至像 Qwen3-4B 這樣的小模型也能匹敵 Qwen2.5-72B-Instruct 的性能。本次Qwen3開源了兩個 MoE 模型的權重Qwen3-235B-A22B一個擁有 2350 多億總參數和 220 多億激活參數的大模型以及Qwen3-30B-A3B一個擁有約 300 億總參數和 30 億激活參數的小型 MoE 模型。此外六個 Dense 模型也已開源包括 Qwen3-32B、Qwen3-14B、Qwen3-8B、Qwen3-4B、Qwen3-1.7B 和 Qwen3-0.6B均在 Apache 2.0 許可下開源。Githubhttps://github.com/QwenLM/Qwen3Bloghttps://qwenlm.github.io/zh/blog/qwen3/模型合集https://www.modelscope.cn/collections/Qwen3-9743180bdc6b48創空間體驗https://www.modelscope.cn/studios/Qwen/qwen3-chat-demo模型亮點小編敲黑板Qwen3 模型支持兩種思考模式思考模式在這種模式下模型會逐步推理經過深思熟慮后給出最終答案適合需要深入思考的復雜問題。非思考模式在此模式中模型提供快速、近乎即時響應適用于對速度要求高于深度的簡單問題。多語言Qwen3 模型支持 119 種語言和方言其中包括印歐語系、漢藏語系、亞非語系、南島語系、德拉威語、突厥語系 、壯侗語系、烏拉爾語系、南亞語系等等。這一廣泛的多語言能力為國際應用開辟了新的可能性讓全球用戶都能受益于這些模型的強大功能。增強的 Agent 能力優化了 Qwen3 模型的 Agent 和 代碼能力同時也加強了對 MCP 的支持后文附使用Qwen3系列模型與MCP結合的實戰教程1、推理部署Transformers在 transformers 中使用 Qwen3-30B-A3B frommodelscopeimportAutoModelForCausalLM,AutoTokenizermodel_nameQwen/Qwen3-30B-A3B# load the tokenizer and the modeltokenizer AutoTokenizer.from_pretrained(model_name)model AutoModelForCausalLM.from_pretrained( model_name, torch_dtypeauto, device_mapauto)# prepare the model inputprompt Give me a short introduction to large language model.messages [ {role: user, content: prompt}]text tokenizer.apply_chat_template( messages, tokenizeFalse, add_generation_promptTrue, enable_thinkingTrue # Switch between thinking and non-thinking modes. Default is True.)model_inputs tokenizer([text], return_tensorspt).to(model.device)# conduct text completiongenerated_ids model.generate( **model_inputs, max_new_tokens32768)output_ids generated_ids[0][len(model_inputs.input_ids[0]):].tolist() # parsing thinking contenttry: # rindex finding 151668 (/think) index len(output_ids) - output_ids[::-1].index(151668)except ValueError: index 0thinking_content tokenizer.decode(output_ids[:index], skip_special_tokensTrue).strip(\n)content tokenizer.decode(output_ids[index:], skip_special_tokensTrue).strip(\n)print(thinking content:, thinking_content)print(content:, content)禁用思考模式只需對參數 enable_thinking 進行如下修改texttokenizer.apply_chat_template(messages,tokenizeFalse,add_generation_promptTrue,enable_thinkingFalse# True is the default value for enable_thinking.)多工具部署開發者朋友們可以使用 sglang0.4.6.post1 或 vllm0.8.4 來創建一個與 OpenAI API 兼容的 API endpointSGLang:SGLANG_USE_MODELSCOPE1python-m sglang.launch_server--model-path Qwen/Qwen3-32B--reasoning-parser qwen3vLLM:VLLM_USE_MODELSCOPE1vllm serve Qwen/Qwen3-32B--enable-reasoning--reasoning-parser deepseek_r1要禁用思考模式可以移除參數 --reasoning-parser以及 --enable-reasoning如果用于本地開發可以通過運行簡單的命令 ollama run qwen3:30b-a3b 來使用 ollama 與模型進行交互。您也可以使用 LMStudio 或者 llama.cpp 以及 ktransformers 等代碼庫進行本地開發Ollama:ollama run modelscope.cn/unsloth/Qwen3-8B-GGUFOllama默認是thinking模式如果需要切換到非thinking模式在prompt后拼接上/no_think 即可。此外Ollama請確保升級到新版本v0.6.6或以上。使用魔搭API-Inference直接調用魔搭平臺的API-Inference也第一時間為Qwen3系列模型提供了支持。魔搭的用戶可通過API調用的方式直接使用。具體API-Inference的使用方式可參見各個模型頁面例如 https://www.modelscope.cn/models/Qwen/Qwen3-32B說明或者參見API-Inference文檔https://www.modelscope.cn/docs/model-service/API-Inference/intro。值得特別說明的是Qwen3系列模型可自由切換思考與普通模式在API接口上通過extra_body的參數來控制。默認enable_thinking配置打開可按需關閉。在開啟思考模式的時候還可以通過thinking_budget參數來限制思考的長度一般推薦thinking_budget不要配置過小以4096以上為宜。調用示例fromopenaiimportOpenAIclientOpenAI(base_urlhttps://api-inference.modelscope.cn/v1/,api_keyMODELSCOPE_SDK_TOKEN,# ModelScope Token)# set extra_body for thinking controlextra_body { # enable thinking, set to False to disable enable_thinking: True, # use thinking_budget to contorl num of tokens used for thinking # thinking_budget: 4096}response client.chat.completions.create( modelQwen/Qwen3-32B, # ModelScope Model-Id messages[ { role: user, content: 9.9和9.11誰大 } ], streamTrue, extra_bodyextra_body)done_thinking Falsefor chunk in response: thinking_chunk chunk.choices[0].delta.reasoning_content answer_chunk chunk.choices[0].delta.content if thinking_chunk ! : print(thinking_chunk, end, flushTrue) elif answer_chunk ! : if not done_thinking: print(\n\n Final Answer \n) done_thinking True print(answer_chunk, end, flushTrue)輸出結果嗯我現在要比較9.9和9.11哪個更大。首先我應該先理解這兩個數字的結構。9.9是一個小數而9.11看起來也是一個小數不過可能有些人可能會誤解為日期或者其他形式不過題目里明確說是比較數值大小所以應該按照數學上的小數來處理。首先我需要確認這兩個數的小數點位置。9.9是九又十分之九也就是90.99.9。而9.11則是九又百分之一十一也就是90.119.11。這時候我需要比較這兩個小數的大小。通常比較小數的方法是從左到右逐位比較直到找到不同的數字為止。首先比較整數部分兩個數都是9所以這部分相等。接下來比較小數部分。第一個數是0.9第二個數是0.11。這時候需要注意小數位數的問題。0.9可以看作0.90因為小數末尾的零不改變數值的大小。這樣兩個小數就變成了0.90和0.11。現在比較0.90和0.11的話第一位小數是9和1顯然9比1大所以0.90大于0.11因此整個數9.9即9.90比9.11大。Final Answer9.9和9.11的比較可以通過以下步驟進行1.**整數部分**兩者均為9相等。2.**小數部分**-9.9可寫為**9.90**補零不改變數值。-比較十分位9.90的十分位是**9**9.11的十分位是**1**。-由于 $91$因此**9.909.11**。**結論** $$\boxed{9.99.11}$$感謝阿里云百煉平臺提供背后算力支持使用ModelScope MCP實驗場集成Qwen3系列模型提供了對于智能體和工具調用更好的能力支持能夠在在思考和非思考模式下精確集成外部工具。我們也第一時間將多個Qwen3模型集成到了ModelScope MCP實驗場提供Qwen3在MCP場景上的工具調用能力的體驗。愉快的讓Qwen3幫我們訂個出行前的準備2、模型微調我們介紹使用ms-swift對Qwen/Qwen3-8B進行SFT/GRPO以及使用Megatron-SWIFT對Qwen/Qwen3-30B-A3B進行SFT。ms-swift是魔搭社區官方提供的大模型與多模態大模型訓練部署框架。ms-swift開源地址https://github.com/modelscope/ms-swift我們將展示可運行的微調demo并給出自定義數據集的格式。在開始微調之前請確保您的環境已準備妥當。git clone https://github.com/modelscope/ms-swift.gitcd ms-swiftpip install-e.pip install liger-kernel transformers-USFT對Qwen3-8B進行訓練的腳本如下在ModelScope提供的免費GPU Notebook中即可運行# 訓練顯存22GB# 你可以指定--dataset AI-ModelScope/alpaca-gpt4-data-zh來跑通實驗CUDA_VISIBLE_DEVICES0 \swift sft \ --model Qwen/Qwen3-8B \ --train_type lora \ --dataset dataset-path \ --torch_dtype bfloat16 \ --num_train_epochs 1 \ --per_device_train_batch_size 1 \ --per_device_eval_batch_size 1 \ --learning_rate 1e-4 \ --lora_rank 8 \ --lora_alpha 32 \ --target_modules all-linear \ --gradient_accumulation_steps 4 \ --eval_steps 50 \ --save_steps 50 \ --save_total_limit 2 \ --logging_steps 5 \ --max_length 2048 \ --output_dir output \ --warmup_ratio 0.05 \ --dataloader_num_workers 4 \ --packing true \ --user_liger_kernel true自定義數據集格式如下system字段可選指定--dataset dataset_path即可{messages:[{role:user,content:浙江的省會在哪},{role:assistant,content:think\nxxx\n/think\n\n浙江的省會在杭州。}]}GRPO以Qwen3-8B為例下面使用ms-swift框架對進行GRPO訓練使用AI-MO/NuminaMath-TIR作為數據集并使用accuracy函數計算模型回答的準確率獎勵, 計算獎勵需要安裝以下環境pip install math_verify0.5.2自定義數據集格式與SFT類似其中assistant部分不必需。如果使用accuracy獎勵則需要solution列來計算準確率。# llm{messages: [{role: system, content: You are a useful and harmless assistant}, {role: user, content: Tell me tomorrows weather}]}{messages: [{role: system, content: You are a useful and harmless math calculator}, {role: user, content: What is 1 1?}, {role: assistant, content: It equals 2}, {role: user, content: What about adding 1?}]}{messages: [{role: user, content: What is your name?}]}# mllm{messages: [{role: user, content: imageWhat is the difference between the two images?}], images: [/xxx/x.jpg]}{messages: [{role: user, content: imageimageWhat is the difference between the two images?}], images: [/xxx/y.jpg, /xxx/z.png]}也可以使用自定義的獎勵函數/獎勵模型進行訓練數據集中的列會傳到獎勵函數的**kwargs中自定義獎勵函數的例子參考swift/examples/train/grpo/plugin/plugin.py--external_plugins examples/train/grpo/plugin/plugin.py \--reward_funcs external_math_acc external_math_format \--reward_model AI-ModelScope/Skywork-Reward-Llama-3.1-8B-v0.2在訓練過程中我們使用vLLM來加速采樣過程。設置num_infer_workers8我們為每個device都部署一個vLLM engine來加速采樣過程。訓練腳本# 70G*8CUDA_VISIBLE_DEVICES0,1,2,3,4,5,6,7 \NPROC_PER_NODE8 \swift rlhf \ --rlhf_type grpo \ --model Qwen/Qwen3-8B \ --train_type full \ --dataset AI-MO/NuminaMath-TIR \ --torch_dtype bfloat16 \ --num_train_epochs 1 \ --per_device_train_batch_size 2 \ --per_device_eval_batch_size 2 \ --learning_rate 1e-6 \ --save_total_limit 2 \ --logging_steps 5 \ --output_dir output \ --gradient_accumulation_steps 1 \ --warmup_ratio 0.05 \ --dataloader_num_workers 4 \ --max_completion_length 4096 \ --vllm_max_model_len 8192 \ --reward_funcs accuracy \ --num_generations 16 \ --use_vllm true \ --vllm_gpu_memory_utilization 0.4 \ --sleep_level 1 \ --offload_model true \ --offload_optimizer true \ --gc_collect_after_offload true \ --deepspeed zero3 \ --num_infer_workers 8 \ --tensor_parallel_size 1 \ --temperature 1.0 \ --top_p 0.85 \ --report_to wandb \ --log_completions true \ --overlong_filter trueMoE訓練Megatron-SWIFTms-swift引入了Megatron的并行技術來加速大模型的訓練包括數據并行、張量并行、流水線并行、序列并行上下文并行專家并行。支持Qwen3、Qwen3-MoE、Qwen2.5、Llama3、Deepseek-R1蒸餾系等模型的預訓練和微調。對于環境準備鏡像和HF與MCore模型權重的轉換可以參考Megatron-SWIFT訓練文檔這里不詳細展開https://swift.readthedocs.io/zh-cn/latest/Instruction/Megatron-SWIFT%E8%AE%AD%E7%BB%83.html我們使用DLC啟動訓練命令訓練環境是2機8 * 80GiB A800# https://help.aliyun.com/zh/pai/user-guide/general-environment-variables# 請確保兩個節點的保存權重路徑相同NNODES$WORLD_SIZE \NODE_RANK$RANK \megatron sft \ --load Qwen3-30B-A3B-Base-mcore \ --dataset liucong/Chinese-DeepSeek-R1-Distill-data-110k-SFT \ --tensor_model_parallel_size 2 \ --expert_model_parallel_size 8 \ --moe_grouped_gemm true \ --moe_shared_expert_overlap true \ --moe_aux_loss_coeff 0.01 \ --micro_batch_size 1 \ --global_batch_size 16 \ --packing true \ --recompute_granularity full \ --recompute_method uniform \ --recompute_num_layers 1 \ --train_iters 2000 \ --eval_iters 50 \ --finetune true \ --cross_entropy_loss_fusion true \ --lr 1e-5 \ --lr_warmup_iters 100 \ --min_lr 1e-6 \ --save megatron_output/Qwen3-30B-A3B-Base \ --eval_interval 200 \ --save_interval 200 \ --max_length 8192 \ --num_workers 8 \ --dataset_num_proc 8 \ --no_save_optim true \ --no_save_rng true \ --sequence_parallel true \ --use_flash_attn true訓練loss圖部分自定義數據集格式與swift sft相同可以在本文上方找到指定--dataset dataset_path即可。使用megatron sft和swift sft進行Qwen3-30B-A3B模型全參數訓練速度/顯存占用對比如下Megatron-LMDeepSpeed-ZeRO2DeepSpeed-ZeRO3訓練速度9.6s/it-91.2s/it顯存占用16*60GiBOOM16*80GiB最后的最后感謝你們的閱讀和喜歡作為一位在一線互聯網行業奮斗多年的老兵我深知在這個瞬息萬變的技術領域中持續學習和進步的重要性。為了幫助更多熱愛技術、渴望成長的朋友我特別整理了一份涵蓋大模型領域的寶貴資料集。這些資料不僅是我多年積累的心血結晶也是我在行業一線實戰經驗的總結。這些學習資料不僅深入淺出而且非常實用讓大家系統而高效地掌握AI大模型的各個知識點。如果你愿意花時間沉下心來學習相信它們一定能為你提供實質性的幫助。這份完整版的大模型 AI 學習資料已經上傳CSDN朋友們如果需要可以微信掃描下方CSDN官方認證二維碼免費領取【保證100%免費】大模型知識腦圖為了成為更好的 AI大模型 開發者這里為大家提供了總的路線圖。它的用處就在于你可以按照上面的知識點去找對應的學習資源保證自己學得較為全面。經典書籍閱讀閱讀AI大模型經典書籍可以幫助讀者提高技術水平開拓視野掌握核心技術提高解決問題的能力同時也可以借鑒他人的經驗。對于想要深入學習AI大模型開發的讀者來說閱讀經典書籍是非常有必要的。實戰案例光學理論是沒用的要學會跟著一起敲要動手實操才能將自己的所學運用到實際當中去這時候可以搞點實戰案例來學習。面試資料我們學習AI大模型必然是想找到高薪的工作下面這些面試題都是總結當前最新、最熱、最高頻的面試題并且每道題都有詳細的答案面試前刷完這套面試題資料小小offer不在話下640套AI大模型報告合集這套包含640份報告的合集涵蓋了AI大模型的理論研究、技術實現、行業應用等多個方面。無論您是科研人員、工程師還是對AI大模型感興趣的愛好者這套報告合集都將為您提供寶貴的信息和啟示。這份完整版的大模型 AI 學習資料已經上傳CSDN朋友們如果需要可以微信掃描下方CSDN官方認證二維碼免費領取【保證100%免費】