fastllm commited on
Commit
4771b13
·
verified ·
1 Parent(s): b88af02

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +16 -340
README.md CHANGED
@@ -1,350 +1,26 @@
1
- ---
2
- library_name: transformers
3
- license: apache-2.0
4
- license_link: https://huggingface.co/Qwen/Qwen3-Next-80B-A3B-Instruct/blob/main/LICENSE
5
- pipeline_tag: text-generation
6
- ---
7
 
8
- # Qwen3-Next-80B-A3B-Instruct
9
- <a href="https://chat.qwen.ai/" target="_blank" style="margin: 2px;">
10
- <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;"/>
11
- </a>
12
 
13
- Over the past few months, we have observed increasingly clear trends toward scaling both total parameters and context lengths in the pursuit of more powerful and agentic artificial intelligence (AI).
14
- We are excited to share our latest advancements in addressing these demands, centered on improving scaling efficiency through innovative model architecture.
15
- We call this next-generation foundation models **Qwen3-Next**.
16
 
17
- ## Highlights
18
-
19
- **Qwen3-Next-80B-A3B** is the first installment in the Qwen3-Next series and features the following key enchancements:
20
- - **Hybrid Attention**: Replaces standard attention with the combination of **Gated DeltaNet** and **Gated Attention**, enabling efficient context modeling for ultra-long context length.
21
- - **High-Sparsity Mixture-of-Experts (MoE)**: Achieves an extreme low activation ratio in MoE layers, drastically reducing FLOPs per token while preserving model capacity.
22
- - **Stability Optimizations**: Includes techniques such as **zero-centered and weight-decayed layernorm**, and other stabilizing enhancements for robust pre-training and post-training.
23
- - **Multi-Token Prediction (MTP)**: Boosts pretraining model performance and accelerates inference.
24
-
25
- We are seeing strong performance in terms of both parameter efficiency and inference speed for Qwen3-Next-80B-A3B:
26
- - Qwen3-Next-80B-A3B-Base outperforms Qwen3-32B-Base on downstream tasks with 10% of the total training cost and with 10 times inference throughput for context over 32K tokens.
27
- - Qwen3-Next-80B-A3B-Instruct performs on par with Qwen3-235B-A22B-Instruct-2507 on certain benchmarks, while demonstrating significant advantages in handling ultra-long-context tasks up to 256K tokens.
28
-
29
- ![Qwen3-Next-80B-A3B-Instruct Benchmark Comparison](https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3-Next/Qwen3-Next-80B-A3B-Instruct.001.jpeg)
30
-
31
- For more details, please refer to our blog post [Qwen3-Next](https://qwenlm.github.io/blog/qwen3_next/).
32
-
33
- ## Model Overview
34
-
35
- > [!Note]
36
- > **Qwen3-Next-80B-A3B-Instruct** supports only instruct (non-thinking) mode and does not generate ``<think></think>`` blocks in its output.
37
-
38
- **Qwen3-Next-80B-A3B-Instruct** has the following features:
39
- - Type: Causal Language Models
40
- - Training Stage: Pretraining (15T tokens) & Post-training
41
- - Number of Parameters: 80B in total and 3B activated
42
- - Number of Paramaters (Non-Embedding): 79B
43
- - Number of Layers: 48
44
- - Hidden Dimension: 2048
45
- - Hybrid Layout: 12 \* (3 \* (Gated DeltaNet -> MoE) -> (Gated Attention -> MoE))
46
- - Gated Attention:
47
- - Number of Attention Heads: 16 for Q and 2 for KV
48
- - Head Dimension: 256
49
- - Rotary Position Embedding Dimension: 64
50
- - Gated DeltaNet:
51
- - Number of Linear Attention Heads: 32 for V and 16 for QK
52
- - Head Dimension: 128
53
- - Mixture of Experts:
54
- - Number of Experts: 512
55
- - Number of Activated Experts: 10
56
- - Number of Shared Experts: 1
57
- - Expert Intermediate Dimension: 512
58
- - Context Length: 262,144 natively and extensible up to 1,010,000 tokens
59
-
60
- <img src="https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3-Next/model_architecture.png" height="384px" title="Qwen3-Next Model Architecture" />
61
-
62
-
63
- ## Performance
64
-
65
- | | Qwen3-30B-A3B-Instruct-2507 | Qwen3-32B Non-Thinking | Qwen3-235B-A22B-Instruct-2507 | Qwen3-Next-80B-A3B-Instruct |
66
- |--- | --- | --- | --- | --- |
67
- | **Knowledge** | | | | |
68
- | MMLU-Pro | 78.4 | 71.9 | **83.0** | 80.6 |
69
- | MMLU-Redux | 89.3 | 85.7 | **93.1** | 90.9 |
70
- | GPQA | 70.4 | 54.6 | **77.5** | 72.9 |
71
- | SuperGPQA | 53.4 | 43.2 | **62.6** | 58.8 |
72
- | **Reasoning** | | | | |
73
- | AIME25 | 61.3 | 20.2 | **70.3** | 69.5 |
74
- | HMMT25 | 43.0 | 9.8 | **55.4** | 54.1 |
75
- | LiveBench 20241125 | 69.0 | 59.8 | 75.4 | **75.8** |
76
- | **Coding** | | | | |
77
- | LiveCodeBench v6 (25.02-25.05) | 43.2 | 29.1 | 51.8 | **56.6** |
78
- | MultiPL-E | 83.8 | 76.9 | **87.9** | 87.8 |
79
- | Aider-Polyglot | 35.6 | 40.0 | **57.3** | 49.8 |
80
- | **Alignment** | | | | |
81
- | IFEval | 84.7 | 83.2 | **88.7** | 87.6 |
82
- | Arena-Hard v2* | 69.0 | 34.1 | 79.2 | **82.7** |
83
- | Creative Writing v3 | 86.0 | 78.3 | **87.5** | 85.3 |
84
- | WritingBench | 85.5 | 75.4 | 85.2 | **87.3** |
85
- | **Agent** | | | | |
86
- | BFCL-v3 | 65.1 | 63.0 | **70.9** | 70.3 |
87
- | TAU1-Retail | 59.1 | 40.1 | **71.3** | 60.9 |
88
- | TAU1-Airline | 40.0 | 17.0 | **44.0** | 44.0 |
89
- | TAU2-Retail | 57.0 | 48.8 | **74.6** | 57.3 |
90
- | TAU2-Airline | 38.0 | 24.0 | **50.0** | 45.5 |
91
- | TAU2-Telecom | 12.3 | 24.6 | **32.5** | 13.2 |
92
- | **Multilingualism** | | | | |
93
- | MultiIF | 67.9 | 70.7 | **77.5** | 75.8 |
94
- | MMLU-ProX | 72.0 | 69.3 | **79.4** | 76.7 |
95
- | INCLUDE | 71.9 | 70.9 | **79.5** | 78.9 |
96
- | PolyMATH | 43.1 | 22.5 | **50.2** | 45.9 |
97
-
98
- *: For reproducibility, we report the win rates evaluated by GPT-4.1.
99
-
100
- ## Quickstart
101
-
102
- The code for Qwen3-Next has been merged into the main branch of Hugging Face `transformers`.
103
-
104
- ```shell
105
- pip install git+https://github.com/huggingface/transformers.git@main
106
- ```
107
-
108
- With earlier versions, you will encounter the following error:
109
- ```
110
- KeyError: 'qwen3_next'
111
- ```
112
-
113
- The following contains a code snippet illustrating how to use the model generate content based on given inputs.
114
- ```python
115
- from transformers import AutoModelForCausalLM, AutoTokenizer
116
-
117
- model_name = "Qwen/Qwen3-Next-80B-A3B-Instruct"
118
-
119
- # load the tokenizer and the model
120
- tokenizer = AutoTokenizer.from_pretrained(model_name)
121
- model = AutoModelForCausalLM.from_pretrained(
122
- model_name,
123
- dtype="auto",
124
- device_map="auto",
125
- )
126
-
127
- # prepare the model input
128
- prompt = "Give me a short introduction to large language model."
129
- messages = [
130
- {"role": "user", "content": prompt},
131
- ]
132
- text = tokenizer.apply_chat_template(
133
- messages,
134
- tokenize=False,
135
- add_generation_prompt=True,
136
- )
137
- model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
138
-
139
- # conduct text completion
140
- generated_ids = model.generate(
141
- **model_inputs,
142
- max_new_tokens=16384,
143
- )
144
- output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
145
-
146
- content = tokenizer.decode(output_ids, skip_special_tokens=True)
147
-
148
- print("content:", content)
149
- ```
150
-
151
- > [!Note]
152
- > Multi-Token Prediction (MTP) is not generally available in Hugging Face Transformers.
153
-
154
- > [!Note]
155
- > The efficiency or throughput improvement depends highly on the implementation.
156
- > It is recommended to adopt a dedicated inference framework, e.g., SGLang and vLLM, for inference tasks.
157
-
158
- > [!Tip]
159
- > Depending on the inference settings, you may observe better efficiency with [`flash-linear-attention`](https://github.com/fla-org/flash-linear-attention#installation) and [`causal-conv1d`](https://github.com/Dao-AILab/causal-conv1d).
160
- > See the above links for detailed instructions and requirements.
161
-
162
-
163
- ## Deployment
164
-
165
- For deployment, you can use the latest `sglang` or `vllm` to create an OpenAI-compatible API endpoint.
166
-
167
- ### SGLang
168
-
169
- [SGLang](https://github.com/sgl-project/sglang) is a fast serving framework for large language models and vision language models.
170
- SGLang could be used to launch a server with OpenAI-compatible API service.
171
-
172
- SGLang has supported Qwen3-Next in its `main` branch, which can be installed from source:
173
- ```shell
174
- pip install 'sglang[all] @ git+https://github.com/sgl-project/sglang.git@main#subdirectory=python'
175
- ```
176
-
177
- The following command can be used to create an API endpoint at `http://localhost:30000/v1` with maximum context length 256K tokens using tensor parallel on 4 GPUs.
178
- ```shell
179
- SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1 python -m sglang.launch_server --model-path Qwen/Qwen3-Next-80B-A3B-Instruct --port 30000 --tp-size 4 --context-length 262144 --mem-fraction-static 0.8
180
- ```
181
-
182
- The following command is recommended for MTP with the rest settings the same as above:
183
- ```shell
184
- SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1 python -m sglang.launch_server --model-path Qwen/Qwen3-Next-80B-A3B-Instruct --port 30000 --tp-size 4 --context-length 262144 --mem-fraction-static 0.8 --speculative-algo NEXTN --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4
185
- ```
186
-
187
- > [!Note]
188
- > The environment variable `SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1` is required at the moment.
189
-
190
- > [!Note]
191
- > The default context length is 256K. Consider reducing the context length to a smaller value, e.g., `32768`, if the server fail to start.
192
-
193
- ### vLLM
194
-
195
- [vLLM](https://github.com/vllm-project/vllm) is a high-throughput and memory-efficient inference and serving engine for LLMs.
196
- vLLM could be used to launch a server with OpenAI-compatible API service.
197
-
198
- vLLM has supported Qwen3-Next in its `main` branch, which can be installed from source:
199
- ```shell
200
- pip install git+https://github.com/vllm-project/vllm.git
201
  ```
202
 
203
- The following command can be used to create an API endpoint at `http://localhost:8000/v1` with maximum context length 256K tokens using tensor parallel on 4 GPUs.
204
- ```shell
205
- VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 vllm serve Qwen/Qwen3-Next-80B-A3B-Instruct --port 8000 --tensor-parallel-size 4 --max-model-len 262144
206
- ```
207
 
208
- The following command is recommended for MTP with the rest settings the same as above:
209
- ```shell
210
- VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 vllm serve Qwen/Qwen3-Next-80B-A3B-Instruct --port 8000 --tensor-parallel-size 4 --max-model-len 262144 --speculative-config '{"method":"qwen3_next_mtp","num_speculative_tokens":2}'
211
  ```
212
 
213
- > [!Note]
214
- > The environment variable `VLLM_ALLOW_LONG_MAX_MODEL_LEN=1` is required at the moment.
215
-
216
- > [!Note]
217
- > The default context length is 256K. Consider reducing the context length to a smaller value, e.g., `32768`, if the server fail to start.
218
-
219
- ## Agentic Use
220
 
221
- 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.
222
-
223
- 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.
224
- ```python
225
- from qwen_agent.agents import Assistant
226
-
227
- # Define LLM
228
- llm_cfg = {
229
- 'model': 'Qwen3-Next-80B-A3B-Instruct',
230
-
231
- # Use a custom endpoint compatible with OpenAI API:
232
- 'model_server': 'http://localhost:8000/v1', # api_base
233
- 'api_key': 'EMPTY',
234
- }
235
-
236
- # Define Tools
237
- tools = [
238
- {'mcpServers': { # You can specify the MCP configuration file
239
- 'time': {
240
- 'command': 'uvx',
241
- 'args': ['mcp-server-time', '--local-timezone=Asia/Shanghai']
242
- },
243
- "fetch": {
244
- "command": "uvx",
245
- "args": ["mcp-server-fetch"]
246
- }
247
- }
248
- },
249
- 'code_interpreter', # Built-in tools
250
- ]
251
-
252
- # Define Agent
253
- bot = Assistant(llm=llm_cfg, function_list=tools)
254
-
255
- # Streaming generation
256
- messages = [{'role': 'user', 'content': 'https://qwenlm.github.io/blog/ Introduce the latest developments of Qwen'}]
257
- for responses in bot.run(messages=messages):
258
- pass
259
- print(responses)
260
  ```
261
-
262
-
263
- ## Processing Ultra-Long Texts
264
-
265
- Qwen3-Next natively supports context lengths of up to 262,144 tokens.
266
- 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.
267
- We have validated the model's performance on context lengths of up to 1 million tokens using the [YaRN](https://arxiv.org/abs/2309.00071) method.
268
-
269
- YaRN is currently supported by several inference frameworks, e.g., `transformers`, `vllm` and `sglang`.
270
- In general, there are two approaches to enabling YaRN for supported frameworks:
271
-
272
- - Modifying the model files:
273
- In the `config.json` file, add the `rope_scaling` fields:
274
- ```json
275
- {
276
- ...,
277
- "rope_scaling": {
278
- "rope_type": "yarn",
279
- "factor": 4.0,
280
- "original_max_position_embeddings": 262144
281
- }
282
- }
283
- ```
284
-
285
- - Passing command line arguments:
286
-
287
- For `vllm`, you can use
288
- ```shell
289
- VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 vllm serve ... --rope-scaling '{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":262144}' --max-model-len 1010000
290
- ```
291
-
292
- For `sglang`, you can use
293
- ```shell
294
- SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1 python -m sglang.launch_server ... --json-model-override-args '{"rope_scaling":{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":262144}}' --context-length 1010000
295
- ```
296
-
297
- > [!NOTE]
298
- > 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.**
299
- > We advise adding the `rope_scaling` configuration only when processing long contexts is required.
300
- > It is also recommended to modify the `factor` as needed. For example, if the typical context length for your application is 524,288 tokens, it would be better to set `factor` as 2.0.
301
-
302
- #### Long-Context Performance
303
-
304
- We test the model on an 1M version of the [RULER](https://arxiv.org/abs/2404.06654) benchmark.
305
-
306
- | Model Name | Acc avg | 4k | 8k | 16k | 32k | 64k | 96k | 128k | 192k | 256k | 384k | 512k | 640k | 768k | 896k | 1000k |
307
- |---------------------------------------------|---------|------|------|------|------|------|------|------|------|------|------|------|------|------|------|-------|
308
- | Qwen3-30B-A3B-Instruct-2507 | 86.8 | 98.0 | 96.7 | 96.9 | 97.2 | 93.4 | 91.0 | 89.1 | 89.8 | 82.5 | 83.6 | 78.4 | 79.7 | 77.6 | 75.7 | 72.8 |
309
- | Qwen3-235B-A22B-Instruct-2507 | 92.5 | 98.5 | 97.6 | 96.9 | 97.3 | 95.8 | 94.9 | 93.9 | 94.5 | 91.0 | 92.2 | 90.9 | 87.8 | 84.8 | 86.5 | 84.5 |
310
- | Qwen3-Next-80B-A3B-Instruct | 91.8 | 98.5 | 99.0 | 98.0 | 98.7 | 97.6 | 95.0 | 96.0 | 94.0 | 93.5 | 91.7 | 86.9 | 85.5 | 81.7 | 80.3 | 80.3 |
311
-
312
- * Qwen3-Next are evaluated with YaRN enabled. Qwen3-2507 models are evaluated with Dual Chunk Attention enabled.
313
- * Since the evaluation is time-consuming, we use 260 samples for each length (13 sub-tasks, 20 samples for each).
314
-
315
- ## Best Practices
316
-
317
- To achieve optimal performance, we recommend the following settings:
318
-
319
- 1. **Sampling Parameters**:
320
- - We suggest using `Temperature=0.7`, `TopP=0.8`, `TopK=20`, and `MinP=0`.
321
- - 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.
322
-
323
- 2. **Adequate Output Length**: We recommend using an output length of 16,384 tokens for most queries, which is adequate for instruct models.
324
-
325
- 3. **Standardize Output Format**: We recommend using prompts to standardize model outputs when benchmarking.
326
- - **Math Problems**: Include "Please reason step by step, and put your final answer within \boxed{}." in the prompt.
327
- - **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"`."
328
-
329
- ### Citation
330
-
331
- If you find our work helpful, feel free to give us a cite.
332
-
333
- ```
334
- @misc{qwen3technicalreport,
335
- title={Qwen3 Technical Report},
336
- author={Qwen Team},
337
- year={2025},
338
- eprint={2505.09388},
339
- archivePrefix={arXiv},
340
- primaryClass={cs.CL},
341
- url={https://arxiv.org/abs/2505.09388},
342
- }
343
-
344
- @article{qwen2.5-1m,
345
- title={Qwen2.5-1M Technical Report},
346
- author={An Yang and Bowen Yu and Chengyuan Li and Dayiheng Liu and Fei Huang and Haoyan Huang and Jiandong Jiang and Jianhong Tu and Jianwei Zhang and Jingren Zhou and Junyang Lin and Kai Dang and Kexin Yang and Le Yu and Mei Li and Minmin Sun and Qin Zhu and Rui Men and Tao He and Weijia Xu and Wenbiao Yin and Wenyuan Yu and Xiafei Qiu and Xingzhang Ren and Xinlong Yang and Yong Li and Zhiying Xu and Zipeng Zhang},
347
- journal={arXiv preprint arXiv:2501.15383},
348
- year={2025}
349
- }
350
- ```
 
1
+ ## project link:
2
+ https://github.com/ztxz16/fastllm
 
 
 
 
3
 
4
+ # Install
 
 
 
5
 
6
+ ## install in linux:
 
 
7
 
8
+ ``` sh
9
+ # (you should install cuda12 first)
10
+ pip install ftllm -U
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ```
12
 
13
+ ## install in windows
 
 
 
14
 
15
+ ``` sh
16
+ pip install https://www.modelscope.cn/models/huangyuyang/fastllmdepend-windows/resolve/master/ftllmdepend-0.0.0.1-py3-none-win_amd64.whl
17
+ pip install ftllm -U
18
  ```
19
 
20
+ # Launch
 
 
 
 
 
 
21
 
22
+ ``` sh
23
+ ftllm chat YOUR_MODEL_PATH # chat
24
+ ftllm webui YOUR_MODEL_PATH # webui
25
+ ftllm server YOUR_MODEL_PATH # server
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  ```