Views
No views yet

enable_thinking=True is no longer required.<think>. Therefore, it is normal for the model's output to contain only </think> without an explicit opening <think> tag.| Qwen3-30B-A3B Thinking | Qwen3-4B Thinking | Qwen3-4B-Thinking-2507 | |
|---|---|---|---|
| Knowledge | |||
| MMLU-Pro | 78.5 | 70.4 | 74.0 |
| MMLU-Redux | 89.5 | 83.7 | 86.1 |
| GPQA | 65.8 | 55.9 | 65.8 |
| SuperGPQA | 51.8 | 42.7 | 47.8 |
| Reasoning | |||
| AIME25 | 70.9 | 65.6 | 81.3 |
| HMMT25 | 49.8 | 42.1 | 55.5 |
| LiveBench 20241125 | 74.3 | 63.6 | 71.8 |
| Coding | |||
| LiveCodeBench v6 (25.02-25.05) | 57.4 | 48.4 | 55.2 |
| CFEval | 1940 | 1671 | 1852 |
| OJBench | 20.7 | 16.1 | 17.9 |
| Alignment | |||
| IFEval | 86.5 | 81.9 | 87.4 |
| Arena-Hard v2$ | 36.3 | 13.7 | 34.9 |
| Creative Writing v3 | 79.1 | 61.1 | 75.6 |
| WritingBench | 77.0 | 73.5 | 83.3 |
| Agent | |||
| BFCL-v3 | 69.1 | 65.9 | 71.2 |
| TAU1-Retail | 61.7 | 33.9 | 66.1 |
| TAU1-Airline | 32.0 | 32.0 | 48.0 |
| TAU2-Retail | 34.2 | 38.6 | 53.5 |
| TAU2-Airline | 36.0 | 28.0 | 58.0 |
| TAU2-Telecom | 22.8 | 17.5 | 27.2 |
| Multilingualism | |||
| MultiIF | 72.2 | 66.3 | 77.3 |
| MMLU-ProX | 73.1 | 61.0 | 64.2 |
| INCLUDE | 71.9 | 61.8 | 64.4 |
| PolyMATH | 46.1 | 40.0 | 46.2 |
transformers and we advise you to use the latest version of transformers.transformers<4.51.0, you will encounter the following error:KeyError: 'qwen3'1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "Qwen/Qwen3-4B-Thinking-2507"
4
5# load the tokenizer and the model
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype="auto",
10 device_map="auto"
11)
12
13# prepare the model input
14prompt = "Give me a short introduction to large language model."
15messages = [
16 {"role": "user", "content": prompt}
17]
18text = tokenizer.apply_chat_template(
19 messages,
20 tokenize=False,
21 add_generation_prompt=True,
22)
23model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
24
25# conduct text completion
26generated_ids = model.generate(
27 **model_inputs,
28 max_new_tokens=32768
29)
30output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
31
32# parsing thinking content
33try:
34 # rindex finding 151668 (</think>)
35 index = len(output_ids) - output_ids[::-1].index(151668)
36except ValueError:
37 index = 0
38
39thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
40content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
41
42print("thinking content:", thinking_content) # no opening <think> tag
43print("content:", content)
44sglang>=0.4.6.post1 or vllm>=0.8.5 or to create an OpenAI-compatible API endpoint:python -m sglang.launch_server --model-path Qwen/Qwen3-4B-Thinking-2507 --context-length 262144 --reasoning-parser deepseek-r1vllm serve Qwen/Qwen3-4B-Thinking-2507 --max-model-len 262144 --enable-reasoning --reasoning-parser deepseek_r11from qwen_agent.agents import Assistant
2
3# Define LLM
4# Using OpenAI-compatible API endpoint. It is recommended to disable the reasoning and the tool call parsing
5# functionality of the deployment frameworks and let Qwen-Agent automate the related operations. For example,
6# `VLLM_USE_MODELSCOPE=true vllm serve Qwen/Qwen3-4B-Thinking-2507 --served-model-name Qwen3-4B-Thinking-2507 --max-model-len 262144`.
7llm_cfg = {
8 'model': 'Qwen3-4B-Thinking-2507',
9
10 # Use a custom endpoint compatible with OpenAI API:
11 'model_server': 'http://localhost:8000/v1', # api_base without reasoning and tool call parsing
12 'api_key': 'EMPTY',
13 'generate_cfg': {
14 'thought_in_content': True,
15 },
16}
17
18# Define Tools
19tools = [
20 {'mcpServers': { # You can specify the MCP configuration file
21 'time': {
22 'command': 'uvx',
23 'args': ['mcp-server-time', '--local-timezone=Asia/Shanghai']
24 },
25 "fetch": {
26 "command": "uvx",
27 "args": ["mcp-server-fetch"]
28 }
29 }
30 },
31 'code_interpreter', # Built-in tools
32]
33
34# Define Agent
35bot = Assistant(llm=llm_cfg, function_list=tools)
36
37# Streaming generation
38messages = [{'role': 'user', 'content': 'https://qwenlm.github.io/blog/ Introduce the latest developments of Qwen'}]
39for responses in bot.run(messages=messages):
40 pass
41print(responses)Temperature=0.6, TopP=0.95, TopK=20, and MinP=0.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.answer field with only the choice letter, e.g., "answer": "C"."@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},
}