littlebird13 commited on
Commit
c6b1886
·
verified ·
1 Parent(s): 64ac916

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +188 -0
README.md ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ license_link: https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct/blob/main/LICENSE
5
+ pipeline_tag: text-generation
6
+ ---
7
+
8
+ # Qwen3-Coder-480B-A35B-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
+ ## Highlights
14
+
15
+ Today, we're announcing **Qwen3-Coder**, our most agentic code model to date. **Qwen3-Coder** is available in multiple sizes, but we're excited to introduce its most powerful variant first: **Qwen3-Coder-480B-A35B-Instruct**. featuring the following key enhancements:
16
+
17
+ - **Significant Performance** among open models on **Agentic Coding**, **Agentic Browser-Use**, and other foundational coding tasks, achieving results comparable to Claude Sonnet 4.
18
+ - **Long-context Capabilities** with native support for **256K** tokens, extendable up to **1M** tokens using Yarn, optimized for repository-scale understanding.
19
+ - **Agentic Coding** supporting for most platfrom such as **Qwen Code**, **CLINE**, featuring a specially designed function call format.
20
+
21
+ ![image/jpeg](https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen3-Coder/qwen3-coder-main.jpg)
22
+
23
+ ## Model Overview
24
+
25
+ **Qwen3-480B-A35B-Instruct** has the following features:
26
+ - Type: Causal Language Models
27
+ - Training Stage: Pretraining & Post-training
28
+ - Number of Parameters: 480B in total and 35B activated
29
+ - Number of Layers: 62
30
+ - Number of Attention Heads (GQA): 96 for Q and 8 for KV
31
+ - Number of Experts: 160
32
+ - Number of Activated Experts: 8
33
+ - Context Length: **262,144 natively**.
34
+
35
+ **NOTE: This model supports only non-thinking mode and does not generate ``<think></think>`` blocks in its output. Meanwhile, specifying `enable_thinking=False` is no longer required.**
36
+
37
+ For more details, including benchmark evaluation, hardware requirements, and inference performance, please refer to our [blog](https://qwenlm.github.io/blog/qwen3-coder/), [GitHub](https://github.com/QwenLM/Qwen3-Coder), and [Documentation](https://qwen.readthedocs.io/en/latest/).
38
+
39
+
40
+ ## Quickstart
41
+
42
+ 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-480B-A35B-Instruct"
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
+ # prepare the model input
64
+ prompt = "Write a quick sort algorithm."
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
+ )
73
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
74
+
75
+ # conduct text completion
76
+ generated_ids = model.generate(
77
+ **model_inputs,
78
+ max_new_tokens=65536
79
+ )
80
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
81
+
82
+ content = tokenizer.decode(output_ids, skip_special_tokens=True)
83
+
84
+ print("content:", content)
85
+ ```
86
+
87
+ For deployment, you can use `sglang>=0.4.6.post1` or `vllm>=0.8.5` or to create an OpenAI-compatible API endpoint:
88
+ - SGLang:
89
+ ```shell
90
+ python -m sglang.launch_server --model-path Qwen/Qwen3-480B-A35B-Instruct-FP8 --tp8 --enable-ep-moe --context-length 262144
91
+ ```
92
+ - vLLM:
93
+ ```shell
94
+ vllm serve Qwen/Qwen3-480B-A35B-Instruct-FP8 --tensor-parallel-size 8 --enenable-expert-parallel --max-model-len 262144
95
+ ```
96
+
97
+ **Note: If you encounter out-of-memory (OOM) issues, consider reducing the context length to a shorter value, such as `32,768`.**
98
+
99
+
100
+
101
+ For local use, applications such as Ollama, LMStudio, MLX-LM, llama.cpp, and KTransformers have also supported Qwen3.
102
+
103
+ ## Note on FP8
104
+
105
+ 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`.
106
+
107
+ You can use the Qwen3-480B-A35B-Instruct-FP8 model with serveral inference frameworks, including `transformers`, `sglang`, and `vllm`, as the original bfloat16 model.
108
+ However, please pay attention to the following known issues:
109
+ - `transformers`:
110
+ - there are currently issues with the "fine-grained fp8" method in `transformers` for distributed inference. You may need to set the environment variable `CUDA_LAUNCH_BLOCKING=1` if multiple devices are used in inference.
111
+
112
+
113
+ ## Agentic Coding
114
+
115
+ Qwen3-Coder excels in tool calling capabilities.
116
+
117
+ You can simply define or use any tools as following example.
118
+ ```python
119
+ # Your tool implementation
120
+ def square_the_number(num: float) -> dict:
121
+ return num ** 2
122
+
123
+ # Define Tools
124
+ tools=[
125
+ {
126
+ "type":"function",
127
+ "function":{
128
+ "name": "square_the_number",
129
+ "description": "output the square of the number.",
130
+ "parameters": {
131
+ "type": "object",
132
+ "required": ["input_num"],
133
+ "properties": {
134
+ 'input_num': {
135
+ 'type': 'number',
136
+ 'description': 'input_num is a number that will be squared'
137
+ }
138
+ },
139
+ }
140
+ }
141
+ }
142
+ ]
143
+
144
+ import OpenAI
145
+ # Define LLM
146
+ client = OpenAI(
147
+ # Use a custom endpoint compatible with OpenAI API
148
+ base_url='http://localhost:8000/v1', # api_base
149
+ api_key="EMPTY"
150
+ )
151
+
152
+ messages = [{'role': 'user', 'content': 'square the number 1024'}]
153
+
154
+ completion = client.chat.completions.create(
155
+ messages=messages,
156
+ model="Qwen3-480B-A35B-Instruct",
157
+ max_tokens=65536,
158
+ tools=tools,
159
+ )
160
+
161
+ print(completion.choice[0])
162
+ ```
163
+
164
+ ## Best Practices
165
+
166
+ To achieve optimal performance, we recommend the following settings:
167
+
168
+ 1. **Sampling Parameters**:
169
+ - We suggest using `temperature=0.7`, `top_p=0.8`, `top_k=20`, `repetition_penalty=1.05`.
170
+
171
+ 2. **Adequate Output Length**: We recommend using an output length of 65,536 tokens for most queries, which is adequate for instruct models.
172
+
173
+
174
+ ### Citation
175
+
176
+ If you find our work helpful, feel free to give us a cite.
177
+
178
+ ```
179
+ @misc{qwen3technicalreport,
180
+ title={Qwen3 Technical Report},
181
+ author={Qwen Team},
182
+ year={2025},
183
+ eprint={2505.09388},
184
+ archivePrefix={arXiv},
185
+ primaryClass={cs.CL},
186
+ url={https://arxiv.org/abs/2505.09388},
187
+ }
188
+ ```