Text Generation
GGUF
English
code
codeqwen
chat
qwen
qwen-coder
Inference Endpoints
conversational
CISCai commited on
Commit
1142221
1 Parent(s): 19b7de3

Upload 13 files

Browse files
.gitattributes CHANGED
@@ -36,3 +36,15 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
36
  Qwen2.5-Coder-32B-Instruct-bf16-00001-of-00003.gguf filter=lfs diff=lfs merge=lfs -text
37
  Qwen2.5-Coder-32B-Instruct-bf16-00002-of-00003.gguf filter=lfs diff=lfs merge=lfs -text
38
  Qwen2.5-Coder-32B-Instruct-bf16-00003-of-00003.gguf filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  Qwen2.5-Coder-32B-Instruct-bf16-00001-of-00003.gguf filter=lfs diff=lfs merge=lfs -text
37
  Qwen2.5-Coder-32B-Instruct-bf16-00002-of-00003.gguf filter=lfs diff=lfs merge=lfs -text
38
  Qwen2.5-Coder-32B-Instruct-bf16-00003-of-00003.gguf filter=lfs diff=lfs merge=lfs -text
39
+ Qwen2.5-Coder-32B-Instruct.imatrix.dat filter=lfs diff=lfs merge=lfs -text
40
+ Qwen2.5-Coder-32B-Instruct.IQ1_M.gguf filter=lfs diff=lfs merge=lfs -text
41
+ Qwen2.5-Coder-32B-Instruct.IQ1_S.gguf filter=lfs diff=lfs merge=lfs -text
42
+ Qwen2.5-Coder-32B-Instruct.IQ2_M.gguf filter=lfs diff=lfs merge=lfs -text
43
+ Qwen2.5-Coder-32B-Instruct.IQ2_S.gguf filter=lfs diff=lfs merge=lfs -text
44
+ Qwen2.5-Coder-32B-Instruct.IQ2_XS.gguf filter=lfs diff=lfs merge=lfs -text
45
+ Qwen2.5-Coder-32B-Instruct.IQ2_XXS.gguf filter=lfs diff=lfs merge=lfs -text
46
+ Qwen2.5-Coder-32B-Instruct.IQ3_M.gguf filter=lfs diff=lfs merge=lfs -text
47
+ Qwen2.5-Coder-32B-Instruct.IQ3_S.gguf filter=lfs diff=lfs merge=lfs -text
48
+ Qwen2.5-Coder-32B-Instruct.IQ3_XS.gguf filter=lfs diff=lfs merge=lfs -text
49
+ Qwen2.5-Coder-32B-Instruct.IQ3_XXS.gguf filter=lfs diff=lfs merge=lfs -text
50
+ Qwen2.5-Coder-32B-Instruct.IQ4_XS.gguf filter=lfs diff=lfs merge=lfs -text
Qwen2.5-Coder-32B-Instruct.IQ1_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee643e0f9f52f4a88624dcf2edc8ffb07c5b948533b89338df50b0f67b698dbc
3
+ size 7932160928
Qwen2.5-Coder-32B-Instruct.IQ1_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4094348e49fbb29ae9db65e30a65dbd366abc610c56665cadd94407daf33d8a5
3
+ size 7274507168
Qwen2.5-Coder-32B-Instruct.IQ2_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9908428b124e745b8fcdcd788ded4572c8e4cdb2923a993525292cd43bcb9ec1
3
+ size 11264441248
Qwen2.5-Coder-32B-Instruct.IQ2_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bddc390f4fd115e6fad2802268927f4e574cb874ac467e8d7e6eb21e3854697e
3
+ size 10387569568
Qwen2.5-Coder-32B-Instruct.IQ2_XS.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2600c702a1b6d8d268fd92a5334198ae0d0cf5f34805e3f23d8dd852ef5fe14a
3
+ size 9957551008
Qwen2.5-Coder-32B-Instruct.IQ2_XXS.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b831d271004f29ca4e58d0e718736699de8e9cb75b38859ba4a6b643384fafc
3
+ size 9028250528
Qwen2.5-Coder-32B-Instruct.IQ3_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f84a88189dd52b7742c0e5ee8cf1c441a96119871d175d3959cbb6bd233844b
3
+ size 14810123168
Qwen2.5-Coder-32B-Instruct.IQ3_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b3c1bd2d5a626caa0089fc6175e091fe4024324314cd230ac0f5fd65e676db2
3
+ size 14436895648
Qwen2.5-Coder-32B-Instruct.IQ3_XS.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78858f3c8a9f270e26b7a8255ae846f19f5965315635057f37f7e4ebf236ee73
3
+ size 13705513888
Qwen2.5-Coder-32B-Instruct.IQ3_XXS.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9fff03f61367ae66ed4318a4db697ea6a866b8b00c2d709a738fee5a3ddd6f32
3
+ size 12839271328
Qwen2.5-Coder-32B-Instruct.IQ4_XS.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:821e8a418fe9fdae149055926eece099befd9c60ebe283eca339d63cd9fcaabb
3
+ size 17693154208
Qwen2.5-Coder-32B-Instruct.imatrix.dat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34e5ed0cbff957d86585ed20be764f679adb822e200463278cf2b1df5e2cf996
3
+ size 14957088
README.md CHANGED
@@ -1,3 +1,450 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ license_link: https://huggingface.co/Qwen/Qwen2.5-Coder-32B-Instruct/blob/main/LICENSE
4
+ language:
5
+ - en
6
+ base_model:
7
+ - Qwen/Qwen2.5-Coder-32B-Instruct
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-32B-Instruct
17
+ model_type: qwen2
18
+ datasets:
19
+ - m-a-p/CodeFeedback-Filtered-Instruction
20
+ quantized_by: CISC
21
+ ---
22
+
23
+ # Qwen2.5-Coder-32B-Instruct - SOTA GGUF
24
+ - Model creator: [Qwen](https://huggingface.co/Qwen)
25
+ - Original model: [Qwen2.5-Coder-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-32B-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-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-32B-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-32B-Instruct.IQ1_S.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ1_S.gguf) | IQ1_S | 1 | 6.8 GB| 7.8 GB | smallest, significant quality loss |
90
+ | [Qwen2.5-Coder-32B-Instruct.IQ1_M.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ1_M.gguf) | IQ1_M | 1 | 7.4 GB| 8.4 GB | very small, significant quality loss |
91
+ | [Qwen2.5-Coder-32B-Instruct.IQ2_XXS.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ2_XXS.gguf) | IQ2_XXS | 2 | 8.4 GB| 9.4 GB | very small, high quality loss |
92
+ | [Qwen2.5-Coder-32B-Instruct.IQ2_XS.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ2_XS.gguf) | IQ2_XS | 2 | 9.3 GB| 10.3 GB | very small, high quality loss |
93
+ | [Qwen2.5-Coder-32B-Instruct.IQ2_S.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ2_S.gguf) | IQ2_S | 2 | 9.7 GB| 10.7 GB | small, substantial quality loss |
94
+ | [Qwen2.5-Coder-32B-Instruct.IQ2_M.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ2_M.gguf) | IQ2_M | 2 | 10.5 GB| 11.5 GB | small, greater quality loss |
95
+ | [Qwen2.5-Coder-32B-Instruct.IQ3_XXS.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ3_XXS.gguf) | IQ3_XXS | 3 | 11.9 GB| 12.9 GB | very small, high quality loss |
96
+ | [Qwen2.5-Coder-32B-Instruct.IQ3_XS.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ3_XS.gguf) | IQ3_XS | 3 | 12.8 GB| 13.8 GB | small, substantial quality loss |
97
+ | [Qwen2.5-Coder-32B-Instruct.IQ3_S.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ3_S.gguf) | IQ3_S | 3 | 13.4 GB| 14.4 GB | small, greater quality loss |
98
+ | [Qwen2.5-Coder-32B-Instruct.IQ3_M.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ3_M.gguf) | IQ3_M | 3 | 13.8 GB| 14.8 GB | medium, balanced quality - recommended |
99
+ | [Qwen2.5-Coder-32B-Instruct.IQ4_XS.gguf](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.IQ4_XS.gguf) | IQ4_XS | 4 | 16.5 GB| 17.5 GB | small, substantial quality loss |
100
+
101
+ Generated importance matrix file: [Qwen2.5-Coder-32B-Instruct.imatrix.dat](https://huggingface.co/CISCai/Qwen2.5-Coder-32B-Instruct-SOTA-GGUF/blob/main/Qwen2.5-Coder-32B-Instruct.imatrix.dat)
102
+
103
+ **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.
104
+
105
+ <!-- README_GGUF.md-provided-files end -->
106
+
107
+ <!-- README_GGUF.md-how-to-run start -->
108
+ ## Example `llama.cpp` command
109
+
110
+ Make sure you are using `llama.cpp` from commit [0becb22](https://github.com/ggerganov/llama.cpp/commit/0becb22ac05b6542bd9d5f2235691aa1d3d4d307) or later.
111
+
112
+ ```shell
113
+ ./llama-cli -ngl 65 -m Qwen2.5-Coder-32B-Instruct.IQ4_XS.gguf --color -c 131072 --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"
114
+ ```
115
+
116
+ Change `-ngl 65` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
117
+
118
+ Change `-c 131072` to the desired sequence length.
119
+
120
+ 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).
121
+ There is a similar option for V-cache (`-ctv`), only available if you enable Flash Attention (`-fa`) as well.
122
+
123
+ 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)
124
+
125
+ ## How to run from Python code
126
+
127
+ You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) module.
128
+
129
+ ### How to load this model in Python code, using llama-cpp-python
130
+
131
+ For full documentation, please see: [llama-cpp-python docs](https://llama-cpp-python.readthedocs.io/en/latest/).
132
+
133
+ #### First install the package
134
+
135
+ Run one of the following commands, according to your system:
136
+
137
+ ```shell
138
+ # Prebuilt wheel with basic CPU support
139
+ pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
140
+ # Prebuilt wheel with NVidia CUDA acceleration
141
+ pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu121 (or cu122 etc.)
142
+ # Prebuilt wheel with Metal GPU acceleration
143
+ pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/metal
144
+ # Build base version with no GPU acceleration
145
+ pip install llama-cpp-python
146
+ # With NVidia CUDA acceleration
147
+ CMAKE_ARGS="-DGGML_CUDA=on" pip install llama-cpp-python
148
+ # Or with OpenBLAS acceleration
149
+ CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
150
+ # Or with AMD ROCm GPU acceleration (Linux only)
151
+ CMAKE_ARGS="-DGGML_HIPBLAS=on" pip install llama-cpp-python
152
+ # Or with Metal GPU acceleration for macOS systems only
153
+ CMAKE_ARGS="-DGGML_METAL=on" pip install llama-cpp-python
154
+ # Or with Vulkan acceleration
155
+ CMAKE_ARGS="-DGGML_VULKAN=on" pip install llama-cpp-python
156
+ # Or with SYCL acceleration
157
+ CMAKE_ARGS="-DGGML_SYCL=on -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx" pip install llama-cpp-python
158
+
159
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
160
+ $env:CMAKE_ARGS = "-DGGML_CUDA=on"
161
+ pip install llama-cpp-python
162
+ ```
163
+
164
+ #### Simple llama-cpp-python example code
165
+
166
+ ```python
167
+ from llama_cpp import Llama
168
+
169
+ # Chat Completion API
170
+
171
+ llm = Llama(model_path="./Qwen2.5-Coder-32B-Instruct.IQ4_XS.gguf", n_gpu_layers=65, n_ctx=131072)
172
+ print(llm.create_chat_completion(
173
+ repeat_penalty = 1.05,
174
+ messages = [
175
+ {
176
+ "role": "user",
177
+ "content": "Pick a LeetCode challenge and solve it in Python."
178
+ }
179
+ ]
180
+ ))
181
+ ```
182
+
183
+ #### Simple llama-cpp-python example fill-in-middle code
184
+
185
+ ```python
186
+ from llama_cpp import Llama
187
+
188
+ # Completion API
189
+
190
+ prompt = "def add("
191
+ suffix = "\n return sum\n\n"
192
+
193
+ llm = Llama(model_path="./Qwen2.5-Coder-32B-Instruct.IQ4_XS.gguf", n_gpu_layers=65, n_ctx=131072)
194
+ output = llm.create_completion(
195
+ temperature = 0.0,
196
+ repeat_penalty = 1.0,
197
+ prompt = prompt,
198
+ suffix = suffix
199
+ )
200
+
201
+ # Models sometimes repeat suffix in response, attempt to filter that
202
+ response = output["choices"][0]["text"]
203
+ response_stripped = response.rstrip()
204
+ unwanted_response_suffix = suffix.rstrip()
205
+ unwanted_response_length = len(unwanted_response_suffix)
206
+
207
+ filtered = False
208
+ if unwanted_response_suffix and response_stripped[-unwanted_response_length:] == unwanted_response_suffix:
209
+ response = response_stripped[:-unwanted_response_length]
210
+ filtered = True
211
+
212
+ 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")
213
+ ```
214
+
215
+ #### Simple llama-cpp-python example function calling code
216
+
217
+ ```python
218
+ from llama_cpp import Llama
219
+
220
+ # Chat Completion API
221
+
222
+ grammar = LlamaGrammar.from_json_schema(json.dumps({
223
+ "type": "array",
224
+ "items": {
225
+ "type": "object",
226
+ "required": [ "name", "arguments" ],
227
+ "properties": {
228
+ "name": {
229
+ "type": "string"
230
+ },
231
+ "arguments": {
232
+ "type": "object"
233
+ }
234
+ }
235
+ }
236
+ }))
237
+
238
+ llm = Llama(model_path="./Qwen2.5-Coder-32B-Instruct.IQ4_XS.gguf", n_gpu_layers=65, n_ctx=131072)
239
+ response = llm.create_chat_completion(
240
+ temperature = 0.0,
241
+ repeat_penalty = 1.05,
242
+ messages = [
243
+ {
244
+ "role": "user",
245
+ "content": "What's the weather like in Oslo and Stockholm?"
246
+ }
247
+ ],
248
+ tools=[{
249
+ "type": "function",
250
+ "function": {
251
+ "name": "get_current_weather",
252
+ "description": "Get the current weather in a given location",
253
+ "parameters": {
254
+ "type": "object",
255
+ "properties": {
256
+ "location": {
257
+ "type": "string",
258
+ "description": "The city and state, e.g. San Francisco, CA"
259
+ },
260
+ "unit": {
261
+ "type": "string",
262
+ "enum": [ "celsius", "fahrenheit" ]
263
+ }
264
+ },
265
+ "required": [ "location" ]
266
+ }
267
+ }
268
+ }],
269
+ grammar = grammar
270
+ )
271
+ print(json.loads(response["choices"][0]["text"]))
272
+
273
+ print(llm.create_chat_completion(
274
+ temperature = 0.0,
275
+ repeat_penalty = 1.05,
276
+ messages = [
277
+ {
278
+ "role": "user",
279
+ "content": "What's the weather like in Oslo?"
280
+ },
281
+ { # The tool_calls is from the response to the above with tool_choice active
282
+ "role": "assistant",
283
+ "content": None,
284
+ "tool_calls": [
285
+ {
286
+ "id": "call__0_get_current_weather_cmpl-...",
287
+ "type": "function",
288
+ "function": {
289
+ "name": "get_current_weather",
290
+ "arguments": { "location": "Oslo, Norway" , "unit": "celsius" }
291
+ }
292
+ }
293
+ ]
294
+ },
295
+ { # The tool_call_id is from tool_calls and content is the result from the function call you made
296
+ "role": "tool",
297
+ "content": "20",
298
+ "tool_call_id": "call__0_get_current_weather_cmpl-..."
299
+ }
300
+ ],
301
+ tools=[{
302
+ "type": "function",
303
+ "function": {
304
+ "name": "get_current_weather",
305
+ "description": "Get the current weather in a given location",
306
+ "parameters": {
307
+ "type": "object",
308
+ "properties": {
309
+ "location": {
310
+ "type": "string",
311
+ "description": "The city and state, e.g. San Francisco, CA"
312
+ },
313
+ "unit": {
314
+ "type": "string",
315
+ "enum": [ "celsius", "fahrenheit" ]
316
+ }
317
+ },
318
+ "required": [ "location" ]
319
+ }
320
+ }
321
+ }],
322
+ #tool_choice={
323
+ # "type": "function",
324
+ # "function": {
325
+ # "name": "get_current_weather"
326
+ # }
327
+ #}
328
+ ))
329
+ ```
330
+
331
+ <!-- README_GGUF.md-how-to-run end -->
332
+
333
+ <!-- original-model-card start -->
334
+ # Qwen2.5-Coder-32B-Instruct
335
+
336
+ ## Introduction
337
+
338
+ 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:
339
+
340
+ - 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.
341
+ - 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.
342
+ - **Long-context Support** up to 128K tokens.
343
+
344
+ **This repo contains the instruction-tuned 32B Qwen2.5-Coder model**, which has the following features:
345
+ - Type: Causal Language Models
346
+ - Training Stage: Pretraining & Post-training
347
+ - Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
348
+ - Number of Parameters: 32.5B
349
+ - Number of Paramaters (Non-Embedding): 31.0B
350
+ - Number of Layers: 64
351
+ - Number of Attention Heads (GQA): 40 for Q and 8 for KV
352
+ - Context Length: Full 131,072 tokens
353
+ - Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2.5 for handling long texts.
354
+
355
+ 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).
356
+
357
+ ## Requirements
358
+
359
+ 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`.
360
+
361
+ With `transformers<4.37.0`, you will encounter the following error:
362
+ ```
363
+ KeyError: 'qwen2'
364
+ ```
365
+
366
+ ## Quickstart
367
+
368
+ Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
369
+
370
+ ```python
371
+ from transformers import AutoModelForCausalLM, AutoTokenizer
372
+
373
+ model_name = "Qwen/Qwen2.5-Coder-32B-Instruct"
374
+
375
+ model = AutoModelForCausalLM.from_pretrained(
376
+ model_name,
377
+ torch_dtype="auto",
378
+ device_map="auto"
379
+ )
380
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
381
+
382
+ prompt = "write a quick sort algorithm."
383
+ messages = [
384
+ {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
385
+ {"role": "user", "content": prompt}
386
+ ]
387
+ text = tokenizer.apply_chat_template(
388
+ messages,
389
+ tokenize=False,
390
+ add_generation_prompt=True
391
+ )
392
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
393
+
394
+ generated_ids = model.generate(
395
+ **model_inputs,
396
+ max_new_tokens=512
397
+ )
398
+ generated_ids = [
399
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
400
+ ]
401
+
402
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
403
+ ```
404
+
405
+ ### Processing Long Texts
406
+
407
+ The current `config.json` is set for context length up to 32,768 tokens.
408
+ To handle extensive inputs exceeding 32,768 tokens, we utilize [YaRN](https://arxiv.org/abs/2309.00071), a technique for enhancing model length extrapolation, ensuring optimal performance on lengthy texts.
409
+
410
+ For supported frameworks, you could add the following to `config.json` to enable YaRN:
411
+ ```json
412
+ {
413
+ ...,
414
+ "rope_scaling": {
415
+ "factor": 4.0,
416
+ "original_max_position_embeddings": 32768,
417
+ "type": "yarn"
418
+ }
419
+ }
420
+ ```
421
+
422
+ For deployment, we recommend using vLLM.
423
+ Please refer to our [Documentation](https://qwen.readthedocs.io/en/latest/deployment/vllm.html) for usage if you are not familar with vLLM.
424
+ Presently, vLLM only supports static YARN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts**.
425
+ We advise adding the `rope_scaling` configuration only when processing long contexts is required.
426
+
427
+ ## Evaluation & Performance
428
+
429
+ Detailed evaluation results are reported in this [📑 blog](https://qwenlm.github.io/blog/qwen2.5-coder-family/).
430
+
431
+ For requirements on GPU memory and the respective throughput, see results [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
432
+
433
+ ## Citation
434
+
435
+ If you find our work helpful, feel free to give us a cite.
436
+
437
+ ```
438
+ @article{hui2024qwen2,
439
+ title={Qwen2. 5-Coder Technical Report},
440
+ 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},
441
+ journal={arXiv preprint arXiv:2409.12186},
442
+ year={2024}
443
+ }
444
+ @article{qwen2,
445
+ title={Qwen2 Technical Report},
446
+ 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},
447
+ journal={arXiv preprint arXiv:2407.10671},
448
+ year={2024}
449
+ }
450
+ ```