TheBloke commited on
Commit
2f24a6f
1 Parent(s): bd81f6b

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +555 -0
README.md ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: codellama/CodeLlama-70b-Instruct-hf
3
+ inference: false
4
+ language:
5
+ - code
6
+ license: llama2
7
+ model_creator: Code Llama
8
+ model_name: Codellama 70B Instruct
9
+ model_type: llama
10
+ pipeline_tag: text-generation
11
+ prompt_template: "Source: system\n\n {system_message}<step> Source: user\n\n {prompt}\
12
+ \ <step> Source: assistant\n \n"
13
+ quantized_by: TheBloke
14
+ tags:
15
+ - llama-2
16
+ ---
17
+ <!-- markdownlint-disable MD041 -->
18
+
19
+ <!-- header start -->
20
+ <!-- 200823 -->
21
+ <div style="width: auto; margin-left: auto; margin-right: auto">
22
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
23
+ </div>
24
+ <div style="display: flex; justify-content: space-between; width: 100%;">
25
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
26
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
27
+ </div>
28
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
29
+ <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>
30
+ </div>
31
+ </div>
32
+ <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>
33
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
34
+ <!-- header end -->
35
+
36
+ # Codellama 70B Instruct - GGUF
37
+ - Model creator: [Code Llama](https://huggingface.co/codellama)
38
+ - Original model: [Codellama 70B Instruct](https://huggingface.co/codellama/CodeLlama-70b-Instruct-hf)
39
+
40
+ <!-- description start -->
41
+ ## Description
42
+
43
+ This repo contains GGUF format model files for [Code Llama's Codellama 70B Instruct](https://huggingface.co/codellama/CodeLlama-70b-Instruct-hf).
44
+
45
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
46
+
47
+ <!-- description end -->
48
+ <!-- README_GGUF.md-about-gguf start -->
49
+ ### About GGUF
50
+
51
+ 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.
52
+
53
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
54
+
55
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
56
+ * [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.
57
+ * [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.
58
+ * [GPT4All](https://gpt4all.io/index.html), a free and open source local running GUI, supporting Windows, Linux and macOS with full GPU accel.
59
+ * [LM Studio](https://lmstudio.ai/), an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration. Linux available, in beta as of 27/11/2023.
60
+ * [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.
61
+ * [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.
62
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
63
+ * [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
64
+ * [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server. Note, as of time of writing (November 27th 2023), ctransformers has not been updated in a long time and does not support many recent models.
65
+
66
+ <!-- README_GGUF.md-about-gguf end -->
67
+ <!-- repositories-available start -->
68
+ ## Repositories available
69
+
70
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-AWQ)
71
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GPTQ)
72
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF)
73
+ * [Code Llama's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/codellama/CodeLlama-70b-Instruct-hf)
74
+ <!-- repositories-available end -->
75
+
76
+ <!-- prompt-template start -->
77
+ ## Prompt template: CodeLlama-70B-Instruct
78
+
79
+ ```
80
+ Source: system
81
+
82
+ {system_message}<step> Source: user
83
+
84
+ {prompt} <step> Source: assistant
85
+
86
+
87
+ ```
88
+
89
+ <!-- prompt-template end -->
90
+
91
+
92
+ <!-- compatibility_gguf start -->
93
+ ## Compatibility
94
+
95
+ These quantised GGUFv2 files are compatible with llama.cpp from August 27th onwards, as of commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221)
96
+
97
+ They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
98
+
99
+ ## Explanation of quantisation methods
100
+
101
+ <details>
102
+ <summary>Click to see details</summary>
103
+
104
+ The new methods available are:
105
+
106
+ * 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)
107
+ * 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.
108
+ * 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.
109
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
110
+ * 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
111
+
112
+ Refer to the Provided Files table below to see what files use which methods, and how.
113
+ </details>
114
+ <!-- compatibility_gguf end -->
115
+
116
+ <!-- README_GGUF.md-provided-files start -->
117
+ ## Provided files
118
+
119
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
120
+ | ---- | ---- | ---- | ---- | ---- | ----- |
121
+ | [codellama-70b-instruct.Q2_K.gguf](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF/blob/main/codellama-70b-instruct.Q2_K.gguf) | Q2_K | 2 | 25.46 GB| 27.96 GB | significant quality loss - not recommended for most purposes |
122
+ | [codellama-70b-instruct.Q3_K_S.gguf](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF/blob/main/codellama-70b-instruct.Q3_K_S.gguf) | Q3_K_S | 3 | 29.92 GB| 32.42 GB | very small, high quality loss |
123
+ | [codellama-70b-instruct.Q3_K_M.gguf](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF/blob/main/codellama-70b-instruct.Q3_K_M.gguf) | Q3_K_M | 3 | 33.27 GB| 35.77 GB | very small, high quality loss |
124
+ | [codellama-70b-instruct.Q3_K_L.gguf](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF/blob/main/codellama-70b-instruct.Q3_K_L.gguf) | Q3_K_L | 3 | 36.15 GB| 38.65 GB | small, substantial quality loss |
125
+ | [codellama-70b-instruct.Q4_0.gguf](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF/blob/main/codellama-70b-instruct.Q4_0.gguf) | Q4_0 | 4 | 38.87 GB| 41.37 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
126
+ | [codellama-70b-instruct.Q4_K_S.gguf](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF/blob/main/codellama-70b-instruct.Q4_K_S.gguf) | Q4_K_S | 4 | 39.25 GB| 41.75 GB | small, greater quality loss |
127
+ | [codellama-70b-instruct.Q4_K_M.gguf](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF/blob/main/codellama-70b-instruct.Q4_K_M.gguf) | Q4_K_M | 4 | 41.42 GB| 43.92 GB | medium, balanced quality - recommended |
128
+ | [codellama-70b-instruct.Q5_0.gguf](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF/blob/main/codellama-70b-instruct.Q5_0.gguf) | Q5_0 | 5 | 47.46 GB| 49.96 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
129
+ | [codellama-70b-instruct.Q5_K_S.gguf](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF/blob/main/codellama-70b-instruct.Q5_K_S.gguf) | Q5_K_S | 5 | 47.46 GB| 49.96 GB | large, low quality loss - recommended |
130
+ | [codellama-70b-instruct.Q5_K_M.gguf](https://huggingface.co/TheBloke/CodeLlama-70B-Instruct-GGUF/blob/main/codellama-70b-instruct.Q5_K_M.gguf) | Q5_K_M | 5 | 48.75 GB| 51.25 GB | large, very low quality loss - recommended |
131
+ | codellama-70b-instruct.Q6_K.gguf | Q6_K | 6 | 56.59 GB| 59.09 GB | very large, extremely low quality loss |
132
+ | codellama-70b-instruct.Q8_0.gguf | Q8_0 | 8 | 73.29 GB| 75.79 GB | very large, extremely low quality loss - not recommended |
133
+
134
+ **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.
135
+
136
+ ### Q6_K and Q8_0 files are split and require joining
137
+
138
+ **Note:** HF does not support uploading files larger than 50GB. Therefore I have uploaded the Q6_K and Q8_0 files as split files.
139
+
140
+ <details>
141
+ <summary>Click for instructions regarding Q6_K and Q8_0 files</summary>
142
+
143
+ ### q6_K
144
+ Please download:
145
+ * `codellama-70b-instruct.Q6_K.gguf-split-a`
146
+ * `codellama-70b-instruct.Q6_K.gguf-split-b`
147
+
148
+ ### q8_0
149
+ Please download:
150
+ * `codellama-70b-instruct.Q8_0.gguf-split-a`
151
+ * `codellama-70b-instruct.Q8_0.gguf-split-b`
152
+
153
+ To join the files, do the following:
154
+
155
+ Linux and macOS:
156
+ ```
157
+ cat codellama-70b-instruct.Q6_K.gguf-split-* > codellama-70b-instruct.Q6_K.gguf && rm codellama-70b-instruct.Q6_K.gguf-split-*
158
+ cat codellama-70b-instruct.Q8_0.gguf-split-* > codellama-70b-instruct.Q8_0.gguf && rm codellama-70b-instruct.Q8_0.gguf-split-*
159
+ ```
160
+ Windows command line:
161
+ ```
162
+ COPY /B codellama-70b-instruct.Q6_K.gguf-split-a + codellama-70b-instruct.Q6_K.gguf-split-b codellama-70b-instruct.Q6_K.gguf
163
+ del codellama-70b-instruct.Q6_K.gguf-split-a codellama-70b-instruct.Q6_K.gguf-split-b
164
+
165
+ COPY /B codellama-70b-instruct.Q8_0.gguf-split-a + codellama-70b-instruct.Q8_0.gguf-split-b codellama-70b-instruct.Q8_0.gguf
166
+ del codellama-70b-instruct.Q8_0.gguf-split-a codellama-70b-instruct.Q8_0.gguf-split-b
167
+ ```
168
+
169
+ </details>
170
+ <!-- README_GGUF.md-provided-files end -->
171
+
172
+ <!-- README_GGUF.md-how-to-download start -->
173
+ ## How to download GGUF files
174
+
175
+ **Note for manual downloaders:** You almost never want to clone the entire repo! Multiple different quantisation formats are provided, and most users only want to pick and download a single file.
176
+
177
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
178
+
179
+ * LM Studio
180
+ * LoLLMS Web UI
181
+ * Faraday.dev
182
+
183
+ ### In `text-generation-webui`
184
+
185
+ Under Download Model, you can enter the model repo: TheBloke/CodeLlama-70B-Instruct-GGUF and below it, a specific filename to download, such as: codellama-70b-instruct.Q4_K_M.gguf.
186
+
187
+ Then click Download.
188
+
189
+ ### On the command line, including multiple files at once
190
+
191
+ I recommend using the `huggingface-hub` Python library:
192
+
193
+ ```shell
194
+ pip3 install huggingface-hub
195
+ ```
196
+
197
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
198
+
199
+ ```shell
200
+ huggingface-cli download TheBloke/CodeLlama-70B-Instruct-GGUF codellama-70b-instruct.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
201
+ ```
202
+
203
+ <details>
204
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
205
+
206
+ You can also download multiple files at once with a pattern:
207
+
208
+ ```shell
209
+ huggingface-cli download TheBloke/CodeLlama-70B-Instruct-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
210
+ ```
211
+
212
+ For more documentation on downloading with `huggingface-cli`, please see: [HF -> Hub Python Library -> Download files -> Download from the CLI](https://huggingface.co/docs/huggingface_hub/guides/download#download-from-the-cli).
213
+
214
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
215
+
216
+ ```shell
217
+ pip3 install hf_transfer
218
+ ```
219
+
220
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
221
+
222
+ ```shell
223
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/CodeLlama-70B-Instruct-GGUF codellama-70b-instruct.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
224
+ ```
225
+
226
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
227
+ </details>
228
+ <!-- README_GGUF.md-how-to-download end -->
229
+
230
+ <!-- README_GGUF.md-how-to-run start -->
231
+ ## Example `llama.cpp` command
232
+
233
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
234
+
235
+ ```shell
236
+ ./main -ngl 35 -m codellama-70b-instruct.Q4_K_M.gguf --color -c 4096 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "Source: system\n\n {system_message}<step> Source: user\n\n {prompt} <step> Source: assistant"
237
+ ```
238
+
239
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
240
+
241
+ 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. Note that longer sequence lengths require much more resources, so you may need to reduce this value.
242
+
243
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
244
+
245
+ 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)
246
+
247
+ ## How to run in `text-generation-webui`
248
+
249
+ Further instructions can be found in the text-generation-webui documentation, here: [text-generation-webui/docs/04 ‐ Model Tab.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/04%20%E2%80%90%20Model%20Tab.md#llamacpp).
250
+
251
+ ## How to run from Python code
252
+
253
+ 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. Note that at the time of writing (Nov 27th 2023), ctransformers has not been updated for some time and is not compatible with some recent models. Therefore I recommend you use llama-cpp-python.
254
+
255
+ ### How to load this model in Python code, using llama-cpp-python
256
+
257
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
258
+
259
+ #### First install the package
260
+
261
+ Run one of the following commands, according to your system:
262
+
263
+ ```shell
264
+ # Base ctransformers with no GPU acceleration
265
+ pip install llama-cpp-python
266
+ # With NVidia CUDA acceleration
267
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
268
+ # Or with OpenBLAS acceleration
269
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
270
+ # Or with CLBLast acceleration
271
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
272
+ # Or with AMD ROCm GPU acceleration (Linux only)
273
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
274
+ # Or with Metal GPU acceleration for macOS systems only
275
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
276
+
277
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
278
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
279
+ pip install llama-cpp-python
280
+ ```
281
+
282
+ #### Simple llama-cpp-python example code
283
+
284
+ ```python
285
+ from llama_cpp import Llama
286
+
287
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
288
+ llm = Llama(
289
+ model_path="./codellama-70b-instruct.Q4_K_M.gguf", # Download the model file first
290
+ n_ctx=4096, # The max sequence length to use - note that longer sequence lengths require much more resources
291
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
292
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
293
+ )
294
+
295
+ # Simple inference example
296
+ output = llm(
297
+ "Source: system\n\n {system_message}<step> Source: user\n\n {prompt} <step> Source: assistant", # Prompt
298
+ max_tokens=512, # Generate up to 512 tokens
299
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
300
+ echo=True # Whether to echo the prompt
301
+ )
302
+
303
+ # Chat Completion API
304
+
305
+ llm = Llama(model_path="./codellama-70b-instruct.Q4_K_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
306
+ llm.create_chat_completion(
307
+ messages = [
308
+ {"role": "system", "content": "You are a story writing assistant."},
309
+ {
310
+ "role": "user",
311
+ "content": "Write a story about llamas."
312
+ }
313
+ ]
314
+ )
315
+ ```
316
+
317
+ ## How to use with LangChain
318
+
319
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
320
+
321
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
322
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
323
+
324
+ <!-- README_GGUF.md-how-to-run end -->
325
+
326
+ <!-- footer start -->
327
+ <!-- 200823 -->
328
+ ## Discord
329
+
330
+ For further support, and discussions on these models and AI in general, join us at:
331
+
332
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
333
+
334
+ ## Thanks, and how to contribute
335
+
336
+ Thanks to the [chirper.ai](https://chirper.ai) team!
337
+
338
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
339
+
340
+ 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.
341
+
342
+ 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.
343
+
344
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
345
+
346
+ * Patreon: https://patreon.com/TheBlokeAI
347
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
348
+
349
+ **Special thanks to**: Aemon Algiz.
350
+
351
+ **Patreon special mentions**: Michael Levine, 阿明, Trailburnt, Nikolai Manek, John Detwiler, Randy H, Will Dee, Sebastain Graf, NimbleBox.ai, Eugene Pentland, Emad Mostaque, Ai Maven, Jim Angel, Jeff Scroggin, Michael Davis, Manuel Alberto Morcote, Stephen Murray, Robert, Justin Joy, Luke @flexchar, Brandon Frisco, Elijah Stavena, S_X, Dan Guido, Undi ., Komninos Chatzipapas, Shadi, theTransient, Lone Striker, Raven Klaugh, jjj, Cap'n Zoog, Michel-Marie MAUDET (LINAGORA), Matthew Berman, David, Fen Risland, Omer Bin Jawed, Luke Pendergrass, Kalila, OG, Erik Bjäreholt, Rooh Singh, Joseph William Delisle, Dan Lewis, TL, John Villwock, AzureBlack, Brad, Pedro Madruga, Caitlyn Gatomon, K, jinyuan sun, Mano Prime, Alex, Jeffrey Morgan, Alicia Loh, Illia Dulskyi, Chadd, transmissions 11, fincy, Rainer Wilmers, ReadyPlayerEmma, knownsqashed, Mandus, biorpg, Deo Leter, Brandon Phillips, SuperWojo, Sean Connelly, Iucharbius, Jack West, Harry Royden McLaughlin, Nicholas, terasurfer, Vitor Caleffi, Duane Dunston, Johann-Peter Hartmann, David Ziegler, Olakabola, Ken Nordquist, Trenton Dambrowitz, Tom X Nguyen, Vadim, Ajan Kanaga, Leonard Tan, Clay Pascal, Alexandros Triantafyllidis, JM33133, Xule, vamX, ya boyyy, subjectnull, Talal Aujan, Alps Aficionado, wassieverse, Ari Malik, James Bentley, Woland, Spencer Kim, Michael Dempsey, Fred von Graf, Elle, zynix, William Richards, Stanislav Ovsiannikov, Edmond Seymore, Jonathan Leane, Martin Kemka, usrbinkat, Enrico Ros
352
+
353
+
354
+ Thank you to all my generous patrons and donaters!
355
+
356
+ And thank you again to a16z for their generous grant.
357
+
358
+ <!-- footer end -->
359
+
360
+ <!-- original-model-card start -->
361
+ # Original model card: Code Llama's Codellama 70B Instruct
362
+
363
+ # **Code Llama**
364
+ Code Llama is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. This is the repository for the 70B instruct-tuned version in the Hugging Face Transformers format. This model is designed for general code synthesis and understanding. Links to other models can be found in the index at the bottom.
365
+
366
+ | | Base Model | Python | Instruct |
367
+ | --- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
368
+ | 7B | [codellama/CodeLlama-7b-hf](https://huggingface.co/codellama/CodeLlama-7b-hf) | [codellama/CodeLlama-7b-Python-hf](https://huggingface.co/codellama/CodeLlama-7b-Python-hf) | [codellama/CodeLlama-7b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-7b-Instruct-hf) |
369
+ | 13B | [codellama/CodeLlama-13b-hf](https://huggingface.co/codellama/CodeLlama-13b-hf) | [codellama/CodeLlama-13b-Python-hf](https://huggingface.co/codellama/CodeLlama-13b-Python-hf) | [codellama/CodeLlama-13b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-13b-Instruct-hf) |
370
+ | 34B | [codellama/CodeLlama-34b-hf](https://huggingface.co/codellama/CodeLlama-34b-hf) | [codellama/CodeLlama-34b-Python-hf](https://huggingface.co/codellama/CodeLlama-34b-Python-hf) | [codellama/CodeLlama-34b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-34b-Instruct-hf) |
371
+ | 70B | [codellama/CodeLlama-70b-hf](https://huggingface.co/codellama/CodeLlama-70b-hf) | [codellama/CodeLlama-70b-Python-hf](https://huggingface.co/codellama/CodeLlama-70b-Python-hf) | [codellama/CodeLlama-70b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-70b-Instruct-hf) |
372
+
373
+ Model capabilities:
374
+
375
+ - [x] Code completion.
376
+ - [ ] Infilling.
377
+ - [x] Instructions / chat.
378
+ - [ ] Python specialist.
379
+
380
+ ## Model Use
381
+
382
+ Install `transformers`
383
+
384
+ ```bash
385
+ pip install transformers accelerate
386
+ ```
387
+
388
+ **Chat use:** The 70B Instruct model uses a [different prompt template](#chat_prompt) than the smaller versions. To use it with `transformers`, we recommend you use the built-in chat template:
389
+
390
+ ```py
391
+ from transformers import AutoTokenizer, AutoModelForCausalLM
392
+ import transformers
393
+ import torch
394
+
395
+ model_id = "codellama/CodeLlama-70b-Instruct-hf"
396
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
397
+ model = AutoModelForCausalLM.from_pretrained(
398
+ model_id,
399
+ torch_dtype=torch.float16,
400
+ device_map="auto",
401
+ )
402
+
403
+ chat = [
404
+ {"role": "system", "content": "You are a helpful and honest code assistant expert in JavaScript. Please, provide all answers to programming questions in JavaScript"},
405
+ {"role": "user", "content": "Write a function that computes the set of sums of all contiguous sublists of a given list."},
406
+ ]
407
+ inputs = tokenizer.apply_chat_template(chat, return_tensors="pt").to("cuda")
408
+
409
+ output = model.generate(input_ids=inputs, max_new_tokens=200)
410
+ output = output[0].to("cpu")
411
+ print(tokenizer.decode(output))
412
+ ```
413
+
414
+ You can also use the model for **text or code completion**. This examples uses transformers' `pipeline` interface:
415
+
416
+ ```py
417
+ from transformers import AutoTokenizer
418
+ import transformers
419
+ import torch
420
+
421
+ model_id = "codellama/CodeLlama-70b-hf"
422
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
423
+ pipeline = transformers.pipeline(
424
+ "text-generation",
425
+ model=model_id,
426
+ torch_dtype=torch.float16,
427
+ device_map="auto",
428
+ )
429
+
430
+ sequences = pipeline(
431
+ 'def fibonacci(',
432
+ do_sample=True,
433
+ temperature=0.2,
434
+ top_p=0.9,
435
+ num_return_sequences=1,
436
+ eos_token_id=tokenizer.eos_token_id,
437
+ max_length=100,
438
+ )
439
+ for seq in sequences:
440
+ print(f"Result: {seq['generated_text']}")
441
+ ```
442
+
443
+ <a name="chat_prompt"></a>
444
+ ## Chat prompt
445
+
446
+ CodeLlama 70B Instruct uses a different format for the chat prompt than previous Llama 2 or CodeLlama models. As mentioned above, the easiest way to use it is with the help of the tokenizer's chat template. If you need to build the string or tokens, manually, here's how to do it.
447
+
448
+ We'll do our tests with the following made-up dialog:
449
+
450
+ ```py
451
+ chat = [
452
+ {"role": "system", "content": "System prompt "},
453
+ {"role": "user", "content": "First user query"},
454
+ {"role": "assistant", "content": "Model response to first query"},
455
+ {"role": "user", "content": "Second user query"},
456
+ ]
457
+ ```
458
+
459
+ First, let's see what the prompt looks like if we use the chat template:
460
+
461
+ ```py
462
+ tokenizer.apply_chat_template(chat, tokenize=False)
463
+ ```
464
+
465
+ ```
466
+ '<s>Source: system\n\n System prompt <step> Source: user\n\n First user query <step> Source: assistant\n\n Model response to first query <step> Source: user\n\n Second user query <step> Source: assistant\nDestination: user\n\n '
467
+ ```
468
+
469
+ So each turn of the conversation has a `Source` (`system`, `user`, or `assistant`), and then the content appears after two newlines and a space. Turns are separated with the special token ` <step> `. After the last turn (which must necessarily come from the `user`), we invite the model to respond by using the special syntax `Source: assistant\nDestination: user\n\n `. Let's see how we can build the same string ourselves:
470
+
471
+ ```py
472
+ output = "<s>"
473
+ for m in chat:
474
+ output += f"Source: {m['role']}\n\n {m['content'].strip()}"
475
+ output += " <step> "
476
+ output += "Source: assistant\nDestination: user\n\n "
477
+ output
478
+ ```
479
+
480
+ ```
481
+ '<s>Source: system\n\n System prompt <step> Source: user\n\n First user query <step> Source: assistant\n\n Model response to first query <step> Source: user\n\n Second user query <step> Source: assistant\nDestination: user\n\n '
482
+ ```
483
+
484
+ To verify that we got it right, we'll compare against the [reference code in the original GitHub repo](https://github.com/facebookresearch/codellama/blob/1af62e1f43db1fa5140fa43cb828465a603a48f3/llama/generation.py#L506). We used the same dialog and tokenized it with the `dialog_prompt_tokens` function and got the following tokens:
485
+
486
+ ```py
487
+ reference_tokens = [1, 7562, 29901, 1788, 13, 13, 2184, 9508, 32015, 7562, 29901, 1404, 13, 13, 3824, 1404, 2346, 32015, 7562, 29901, 20255, 13, 13, 8125, 2933, 304, 937, 2346, 32015, 7562, 29901, 1404, 13, 13, 6440, 1404, 2346, 32015, 7562, 29901, 20255, 13, 14994, 3381, 29901, 1404, 13, 13, 29871]
488
+ ```
489
+
490
+ Let's see what we get with the string we built using our Python loop. Note that we don't add "special tokens" because the string already starts with `<s>`, the beginning of sentence token:
491
+
492
+ ```py
493
+ tokens = tokenizer.encode(output, add_special_tokens=False)
494
+ assert reference_tokens == tokens
495
+ ```
496
+
497
+ Similarly, let's verify that the chat template produces the same token sequence:
498
+
499
+ ```py
500
+ assert reference_tokens == tokenizer.apply_chat_template(chat)
501
+ ```
502
+
503
+ As a final detail, please note that if the dialog does not start with a `system` turn, the [original code will insert one with an empty content string](https://github.com/facebookresearch/codellama/blob/1af62e1f43db1fa5140fa43cb828465a603a48f3/llama/generation.py#L418).
504
+
505
+
506
+ ## Model Details
507
+ *Note: Use of this model is governed by the Meta license. Meta developed and publicly released the Code Llama family of large language models (LLMs).
508
+
509
+ **Model Developers** Meta
510
+
511
+ **Variations** Code Llama comes in four model sizes, and three variants:
512
+
513
+ * Code Llama: base models designed for general code synthesis and understanding
514
+ * Code Llama - Python: designed specifically for Python
515
+ * Code Llama - Instruct: for instruction following and safer deployment
516
+
517
+ All variants are available in sizes of 7B, 13B, 34B, and 70B parameters.
518
+
519
+ **This repository contains the Instruct version of the 70B parameters model.**
520
+
521
+ **Input** Models input text only.
522
+
523
+ **Output** Models generate text only.
524
+
525
+ **Model Architecture** Code Llama is an auto-regressive language model that uses an optimized transformer architecture. It was fine-tuned with up to 16k tokens. This variant **does not** support long context of up to 100k tokens.
526
+
527
+ **Model Dates** Code Llama and its variants have been trained between January 2023 and January 2024.
528
+
529
+ **Status** This is a static model trained on an offline dataset. Future versions of Code Llama - Instruct will be released as we improve model safety with community feedback.
530
+
531
+ **License** A custom commercial license is available at: [https://ai.meta.com/resources/models-and-libraries/llama-downloads/](https://ai.meta.com/resources/models-and-libraries/llama-downloads/)
532
+
533
+ **Research Paper** More information can be found in the paper "[Code Llama: Open Foundation Models for Code](https://ai.meta.com/research/publications/code-llama-open-foundation-models-for-code/)" or its [arXiv page](https://arxiv.org/abs/2308.12950).
534
+
535
+ ## Intended Use
536
+ **Intended Use Cases** Code Llama and its variants are intended for commercial and research use in English and relevant programming languages. The base model Code Llama can be adapted for a variety of code synthesis and understanding tasks, Code Llama - Python is designed specifically to handle the Python programming language, and Code Llama - Instruct is intended to be safer to use for code assistant and generation applications.
537
+
538
+ **Out-of-Scope Uses** Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in languages other than English. Use in any other way that is prohibited by the Acceptable Use Policy and Licensing Agreement for Code Llama and its variants.
539
+
540
+ ## Hardware and Software
541
+ **Training Factors** We used custom training libraries. The training and fine-tuning of the released models have been performed Meta’s Research Super Cluster.
542
+ **Carbon Footprint** In aggregate, training all 12 Code Llama models required 1400K GPU hours of computation on hardware of type A100-80GB (TDP of 350-400W). Estimated total emissions were 228.55 tCO2eq, 100% of which were offset by Meta’s sustainability program.
543
+
544
+ ## Evaluation Results
545
+
546
+ See evaluations for the main models and detailed ablations in Section 3 and safety evaluations in Section 4 of the research paper.
547
+
548
+
549
+ ## Ethical Considerations and Limitations
550
+
551
+ Code Llama and its variants are a new technology that carries risks with use. Testing conducted to date has been in English, and has not covered, nor could it cover all scenarios. For these reasons, as with all LLMs, Code Llama’s potential outputs cannot be predicted in advance, and the model may in some instances produce inaccurate or objectionable responses to user prompts. Therefore, before deploying any applications of Code Llama, developers should perform safety testing and tuning tailored to their specific applications of the model.
552
+
553
+ Please see the Responsible Use Guide available available at [https://ai.meta.com/llama/responsible-use-guide](https://ai.meta.com/llama/responsible-use-guide).
554
+
555
+ <!-- original-model-card end -->