---
libraryname: transformers
license: apache-2.0
licenselink: https://huggingface.co/Qwen/Qwen3-8B/blob/main/LICENSE
pipelinetag: text-generation
basemodel:
Qwen3 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:
Qwen3-8B has the following features:
For more details, including benchmark evaluation, hardware requirements, and inference performance, please refer to our blog, GitHub, and Documentation.
The code of Qwen3 has been in the latest Hugging Face INLINECODE
0B43BED3B and we advise you to use the latest version of INLINECODE1AEA4F724.With INLINECODE
21AA59451, you will encounter the following error:The following contains a code snippet illustrating how to use the model generate content based on given inputs.
CODEBLOCK
For deployment, you can use INLINECODE
36F122A96 or INLINECODE4313CC17F or to create an OpenAI-compatible API endpoint:For local use, applications such as Ollama, LMStudio, MLX-LM, llama.cpp, and KTransformers have also supported Qwen3.
> [!TIP]
> The INLINECODE
By 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 INLINECODE
135A191F55 or leaving it as the default value in INLINECODE141ED2D8B2, the model will engage its thinking mode.CODEBLOCK
2D2CBB244In this mode, the model will generate think content wrapped in a INLINECODE
15D2A8DC12 block, followed by the final response.> [!NOTE]
> For thinking mode, use INLINECODE
We 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.
CODEBLOCK33C88EA8E
In this mode, the model will not generate any think content and will not include a INLINECODE220A0303F2 block.
> [!NOTE]
> For non-thinking mode, we suggest using INLINECODE23410C0AC6, INLINECODE24D5E03085, INLINECODE25C1B2F8D0, and INLINECODE265B959F22. For more detailed guidance, please refer to the Best Practices section.
We provide a soft switch mechanism that allows users to dynamically control the model's behavior when INLINECODE
27DABD5754. Specifically, you can add INLINECODE2801F42B9B and INLINECODE29ACEECF04 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.Here is an example of a multi-turn conversation:
CODEBLOCK
48274414B> [!NOTE]
> For API compatibility, when INLINECODE
Qwen3 excels in tool calling capabilities. We recommend using 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.
To define the available tools, you can use the MCP configuration file, use the integrated tool of Qwen-Agent, or integrate other tools by yourself.
INLINECODE40171819F8INLINECODE410FEEF427transformersINLINECODE42F75C716Fllama.cppINLINECODE4301E0C158vllmINLINECODE445B08A248sglangINLINECODE4589F926E8config.jsonINLINECODE46AF35A355ropescalingINLINECODE47547CEAEDINLINECODE496227E80AINLINECODE503BA2515Allama.cppINLINECODE519F66D2E8vllmINLINECODE52C3BCB099INLINECODE54E048760DINLINECODE55FAFCACFDsglangINLINECODE5641627319INLINECODE5852567E3AINLINECODE5937FB02F6llama-serverINLINECODE60180847F9llama.cppINLINECODE61EB7EE44AINLINECODE632973681DINLINECODE64DC10C8DAINLINECODE660A8FC603 for 'ropetype'='yarn': {'originalmaxpositionembeddings'}
> INLINECODE69EA0C967CropescalingINLINECODE7066FBA89EfactorINLINECODE710525BABFfactorINLINECODE72A9385AA8maxpositionembeddingsINLINECODE73519F84A8config.jsonINLINECODE74DB05D17Fenablethinking=TrueINLINECODE75923209AETemperature=0.6INLINECODE7615D8703BTopP=0.95INLINECODE7717ACB621TopK=20INLINECODE784C5026F5MinP=0INLINECODE7943F8D96Aenablethinking=FalseINLINECODE80CA14A583Temperature=0.7INLINECODE8171A144CBTopP=0.8INLINECODE821EE757C2TopK=20INLINECODE83DF81F09EMinP=0INLINECODE84BC71E7F6presencepenaltyINLINECODE854FBF09BEanswerINLINECODE86849894CA"answer": "C"`."
If you find our work helpful, feel free to give us a cite.
CODEBLOCK
5_4970BF3E