danielhanchen commited on
Commit
29f5c71
·
verified ·
1 Parent(s): 4206b1b

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +191 -3
README.md CHANGED
@@ -1,3 +1,191 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - unsloth
4
+ base_model:
5
+ - Qwen/Qwen3-Coder-30B-A3B-Instruct
6
+ library_name: transformers
7
+ license: apache-2.0
8
+ license_link: https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct/blob/main/LICENSE
9
+ pipeline_tag: text-generation
10
+ ---
11
+ > [!NOTE]
12
+ > Includes Unsloth **chat template fixes**! <br> For `llama.cpp`, use `--jinja`
13
+ >
14
+
15
+ <div>
16
+ <p style="margin-top: 0;margin-bottom: 0;">
17
+ <em><a href="https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf">Unsloth Dynamic 2.0</a> achieves superior accuracy & outperforms other leading quants.</em>
18
+ </p>
19
+ <div style="display: flex; gap: 5px; align-items: center; ">
20
+ <a href="https://github.com/unslothai/unsloth/">
21
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
22
+ </a>
23
+ <a href="https://discord.gg/unsloth">
24
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
25
+ </a>
26
+ <a href="https://docs.unsloth.ai/">
27
+ <img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
28
+ </a>
29
+ </div>
30
+ </div>
31
+
32
+
33
+ # Qwen3-Coder-3B-A3B-Instruct
34
+ <a href="https://chat.qwen.ai/" target="_blank" style="margin: 2px;">
35
+ <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;"/>
36
+ </a>
37
+
38
+ ## Highlights
39
+
40
+ **Qwen3-Coder** is available in multiple sizes. Today, we're excited to introduce **Qwen3-Coder-30B-A3B-Instruct**. This streamlined model maintains impressive performance and efficiency, featuring the following key enhancements:
41
+
42
+ - **Significant Performance** among open models on **Agentic Coding**, **Agentic Browser-Use**, and other foundational coding tasks.
43
+ - **Long-context Capabilities** with native support for **256K** tokens, extendable up to **1M** tokens using Yarn, optimized for repository-scale understanding.
44
+ - **Agentic Coding** supporting for most platform such as **Qwen Code**, **CLINE**, featuring a specially designed function call format.
45
+
46
+ ![image/jpeg](placeholder of Qwen3-Coder-30B-A3B-Instruct performance image )
47
+
48
+ ## Model Overview
49
+
50
+ **Qwen3-Coder-30B-A3B-Instruct** has the following features:
51
+ - Type: Causal Language Models
52
+ - Training Stage: Pretraining & Post-training
53
+ - Number of Parameters: 30.5B in total and 3.3B activated
54
+ - Number of Layers: 48
55
+ - Number of Attention Heads (GQA): 32 for Q and 4 for KV
56
+ - Number of Experts: 128
57
+ - Number of Activated Experts: 8
58
+ - Context Length: **262,144 natively**.
59
+
60
+ **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.**
61
+
62
+ 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/).
63
+
64
+
65
+ ## Quickstart
66
+
67
+ We advise you to use the latest version of `transformers`.
68
+
69
+ With `transformers<4.51.0`, you will encounter the following error:
70
+ ```
71
+ KeyError: 'qwen3_moe'
72
+ ```
73
+
74
+ The following contains a code snippet illustrating how to use the model generate content based on given inputs.
75
+ ```python
76
+ from transformers import AutoModelForCausalLM, AutoTokenizer
77
+
78
+ model_name = "Qwen/Qwen3-Coder-30B-A3B-Instruct"
79
+
80
+ # load the tokenizer and the model
81
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
82
+ model = AutoModelForCausalLM.from_pretrained(
83
+ model_name,
84
+ torch_dtype="auto",
85
+ device_map="auto"
86
+ )
87
+
88
+ # prepare the model input
89
+ prompt = "Write a quick sort algorithm."
90
+ messages = [
91
+ {"role": "user", "content": prompt}
92
+ ]
93
+ text = tokenizer.apply_chat_template(
94
+ messages,
95
+ tokenize=False,
96
+ add_generation_prompt=True,
97
+ )
98
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
99
+
100
+ # conduct text completion
101
+ generated_ids = model.generate(
102
+ **model_inputs,
103
+ max_new_tokens=65536
104
+ )
105
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
106
+
107
+ content = tokenizer.decode(output_ids, skip_special_tokens=True)
108
+
109
+ print("content:", content)
110
+ ```
111
+
112
+ **Note: If you encounter out-of-memory (OOM) issues, consider reducing the context length to a shorter value, such as `32,768`.**
113
+
114
+ For local use, applications such as Ollama, LMStudio, MLX-LM, llama.cpp, and KTransformers have also supported Qwen3.
115
+
116
+ ## Agentic Coding
117
+
118
+ Qwen3-Coder excels in tool calling capabilities.
119
+
120
+ You can simply define or use any tools as following example.
121
+ ```python
122
+ # Your tool implementation
123
+ def square_the_number(num: float) -> dict:
124
+ return num ** 2
125
+
126
+ # Define Tools
127
+ tools=[
128
+ {
129
+ "type":"function",
130
+ "function":{
131
+ "name": "square_the_number",
132
+ "description": "output the square of the number.",
133
+ "parameters": {
134
+ "type": "object",
135
+ "required": ["input_num"],
136
+ "properties": {
137
+ 'input_num': {
138
+ 'type': 'number',
139
+ 'description': 'input_num is a number that will be squared'
140
+ }
141
+ },
142
+ }
143
+ }
144
+ }
145
+ ]
146
+
147
+ import OpenAI
148
+ # Define LLM
149
+ client = OpenAI(
150
+ # Use a custom endpoint compatible with OpenAI API
151
+ base_url='http://localhost:8000/v1', # api_base
152
+ api_key="EMPTY"
153
+ )
154
+
155
+ messages = [{'role': 'user', 'content': 'square the number 1024'}]
156
+
157
+ completion = client.chat.completions.create(
158
+ messages=messages,
159
+ model="Qwen3-Coder-30B-A3B-Instruct",
160
+ max_tokens=65536,
161
+ tools=tools,
162
+ )
163
+
164
+ print(completion.choice[0])
165
+ ```
166
+
167
+ ## Best Practices
168
+
169
+ To achieve optimal performance, we recommend the following settings:
170
+
171
+ 1. **Sampling Parameters**:
172
+ - We suggest using `temperature=0.7`, `top_p=0.8`, `top_k=20`, `repetition_penalty=1.05`.
173
+
174
+ 2. **Adequate Output Length**: We recommend using an output length of 65,536 tokens for most queries, which is adequate for instruct models.
175
+
176
+
177
+ ### Citation
178
+
179
+ If you find our work helpful, feel free to give us a cite.
180
+
181
+ ```
182
+ @misc{qwen3technicalreport,
183
+ title={Qwen3 Technical Report},
184
+ author={Qwen Team},
185
+ year={2025},
186
+ eprint={2505.09388},
187
+ archivePrefix={arXiv},
188
+ primaryClass={cs.CL},
189
+ url={https://arxiv.org/abs/2505.09388},
190
+ }
191
+ ```