TheBloke commited on
Commit
29cf42e
1 Parent(s): 2bf9779

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +467 -0
README.md ADDED
@@ -0,0 +1,467 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: https://huggingface.co/codefuse-ai/CodeFuse-CodeLlama-34B
3
+ inference: false
4
+ license: other
5
+ model_creator: CodeFuse AI
6
+ model_name: CodeFuse CodeLlama 34B
7
+ model_type: llama
8
+ quantized_by: TheBloke
9
+ tasks:
10
+ - code-generation
11
+ ---
12
+
13
+ <!-- header start -->
14
+ <!-- 200823 -->
15
+ <div style="width: auto; margin-left: auto; margin-right: auto">
16
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
17
+ </div>
18
+ <div style="display: flex; justify-content: space-between; width: 100%;">
19
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
20
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
21
+ </div>
22
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
23
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
24
+ </div>
25
+ </div>
26
+ <div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">TheBloke's LLM work is generously supported by a grant from <a href="https://a16z.com">andreessen horowitz (a16z)</a></p></div>
27
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
28
+ <!-- header end -->
29
+
30
+ # CodeFuse CodeLlama 34B - GGUF
31
+ - Model creator: [CodeFuse AI](https://huggingface.co/codefuse-ai)
32
+ - Original model: [CodeFuse CodeLlama 34B](https://huggingface.co/codefuse-ai/CodeFuse-CodeLlama-34B)
33
+
34
+ <!-- description start -->
35
+ ## Description
36
+
37
+ This repo contains GGUF format model files for [CodeFuse AI's CodeFuse CodeLlama 34B](https://huggingface.co/codefuse-ai/CodeFuse-CodeLlama-34B).
38
+
39
+ <!-- description end -->
40
+ <!-- README_GGUF.md-about-gguf start -->
41
+ ### About GGUF
42
+
43
+ GGUF is a new format introduced by the llama.cpp team on August 21st 2023. It is a replacement for GGML, which is no longer supported by llama.cpp. GGUF offers numerous advantages over GGML, such as better tokenisation, and support for special tokens. It is also supports metadata, and is designed to be extensible.
44
+
45
+ Here is an incomplate list of clients and libraries that are known to support GGUF:
46
+
47
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
48
+ * [text-generation-webui](https://github.com/oobabooga/text-generation-webui), the most widely used web UI, with many features and powerful extensions. Supports GPU acceleration.
49
+ * [KoboldCpp](https://github.com/LostRuins/koboldcpp), a fully featured web UI, with GPU accel across all platforms and GPU architectures. Especially good for story telling.
50
+ * [LM Studio](https://lmstudio.ai/), an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration.
51
+ * [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui), a great web UI with many interesting and unique features, including a full model library for easy model selection.
52
+ * [Faraday.dev](https://faraday.dev/), an attractive and easy to use character-based chat GUI for Windows and macOS (both Silicon and Intel), with GPU acceleration.
53
+ * [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server.
54
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
55
+ * [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
56
+
57
+ <!-- README_GGUF.md-about-gguf end -->
58
+ <!-- repositories-available start -->
59
+ ## Repositories available
60
+
61
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GPTQ)
62
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF)
63
+ * [CodeFuse AI's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/codefuse-ai/CodeFuse-CodeLlama-34B)
64
+ <!-- repositories-available end -->
65
+
66
+ <!-- prompt-template start -->
67
+ ## Prompt template: CodeFuse
68
+
69
+ ```
70
+ <|role_start|>system<|role_end|>{system_message}
71
+ <|role_start|>human<|role_end|>{prompt}
72
+ <|role_start|>bot<|role_end|>
73
+
74
+ ```
75
+
76
+ <!-- prompt-template end -->
77
+ <!-- licensing start -->
78
+ ## Licensing
79
+
80
+ The creator of the source model has listed its license as `other`, and this quantization has therefore used that same license.
81
+
82
+ As this model is based on Llama 2, it is also subject to the Meta Llama 2 license terms, and the license files for that are additionally included. It should therefore be considered as being claimed to be licensed under both licenses. I contacted Hugging Face for clarification on dual licensing but they do not yet have an official position. Should this change, or should Meta provide any feedback on this situation, I will update this section accordingly.
83
+
84
+ In the meantime, any questions regarding licensing, and in particular how these two licenses might interact, should be directed to the original model repository: [CodeFuse AI's CodeFuse CodeLlama 34B](https://huggingface.co/codefuse-ai/CodeFuse-CodeLlama-34B).
85
+ <!-- licensing end -->
86
+ <!-- compatibility_gguf start -->
87
+ ## Compatibility
88
+
89
+ These quantised GGUFv2 files are compatible with llama.cpp from August 27th onwards, as of commit [d0cee0d36d5be95a0d9088b674dbb27354107221](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221)
90
+
91
+ They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
92
+
93
+ ## Explanation of quantisation methods
94
+ <details>
95
+ <summary>Click to see details</summary>
96
+
97
+ The new methods available are:
98
+ * GGML_TYPE_Q2_K - "type-1" 2-bit quantization in super-blocks containing 16 blocks, each block having 16 weight. Block scales and mins are quantized with 4 bits. This ends up effectively using 2.5625 bits per weight (bpw)
99
+ * GGML_TYPE_Q3_K - "type-0" 3-bit quantization in super-blocks containing 16 blocks, each block having 16 weights. Scales are quantized with 6 bits. This end up using 3.4375 bpw.
100
+ * GGML_TYPE_Q4_K - "type-1" 4-bit quantization in super-blocks containing 8 blocks, each block having 32 weights. Scales and mins are quantized with 6 bits. This ends up using 4.5 bpw.
101
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
102
+ * GGML_TYPE_Q6_K - "type-0" 6-bit quantization. Super-blocks with 16 blocks, each block having 16 weights. Scales are quantized with 8 bits. This ends up using 6.5625 bpw
103
+
104
+ Refer to the Provided Files table below to see what files use which methods, and how.
105
+ </details>
106
+ <!-- compatibility_gguf end -->
107
+
108
+ <!-- README_GGUF.md-provided-files start -->
109
+ ## Provided files
110
+
111
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
112
+ | ---- | ---- | ---- | ---- | ---- | ----- |
113
+ | [codefuse-codellama-34b.Q2_K.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q2_K.gguf) | Q2_K | 2 | 14.21 GB| 16.71 GB | smallest, significant quality loss - not recommended for most purposes |
114
+ | [codefuse-codellama-34b.Q3_K_S.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q3_K_S.gguf) | Q3_K_S | 3 | 14.61 GB| 17.11 GB | very small, high quality loss |
115
+ | [codefuse-codellama-34b.Q3_K_M.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q3_K_M.gguf) | Q3_K_M | 3 | 16.28 GB| 18.78 GB | very small, high quality loss |
116
+ | [codefuse-codellama-34b.Q3_K_L.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q3_K_L.gguf) | Q3_K_L | 3 | 17.77 GB| 20.27 GB | small, substantial quality loss |
117
+ | [codefuse-codellama-34b.Q4_0.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q4_0.gguf) | Q4_0 | 4 | 19.05 GB| 21.55 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
118
+ | [codefuse-codellama-34b.Q4_K_S.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q4_K_S.gguf) | Q4_K_S | 4 | 19.15 GB| 21.65 GB | small, greater quality loss |
119
+ | [codefuse-codellama-34b.Q4_K_M.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q4_K_M.gguf) | Q4_K_M | 4 | 20.22 GB| 22.72 GB | medium, balanced quality - recommended |
120
+ | [codefuse-codellama-34b.Q5_0.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q5_0.gguf) | Q5_0 | 5 | 23.24 GB| 25.74 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
121
+ | [codefuse-codellama-34b.Q5_K_S.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q5_K_S.gguf) | Q5_K_S | 5 | 23.24 GB| 25.74 GB | large, low quality loss - recommended |
122
+ | [codefuse-codellama-34b.Q5_K_M.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q5_K_M.gguf) | Q5_K_M | 5 | 23.84 GB| 26.34 GB | large, very low quality loss - recommended |
123
+ | [codefuse-codellama-34b.Q6_K.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q6_K.gguf) | Q6_K | 6 | 27.68 GB| 30.18 GB | very large, extremely low quality loss |
124
+ | [codefuse-codellama-34b.Q8_0.gguf](https://huggingface.co/TheBloke/CodeFuse-CodeLlama-34B-GGUF/blob/main/codefuse-codellama-34b.Q8_0.gguf) | Q8_0 | 8 | 35.86 GB| 38.36 GB | very large, extremely low quality loss - not recommended |
125
+
126
+ **Note**: the above RAM figures assume no GPU offloading. If layers are offloaded to the GPU, this will reduce RAM usage and use VRAM instead.
127
+
128
+
129
+
130
+ <!-- README_GGUF.md-provided-files end -->
131
+
132
+ <!-- README_GGUF.md-how-to-run start -->
133
+ ## Example `llama.cpp` command
134
+
135
+ Make sure you are using `llama.cpp` from commit [d0cee0d36d5be95a0d9088b674dbb27354107221](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
136
+
137
+ ```shell
138
+ ./main -ngl 32 -m codefuse-codellama-34b.q4_K_M.gguf --color -c 4096 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<|role_start|>system<|role_end|>{system_message}\n<|role_start|>human<|role_end|>{prompt}\n<|role_start|>bot<|role_end|>"
139
+ ```
140
+
141
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
142
+
143
+ Change `-c 4096` to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the GGUF file and set by llama.cpp automatically.
144
+
145
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
146
+
147
+ 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)
148
+
149
+ ## How to run in `text-generation-webui`
150
+
151
+ Further instructions here: [text-generation-webui/docs/llama.cpp.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/llama.cpp.md).
152
+
153
+ ## How to run from Python code
154
+
155
+ You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) or [ctransformers](https://github.com/marella/ctransformers) libraries.
156
+
157
+ ### How to load this model from Python using ctransformers
158
+
159
+ #### First install the package
160
+
161
+ ```bash
162
+ # Base ctransformers with no GPU acceleration
163
+ pip install ctransformers>=0.2.24
164
+ # Or with CUDA GPU acceleration
165
+ pip install ctransformers[cuda]>=0.2.24
166
+ # Or with ROCm GPU acceleration
167
+ CT_HIPBLAS=1 pip install ctransformers>=0.2.24 --no-binary ctransformers
168
+ # Or with Metal GPU acceleration for macOS systems
169
+ CT_METAL=1 pip install ctransformers>=0.2.24 --no-binary ctransformers
170
+ ```
171
+
172
+ #### Simple example code to load one of these GGUF models
173
+
174
+ ```python
175
+ from ctransformers import AutoModelForCausalLM
176
+
177
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
178
+ llm = AutoModelForCausalLM.from_pretrained("TheBloke/CodeFuse-CodeLlama-34B-GGUF", model_file="codefuse-codellama-34b.q4_K_M.gguf", model_type="llama", gpu_layers=50)
179
+
180
+ print(llm("AI is going to"))
181
+ ```
182
+
183
+ ## How to use with LangChain
184
+
185
+ Here's guides on using llama-cpp-python or ctransformers with LangChain:
186
+
187
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
188
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
189
+
190
+ <!-- README_GGUF.md-how-to-run end -->
191
+
192
+ <!-- footer start -->
193
+ <!-- 200823 -->
194
+ ## Discord
195
+
196
+ For further support, and discussions on these models and AI in general, join us at:
197
+
198
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
199
+
200
+ ## Thanks, and how to contribute
201
+
202
+ Thanks to the [chirper.ai](https://chirper.ai) team!
203
+
204
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
205
+
206
+ I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
207
+
208
+ If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
209
+
210
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
211
+
212
+ * Patreon: https://patreon.com/TheBlokeAI
213
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
214
+
215
+ **Special thanks to**: Aemon Algiz.
216
+
217
+ **Patreon special mentions**: Alicia Loh, Stephen Murray, K, Ajan Kanaga, RoA, Magnesian, Deo Leter, Olakabola, Eugene Pentland, zynix, Deep Realms, Raymond Fosdick, Elijah Stavena, Iucharbius, Erik Bjäreholt, Luis Javier Navarrete Lozano, Nicholas, theTransient, John Detwiler, alfie_i, knownsqashed, Mano Prime, Willem Michiel, Enrico Ros, LangChain4j, OG, Michael Dempsey, Pierre Kircher, Pedro Madruga, James Bentley, Thomas Belote, Luke @flexchar, Leonard Tan, Johann-Peter Hartmann, Illia Dulskyi, Fen Risland, Chadd, S_X, Jeff Scroggin, Ken Nordquist, Sean Connelly, Artur Olbinski, Swaroop Kallakuri, Jack West, Ai Maven, David Ziegler, Russ Johnson, transmissions 11, John Villwock, Alps Aficionado, Clay Pascal, Viktor Bowallius, Subspace Studios, Rainer Wilmers, Trenton Dambrowitz, vamX, Michael Levine, 준교 김, Brandon Frisco, Kalila, Trailburnt, Randy H, Talal Aujan, Nathan Dryer, Vadim, 阿明, ReadyPlayerEmma, Tiffany J. Kim, George Stoitzev, Spencer Kim, Jerry Meng, Gabriel Tamborski, Cory Kujawski, Jeffrey Morgan, Spiking Neurons AB, Edmond Seymore, Alexandros Triantafyllidis, Lone Striker, Cap'n Zoog, Nikolai Manek, danny, ya boyyy, Derek Yates, usrbinkat, Mandus, TL, Nathan LeClaire, subjectnull, Imad Khwaja, webtim, Raven Klaugh, Asp the Wyvern, Gabriel Puliatti, Caitlyn Gatomon, Joseph William Delisle, Jonathan Leane, Luke Pendergrass, SuperWojo, Sebastain Graf, Will Dee, Fred von Graf, Andrey, Dan Guido, Daniel P. Andersen, Nitin Borwankar, Elle, Vitor Caleffi, biorpg, jjj, NimbleBox.ai, Pieter, Matthew Berman, terasurfer, Michael Davis, Alex, Stanislav Ovsiannikov
218
+
219
+
220
+ Thank you to all my generous patrons and donaters!
221
+
222
+ And thank you again to a16z for their generous grant.
223
+
224
+ <!-- footer end -->
225
+
226
+ <!-- original-model-card start -->
227
+ # Original model card: CodeFuse AI's CodeFuse CodeLlama 34B
228
+
229
+ # Model Card for CodeFuse-CodeLlama-34B
230
+ ![logo](LOGO.png)
231
+
232
+ [[中文]](#chinese) [[English]](#english)
233
+
234
+
235
+
236
+ <a id="english"></a>
237
+
238
+ ## Model Description
239
+
240
+ CodeFuse-CodeLlama-34B is a 34B Code-LLM finetuned by QLoRA of multiple code tasks(600k instrunctions/answers) on the base model CodeLlama-34b-Python.
241
+ The context length of finetuning is 4K while it is able to be finetuned by 16k context if necessary.
242
+ <br>
243
+
244
+ ## News and Updates
245
+
246
+ 🔥🔥🔥 CodeFuse-CodeLlama34B-MFT has achived 74.4% of pass@1 on HumanEval, which is SOTA at present.
247
+
248
+ <br>
249
+
250
+ ## Performance
251
+
252
+
253
+ | Model | HumanEval(pass@1) | Date |
254
+ |:----------------------------|:-----------------:|:-------:|
255
+ | **CodeFuse-CodeLlama-34B** | **74.4%** | 2023.9 |
256
+ | WizardCoder-Python-34B-V1.0 | 73.2% | 2023.8 |
257
+ | GPT-4(zero-shot) | 67.0% | 2023.3 |
258
+ | PanGu-Coder2 15B | 61.6% | 2023.8 |
259
+ | CodeLlama-34b-Python | 53.7% | 2023.8 |
260
+ | CodeLlama-34b | 48.8% | 2023.8 |
261
+ | GPT-3.5(zero-shot) | 48.1% | 2022.11 |
262
+ | OctoCoder | 46.2% | 2023.8 |
263
+ | StarCoder-15B | 33.6% | 2023.5 |
264
+ | LLaMA 2 70B(zero-shot) | 29.9% | 2023.7 |
265
+
266
+ <br>
267
+
268
+ ## Requirements
269
+
270
+ * python>=3.8
271
+ * pytorch>=2.0.0
272
+ * transformers==4.32.0
273
+ * Sentencepiece
274
+ * CUDA 11.4
275
+ <br>
276
+
277
+ ## Inference String Format
278
+
279
+ The inference string is a concatenated string formed by combining conversation data(system, human and bot contents) in the training data format. It is used as input during the inference process.
280
+ Here is an example format of the concatenated string:
281
+
282
+ ```python
283
+ """
284
+ <|role_start|>system<|role_end|>System instruction
285
+ <|role_start|>human<|role_end|>Human 1st round input
286
+ <|role_start|>bot<|role_end|>Bot 1st round output</s>
287
+ <|role_start|>human<|role_end|>Human 2nd round input
288
+ <|role_start|>bot<|role_end|>Bot 2nd round output</s>
289
+ ...
290
+ ...
291
+ ...
292
+ <|role_start|>human<|role_end|>Human nth round input
293
+ <|role_start|>bot<|role_end|>{Bot output to be genreated}</s>
294
+ """
295
+ ```
296
+
297
+ When applying inference, you always make your input string end with "<|role_start|>bot<|role_end|>" to ask the model generating answers.
298
+
299
+ ## Quickstart
300
+
301
+ ```bash
302
+ pip install -r requirements.txt
303
+ ```
304
+
305
+ ```python
306
+ import torch
307
+ from transformers import (
308
+ AutoTokenizer,
309
+ AutoModelForCausalLM,
310
+ )
311
+ tokenizer = AutoTokenizer.from_pretrained(mode_name_or_path, trust_remote_code=True, use_fast=False, legacy=False)
312
+ tokenizer.padding_side = "left"
313
+ tokenizer.pad_token_id = tokenizer.convert_tokens_to_ids("<unk>")
314
+ tokenizer.eos_token_id = tokenizer.convert_tokens_to_ids("</s>")
315
+ # try 4bit loading if cuda memory not enough
316
+ model = AutoModelForCausalLM.from_pretrained(mode_name_or_path,
317
+ trust_remote_code=True,
318
+ load_in_4bit=False,
319
+ device_map="auto",
320
+ torch_dtype=torch.bfloat16)
321
+ model.eval()
322
+
323
+ HUMAN_ROLE_START_TAG = "<|role_start|>human<|role_end|>"
324
+ BOT_ROLE_START_TAG = "<|role_start|>bot<|role_end|>"
325
+
326
+ text = f"{HUMAN_ROLE_START_TAG}write a python function of quick sort.{BOT_ROLE_START_TAG}"
327
+ inputs = tokenizer(text, return_tensors='pt', padding=True, add_special_tokens=False).to("cuda")
328
+ outputs = model.generate(
329
+ inputs=inputs["input_ids"],
330
+ attention_mask=inputs["attention_mask"],
331
+ max_new_tokens=512,
332
+ top_p=0.95,
333
+ temperature=0.1,
334
+ do_sample=True,
335
+ eos_token_id=tokenizer.eos_token_id,
336
+ pad_token_id=tokenizer.pad_token_id
337
+ )
338
+ gen_text = tokenizer.batch_decode(outputs[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)
339
+ print(gen_text)
340
+ ```
341
+
342
+ ## MD5
343
+ We notice that the file may be corrupted during transfer process. Please check MD5 value before use.
344
+
345
+ | Model File | MD5 Value |
346
+ |:---------------------------------|:--------------------------------:|
347
+ | pytorch_model-00001-of-00007.bin | 8d544b1bcb3449934184d4141137329c |
348
+ | pytorch_model-00002-of-00007.bin | 9d5dbb30911e48a42fb6d0fcabb322a4 |
349
+ | pytorch_model-00003-of-00007.bin | b0d4aecee0457d9332005a187e1fffed |
350
+ | pytorch_model-00004-of-00007.bin | 5c7e002de5eab77d0194a2b0f6de0c24 |
351
+ | pytorch_model-00005-of-00007.bin | d22a511aa26b5b17117b665a877490ab |
352
+ | pytorch_model-00006-of-00007.bin | a5c28ac277fac07d16dd66537e54d109 |
353
+ | pytorch_model-00007-of-00007.bin | a967e2c6195477b7407089c0bffa2d53 |
354
+
355
+
356
+ <a id="chinese"></a>
357
+
358
+ ## 模型简介
359
+
360
+ CodeFuse-CodeLlama34B-MFT 是一个通过QLoRA对基座模型CodeLlama-34b-Python进行多代码任务微调的代码大模型。模型微调采用了4k上下文。如果有必要,可以扩展到16k。
361
+ <br>
362
+
363
+ ## 新闻
364
+
365
+ 🔥🔥🔥 CodeFuse-CodeLlama34B-MFT模型在HumanEval pass@1上可以达到74.4%, 为当前开源SOTA。
366
+
367
+ <br>
368
+
369
+ ## 评测表现(代码)
370
+
371
+ | 模型 | HumanEval(pass@1) | 日期 |
372
+ |:----------------------------|:-----------------:|:-------:|
373
+ | **CodeFuse-CodeLlama-34B** | **74.4%** | 2023.9 |
374
+ | WizardCoder-Python-34B-V1.0 | 73.2% | 2023.8 |
375
+ | GPT-4(zero-shot) | 67.0% | 2023.3 |
376
+ | PanGu-Coder2 15B | 61.6% | 2023.8 |
377
+ | CodeLlama-34b-Python | 53.7% | 2023.8 |
378
+ | CodeLlama-34b | 48.8% | 2023.8 |
379
+ | GPT-3.5(zero-shot) | 48.1% | 2022.11 |
380
+ | OctoCoder | 46.2% | 2023.8 |
381
+ | StarCoder-15B | 33.6% | 2023.5 |
382
+ | LLaMA 2 70B(zero-shot) | 29.9% | 2023.7 |
383
+
384
+ <br>
385
+
386
+ ## Requirements
387
+
388
+ * python>=3.8
389
+ * pytorch>=2.0.0
390
+ * transformers==4.32.0
391
+ * CUDA 11.4
392
+ <br>
393
+
394
+ ## 推理数据格式
395
+
396
+ 推理数据为模型在训练数据格式下拼接的字符串形式,它也是推理时输入prompt拼接的方式:
397
+
398
+ ```python
399
+ """
400
+ <|role_start|>system<|role_end|>这是System指令
401
+ <|role_start|>human<|role_end|>这是第1轮用户输入的问题
402
+ <|role_start|>bot<|role_end|>这是第1轮模型生成的内容</s>
403
+ <|role_start|>human<|role_end|>这是第2轮用户输入的问题
404
+ <|role_start|>bot<|role_end|>这是第2轮模型生成的内容</s>
405
+ ...
406
+ ...
407
+ ...
408
+ <|role_start|>human<|role_end|>这是第n轮用户输入的问题
409
+ <|role_start|>bot<|role_end|>{模型现在要生成的内容}</s>
410
+ """
411
+ ```
412
+
413
+ 推理时,请确保拼接的prompt字符串以"<|role_start|>bot<|role_end|>"结尾,引导模型生成回答。
414
+
415
+ ## 快速使用
416
+
417
+ ```python
418
+ from transformers import (
419
+ AutoTokenizer,
420
+ AutoModelForCausalLM,
421
+ )
422
+ tokenizer = AutoTokenizer.from_pretrained(mode_name_or_path, trust_remote_code=True, use_fast=False, legacy=False)
423
+ tokenizer.padding_side = "left"
424
+ tokenizer.pad_token_id = tokenizer.convert_tokens_to_ids("<unk>")
425
+ tokenizer.eos_token_id = tokenizer.convert_tokens_to_ids("</s>")
426
+ # 如果显存不够,可以考虑量化加载
427
+ model = AutoModelForCausalLM.from_pretrained(mode_name_or_path,
428
+ trust_remote_code=True,
429
+ load_in_4bit=False,
430
+ device_map="auto",
431
+ torch_dtype=torch.bfloat16)
432
+ model.eval()
433
+
434
+ HUMAN_ROLE_START_TAG = "<|role_start|>human<|role_end|>"
435
+ BOT_ROLE_START_TAG = "<|role_start|>bot<|role_end|>"
436
+
437
+ text = f"{HUMAN_ROLE_START_TAG}请用C++实现求解第n个斐波那契数{BOT_ROLE_START_TAG}"
438
+ inputs = tokenizer(text, return_tensors='pt', padding=True, add_special_tokens=False).to("cuda")
439
+ outputs = model.generate(
440
+ inputs=inputs["input_ids"],
441
+ attention_mask=inputs["attention_mask"],
442
+ max_new_tokens=512,
443
+ top_p=0.95,
444
+ temperature=0.1,
445
+ do_sample=True,
446
+ eos_token_id=tokenizer.eos_token_id,
447
+ pad_token_id=tokenizer.pad_token_id
448
+ )
449
+ gen_text = tokenizer.batch_decode(outputs[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)
450
+ print(gen_text)
451
+ ```
452
+
453
+
454
+ ## MD5
455
+ 我们发现模型文件可能会在传输过程中损坏,使用前请检查文件MD5值。
456
+
457
+ | 模型文件 | MD5值 |
458
+ |:---------------------------------|:--------------------------------:|
459
+ | pytorch_model-00001-of-00007.bin | 8d544b1bcb3449934184d4141137329c |
460
+ | pytorch_model-00002-of-00007.bin | 9d5dbb30911e48a42fb6d0fcabb322a4 |
461
+ | pytorch_model-00003-of-00007.bin | b0d4aecee0457d9332005a187e1fffed |
462
+ | pytorch_model-00004-of-00007.bin | 5c7e002de5eab77d0194a2b0f6de0c24 |
463
+ | pytorch_model-00005-of-00007.bin | d22a511aa26b5b17117b665a877490ab |
464
+ | pytorch_model-00006-of-00007.bin | a5c28ac277fac07d16dd66537e54d109 |
465
+ | pytorch_model-00007-of-00007.bin | a967e2c6195477b7407089c0bffa2d53 |
466
+
467
+ <!-- original-model-card end -->