Upload 5 files
Browse files
.gitattributes
CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
Qwen2.5-Coder-0.5B-Instruct-bf16-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
|
37 |
+
Qwen2.5-Coder-0.5B-Instruct-bf16-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
|
38 |
+
Qwen2.5-Coder-0.5B-Instruct.IQ4_NL.gguf filter=lfs diff=lfs merge=lfs -text
|
Qwen2.5-Coder-0.5B-Instruct-bf16-00001-of-00002.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:daca627e84745a6b273ee0946559e371bda6d9496e03a19ed1da93df7a845206
|
3 |
+
size 5931872
|
Qwen2.5-Coder-0.5B-Instruct-bf16-00002-of-00002.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:617bd1d5c9b6f1c43d2b3239fb82de50fe6abd51ed632e05704b204b81866d3e
|
3 |
+
size 988225248
|
Qwen2.5-Coder-0.5B-Instruct.IQ4_NL.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2b27a86883300bb7b7358dff9550636dc7f6351e640aa0adee33106e01c83c05
|
3 |
+
size 353531520
|
Qwen2.5-Coder-0.5B-Instruct.imatrix.dat
ADDED
Binary file (989 kB). View file
|
|
README.md
CHANGED
@@ -1,3 +1,417 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
license_link: https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct/blob/main/LICENSE
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
base_model:
|
7 |
+
- Qwen/Qwen2.5-Coder-0.5B
|
8 |
+
pipeline_tag: text-generation
|
9 |
+
tags:
|
10 |
+
- code
|
11 |
+
- codeqwen
|
12 |
+
- chat
|
13 |
+
- qwen
|
14 |
+
- qwen-coder
|
15 |
+
model_creator: Qwen
|
16 |
+
model_name: Qwen2.5-Coder-0.5B-Instruct
|
17 |
+
model_type: qwen2
|
18 |
+
datasets:
|
19 |
+
- m-a-p/CodeFeedback-Filtered-Instruction
|
20 |
+
quantized_by: CISC
|
21 |
+
---
|
22 |
+
|
23 |
+
# Qwen2.5-Coder-0.5B-Instruct - SOTA GGUF
|
24 |
+
- Model creator: [Qwen](https://huggingface.co/Qwen)
|
25 |
+
- Original model: [Qwen2.5-Coder-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct)
|
26 |
+
|
27 |
+
<!-- description start -->
|
28 |
+
## Description
|
29 |
+
|
30 |
+
This repo contains State Of The Art quantized GGUF format model files for [Qwen2.5-Coder-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct).
|
31 |
+
|
32 |
+
Quantization was done with an importance matrix that was trained for ~1M tokens (256 batches of 4096 tokens) of answers from the [CodeFeedback-Filtered-Instruction](https://huggingface.co/datasets/m-a-p/CodeFeedback-Filtered-Instruction) dataset.
|
33 |
+
|
34 |
+
Fill-in-Middle tokens are automatically detected and supported as of commit [11ac980](https://github.com/ggerganov/llama.cpp/commit/11ac9800aff532715a5bc7991062c68ba3472e6e), see [example](#simple-llama-cpp-python-example-fill-in-middle-code).
|
35 |
+
|
36 |
+
<!-- description end -->
|
37 |
+
|
38 |
+
|
39 |
+
<!-- prompt-template start -->
|
40 |
+
## Prompt template: ChatML
|
41 |
+
|
42 |
+
```
|
43 |
+
<|im_start|>system
|
44 |
+
{system_prompt}<|im_end|>
|
45 |
+
<|im_start|>user
|
46 |
+
{prompt}<|im_end|>
|
47 |
+
<|im_start|>assistant
|
48 |
+
```
|
49 |
+
|
50 |
+
<!-- prompt-template end -->
|
51 |
+
|
52 |
+
|
53 |
+
<!-- compatibility_gguf start -->
|
54 |
+
## Compatibility
|
55 |
+
|
56 |
+
These quantised GGUFv3 files are compatible with llama.cpp from February 27th 2024 onwards, as of commit [0becb22](https://github.com/ggerganov/llama.cpp/commit/0becb22ac05b6542bd9d5f2235691aa1d3d4d307)
|
57 |
+
|
58 |
+
They are also compatible with many third party UIs and libraries provided they are built using a recent llama.cpp.
|
59 |
+
|
60 |
+
## Explanation of quantisation methods
|
61 |
+
|
62 |
+
<details>
|
63 |
+
<summary>Click to see details</summary>
|
64 |
+
|
65 |
+
The new methods available are:
|
66 |
+
|
67 |
+
* GGML_TYPE_IQ1_S - 1-bit quantization in super-blocks with an importance matrix applied, effectively using 1.56 bits per weight (bpw)
|
68 |
+
* GGML_TYPE_IQ1_M - 1-bit quantization in super-blocks with an importance matrix applied, effectively using 1.75 bpw
|
69 |
+
* GGML_TYPE_IQ2_XXS - 2-bit quantization in super-blocks with an importance matrix applied, effectively using 2.06 bpw
|
70 |
+
* GGML_TYPE_IQ2_XS - 2-bit quantization in super-blocks with an importance matrix applied, effectively using 2.31 bpw
|
71 |
+
* GGML_TYPE_IQ2_S - 2-bit quantization in super-blocks with an importance matrix applied, effectively using 2.5 bpw
|
72 |
+
* GGML_TYPE_IQ2_M - 2-bit quantization in super-blocks with an importance matrix applied, effectively using 2.7 bpw
|
73 |
+
* GGML_TYPE_IQ3_XXS - 3-bit quantization in super-blocks with an importance matrix applied, effectively using 3.06 bpw
|
74 |
+
* GGML_TYPE_IQ3_XS - 3-bit quantization in super-blocks with an importance matrix applied, effectively using 3.3 bpw
|
75 |
+
* GGML_TYPE_IQ3_S - 3-bit quantization in super-blocks with an importance matrix applied, effectively using 3.44 bpw
|
76 |
+
* GGML_TYPE_IQ3_M - 3-bit quantization in super-blocks with an importance matrix applied, effectively using 3.66 bpw
|
77 |
+
* GGML_TYPE_IQ4_XS - 4-bit quantization in super-blocks with an importance matrix applied, effectively using 4.25 bpw
|
78 |
+
* GGML_TYPE_IQ4_NL - 4-bit non-linearly mapped quantization with an importance matrix applied, effectively using 4.5 bpw
|
79 |
+
|
80 |
+
Refer to the Provided Files table below to see what files use which methods, and how.
|
81 |
+
</details>
|
82 |
+
<!-- compatibility_gguf end -->
|
83 |
+
|
84 |
+
<!-- README_GGUF.md-provided-files start -->
|
85 |
+
## Provided files
|
86 |
+
|
87 |
+
| Name | Quant method | Bits | Size | Max RAM required | Use case |
|
88 |
+
| ---- | ---- | ---- | ---- | ---- | ----- |
|
89 |
+
| [Qwen2.5-Coder-0.5B-Instruct.IQ4_NL.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-0.5B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-0.5B-Instruct.IQ4_NL.gguf) | IQ4_NL | 4 | 0.3 GB| 0.7 GB | medium, balanced quality - recommended |
|
90 |
+
|
91 |
+
Generated importance matrix file: [Qwen2.5-Coder-0.5B-Instruct.imatrix.dat](https://huggingface.co/CISCai/Qwen2.5-Coder-0.5B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-0.5B-Instruct.imatrix.dat)
|
92 |
+
|
93 |
+
**Note**: the above RAM figures assume no GPU offloading with 4K context. If layers are offloaded to the GPU, this will reduce RAM usage and use VRAM instead.
|
94 |
+
|
95 |
+
<!-- README_GGUF.md-provided-files end -->
|
96 |
+
|
97 |
+
<!-- README_GGUF.md-how-to-run start -->
|
98 |
+
## Example `llama.cpp` command
|
99 |
+
|
100 |
+
Make sure you are using `llama.cpp` from commit [0becb22](https://github.com/ggerganov/llama.cpp/commit/0becb22ac05b6542bd9d5f2235691aa1d3d4d307) or later.
|
101 |
+
|
102 |
+
```shell
|
103 |
+
./llama-cli -ngl 25 -m Qwen2.5-Coder-0.5B-Instruct.IQ4_XS.gguf --color -c 32768 --temp 0.7 --top-p 0.8 --top-k 20 --repeat-penalty 1.05 -p "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
|
104 |
+
```
|
105 |
+
|
106 |
+
Change `-ngl 25` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
|
107 |
+
|
108 |
+
Change `-c 32768` to the desired sequence length.
|
109 |
+
|
110 |
+
If you are low on V/RAM try quantizing the K-cache with `-ctk q8_0` or even `-ctk q4_0` for big memory savings (depending on context size).
|
111 |
+
There is a similar option for V-cache (`-ctv`), only available if you enable Flash Attention (`-fa`) as well.
|
112 |
+
|
113 |
+
For other parameters and how to use them, please refer to [the llama.cpp documentation](https://github.com/ggerganov/llama.cpp/blob/master/examples/main/README.md)
|
114 |
+
|
115 |
+
## How to run from Python code
|
116 |
+
|
117 |
+
You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) module.
|
118 |
+
|
119 |
+
### How to load this model in Python code, using llama-cpp-python
|
120 |
+
|
121 |
+
For full documentation, please see: [llama-cpp-python docs](https://llama-cpp-python.readthedocs.io/en/latest/).
|
122 |
+
|
123 |
+
#### First install the package
|
124 |
+
|
125 |
+
Run one of the following commands, according to your system:
|
126 |
+
|
127 |
+
```shell
|
128 |
+
# Prebuilt wheel with basic CPU support
|
129 |
+
pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
|
130 |
+
# Prebuilt wheel with NVidia CUDA acceleration
|
131 |
+
pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu121 (or cu122 etc.)
|
132 |
+
# Prebuilt wheel with Metal GPU acceleration
|
133 |
+
pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/metal
|
134 |
+
# Build base version with no GPU acceleration
|
135 |
+
pip install llama-cpp-python
|
136 |
+
# With NVidia CUDA acceleration
|
137 |
+
CMAKE_ARGS="-DGGML_CUDA=on" pip install llama-cpp-python
|
138 |
+
# Or with OpenBLAS acceleration
|
139 |
+
CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
|
140 |
+
# Or with AMD ROCm GPU acceleration (Linux only)
|
141 |
+
CMAKE_ARGS="-DGGML_HIPBLAS=on" pip install llama-cpp-python
|
142 |
+
# Or with Metal GPU acceleration for macOS systems only
|
143 |
+
CMAKE_ARGS="-DGGML_METAL=on" pip install llama-cpp-python
|
144 |
+
# Or with Vulkan acceleration
|
145 |
+
CMAKE_ARGS="-DGGML_VULKAN=on" pip install llama-cpp-python
|
146 |
+
# Or with SYCL acceleration
|
147 |
+
CMAKE_ARGS="-DGGML_SYCL=on -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx" pip install llama-cpp-python
|
148 |
+
|
149 |
+
# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
|
150 |
+
$env:CMAKE_ARGS = "-DGGML_CUDA=on"
|
151 |
+
pip install llama-cpp-python
|
152 |
+
```
|
153 |
+
|
154 |
+
#### Simple llama-cpp-python example code
|
155 |
+
|
156 |
+
```python
|
157 |
+
from llama_cpp import Llama
|
158 |
+
|
159 |
+
# Chat Completion API
|
160 |
+
|
161 |
+
llm = Llama(model_path="./Qwen2.5-Coder-0.5B-Instruct.IQ4_NL.gguf", n_gpu_layers=25, n_ctx=32768)
|
162 |
+
print(llm.create_chat_completion(
|
163 |
+
repeat_penalty = 1.05,
|
164 |
+
messages = [
|
165 |
+
{
|
166 |
+
"role": "user",
|
167 |
+
"content": "Pick a LeetCode challenge and solve it in Python."
|
168 |
+
}
|
169 |
+
]
|
170 |
+
))
|
171 |
+
```
|
172 |
+
|
173 |
+
#### Simple llama-cpp-python example fill-in-middle code
|
174 |
+
|
175 |
+
```python
|
176 |
+
from llama_cpp import Llama
|
177 |
+
|
178 |
+
# Completion API
|
179 |
+
|
180 |
+
prompt = "def add("
|
181 |
+
suffix = "\n return sum\n\n"
|
182 |
+
|
183 |
+
llm = Llama(model_path="./Qwen2.5-Coder-0.5B-Instruct.IQ4_NL.gguf", n_gpu_layers=25, n_ctx=32768)
|
184 |
+
output = llm.create_completion(
|
185 |
+
temperature = 0.0,
|
186 |
+
repeat_penalty = 1.0,
|
187 |
+
prompt = prompt,
|
188 |
+
suffix = suffix
|
189 |
+
)
|
190 |
+
|
191 |
+
# Models sometimes repeat suffix in response, attempt to filter that
|
192 |
+
response = output["choices"][0]["text"]
|
193 |
+
response_stripped = response.rstrip()
|
194 |
+
unwanted_response_suffix = suffix.rstrip()
|
195 |
+
unwanted_response_length = len(unwanted_response_suffix)
|
196 |
+
|
197 |
+
filtered = False
|
198 |
+
if unwanted_response_suffix and response_stripped[-unwanted_response_length:] == unwanted_response_suffix:
|
199 |
+
response = response_stripped[:-unwanted_response_length]
|
200 |
+
filtered = True
|
201 |
+
|
202 |
+
print(f"Fill-in-Middle completion{' (filtered)' if filtered else ''}:\n\n{prompt}\033[32m{response}\033[{'33' if filtered else '0'}m{suffix}\033[0m")
|
203 |
+
```
|
204 |
+
|
205 |
+
#### Simple llama-cpp-python example function calling code
|
206 |
+
|
207 |
+
```python
|
208 |
+
from llama_cpp import Llama
|
209 |
+
|
210 |
+
# Chat Completion API
|
211 |
+
|
212 |
+
grammar = LlamaGrammar.from_json_schema(json.dumps({
|
213 |
+
"type": "array",
|
214 |
+
"items": {
|
215 |
+
"type": "object",
|
216 |
+
"required": [ "name", "arguments" ],
|
217 |
+
"properties": {
|
218 |
+
"name": {
|
219 |
+
"type": "string"
|
220 |
+
},
|
221 |
+
"arguments": {
|
222 |
+
"type": "object"
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}))
|
227 |
+
|
228 |
+
llm = Llama(model_path="./Qwen2.5-Coder-0.5B-Instruct.IQ4_NL.gguf", n_gpu_layers=25, n_ctx=32768)
|
229 |
+
response = llm.create_chat_completion(
|
230 |
+
temperature = 0.0,
|
231 |
+
repeat_penalty = 1.05,
|
232 |
+
messages = [
|
233 |
+
{
|
234 |
+
"role": "user",
|
235 |
+
"content": "What's the weather like in Oslo and Stockholm?"
|
236 |
+
}
|
237 |
+
],
|
238 |
+
tools=[{
|
239 |
+
"type": "function",
|
240 |
+
"function": {
|
241 |
+
"name": "get_current_weather",
|
242 |
+
"description": "Get the current weather in a given location",
|
243 |
+
"parameters": {
|
244 |
+
"type": "object",
|
245 |
+
"properties": {
|
246 |
+
"location": {
|
247 |
+
"type": "string",
|
248 |
+
"description": "The city and state, e.g. San Francisco, CA"
|
249 |
+
},
|
250 |
+
"unit": {
|
251 |
+
"type": "string",
|
252 |
+
"enum": [ "celsius", "fahrenheit" ]
|
253 |
+
}
|
254 |
+
},
|
255 |
+
"required": [ "location" ]
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}],
|
259 |
+
grammar = grammar
|
260 |
+
)
|
261 |
+
print(json.loads(response["choices"][0]["text"]))
|
262 |
+
|
263 |
+
print(llm.create_chat_completion(
|
264 |
+
temperature = 0.0,
|
265 |
+
repeat_penalty = 1.05,
|
266 |
+
messages = [
|
267 |
+
{
|
268 |
+
"role": "user",
|
269 |
+
"content": "What's the weather like in Oslo?"
|
270 |
+
},
|
271 |
+
{ # The tool_calls is from the response to the above with tool_choice active
|
272 |
+
"role": "assistant",
|
273 |
+
"content": None,
|
274 |
+
"tool_calls": [
|
275 |
+
{
|
276 |
+
"id": "call__0_get_current_weather_cmpl-...",
|
277 |
+
"type": "function",
|
278 |
+
"function": {
|
279 |
+
"name": "get_current_weather",
|
280 |
+
"arguments": { "location": "Oslo, Norway" , "unit": "celsius" }
|
281 |
+
}
|
282 |
+
}
|
283 |
+
]
|
284 |
+
},
|
285 |
+
{ # The tool_call_id is from tool_calls and content is the result from the function call you made
|
286 |
+
"role": "tool",
|
287 |
+
"content": "20",
|
288 |
+
"tool_call_id": "call__0_get_current_weather_cmpl-..."
|
289 |
+
}
|
290 |
+
],
|
291 |
+
tools=[{
|
292 |
+
"type": "function",
|
293 |
+
"function": {
|
294 |
+
"name": "get_current_weather",
|
295 |
+
"description": "Get the current weather in a given location",
|
296 |
+
"parameters": {
|
297 |
+
"type": "object",
|
298 |
+
"properties": {
|
299 |
+
"location": {
|
300 |
+
"type": "string",
|
301 |
+
"description": "The city and state, e.g. San Francisco, CA"
|
302 |
+
},
|
303 |
+
"unit": {
|
304 |
+
"type": "string",
|
305 |
+
"enum": [ "celsius", "fahrenheit" ]
|
306 |
+
}
|
307 |
+
},
|
308 |
+
"required": [ "location" ]
|
309 |
+
}
|
310 |
+
}
|
311 |
+
}],
|
312 |
+
#tool_choice={
|
313 |
+
# "type": "function",
|
314 |
+
# "function": {
|
315 |
+
# "name": "get_current_weather"
|
316 |
+
# }
|
317 |
+
#}
|
318 |
+
))
|
319 |
+
```
|
320 |
+
|
321 |
+
<!-- README_GGUF.md-how-to-run end -->
|
322 |
+
|
323 |
+
<!-- original-model-card start -->
|
324 |
+
# Qwen2.5-Coder-0.5B-Instruct
|
325 |
+
|
326 |
+
## Introduction
|
327 |
+
|
328 |
+
Qwen2.5-Coder is the latest series of Code-Specific Qwen large language models (formerly known as CodeQwen). As of now, Qwen2.5-Coder has covered six mainstream model sizes, 0.5, 1.5, 3, 7, 14, 32 billion parameters, to meet the needs of different developers. Qwen2.5-Coder brings the following improvements upon CodeQwen1.5:
|
329 |
+
|
330 |
+
- Significantly improvements in **code generation**, **code reasoning** and **code fixing**. Base on the strong Qwen2.5, we scale up the training tokens into 5.5 trillion including source code, text-code grounding, Synthetic data, etc. Qwen2.5-Coder-32B has become the current state-of-the-art open-source codeLLM, with its coding abilities matching those of GPT-4o.
|
331 |
+
- A more comprehensive foundation for real-world applications such as **Code Agents**. Not only enhancing coding capabilities but also maintaining its strengths in mathematics and general competencies.
|
332 |
+
|
333 |
+
**This repo contains the instruction-tuned 0.5B Qwen2.5-Coder model**, which has the following features:
|
334 |
+
- Type: Causal Language Models
|
335 |
+
- Training Stage: Pretraining & Post-training
|
336 |
+
- Architecture: transformers with RoPE, SwiGLU, RMSNorm, Attention QKV bias and tied word embeddings
|
337 |
+
- Number of Parameters: 0.49B
|
338 |
+
- Number of Paramaters (Non-Embedding): 0.36B
|
339 |
+
- Number of Layers: 24
|
340 |
+
- Number of Attention Heads (GQA): 14 for Q and 2 for KV
|
341 |
+
- Context Length: Full 32,768 tokens
|
342 |
+
|
343 |
+
For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2.5-coder-family/), [GitHub](https://github.com/QwenLM/Qwen2.5-Coder), [Documentation](https://qwen.readthedocs.io/en/latest/), [Arxiv](https://arxiv.org/abs/2409.12186).
|
344 |
+
|
345 |
+
## Requirements
|
346 |
+
|
347 |
+
The code of Qwen2.5-Coder has been in the latest Hugging face `transformers` and we advise you to use the latest version of `transformers`.
|
348 |
+
|
349 |
+
With `transformers<4.37.0`, you will encounter the following error:
|
350 |
+
```
|
351 |
+
KeyError: 'qwen2'
|
352 |
+
```
|
353 |
+
|
354 |
+
## Quickstart
|
355 |
+
|
356 |
+
Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
|
357 |
+
|
358 |
+
```python
|
359 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
360 |
+
|
361 |
+
model_name = "Qwen/Qwen2.5-Coder-0.5B-Instruct"
|
362 |
+
|
363 |
+
model = AutoModelForCausalLM.from_pretrained(
|
364 |
+
model_name,
|
365 |
+
torch_dtype="auto",
|
366 |
+
device_map="auto"
|
367 |
+
)
|
368 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
369 |
+
|
370 |
+
prompt = "write a quick sort algorithm."
|
371 |
+
messages = [
|
372 |
+
{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
|
373 |
+
{"role": "user", "content": prompt}
|
374 |
+
]
|
375 |
+
text = tokenizer.apply_chat_template(
|
376 |
+
messages,
|
377 |
+
tokenize=False,
|
378 |
+
add_generation_prompt=True
|
379 |
+
)
|
380 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
381 |
+
|
382 |
+
generated_ids = model.generate(
|
383 |
+
**model_inputs,
|
384 |
+
max_new_tokens=512
|
385 |
+
)
|
386 |
+
generated_ids = [
|
387 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
388 |
+
]
|
389 |
+
|
390 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
391 |
+
```
|
392 |
+
|
393 |
+
|
394 |
+
## Evaluation & Performance
|
395 |
+
|
396 |
+
Detailed evaluation results are reported in this [📑 blog](https://qwenlm.github.io/blog/qwen2.5-coder-family/).
|
397 |
+
|
398 |
+
For requirements on GPU memory and the respective throughput, see results [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
|
399 |
+
|
400 |
+
## Citation
|
401 |
+
|
402 |
+
If you find our work helpful, feel free to give us a cite.
|
403 |
+
|
404 |
+
```
|
405 |
+
@article{hui2024qwen2,
|
406 |
+
title={Qwen2. 5-Coder Technical Report},
|
407 |
+
author={Hui, Binyuan and Yang, Jian and Cui, Zeyu and Yang, Jiaxi and Liu, Dayiheng and Zhang, Lei and Liu, Tianyu and Zhang, Jiajun and Yu, Bowen and Dang, Kai and others},
|
408 |
+
journal={arXiv preprint arXiv:2409.12186},
|
409 |
+
year={2024}
|
410 |
+
}
|
411 |
+
@article{qwen2,
|
412 |
+
title={Qwen2 Technical Report},
|
413 |
+
author={An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhihao Fan},
|
414 |
+
journal={arXiv preprint arXiv:2407.10671},
|
415 |
+
year={2024}
|
416 |
+
}
|
417 |
+
```
|