{"Code":200,"Data":{"AigcAttributes":"{}","AigcIsTop":0,"AigcType":"","AlreadyStar":false,"ApplyMeta":"{}","ApprovalMode":1,"ApprovalNotifyEmail":"","Architectures":["Qwen3ForCausalLM"],"Avatar":"https://resouces.modelscope.cn/avatar/56d9e1ec-12f1-4d2b-a749-04ade9830aba.png","Backbone":[],"BackendSupport":{"architectures":["Qwen3ForCausalLM"],"backend_info":{"deploy_task":["text","emb"],"lmdeploy":{},"lmdeploy_turbomind":{"text":"0.9.1"},"ollama":null,"sglang":{"text":"0.5.2"},"vllm":{"emb":"0.9.2","text":"0.9.2"}},"model_id":"Qwen/Qwen3-32B"},"BaseModel":[],"BaseModelRelation":"","CardReady":0,"CardUnreadyReason":"","CertificationCreateBy":"","CertificationCreatedTime":-62135596800,"ChineseName":"千问3-32B","CoverHeight":0,"CoverImages":[],"CoverWidth":0,"CreatedBy":"Cherrytest","CreatedTime":1745834888,"DashSdkParameter":"","Datasets":{},"DemoAvailable":0,"DemoUnavailableReason":"","Description":"","Domain":[],"Downloads":4961829,"ExampleCodeAvailable":0,"ExampleCodeUnavailableReason":"","ForbiddenVisibilityUpdate":false,"Frameworks":["pytorch"],"FromSite":"maas","Id":466234,"Integrating":0,"IntegrationFailureLog":"","IntegrationFailureReason":"","IsAccessible":1,"IsCertification":4,"IsHot":0,"IsNewModel":false,"IsOnline":1,"IsPreTrain":0,"IsPublished":1,"IsTop":0,"Language":[],"LastUpdatedTime":1753546361,"Libraries":["transformer","safetensors","pytorch"],"License":"apache-2.0","LicenseLink":"","LicenseName":"","Meta":"","Metrics":[],"ModelDetail":{},"ModelInfos":{"safetensor":{"chat_template":"{%- if tools %}\n    {{- '\u003c|im_start|\u003esystem\\n' }}\n    {%- if messages[0].role == 'system' %}\n        {{- messages[0].content + '\\n\\n' }}\n    {%- endif %}\n    {{- \"# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within \u003ctools\u003e\u003c/tools\u003e XML tags:\\n\u003ctools\u003e\" }}\n    {%- for tool in tools %}\n        {{- \"\\n\" }}\n        {{- tool | tojson }}\n    {%- endfor %}\n    {{- \"\\n\u003c/tools\u003e\\n\\nFor each function call, return a json object with function name and arguments within \u003ctool_call\u003e\u003c/tool_call\u003e XML tags:\\n\u003ctool_call\u003e\\n{\\\"name\\\": \u003cfunction-name\u003e, \\\"arguments\\\": \u003cargs-json-object\u003e}\\n\u003c/tool_call\u003e\u003c|im_end|\u003e\\n\" }}\n{%- else %}\n    {%- if messages[0].role == 'system' %}\n        {{- '\u003c|im_start|\u003esystem\\n' + messages[0].content + '\u003c|im_end|\u003e\\n' }}\n    {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n    {%- set index = (messages|length - 1) - loop.index0 %}\n    {%- if ns.multi_step_tool and message.role == \"user\" and message.content is string and not(message.content.startswith('\u003ctool_response\u003e') and message.content.endswith('\u003c/tool_response\u003e')) %}\n        {%- set ns.multi_step_tool = false %}\n        {%- set ns.last_query_index = index %}\n    {%- endif %}\n{%- endfor %}\n{%- for message in messages %}\n    {%- if message.content is string %}\n        {%- set content = message.content %}\n    {%- else %}\n        {%- set content = '' %}\n    {%- endif %}\n    {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n        {{- '\u003c|im_start|\u003e' + message.role + '\\n' + content + '\u003c|im_end|\u003e' + '\\n' }}\n    {%- elif message.role == \"assistant\" %}\n        {%- set reasoning_content = '' %}\n        {%- if message.reasoning_content is string %}\n            {%- set reasoning_content = message.reasoning_content %}\n        {%- else %}\n            {%- if '\u003c/think\u003e' in content %}\n                {%- set reasoning_content = content.split('\u003c/think\u003e')[0].rstrip('\\n').split('\u003cthink\u003e')[-1].lstrip('\\n') %}\n                {%- set content = content.split('\u003c/think\u003e')[-1].lstrip('\\n') %}\n            {%- endif %}\n        {%- endif %}\n        {%- if loop.index0 \u003e ns.last_query_index %}\n            {%- if loop.last or (not loop.last and reasoning_content) %}\n                {{- '\u003c|im_start|\u003e' + message.role + '\\n\u003cthink\u003e\\n' + reasoning_content.strip('\\n') + '\\n\u003c/think\u003e\\n\\n' + content.lstrip('\\n') }}\n            {%- else %}\n                {{- '\u003c|im_start|\u003e' + message.role + '\\n' + content }}\n            {%- endif %}\n        {%- else %}\n            {{- '\u003c|im_start|\u003e' + message.role + '\\n' + content }}\n        {%- endif %}\n        {%- if message.tool_calls %}\n            {%- for tool_call in message.tool_calls %}\n                {%- if (loop.first and content) or (not loop.first) %}\n                    {{- '\\n' }}\n                {%- endif %}\n                {%- if tool_call.function %}\n                    {%- set tool_call = tool_call.function %}\n                {%- endif %}\n                {{- '\u003ctool_call\u003e\\n{\"name\": \"' }}\n                {{- tool_call.name }}\n                {{- '\", \"arguments\": ' }}\n                {%- if tool_call.arguments is string %}\n                    {{- tool_call.arguments }}\n                {%- else %}\n                    {{- tool_call.arguments | tojson }}\n                {%- endif %}\n                {{- '}\\n\u003c/tool_call\u003e' }}\n            {%- endfor %}\n        {%- endif %}\n        {{- '\u003c|im_end|\u003e\\n' }}\n    {%- elif message.role == \"tool\" %}\n        {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n            {{- '\u003c|im_start|\u003euser' }}\n        {%- endif %}\n        {{- '\\n\u003ctool_response\u003e\\n' }}\n        {{- content }}\n        {{- '\\n\u003c/tool_response\u003e' }}\n        {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n            {{- '\u003c|im_end|\u003e\\n' }}\n        {%- endif %}\n    {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n    {{- '\u003c|im_start|\u003eassistant\\n' }}\n    {%- if enable_thinking is defined and enable_thinking is false %}\n        {{- '\u003cthink\u003e\\n\\n\u003c/think\u003e\\n\\n' }}\n    {%- endif %}\n{%- endif %}","files":[{"name":"model.safetensors.index.json","sha256":"bed42c6c55274bc08a1f616bceb3bcb84b3f02cb6584c573bd18c6519291ecd0","size":58330},{"name":"model-00001-of-00017.safetensors","sha256":"52562b2ff97b61764260273e71bf5b4cf8a66f569399398f26dec0300fcf1316","size":3957109648},{"name":"model-00002-of-00017.safetensors","sha256":"e26764b2c6878e3fb7198895fa833ec62838d84a19665e6abfbae43c6daf02b3","size":3900791760},{"name":"model-00003-of-00017.safetensors","sha256":"6c5ba7bed9c52bc121e75cbe8a7be46936d0006cc80f42a6d5886ed40b4c2a62","size":3900791760},{"name":"model-00004-of-00017.safetensors","sha256":"f736f6ac4d8c30866107fb1185a05b3c3cfce9717720082f466fa44e691bcec8","size":3900791800},{"name":"model-00005-of-00017.safetensors","sha256":"a52ed375c083209c54d42ac510afeb1fbb5af4f193be2dc7d103f665a0f212d3","size":3900791800},{"name":"model-00006-of-00017.safetensors","sha256":"37fae28990b0e4a70228549d040c0393e87bee3820d59e58e47844974d8dff5b","size":3900791800},{"name":"model-00007-of-00017.safetensors","sha256":"37776006aeaba29eca8bc73b2b963fe3477e1c2e3f6a27cb9527be75b905e1bf","size":3900791800},{"name":"model-00008-of-00017.safetensors","sha256":"73e74e9129674fe330948005075d70ab4fa0b92b68fb220c5a693f9cea553730","size":3900791800},{"name":"model-00009-of-00017.safetensors","sha256":"a044b3602a01bd8ea62ff51badf9cc038ab1d73d97399480e6a55b4c86fa7fa6","size":3900791800},{"name":"model-00010-of-00017.safetensors","sha256":"9966612ba7ecfc2cd2e592fb95224b86d743271ff88e172cc272a4b26382aa75","size":3900791800},{"name":"model-00011-of-00017.safetensors","sha256":"e2a058a0ac7d4b992b731c29221ecfb4b76b8a48d9004d0e8a62ba44f699845c","size":3900791800},{"name":"model-00012-of-00017.safetensors","sha256":"58a1aa89093fea07325f787072a468e3482a470ff4b7fe5ead5f749683907c40","size":3900791800},{"name":"model-00013-of-00017.safetensors","sha256":"35f3381bab31a23370c37d922290aeecdf603418336058fb86fe42d8f51ac40c","size":3900791800},{"name":"model-00014-of-00017.safetensors","sha256":"8713b062ddc178acf5917610b7f4b64eede833b2ea4aa37bd562dcf2f3a3339d","size":3900791800},{"name":"model-00015-of-00017.safetensors","sha256":"bec439d23931821a236d8f62fa79deecf5551bd25602278aa2ae0ce432b378cf","size":3900791800},{"name":"model-00016-of-00017.safetensors","sha256":"e569139fadd61fe7c8f9eb1c976d9a627cae48c57ddf228cfbd0593c59c64ff7","size":3900791800},{"name":"model-00017-of-00017.safetensors","sha256":"1f47c318fcd7797c0f85b4233cb754438b10e795b8bc874889090c416a94bd38","size":3055341992}],"model_size":32762123264,"tensor_type":["BF16"]}},"ModelRevisions":null,"ModelSource":"USER_UPLOAD","ModelTools":"","ModelType":["qwen3"],"MuseInfo":null,"NEXA":{"Catalogues":null,"ModelCover":"","ScientificField":"","Source":"","SubScientificField":null},"Name":"Qwen3-32B","NewVersion":"","NickName":"小橙鱼","OfficialTags":null,"OpenAiSwingDeployInfo":{"Order":3000,"Recommend":[{"Backend":["vllm"],"Channel":"fc","GpuMemory":"0","ImageTag":["ubuntu22.04-cuda12.4.0-py310-torch2.4.0-1.21.0-LLM-vllm085"],"InstanceType":"fc.gpu.tesla.1","Memory":"64000","ModelFamily":"","Version":"v1.0.0","deploy_task":["text-generation"]},{"Backend":["vllm"],"Channel":"eas","GpuMemory":"0","ImageTag":["ubuntu22.04-cuda12.4.0-py310-torch2.4.0-1.21.0-LLM-vllm085"],"InstanceType":"ecs.gn6i-c40g1.10xlarge","Memory":"64000","ModelFamily":"","Version":"v1.0.0","deploy_task":["text-generation"]}],"lmdeploy":{"eas":{"Script":"","requirements":""},"ens":{"Script":"","requirements":""},"fc":{"Script":"","requirements":""},"image_tag":""},"ollama":{"eas":{"Script":"","requirements":""},"ens":{"Script":"","requirements":""},"fc":{"Script":"","requirements":""},"image_tag":""},"pipeline":{"eas":{"Script":"","requirements":""},"ens":{"Script":"","requirements":""},"fc":{"Script":"","requirements":""},"image_tag":""},"vllm":{"eas":{"Script":"","requirements":""},"ens":{"Script":"","requirements":""},"fc":{"Script":"","requirements":""},"image_tag":""}},"Organization":{"ApplyFailureReason":"","ApplyReason":"","Avatar":"https://resources.modelscope.cn/avatar/4c40e6ce-1348-43b5-a3bc-6bafec6ac805.jpg","CreateCompetition":false,"CreatedBy":"Cherrytest","Description":"[\"root\",{},[\"p\",{},[\"span\",{\"data-type\":\"text\"},[\"span\",{\"data-type\":\"leaf\"},\"欢迎来到 Qwen 👋 !\"]]],[\"p\",{},[\"span\",{\"data-type\":\"text\"},[\"span\",{\"data-type\":\"leaf\"},\"这是 Qwen 的组织，来自阿里的大模型家族。在这个组织中，我们不断发布大型语言模型 (LLM)、大型多模态模型 (LMM) 和其他 AGI 相关项目。快来查看并享受吧！\"]]]]","DisplayUrl":"","Email":"","EmailDomain":"","FollowerCnt":0,"FromSite":"","FullName":"千问","GithubAddress":"https://qwen.ai/","GmtCreated":"2023-08-02T03:48:45Z","GmtModified":"2026-11-06T03:01:02Z","Id":209,"InitAdminMembers":"","IsApply":false,"IsCertification":"","MemberCnt":0,"Mobile":"","Name":"Qwen","Path":"","Roles":null,"SocialLinks":null,"StarCnt":0,"Status":0,"SubscribeVo":null,"Type":2},"PaiModelGalleryUrl":{"deploy":"https://account.aliyun.com/login/login.htm?oauth_callback=https%3A//pai.console.aliyun.com/regionId%3Dcn-hangzhou%23/quick-start/models/Qwen3-32B/intro%3FviewType%3DDeploy%26from%3DModelScope\u0026lang=zh","evaluation":"https://account.aliyun.com/login/login.htm?oauth_callback=https%3A//pai.console.aliyun.com/regionId%3Dcn-hangzhou%23/quick-start/evaluations/create%3FmodelName%3DQwen3-32B%26modelOrigin%3DPAI\u0026lang=zh","train":"https://account.aliyun.com/login/login.htm?oauth_callback=https%3A//pai.console.aliyun.com/regionId%3Dcn-hangzhou%23/quick-start/models/Qwen3-32B/intro%3FviewType%3DTrain%26from%3DModelScope\u0026lang=zh"},"PaiSdkParameter":null,"Path":"Qwen","ProtectedMode":2,"ReadMeContent":"\n# Qwen3-32B\n\u003ca href=\"https://chat.qwen.ai/\" target=\"_blank\" style=\"margin: 2px;\"\u003e\n    \u003cimg alt=\"Chat\" src=\"https://img.shields.io/badge/%F0%9F%92%9C%EF%B8%8F%20Qwen%20Chat%20-536af5\" style=\"display: inline-block; vertical-align: middle;\"/\u003e\n\u003c/a\u003e\n\n## Qwen3 Highlights\n\nQwen3 is the latest generation of large language models in Qwen series, offering a comprehensive suite of dense and mixture-of-experts (MoE) models. Built upon extensive training, Qwen3 delivers groundbreaking advancements in reasoning, instruction-following, agent capabilities, and multilingual support, with the following key features:\n\n- **Uniquely support of seamless switching between thinking mode** (for complex logical reasoning, math, and coding) and **non-thinking mode** (for efficient, general-purpose dialogue) **within single model**, ensuring optimal performance across various scenarios.\n- **Significantly enhancement in its reasoning capabilities**, surpassing previous QwQ (in thinking mode) and Qwen2.5 instruct models (in non-thinking mode) on mathematics, code generation, and commonsense logical reasoning.\n- **Superior human preference alignment**, excelling in creative writing, role-playing, multi-turn dialogues, and instruction following, to deliver a more natural, engaging, and immersive conversational experience.\n- **Expertise in agent capabilities**, enabling precise integration with external tools in both thinking and unthinking modes and achieving leading performance among open-source models in complex agent-based tasks.\n- **Support of 100+ languages and dialects** with strong capabilities for **multilingual instruction following** and **translation**.\n\n## Model Overview\n\n**Qwen3-32B** has the following features:\n- Type: Causal Language Models\n- Training Stage: Pretraining \u0026 Post-training\n- Number of Parameters: 32.8B\n- Number of Paramaters (Non-Embedding): 31.2B\n- Number of Layers: 64\n- Number of Attention Heads (GQA): 64 for Q and 8 for KV\n- Context Length: 32,768 natively and [131,072 tokens with YaRN](#processing-long-texts). \n\nFor more details, including benchmark evaluation, hardware requirements, and inference performance, please refer to our [blog](https://qwenlm.github.io/blog/qwen3/), [GitHub](https://github.com/QwenLM/Qwen3), and [Documentation](https://qwen.readthedocs.io/en/latest/).\n\n## Quickstart\n\nThe code of Qwen3 has been in the latest Hugging Face `transformers` and we advise you to use the latest version of `transformers`.\n\nWith `transformers\u003c4.51.0`, you will encounter the following error:\n```\nKeyError: 'qwen3'\n```\n\nThe following contains a code snippet illustrating how to use the model generate content based on given inputs. \n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\nmodel_name = \"Qwen/Qwen3-32B\"\n\n# load the tokenizer and the model\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModelForCausalLM.from_pretrained(\n    model_name,\n    torch_dtype=\"auto\",\n    device_map=\"auto\"\n)\n\n# prepare the model input\nprompt = \"Give me a short introduction to large language model.\"\nmessages = [\n    {\"role\": \"user\", \"content\": prompt}\n]\ntext = tokenizer.apply_chat_template(\n    messages,\n    tokenize=False,\n    add_generation_prompt=True,\n    enable_thinking=True # Switches between thinking and non-thinking modes. Default is True.\n)\nmodel_inputs = tokenizer([text], return_tensors=\"pt\").to(model.device)\n\n# conduct text completion\ngenerated_ids = model.generate(\n    **model_inputs,\n    max_new_tokens=32768\n)\noutput_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() \n\n# parsing thinking content\ntry:\n    # rindex finding 151668 (\u003c/think\u003e)\n    index = len(output_ids) - output_ids[::-1].index(151668)\nexcept ValueError:\n    index = 0\n\nthinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip(\"\\n\")\ncontent = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip(\"\\n\")\n\nprint(\"thinking content:\", thinking_content)\nprint(\"content:\", content)\n```\n\nFor deployment, you can use `sglang\u003e=0.4.6.post1` or `vllm\u003e=0.8.5` or to create an OpenAI-compatible API endpoint:\n- SGLang:\n    ```shell\n    python -m sglang.launch_server --model-path Qwen/Qwen3-32B --reasoning-parser qwen3\n    ```\n- vLLM:\n    ```shell\n    vllm serve Qwen/Qwen3-32B --enable-reasoning --reasoning-parser deepseek_r1\n    ```\n\nFor local use, applications such as Ollama, LMStudio, MLX-LM, llama.cpp, and KTransformers have also supported Qwen3.\n\n## Switching Between Thinking and Non-Thinking Mode\n\n\u003e [!TIP]\n\u003e The `enable_thinking` switch is also available in APIs created by SGLang and vLLM. \n\u003e Please refer to our documentation for [SGLang](https://qwen.readthedocs.io/en/latest/deployment/sglang.html#thinking-non-thinking-modes) and [vLLM](https://qwen.readthedocs.io/en/latest/deployment/vllm.html#thinking-non-thinking-modes) users.\n\n### `enable_thinking=True`\n\nBy default, Qwen3 has thinking capabilities enabled, similar to QwQ-32B. This means the model will use its reasoning abilities to enhance the quality of generated responses. For example, when explicitly setting `enable_thinking=True` or leaving it as the default value in `tokenizer.apply_chat_template`, the model will engage its thinking mode.\n\n```python\ntext = tokenizer.apply_chat_template(\n    messages,\n    tokenize=False,\n    add_generation_prompt=True,\n    enable_thinking=True  # True is the default value for enable_thinking\n)\n```\n\nIn this mode, the model will generate think content wrapped in a `\u003cthink\u003e...\u003c/think\u003e` block, followed by the final response.\n\n\u003e [!NOTE]\n\u003e For thinking mode, use `Temperature=0.6`, `TopP=0.95`, `TopK=20`, and `MinP=0` (the default setting in `generation_config.json`). **DO NOT use greedy decoding**, as it can lead to performance degradation and endless repetitions. For more detailed guidance, please refer to the [Best Practices](#best-practices) section.\n\n\n### `enable_thinking=False`\n\nWe provide a hard switch to strictly disable the model's thinking behavior, aligning its functionality with the previous Qwen2.5-Instruct models. This mode is particularly useful in scenarios where disabling thinking is essential for enhancing efficiency.\n\n```python\ntext = tokenizer.apply_chat_template(\n    messages,\n    tokenize=False,\n    add_generation_prompt=True,\n    enable_thinking=False  # Setting enable_thinking=False disables thinking mode\n)\n```\n\nIn this mode, the model will not generate any think content and will not include a `\u003cthink\u003e...\u003c/think\u003e` block.\n\n\u003e [!NOTE]\n\u003e For non-thinking mode, we suggest using `Temperature=0.7`, `TopP=0.8`, `TopK=20`, and `MinP=0`. For more detailed guidance, please refer to the [Best Practices](#best-practices) section.\n\n### Advanced Usage: Switching Between Thinking and Non-Thinking Modes via User Input\n\nWe provide a soft switch mechanism that allows users to dynamically control the model's behavior when `enable_thinking=True`. Specifically, you can add `/think` and `/no_think` to user prompts or system messages to switch the model's thinking mode from turn to turn. The model will follow the most recent instruction in multi-turn conversations.\n\nHere is an example of a multi-turn conversation:\n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\nclass QwenChatbot:\n    def __init__(self, model_name=\"Qwen/Qwen3-32B\"):\n        self.tokenizer = AutoTokenizer.from_pretrained(model_name)\n        self.model = AutoModelForCausalLM.from_pretrained(model_name)\n        self.history = []\n\n    def generate_response(self, user_input):\n        messages = self.history + [{\"role\": \"user\", \"content\": user_input}]\n\n        text = self.tokenizer.apply_chat_template(\n            messages,\n            tokenize=False,\n            add_generation_prompt=True\n        )\n\n        inputs = self.tokenizer(text, return_tensors=\"pt\")\n        response_ids = self.model.generate(**inputs, max_new_tokens=32768)[0][len(inputs.input_ids[0]):].tolist()\n        response = self.tokenizer.decode(response_ids, skip_special_tokens=True)\n\n        # Update history\n        self.history.append({\"role\": \"user\", \"content\": user_input})\n        self.history.append({\"role\": \"assistant\", \"content\": response})\n\n        return response\n\n# Example Usage\nif __name__ == \"__main__\":\n    chatbot = QwenChatbot()\n\n    # First input (without /think or /no_think tags, thinking mode is enabled by default)\n    user_input_1 = \"How many r's in strawberries?\"\n    print(f\"User: {user_input_1}\")\n    response_1 = chatbot.generate_response(user_input_1)\n    print(f\"Bot: {response_1}\")\n    print(\"----------------------\")\n\n    # Second input with /no_think\n    user_input_2 = \"Then, how many r's in blueberries? /no_think\"\n    print(f\"User: {user_input_2}\")\n    response_2 = chatbot.generate_response(user_input_2)\n    print(f\"Bot: {response_2}\") \n    print(\"----------------------\")\n\n    # Third input with /think\n    user_input_3 = \"Really? /think\"\n    print(f\"User: {user_input_3}\")\n    response_3 = chatbot.generate_response(user_input_3)\n    print(f\"Bot: {response_3}\")\n```\n\n\u003e [!NOTE]\n\u003e For API compatibility, when `enable_thinking=True`, regardless of whether the user uses `/think` or `/no_think`, the model will always output a block wrapped in `\u003cthink\u003e...\u003c/think\u003e`. However, the content inside this block may be empty if thinking is disabled.\n\u003e When `enable_thinking=False`, the soft switches are not valid. Regardless of any `/think` or `/no_think` tags input by the user, the model will not generate think content and will not include a `\u003cthink\u003e...\u003c/think\u003e` block.\n\n## Agentic Use\n\nQwen3 excels in tool calling capabilities. We recommend using [Qwen-Agent](https://github.com/QwenLM/Qwen-Agent) to make the best use of agentic ability of Qwen3. Qwen-Agent encapsulates tool-calling templates and tool-calling parsers internally, greatly reducing coding complexity.\n\nTo define the available tools, you can use the MCP configuration file, use the integrated tool of Qwen-Agent, or integrate other tools by yourself.\n```python\nfrom qwen_agent.agents import Assistant\n\n# Define LLM\nllm_cfg = {\n    'model': 'Qwen3-32B',\n\n    # Use the endpoint provided by Alibaba Model Studio:\n    # 'model_type': 'qwen_dashscope',\n    # 'api_key': os.getenv('DASHSCOPE_API_KEY'),\n\n    # Use a custom endpoint compatible with OpenAI API:\n    'model_server': 'http://localhost:8000/v1',  # api_base\n    'api_key': 'EMPTY',\n\n    # Other parameters:\n    # 'generate_cfg': {\n    #         # Add: When the response content is `\u003cthink\u003ethis is the thought\u003c/think\u003ethis is the answer;\n    #         # Do not add: When the response has been separated by reasoning_content and content.\n    #         'thought_in_content': True,\n    #     },\n}\n\n# Define Tools\ntools = [\n    {'mcpServers': {  # You can specify the MCP configuration file\n            'time': {\n                'command': 'uvx',\n                'args': ['mcp-server-time', '--local-timezone=Asia/Shanghai']\n            },\n            \"fetch\": {\n                \"command\": \"uvx\",\n                \"args\": [\"mcp-server-fetch\"]\n            }\n        }\n    },\n  'code_interpreter',  # Built-in tools\n]\n\n# Define Agent\nbot = Assistant(llm=llm_cfg, function_list=tools)\n\n# Streaming generation\nmessages = [{'role': 'user', 'content': 'https://qwenlm.github.io/blog/ Introduce the latest developments of Qwen'}]\nfor responses in bot.run(messages=messages):\n    pass\nprint(responses)\n```\n\n## Processing Long Texts\n\nQwen3 natively supports context lengths of up to 32,768 tokens. For conversations where the total length (including both input and output) significantly exceeds this limit, we recommend using RoPE scaling techniques to handle long texts effectively. We have validated the model's performance on context lengths of up to 131,072 tokens using the [YaRN](https://arxiv.org/abs/2309.00071) method.\n\nYaRN is currently supported by several inference frameworks, e.g., `transformers` and `llama.cpp` for local use, `vllm` and `sglang` for deployment. In general, there are two approaches to enabling YaRN for supported frameworks:\n\n- Modifying the model files:\n  In the `config.json` file, add the `rope_scaling` fields:\n    ```json\n    {\n        ...,\n        \"rope_scaling\": {\n            \"rope_type\": \"yarn\",\n            \"factor\": 4.0,\n            \"original_max_position_embeddings\": 32768\n        }\n    }\n    ```\n  For `llama.cpp`, you need to regenerate the GGUF file after the modification.\n\n- Passing command line arguments:\n\n  For `vllm`, you can use\n    ```shell\n    vllm serve ... --rope-scaling '{\"rope_type\":\"yarn\",\"factor\":4.0,\"original_max_position_embeddings\":32768}' --max-model-len 131072  \n    ```\n\n  For `sglang`, you can use\n    ```shell\n    python -m sglang.launch_server ... --json-model-override-args '{\"rope_scaling\":{\"rope_type\":\"yarn\",\"factor\":4.0,\"original_max_position_embeddings\":32768}}'\n    ```\n\n  For `llama-server` from `llama.cpp`, you can use\n    ```shell\n    llama-server ... --rope-scaling yarn --rope-scale 4 --yarn-orig-ctx 32768\n    ```\n\n\u003e [!IMPORTANT]\n\u003e If you encounter the following warning\n\u003e ```\n\u003e Unrecognized keys in `rope_scaling` for 'rope_type'='yarn': {'original_max_position_embeddings'}\n\u003e ```\n\u003e please upgrade `transformers\u003e=4.51.0`.\n\n\u003e [!NOTE]\n\u003e All the notable open-source frameworks implement static YaRN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts.**\n\u003e We advise adding the `rope_scaling` configuration only when processing long contexts is required. \n\u003e It is also recommended to modify the `factor` as needed. For example, if the typical context length for your application is 65,536 tokens, it would be better to set `factor` as 2.0. \n\n\u003e [!NOTE]\n\u003e The default `max_position_embeddings` in `config.json` is set to 40,960. This allocation includes reserving 32,768 tokens for outputs and 8,192 tokens for typical prompts, which is sufficient for most scenarios involving short text processing. If the average context length does not exceed 32,768 tokens, we do not recommend enabling YaRN in this scenario, as it may potentially degrade model performance.\n\n\u003e [!TIP]\n\u003e The endpoint provided by Alibaba Model Studio supports dynamic YaRN by default and no extra configuration is needed.\n\n## Best Practices\n\nTo achieve optimal performance, we recommend the following settings:\n\n1. **Sampling Parameters**:\n   - For thinking mode (`enable_thinking=True`), use `Temperature=0.6`, `TopP=0.95`, `TopK=20`, and `MinP=0`. **DO NOT use greedy decoding**, as it can lead to performance degradation and endless repetitions.\n   - For non-thinking mode (`enable_thinking=False`), we suggest using `Temperature=0.7`, `TopP=0.8`, `TopK=20`, and `MinP=0`.\n   - For supported frameworks, you can adjust the `presence_penalty` parameter between 0 and 2 to reduce endless repetitions. However, using a higher value may occasionally result in language mixing and a slight decrease in model performance.\n\n2. **Adequate Output Length**: We recommend using an output length of 32,768 tokens for most queries. For benchmarking on highly complex problems, such as those found in math and programming competitions, we suggest setting the max output length to 38,912 tokens. This provides the model with sufficient space to generate detailed and comprehensive responses, thereby enhancing its overall performance.\n\n3. **Standardize Output Format**: We recommend using prompts to standardize model outputs when benchmarking.\n   - **Math Problems**: Include \"Please reason step by step, and put your final answer within \\boxed{}.\" in the prompt.\n   - **Multiple-Choice Questions**: Add the following JSON structure to the prompt to standardize responses: \"Please show your choice in the `answer` field with only the choice letter, e.g., `\"answer\": \"C\"`.\"\n\n4. **No Thinking Content in History**: In multi-turn conversations, the historical model output should only include the final output part and does not need to include the thinking content. It is implemented in the provided chat template in Jinja2. However, for frameworks that do not directly use the Jinja2 chat template, it is up to the developers to ensure that the best practice is followed.\n\n### Citation\n\nIf you find our work helpful, feel free to give us a cite.\n\n```\n@misc{qwen3technicalreport,\n      title={Qwen3 Technical Report}, \n      author={Qwen Team},\n      year={2025},\n      eprint={2505.09388},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL},\n      url={https://arxiv.org/abs/2505.09388}, \n}\n```\n","ReadMeTips":null,"RelatedArxivId":["2309.00071","2505.09388"],"RelatedPaper":[35495,145214],"Revision":"master","Stars":407,"StorageSize":65540299108,"Studios":[],"SubVisionFoundation":"","SupportApiInference":false,"SupportDashDeployment":0,"SupportDashInference":0,"SupportDashTraining":0,"SupportDeployment":0,"SupportExperience":0,"SupportFinetuning":0,"SupportFlexTrain":0,"SupportInference":"","SupportPaiModelGallery":["deploy","train","evaluation"],"SupportPaiSdk":0,"SupportPivotEval":false,"SwingDeployInfo":null,"Tags":[],"Tasks":[{"ChineseName":"文本生成","Description":"","DomainName":"nlp","Id":22,"IsExhibition":true,"IsHot":0,"IsLeaf":true,"IsLoginRequired":true,"IsRetrieval":true,"Level":1,"Name":"text-generation","ParentId":-1,"ParentTask":null,"Sorting":0,"SupportWidgets":false,"TypicalModel":"","WidgetConfig":"{\"task\": \"text-generation\", \"inputs\": [{\"type\": \"text\", \"validator\": {\"max_words\": \"1000\"}, \"displayType\": \"OnlyTextArea\"}], \"output\": {\"displayType\": \"ReadonlyText\", \"transformOutputs\": [{\"outputKey\": \"text\"}], \"displayOutputMapping\": \"text\"}, \"examples\": []}","WidgetValidator":""}],"Tools":[],"TriggerWords":null,"Visibility":5,"VisionFoundation":"","_":null,"widgets":[]},"Message":"success","RequestId":"20d7e1b1-6474-417c-ab91-45e953b9e03f","Success":true}