mateo123123 commited on
Commit
f435e56
·
verified ·
1 Parent(s): dacf9cb

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +255 -0
README.md CHANGED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ license_link: https://huggingface.co/Qwen/Qwen3-235B-A22B-Thinking-2507-FP8/blob/main/LICENSE
5
+ pipeline_tag: text-generation
6
+ base_model:
7
+ - Qwen/Qwen3-235B-A22B-Thinking-2507
8
+ ---
9
+
10
+ # Qwen3-235B-A22B-Thinking-2507-FP8
11
+ <a href="https://chat.qwen.ai/" target="_blank" style="margin: 2px;">
12
+ <img 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;"/>
13
+ </a>
14
+
15
+ ## Highlights
16
+
17
+ Over the past three months, we have continued to scale the **thinking capability** of Qwen3-235B-A22B, improving both the **quality and depth** of reasoning. We are pleased to introduce **Qwen3-235B-A22B-Thinking-2507-FP8**, featuring the following key enhancements:
18
+ - **Significantly improved performance** on reasoning tasks, including logical reasoning, mathematics, science, coding, and academic benchmarks that typically require human expertise — achieving **state-of-the-art results among open-source thinking models**.
19
+ - **Markedly better general capabilities**, such as instruction following, tool usage, text generation, and alignment with human preferences.
20
+ - **Enhanced 256K long-context understanding** capabilities.
21
+
22
+ **NOTE**: This version has an increased thinking length. We strongly recommend its use in highly complex reasoning tasks.
23
+
24
+ ![image/jpeg](https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen3-2507/Qwen3-235B-A22B-Thinking-2507.jpeg)
25
+
26
+ ## Model Overview
27
+
28
+ This repo contains the FP8 version of **Qwen3-235B-A22B-Thinking-2507**, which has the following features:
29
+ - Type: Causal Language Models
30
+ - Training Stage: Pretraining & Post-training
31
+ - Number of Parameters: 235B in total and 22B activated
32
+ - Number of Paramaters (Non-Embedding): 234B
33
+ - Number of Layers: 94
34
+ - Number of Attention Heads (GQA): 64 for Q and 4 for KV
35
+ - Number of Experts: 128
36
+ - Number of Activated Experts: 8
37
+ - Context Length: **262,144 natively**.
38
+
39
+ **NOTE: This model supports only thinking mode. Meanwhile, specifying `enable_thinking=True` is no longer required.**
40
+
41
+ Additionally, to enforce model thinking, the default chat template automatically includes `<think>`. Therefore, it is normal for the model's output to contain only `</think>` without an explicit opening `<think>` tag.
42
+
43
+ For 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/).
44
+
45
+ ## Performance
46
+
47
+
48
+ | | Deepseek-R1-0528 | OpenAI O4-mini | OpenAI O3 | Gemini-2.5 Pro | Claude4 Opus Thinking | Qwen3-235B-A22B Thinking | Qwen3-235B-A22B-Thinking-2507 |
49
+ |--- | --- | --- | --- | --- | --- | --- | --- |
50
+ | **Knowledge** | | | | | | | |
51
+ | MMLU-Pro | 85.0 | 81.9 | **85.9** | 85.6 | - | 82.8 | 84.4 |
52
+ | MMLU-Redux | 93.4 | 92.8 | **94.9** | 94.4 | 94.6 | 92.7 | 93.8 |
53
+ | GPQA | 81.0 | 81.4* | 83.3* | **86.4** | 79.6 | 71.1 | 81.1 |
54
+ | SuperGPQA | 61.7 | 56.4 | - | 62.3 | - | 60.7 | **64.9** |
55
+ | **Reasoning** | | | | | | |
56
+ | AIME25 | 87.5 | **92.7*** | 88.9* | 88.0 | 75.5 | 81.5 | 92.3 |
57
+ | HMMT25 | 79.4 | 66.7 | 77.5 | 82.5 | 58.3 | 62.5 | **83.9** |
58
+ | LiveBench 20241125 | 74.7 | 75.8 | 78.3 | **82.4** | 78.2 | 77.1 | 78.4 |
59
+ | HLE | 17.7# | 18.1* | 20.3 | **21.6** | 10.7 | 11.8# | 18.2# |
60
+ | **Coding** | | | | | | | |
61
+ | LiveCodeBench v6 (25.02-25.05) | 68.7 | 71.8 | 58.6 | 72.5 | 48.9 | 55.7 | **74.1** |
62
+ | CFEval | 2099 | 1929 | 2043 | 2001 | - | 2056 | **2134** |
63
+ | OJBench | 33.6 | 33.3 | 25.4 | **38.9** | - | 25.6 | 32.5 |
64
+ | **Alignment** | | | | | | | |
65
+ | IFEval | 79.1 | **92.4** | 92.1 | 90.8 | 89.7 | 83.4 | 87.8 |
66
+ | Arena-Hard v2$ | 72.2 | 59.3 | **80.8** | 72.5 | 59.1 | 61.5 | 79.7 |
67
+ | Creative Writing v3 | 86.3 | 78.8 | **87.7** | 85.9 | 83.8 | 84.6 | 86.1 |
68
+ | WritingBench | 83.2 | 78.4 | 85.3 | 83.1 | 79.1 | 80.3 | **88.3** |
69
+ | **Agent** | | | | | | | |
70
+ | BFCL-v3 | 63.8 | 67.2 | **72.4** | 67.2 | 61.8 | 70.8 | 71.9 |
71
+ | TAU1-Retail | 63.9 | 71.8 | 73.9 | **74.8** | - | 54.8 | 67.8 |
72
+ | TAU1-Airline | **53.5** | 49.2 | 52.0 | 52.0 | - | 26.0 | 46.0 |
73
+ | TAU2-Retail | 64.9 | 71.0 | **76.3** | 71.3 | - | 40.4 | 71.9 |
74
+ | TAU2-Airline | 60.0 | 59.0 | **70.0** | 60.0 | - | 30.0 | 58.0 |
75
+ | TAU2-Telecom | 33.3 | 42.0 | **60.5** | 37.4 | - | 21.9 | 45.6 |
76
+ | **Multilingualism** | | | | | | | |
77
+ | MultiIF | 63.5 | 78.0 | 80.3 | 77.8 | - | 71.9 | **80.6** |
78
+ | MMLU-ProX | 80.6 | 79.0 | 83.3 | **84.7** | - | 80.0 | 81.0 |
79
+ | INCLUDE | 79.4 | 80.8 | **86.6** | 85.1 | - | 78.7 | 81.0 |
80
+ | PolyMATH | 46.9 | 48.7 | 49.7 | 52.2 | - | 54.7 | **60.1** |
81
+
82
+ \* For OpenAI O4-mini and O3, we use a medium reasoning effort, except for scores marked with *, which are generated using high reasoning effort.
83
+
84
+ \# According to the official evaluation criteria of HLE, scores marked with \# refer to models that are not multi-modal and were evaluated only on the text-only subset.
85
+
86
+ $ For reproducibility, we report the win rates evaluated by GPT-4.1.
87
+
88
+ \& For highly challenging tasks (including PolyMATH and all reasoning and coding tasks), we use an output length of 81,920 tokens. For all other tasks, we set the output length to 32,768.
89
+
90
+
91
+ ## Quickstart
92
+
93
+ The code of Qwen3-MoE has been in the latest Hugging Face `transformers` and we advise you to use the latest version of `transformers`.
94
+
95
+ With `transformers<4.51.0`, you will encounter the following error:
96
+ ```
97
+ KeyError: 'qwen3_moe'
98
+ ```
99
+
100
+ The following contains a code snippet illustrating how to use the model generate content based on given inputs.
101
+ ```python
102
+ from transformers import AutoModelForCausalLM, AutoTokenizer
103
+
104
+ model_name = "Qwen/Qwen3-235B-A22B-Thinking-2507-FP8"
105
+
106
+ # load the tokenizer and the model
107
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
108
+ model = AutoModelForCausalLM.from_pretrained(
109
+ model_name,
110
+ torch_dtype="auto",
111
+ device_map="auto"
112
+ )
113
+
114
+ # prepare the model input
115
+ prompt = "Give me a short introduction to large language model."
116
+ messages = [
117
+ {"role": "user", "content": prompt}
118
+ ]
119
+ text = tokenizer.apply_chat_template(
120
+ messages,
121
+ tokenize=False,
122
+ add_generation_prompt=True,
123
+ )
124
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
125
+
126
+ # conduct text completion
127
+ generated_ids = model.generate(
128
+ **model_inputs,
129
+ max_new_tokens=32768
130
+ )
131
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
132
+
133
+ # parsing thinking content
134
+ try:
135
+ # rindex finding 151668 (</think>)
136
+ index = len(output_ids) - output_ids[::-1].index(151668)
137
+ except ValueError:
138
+ index = 0
139
+
140
+ thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
141
+ content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
142
+
143
+ print("thinking content:", thinking_content) # no opening <think> tag
144
+ print("content:", content)
145
+
146
+ ```
147
+
148
+ For deployment, you can use `sglang>=0.4.6.post1` or `vllm>=0.8.5` or to create an OpenAI-compatible API endpoint:
149
+ - SGLang:
150
+ ```shell
151
+ python -m sglang.launch_server --model-path Qwen/Qwen3-235B-A22B-Thinking-2507-FP8 --tp 4 --context-length 262144 --reasoning-parser deepseek-r1
152
+ ```
153
+ - vLLM:
154
+ ```shell
155
+ vllm serve Qwen/Qwen3-235B-A22B-Thinking-2507-FP8 --tensor-parallel-size 4 --max-model-len 262144 --enable-reasoning --reasoning-parser deepseek_r1
156
+ ```
157
+
158
+ **Note: If you encounter out-of-memory (OOM) issues, you may consider reducing the context length to a smaller value. However, since the model may require longer token sequences for reasoning, we strongly recommend using a context length greater than 131,072 when possible.**
159
+
160
+ For local use, applications such as Ollama, LMStudio, MLX-LM, llama.cpp, and KTransformers have also supported Qwen3.
161
+
162
+ ## Note on FP8
163
+
164
+ For convenience and performance, we have provided `fp8`-quantized model checkpoint for Qwen3, whose name ends with `-FP8`. The quantization method is fine-grained `fp8` quantization with block size of 128. You can find more details in the `quantization_config` field in `config.json`.
165
+
166
+ You can use the Qwen3-235B-A22B-Thinking-2507-FP8 model with serveral inference frameworks, including `transformers`, `sglang`, and `vllm`, as the original bfloat16 model.
167
+
168
+ ## Agentic Use
169
+
170
+ Qwen3 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.
171
+
172
+ 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.
173
+ ```python
174
+ from qwen_agent.agents import Assistant
175
+
176
+ # Define LLM
177
+ # Using Alibaba Cloud Model Studio
178
+ llm_cfg = {
179
+ 'model': 'qwen3-235b-a22b-thinking-2507',
180
+ 'model_type': 'qwen_dashscope',
181
+ }
182
+
183
+ # Using OpenAI-compatible API endpoint. It is recommended to disable the reasoning and the tool call parsing
184
+ # functionality of the deployment frameworks and let Qwen-Agent automate the related operations. For example,
185
+ # `VLLM_USE_MODELSCOPE=true vllm serve Qwen/Qwen3-235B-A22B-Thinking-2507-FP8 --served-model-name Qwen3-235B-A22B-Thinking-2507 --tensor-parallel-size 4 --max-model-len 262144`.
186
+ #
187
+ # llm_cfg = {
188
+ # 'model': 'Qwen3-235B-A22B-Thinking-2507',
189
+ #
190
+ # # Use a custom endpoint compatible with OpenAI API:
191
+ # 'model_server': 'http://localhost:8000/v1', # api_base without reasoning and tool call parsing
192
+ # 'api_key': 'EMPTY',
193
+ # 'generate_cfg': {
194
+ # 'thought_in_content': True,
195
+ # },
196
+ # }
197
+
198
+ # Define Tools
199
+ tools = [
200
+ {'mcpServers': { # You can specify the MCP configuration file
201
+ 'time': {
202
+ 'command': 'uvx',
203
+ 'args': ['mcp-server-time', '--local-timezone=Asia/Shanghai']
204
+ },
205
+ "fetch": {
206
+ "command": "uvx",
207
+ "args": ["mcp-server-fetch"]
208
+ }
209
+ }
210
+ },
211
+ 'code_interpreter', # Built-in tools
212
+ ]
213
+
214
+ # Define Agent
215
+ bot = Assistant(llm=llm_cfg, function_list=tools)
216
+
217
+ # Streaming generation
218
+ messages = [{'role': 'user', 'content': 'https://qwenlm.github.io/blog/ Introduce the latest developments of Qwen'}]
219
+ for responses in bot.run(messages=messages):
220
+ pass
221
+ print(responses)
222
+ ```
223
+
224
+ ## Best Practices
225
+
226
+ To achieve optimal performance, we recommend the following settings:
227
+
228
+ 1. **Sampling Parameters**:
229
+ - We suggest using `Temperature=0.6`, `TopP=0.95`, `TopK=20`, and `MinP=0`.
230
+ - 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.
231
+
232
+ 2. **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 81,920 tokens. This provides the model with sufficient space to generate detailed and comprehensive responses, thereby enhancing its overall performance.
233
+
234
+ 3. **Standardize Output Format**: We recommend using prompts to standardize model outputs when benchmarking.
235
+ - **Math Problems**: Include "Please reason step by step, and put your final answer within \boxed{}." in the prompt.
236
+ - **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"`."
237
+
238
+ 4. **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.
239
+
240
+
241
+ ### Citation
242
+
243
+ If you find our work helpful, feel free to give us a cite.
244
+
245
+ ```
246
+ @misc{qwen3technicalreport,
247
+ title={Qwen3 Technical Report},
248
+ author={Qwen Team},
249
+ year={2025},
250
+ eprint={2505.09388},
251
+ archivePrefix={arXiv},
252
+ primaryClass={cs.CL},
253
+ url={https://arxiv.org/abs/2505.09388},
254
+ }
255
+ ```