Update README.md
Browse files
README.md
CHANGED
@@ -1,355 +1,200 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
pipeline_tag: text-generation
|
6 |
-
base_model:
|
7 |
-
- Qwen/Qwen3-30B-A3B-Base
|
8 |
---
|
9 |
|
10 |
-
#
|
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 |
-
## Qwen3 Highlights
|
16 |
-
|
17 |
-
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:
|
18 |
-
|
19 |
-
- **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.
|
20 |
-
- **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.
|
21 |
-
- **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.
|
22 |
-
- **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.
|
23 |
-
- **Support of 100+ languages and dialects** with strong capabilities for **multilingual instruction following** and **translation**.
|
24 |
-
|
25 |
-
## Model Overview
|
26 |
-
|
27 |
-
**Qwen3-30B-A3B** has the following features:
|
28 |
-
- Type: Causal Language Models
|
29 |
-
- Training Stage: Pretraining & Post-training
|
30 |
-
- Number of Parameters: 30.5B in total and 3.3B activated
|
31 |
-
- Number of Paramaters (Non-Embedding): 29.9B
|
32 |
-
- Number of Layers: 48
|
33 |
-
- Number of Attention Heads (GQA): 32 for Q and 4 for KV
|
34 |
-
- Number of Experts: 128
|
35 |
-
- Number of Activated Experts: 8
|
36 |
-
- Context Length: 32,768 natively and [131,072 tokens with YaRN](#processing-long-texts).
|
37 |
-
|
38 |
-
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/).
|
39 |
-
|
40 |
-
## Quickstart
|
41 |
-
|
42 |
-
The code of Qwen3-MoE has been in the latest Hugging Face `transformers` and we advise you to use the latest version of `transformers`.
|
43 |
-
|
44 |
-
With `transformers<4.51.0`, you will encounter the following error:
|
45 |
-
```
|
46 |
-
KeyError: 'qwen3_moe'
|
47 |
-
```
|
48 |
-
|
49 |
-
The following contains a code snippet illustrating how to use the model generate content based on given inputs.
|
50 |
-
```python
|
51 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
52 |
-
|
53 |
-
model_name = "Qwen/Qwen3-30B-A3B"
|
54 |
-
|
55 |
-
# load the tokenizer and the model
|
56 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
57 |
-
model = AutoModelForCausalLM.from_pretrained(
|
58 |
-
model_name,
|
59 |
-
torch_dtype="auto",
|
60 |
-
device_map="auto"
|
61 |
-
)
|
62 |
|
63 |
-
|
64 |
-
prompt = "Give me a short introduction to large language model."
|
65 |
-
messages = [
|
66 |
-
{"role": "user", "content": prompt}
|
67 |
-
]
|
68 |
-
text = tokenizer.apply_chat_template(
|
69 |
-
messages,
|
70 |
-
tokenize=False,
|
71 |
-
add_generation_prompt=True,
|
72 |
-
enable_thinking=True # Switches between thinking and non-thinking modes. Default is True.
|
73 |
-
)
|
74 |
-
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
75 |
|
76 |
-
|
77 |
-
generated_ids = model.generate(
|
78 |
-
**model_inputs,
|
79 |
-
max_new_tokens=32768
|
80 |
-
)
|
81 |
-
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
|
82 |
-
|
83 |
-
# parsing thinking content
|
84 |
-
try:
|
85 |
-
# rindex finding 151668 (</think>)
|
86 |
-
index = len(output_ids) - output_ids[::-1].index(151668)
|
87 |
-
except ValueError:
|
88 |
-
index = 0
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
#
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
{
|
279 |
-
...,
|
280 |
-
"rope_scaling": {
|
281 |
-
"rope_type": "yarn",
|
282 |
-
"factor": 4.0,
|
283 |
-
"original_max_position_embeddings": 32768
|
284 |
-
}
|
285 |
-
}
|
286 |
-
```
|
287 |
-
For `llama.cpp`, you need to regenerate the GGUF file after the modification.
|
288 |
-
|
289 |
-
- Passing command line arguments:
|
290 |
-
|
291 |
-
For `vllm`, you can use
|
292 |
-
```shell
|
293 |
-
vllm serve ... --rope-scaling '{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":32768}' --max-model-len 131072
|
294 |
-
```
|
295 |
-
|
296 |
-
For `sglang`, you can use
|
297 |
-
```shell
|
298 |
-
python -m sglang.launch_server ... --json-model-override-args '{"rope_scaling":{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":32768}}'
|
299 |
-
```
|
300 |
-
|
301 |
-
For `llama-server` from `llama.cpp`, you can use
|
302 |
-
```shell
|
303 |
-
llama-server ... --rope-scaling yarn --rope-scale 4 --yarn-orig-ctx 32768
|
304 |
-
```
|
305 |
-
|
306 |
-
> [!IMPORTANT]
|
307 |
-
> If you encounter the following warning
|
308 |
-
> ```
|
309 |
-
> Unrecognized keys in `rope_scaling` for 'rope_type'='yarn': {'original_max_position_embeddings'}
|
310 |
-
> ```
|
311 |
-
> please upgrade `transformers>=4.51.0`.
|
312 |
-
|
313 |
-
> [!NOTE]
|
314 |
-
> 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.**
|
315 |
-
> We advise adding the `rope_scaling` configuration only when processing long contexts is required.
|
316 |
-
> 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.
|
317 |
-
|
318 |
-
> [!NOTE]
|
319 |
-
> 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.
|
320 |
-
|
321 |
-
> [!TIP]
|
322 |
-
> The endpoint provided by Alibaba Model Studio supports dynamic YaRN by default and no extra configuration is needed.
|
323 |
-
|
324 |
-
## Best Practices
|
325 |
-
|
326 |
-
To achieve optimal performance, we recommend the following settings:
|
327 |
-
|
328 |
-
1. **Sampling Parameters**:
|
329 |
-
- 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.
|
330 |
-
- For non-thinking mode (`enable_thinking=False`), we suggest using `Temperature=0.7`, `TopP=0.8`, `TopK=20`, and `MinP=0`.
|
331 |
-
- 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.
|
332 |
-
|
333 |
-
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 38,912 tokens. This provides the model with sufficient space to generate detailed and comprehensive responses, thereby enhancing its overall performance.
|
334 |
-
|
335 |
-
3. **Standardize Output Format**: We recommend using prompts to standardize model outputs when benchmarking.
|
336 |
-
- **Math Problems**: Include "Please reason step by step, and put your final answer within \boxed{}." in the prompt.
|
337 |
-
- **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"`."
|
338 |
-
|
339 |
-
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.
|
340 |
-
|
341 |
-
### Citation
|
342 |
-
|
343 |
-
If you find our work helpful, feel free to give us a cite.
|
344 |
-
|
345 |
-
```
|
346 |
-
@misc{qwen3technicalreport,
|
347 |
-
title={Qwen3 Technical Report},
|
348 |
-
author={Qwen Team},
|
349 |
-
year={2025},
|
350 |
-
eprint={2505.09388},
|
351 |
-
archivePrefix={arXiv},
|
352 |
-
primaryClass={cs.CL},
|
353 |
-
url={https://arxiv.org/abs/2505.09388},
|
354 |
-
}
|
355 |
-
```
|
|
|
1 |
---
|
2 |
+
# For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1
|
3 |
+
# Doc / guide: https://huggingface.co/docs/hub/model-cards
|
4 |
+
{}
|
|
|
|
|
|
|
5 |
---
|
6 |
|
7 |
+
# Model Card for Model ID
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
## Model Details
|
14 |
+
|
15 |
+
### Model Description
|
16 |
+
|
17 |
+
<!-- Provide a longer summary of what this model is. -->
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
- **Developed by:** [More Information Needed]
|
22 |
+
- **Funded by [optional]:** [More Information Needed]
|
23 |
+
- **Shared by [optional]:** [More Information Needed]
|
24 |
+
- **Model type:** [More Information Needed]
|
25 |
+
- **Language(s) (NLP):** [More Information Needed]
|
26 |
+
- **License:** [More Information Needed]
|
27 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
28 |
+
|
29 |
+
### Model Sources [optional]
|
30 |
+
|
31 |
+
<!-- Provide the basic links for the model. -->
|
32 |
+
|
33 |
+
- **Repository:** [More Information Needed]
|
34 |
+
- **Paper [optional]:** [More Information Needed]
|
35 |
+
- **Demo [optional]:** [More Information Needed]
|
36 |
+
|
37 |
+
## Uses
|
38 |
+
|
39 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
40 |
+
|
41 |
+
### Direct Use
|
42 |
+
|
43 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
44 |
+
|
45 |
+
[More Information Needed]
|
46 |
+
|
47 |
+
### Downstream Use [optional]
|
48 |
+
|
49 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
50 |
+
|
51 |
+
[More Information Needed]
|
52 |
+
|
53 |
+
### Out-of-Scope Use
|
54 |
+
|
55 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
56 |
+
|
57 |
+
[More Information Needed]
|
58 |
+
|
59 |
+
## Bias, Risks, and Limitations
|
60 |
+
|
61 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
62 |
+
|
63 |
+
[More Information Needed]
|
64 |
+
|
65 |
+
### Recommendations
|
66 |
+
|
67 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
68 |
+
|
69 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
70 |
+
|
71 |
+
## How to Get Started with the Model
|
72 |
+
|
73 |
+
Use the code below to get started with the model.
|
74 |
+
|
75 |
+
[More Information Needed]
|
76 |
+
|
77 |
+
## Training Details
|
78 |
+
|
79 |
+
### Training Data
|
80 |
+
|
81 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
82 |
+
|
83 |
+
[More Information Needed]
|
84 |
+
|
85 |
+
### Training Procedure
|
86 |
+
|
87 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
88 |
+
|
89 |
+
#### Preprocessing [optional]
|
90 |
+
|
91 |
+
[More Information Needed]
|
92 |
+
|
93 |
+
|
94 |
+
#### Training Hyperparameters
|
95 |
+
|
96 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
97 |
+
|
98 |
+
#### Speeds, Sizes, Times [optional]
|
99 |
+
|
100 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
101 |
+
|
102 |
+
[More Information Needed]
|
103 |
+
|
104 |
+
## Evaluation
|
105 |
+
|
106 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
107 |
+
|
108 |
+
### Testing Data, Factors & Metrics
|
109 |
+
|
110 |
+
#### Testing Data
|
111 |
+
|
112 |
+
<!-- This should link to a Dataset Card if possible. -->
|
113 |
+
|
114 |
+
[More Information Needed]
|
115 |
+
|
116 |
+
#### Factors
|
117 |
+
|
118 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
119 |
+
|
120 |
+
[More Information Needed]
|
121 |
+
|
122 |
+
#### Metrics
|
123 |
+
|
124 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
125 |
+
|
126 |
+
[More Information Needed]
|
127 |
+
|
128 |
+
### Results
|
129 |
+
|
130 |
+
[More Information Needed]
|
131 |
+
|
132 |
+
#### Summary
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
## Model Examination [optional]
|
137 |
+
|
138 |
+
<!-- Relevant interpretability work for the model goes here -->
|
139 |
+
|
140 |
+
[More Information Needed]
|
141 |
+
|
142 |
+
## Environmental Impact
|
143 |
+
|
144 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
145 |
+
|
146 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
147 |
+
|
148 |
+
- **Hardware Type:** [More Information Needed]
|
149 |
+
- **Hours used:** [More Information Needed]
|
150 |
+
- **Cloud Provider:** [More Information Needed]
|
151 |
+
- **Compute Region:** [More Information Needed]
|
152 |
+
- **Carbon Emitted:** [More Information Needed]
|
153 |
+
|
154 |
+
## Technical Specifications [optional]
|
155 |
+
|
156 |
+
### Model Architecture and Objective
|
157 |
+
|
158 |
+
[More Information Needed]
|
159 |
+
|
160 |
+
### Compute Infrastructure
|
161 |
+
|
162 |
+
[More Information Needed]
|
163 |
+
|
164 |
+
#### Hardware
|
165 |
+
|
166 |
+
[More Information Needed]
|
167 |
+
|
168 |
+
#### Software
|
169 |
+
|
170 |
+
[More Information Needed]
|
171 |
+
|
172 |
+
## Citation [optional]
|
173 |
+
|
174 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
175 |
+
|
176 |
+
**BibTeX:**
|
177 |
+
|
178 |
+
[More Information Needed]
|
179 |
+
|
180 |
+
**APA:**
|
181 |
+
|
182 |
+
[More Information Needed]
|
183 |
+
|
184 |
+
## Glossary [optional]
|
185 |
+
|
186 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
187 |
+
|
188 |
+
[More Information Needed]
|
189 |
+
|
190 |
+
## More Information [optional]
|
191 |
+
|
192 |
+
[More Information Needed]
|
193 |
+
|
194 |
+
## Model Card Authors [optional]
|
195 |
+
|
196 |
+
[More Information Needed]
|
197 |
+
|
198 |
+
## Model Card Contact
|
199 |
+
|
200 |
+
[More Information Needed]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|