cjpais commited on
Commit
66606b2
·
verified ·
1 Parent(s): eefb431

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +245 -3
README.md CHANGED
@@ -1,3 +1,245 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ pipeline_tag: text-generation
4
+ language:
5
+ - en
6
+ license_link: LICENSE
7
+ base_model: Qwen/Qwen2.5-Coder-7B
8
+ quantized_by: bartowski
9
+ tags:
10
+ - llamafile
11
+ - code
12
+ - codeqwen
13
+ - chat
14
+ - qwen
15
+ - qwen-coder
16
+ ---
17
+
18
+ # Qwen 2.5 Coder 7B - llamafile
19
+
20
+ - Model creator: [Qwen](https://huggingface.co/Qwen/)
21
+ - Original model: [Qwen/Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct)
22
+
23
+ Mozilla packaged the Qwen 2.5 Coder models into executable weights that we
24
+ call [llamafiles](https://github.com/Mozilla-Ocho/llamafile). This gives
25
+ you the easiest fastest way to use the model on Linux, MacOS, Windows,
26
+ FreeBSD, OpenBSD and NetBSD systems you control on both AMD64 and ARM64.
27
+
28
+ *Software Last Updated: 2025-03-31*
29
+
30
+ *Llamafile Version: 0.9.2*
31
+
32
+ ## Quickstart
33
+
34
+ To get started, you need both the Qwen 2.5 Coder weights, and the llamafile
35
+ software. Both of them are included in a single file, which can be
36
+ downloaded and run as follows:
37
+
38
+ ```
39
+ wget https://huggingface.co/Mozilla/Qwen2.5.1-Coder-7B-Instruct-llamafile/resolve/main/Qwen2.5.1-Coder-7B-Instruct-Q6_K.llamafile
40
+ chmod +x Qwen2.5.1-Coder-7B-Instruct-Q6_K.llamafile
41
+ ./Qwen2.5.1-Coder-7B-Instruct-Q6_K.llamafile
42
+ ```
43
+
44
+ The default mode of operation for these llamafiles is our new command
45
+ line chatbot interface.
46
+
47
+ ## Usage
48
+
49
+ You can use triple quotes to ask questions on multiple lines. You can
50
+ pass commands like `/stats` and `/context` to see runtime status
51
+ information. You can change the system prompt by passing the `-p "new
52
+ system prompt"` flag. You can press CTRL-C to interrupt the model.
53
+ Finally CTRL-D may be used to exit.
54
+
55
+ If you prefer to use a web GUI, then a `--server` mode is provided, that
56
+ will open a tab with a chatbot and completion interface in your browser.
57
+ For additional help on how it may be used, pass the `--help` flag. The
58
+ server also has an OpenAI API compatible completions endpoint that can
59
+ be accessed via Python using the `openai` pip package.
60
+
61
+ ```
62
+ .Qwen2.5.1-Coder-7B-Instruct-Q6_K.llamafile --server
63
+ ```
64
+
65
+ An advanced CLI mode is provided that's useful for shell scripting. You
66
+ can use it by passing the `--cli` flag. For additional help on how it
67
+ may be used, pass the `--help` flag.
68
+
69
+ ```
70
+ ./Qwen2.5.1-Coder-7B-Instruct-Q6_K.llamafile --cli -p 'four score and seven' --log-disable
71
+ ```
72
+
73
+ ## Troubleshooting
74
+
75
+ Having **trouble?** See the ["Gotchas"
76
+ section](https://github.com/mozilla-ocho/llamafile/?tab=readme-ov-file#gotchas-and-troubleshooting)
77
+ of the README.
78
+
79
+ On Linux, the way to avoid run-detector errors is to install the APE
80
+ interpreter.
81
+
82
+ ```sh
83
+ sudo wget -O /usr/bin/ape https://cosmo.zip/pub/cosmos/bin/ape-$(uname -m).elf
84
+ sudo chmod +x /usr/bin/ape
85
+ sudo sh -c "echo ':APE:M::MZqFpD::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register"
86
+ sudo sh -c "echo ':APE-jart:M::jartsr::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register"
87
+ ```
88
+
89
+ On Windows there's a 4GB limit on executable sizes.
90
+
91
+ ## Context Window
92
+
93
+ This model has a max context window size of 128k tokens. By default, a
94
+ context window size of 8192 tokens is used. You can ask llamafile
95
+ to use the maximum context size by passing the `-c 0` flag. That's big
96
+ enough for a small book. If you want to be able to have a conversation
97
+ with your book, you can use the `-f book.txt` flag.
98
+
99
+ ## GPU Acceleration
100
+
101
+ On GPUs with sufficient RAM, the `-ngl 999` flag may be passed to use
102
+ the system's NVIDIA or AMD GPU(s). On Windows, only the graphics card
103
+ driver needs to be installed if you own an NVIDIA GPU. On Windows, if
104
+ you have an AMD GPU, you should install the ROCm SDK v6.1 and then pass
105
+ the flags `--recompile --gpu amd` the first time you run your llamafile.
106
+
107
+ On NVIDIA GPUs, by default, the prebuilt tinyBLAS library is used to
108
+ perform matrix multiplications. This is open source software, but it
109
+ doesn't go as fast as closed source cuBLAS. If you have the CUDA SDK
110
+ installed on your system, then you can pass the `--recompile` flag to
111
+ build a GGML CUDA library just for your system that uses cuBLAS. This
112
+ ensures you get maximum performance.
113
+
114
+ For further information, please see the [llamafile
115
+ README](https://github.com/mozilla-ocho/llamafile/).
116
+
117
+ ## About llamafile
118
+
119
+ llamafile is a new format introduced by Mozilla on Nov 20th 2023. It
120
+ uses Cosmopolitan Libc to turn LLM weights into runnable llama.cpp
121
+ binaries that run on the stock installs of six OSes for both ARM64 and
122
+ AMD64.
123
+
124
+ ---
125
+
126
+ # Qwen2.5-Coder-7B-Instruct
127
+ <a href="https://chat.qwenlm.ai/" target="_blank" style="margin: 2px;">
128
+ <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;"/>
129
+ </a>
130
+
131
+ ## Introduction
132
+
133
+ 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:
134
+
135
+ - 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.
136
+ - 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.
137
+ - **Long-context Support** up to 128K tokens.
138
+
139
+ **This repo contains the instruction-tuned 7B Qwen2.5-Coder model**, which has the following features:
140
+ - Type: Causal Language Models
141
+ - Training Stage: Pretraining & Post-training
142
+ - Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
143
+ - Number of Parameters: 7.61B
144
+ - Number of Paramaters (Non-Embedding): 6.53B
145
+ - Number of Layers: 28
146
+ - Number of Attention Heads (GQA): 28 for Q and 4 for KV
147
+ - Context Length: Full 131,072 tokens
148
+ - Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2.5 for handling long texts.
149
+
150
+ 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).
151
+
152
+ ## Requirements
153
+
154
+ 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`.
155
+
156
+ With `transformers<4.37.0`, you will encounter the following error:
157
+ ```
158
+ KeyError: 'qwen2'
159
+ ```
160
+
161
+ ## Quickstart
162
+
163
+ Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
164
+
165
+ ```python
166
+ from transformers import AutoModelForCausalLM, AutoTokenizer
167
+
168
+ model_name = "Qwen/Qwen2.5-Coder-7B-Instruct"
169
+
170
+ model = AutoModelForCausalLM.from_pretrained(
171
+ model_name,
172
+ torch_dtype="auto",
173
+ device_map="auto"
174
+ )
175
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
176
+
177
+ prompt = "write a quick sort algorithm."
178
+ messages = [
179
+ {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
180
+ {"role": "user", "content": prompt}
181
+ ]
182
+ text = tokenizer.apply_chat_template(
183
+ messages,
184
+ tokenize=False,
185
+ add_generation_prompt=True
186
+ )
187
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
188
+
189
+ generated_ids = model.generate(
190
+ **model_inputs,
191
+ max_new_tokens=512
192
+ )
193
+ generated_ids = [
194
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
195
+ ]
196
+
197
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
198
+ ```
199
+
200
+ ### Processing Long Texts
201
+
202
+ The current `config.json` is set for context length up to 32,768 tokens.
203
+ 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.
204
+
205
+ For supported frameworks, you could add the following to `config.json` to enable YaRN:
206
+ ```json
207
+ {
208
+ ...,
209
+ "rope_scaling": {
210
+ "factor": 4.0,
211
+ "original_max_position_embeddings": 32768,
212
+ "type": "yarn"
213
+ }
214
+ }
215
+ ```
216
+
217
+ For deployment, we recommend using vLLM.
218
+ Please refer to our [Documentation](https://qwen.readthedocs.io/en/latest/deployment/vllm.html) for usage if you are not familar with vLLM.
219
+ Presently, vLLM only supports static YARN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts**.
220
+ We advise adding the `rope_scaling` configuration only when processing long contexts is required.
221
+
222
+ ## Evaluation & Performance
223
+
224
+ Detailed evaluation results are reported in this [📑 blog](https://qwenlm.github.io/blog/qwen2.5-coder-family/).
225
+
226
+ For requirements on GPU memory and the respective throughput, see results [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
227
+
228
+ ## Citation
229
+
230
+ If you find our work helpful, feel free to give us a cite.
231
+
232
+ ```
233
+ @article{hui2024qwen2,
234
+ title={Qwen2. 5-Coder Technical Report},
235
+ 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},
236
+ journal={arXiv preprint arXiv:2409.12186},
237
+ year={2024}
238
+ }
239
+ @article{qwen2,
240
+ title={Qwen2 Technical Report},
241
+ 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},
242
+ journal={arXiv preprint arXiv:2407.10671},
243
+ year={2024}
244
+ }
245
+ ```