Transformers
GGUF
English
stablelm_epoch
causal-lm
code
Eval Results
7 papers
TheBloke commited on
Commit
32b38e7
1 Parent(s): ca63e29

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +576 -0
README.md ADDED
@@ -0,0 +1,576 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: stabilityai/stable-code-3b
3
+ datasets:
4
+ - tiiuae/falcon-refinedweb
5
+ - bigcode/the-stack-github-issues
6
+ - bigcode/commitpackft
7
+ - bigcode/starcoderdata
8
+ - EleutherAI/proof-pile-2
9
+ - meta-math/MetaMathQA
10
+ inference: false
11
+ language:
12
+ - en
13
+ library_name: transformers
14
+ license: other
15
+ metrics:
16
+ - code_eval
17
+ model-index:
18
+ - name: StarCoderBase-3B
19
+ results:
20
+ - dataset:
21
+ name: MultiPL-HumanEval (Python)
22
+ type: nuprl/MultiPL-E
23
+ metrics:
24
+ - name: pass@1
25
+ type: pass@1
26
+ value: 32.4
27
+ verified: false
28
+ task:
29
+ type: text-generation
30
+ - dataset:
31
+ name: MultiPL-HumanEval (C++)
32
+ type: nuprl/MultiPL-E
33
+ metrics:
34
+ - name: pass@1
35
+ type: pass@1
36
+ value: 30.9
37
+ verified: false
38
+ task:
39
+ type: text-generation
40
+ - dataset:
41
+ name: MultiPL-HumanEval (Java)
42
+ type: nuprl/MultiPL-E
43
+ metrics:
44
+ - name: pass@1
45
+ type: pass@1
46
+ value: 32.1
47
+ verified: false
48
+ task:
49
+ type: text-generation
50
+ - dataset:
51
+ name: MultiPL-HumanEval (JavaScript)
52
+ type: nuprl/MultiPL-E
53
+ metrics:
54
+ - name: pass@1
55
+ type: pass@1
56
+ value: 32.1
57
+ verified: false
58
+ task:
59
+ type: text-generation
60
+ - dataset:
61
+ name: MultiPL-HumanEval (PHP)
62
+ type: nuprl/MultiPL-E
63
+ metrics:
64
+ - name: pass@1
65
+ type: pass@1
66
+ value: 24.2
67
+ verified: false
68
+ task:
69
+ type: text-generation
70
+ - dataset:
71
+ name: MultiPL-HumanEval (Rust)
72
+ type: nuprl/MultiPL-E
73
+ metrics:
74
+ - name: pass@1
75
+ type: pass@1
76
+ value: 23.0
77
+ verified: false
78
+ task:
79
+ type: text-generation
80
+ model_creator: Stability AI
81
+ model_name: Stable Code 3B
82
+ model_type: stablelm_epoch
83
+ prompt_template: '{prompt}
84
+
85
+ '
86
+ quantized_by: TheBloke
87
+ tags:
88
+ - causal-lm
89
+ - code
90
+ ---
91
+ <!-- markdownlint-disable MD041 -->
92
+
93
+ <!-- header start -->
94
+ <!-- 200823 -->
95
+ <div style="width: auto; margin-left: auto; margin-right: auto">
96
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
97
+ </div>
98
+ <div style="display: flex; justify-content: space-between; width: 100%;">
99
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
100
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
101
+ </div>
102
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
103
+ <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>
104
+ </div>
105
+ </div>
106
+ <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>
107
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
108
+ <!-- header end -->
109
+
110
+ # Stable Code 3B - GGUF
111
+ - Model creator: [Stability AI](https://huggingface.co/stabilityai)
112
+ - Original model: [Stable Code 3B](https://huggingface.co/stabilityai/stable-code-3b)
113
+
114
+ <!-- description start -->
115
+ ## Description
116
+
117
+ This repo contains GGUF format model files for [Stability AI's Stable Code 3B](https://huggingface.co/stabilityai/stable-code-3b).
118
+
119
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
120
+
121
+ <!-- description end -->
122
+ <!-- README_GGUF.md-about-gguf start -->
123
+ ### About GGUF
124
+
125
+ 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.
126
+
127
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
128
+
129
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
130
+ * [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.
131
+ * [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.
132
+ * [GPT4All](https://gpt4all.io/index.html), a free and open source local running GUI, supporting Windows, Linux and macOS with full GPU accel.
133
+ * [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.
134
+ * [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.
135
+ * [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.
136
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
137
+ * [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
138
+ * [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.
139
+
140
+ <!-- README_GGUF.md-about-gguf end -->
141
+ <!-- repositories-available start -->
142
+ ## Repositories available
143
+
144
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/stable-code-3b-GPTQ)
145
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/stable-code-3b-GGUF)
146
+ * [Stability AI's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/stabilityai/stable-code-3b)
147
+ <!-- repositories-available end -->
148
+
149
+ <!-- prompt-template start -->
150
+ ## Prompt template: None
151
+
152
+ ```
153
+ {prompt}
154
+
155
+ ```
156
+
157
+ <!-- prompt-template end -->
158
+
159
+
160
+ <!-- compatibility_gguf start -->
161
+ ## Compatibility
162
+
163
+ 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)
164
+
165
+ They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
166
+
167
+ ## Explanation of quantisation methods
168
+
169
+ <details>
170
+ <summary>Click to see details</summary>
171
+
172
+ The new methods available are:
173
+
174
+ * 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)
175
+ * 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.
176
+ * 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.
177
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
178
+ * 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
179
+
180
+ Refer to the Provided Files table below to see what files use which methods, and how.
181
+ </details>
182
+ <!-- compatibility_gguf end -->
183
+
184
+ <!-- README_GGUF.md-provided-files start -->
185
+ ## Provided files
186
+
187
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
188
+ | ---- | ---- | ---- | ---- | ---- | ----- |
189
+ | [stable-code-3b.Q2_K.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q2_K.gguf) | Q2_K | 2 | 1.08 GB| 3.58 GB | significant quality loss - not recommended for most purposes |
190
+ | [stable-code-3b.Q3_K_S.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q3_K_S.gguf) | Q3_K_S | 3 | 1.25 GB| 3.75 GB | very small, high quality loss |
191
+ | [stable-code-3b.Q3_K_M.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q3_K_M.gguf) | Q3_K_M | 3 | 1.39 GB| 3.89 GB | very small, high quality loss |
192
+ | [stable-code-3b.Q3_K_L.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q3_K_L.gguf) | Q3_K_L | 3 | 1.51 GB| 4.01 GB | small, substantial quality loss |
193
+ | [stable-code-3b.Q4_0.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q4_0.gguf) | Q4_0 | 4 | 1.61 GB| 4.11 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
194
+ | [stable-code-3b.Q4_K_S.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q4_K_S.gguf) | Q4_K_S | 4 | 1.62 GB| 4.12 GB | small, greater quality loss |
195
+ | [stable-code-3b.Q4_K_M.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q4_K_M.gguf) | Q4_K_M | 4 | 1.71 GB| 4.21 GB | medium, balanced quality - recommended |
196
+ | [stable-code-3b.Q5_0.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q5_0.gguf) | Q5_0 | 5 | 1.94 GB| 4.44 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
197
+ | [stable-code-3b.Q5_K_S.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q5_K_S.gguf) | Q5_K_S | 5 | 1.94 GB| 4.44 GB | large, low quality loss - recommended |
198
+ | [stable-code-3b.Q5_K_M.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q5_K_M.gguf) | Q5_K_M | 5 | 1.99 GB| 4.49 GB | large, very low quality loss - recommended |
199
+ | [stable-code-3b.Q6_K.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q6_K.gguf) | Q6_K | 6 | 2.30 GB| 4.80 GB | very large, extremely low quality loss |
200
+ | [stable-code-3b.Q8_0.gguf](https://huggingface.co/TheBloke/stable-code-3b-GGUF/blob/main/stable-code-3b.Q8_0.gguf) | Q8_0 | 8 | 2.97 GB| 5.47 GB | very large, extremely low quality loss - not recommended |
201
+
202
+ **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.
203
+
204
+
205
+
206
+ <!-- README_GGUF.md-provided-files end -->
207
+
208
+ <!-- README_GGUF.md-how-to-download start -->
209
+ ## How to download GGUF files
210
+
211
+ **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.
212
+
213
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
214
+
215
+ * LM Studio
216
+ * LoLLMS Web UI
217
+ * Faraday.dev
218
+
219
+ ### In `text-generation-webui`
220
+
221
+ Under Download Model, you can enter the model repo: TheBloke/stable-code-3b-GGUF and below it, a specific filename to download, such as: stable-code-3b.Q4_K_M.gguf.
222
+
223
+ Then click Download.
224
+
225
+ ### On the command line, including multiple files at once
226
+
227
+ I recommend using the `huggingface-hub` Python library:
228
+
229
+ ```shell
230
+ pip3 install huggingface-hub
231
+ ```
232
+
233
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
234
+
235
+ ```shell
236
+ huggingface-cli download TheBloke/stable-code-3b-GGUF stable-code-3b.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
237
+ ```
238
+
239
+ <details>
240
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
241
+
242
+ You can also download multiple files at once with a pattern:
243
+
244
+ ```shell
245
+ huggingface-cli download TheBloke/stable-code-3b-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
246
+ ```
247
+
248
+ 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).
249
+
250
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
251
+
252
+ ```shell
253
+ pip3 install hf_transfer
254
+ ```
255
+
256
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
257
+
258
+ ```shell
259
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/stable-code-3b-GGUF stable-code-3b.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
260
+ ```
261
+
262
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
263
+ </details>
264
+ <!-- README_GGUF.md-how-to-download end -->
265
+
266
+ <!-- README_GGUF.md-how-to-run start -->
267
+ ## Example `llama.cpp` command
268
+
269
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
270
+
271
+ ```shell
272
+ ./main -ngl 35 -m stable-code-3b.Q4_K_M.gguf --color -c 16384 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "{prompt}"
273
+ ```
274
+
275
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
276
+
277
+ Change `-c 16384` 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.
278
+
279
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
280
+
281
+ 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)
282
+
283
+ ## How to run in `text-generation-webui`
284
+
285
+ 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).
286
+
287
+ ## How to run from Python code
288
+
289
+ 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.
290
+
291
+ ### How to load this model in Python code, using llama-cpp-python
292
+
293
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
294
+
295
+ #### First install the package
296
+
297
+ Run one of the following commands, according to your system:
298
+
299
+ ```shell
300
+ # Base ctransformers with no GPU acceleration
301
+ pip install llama-cpp-python
302
+ # With NVidia CUDA acceleration
303
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
304
+ # Or with OpenBLAS acceleration
305
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
306
+ # Or with CLBLast acceleration
307
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
308
+ # Or with AMD ROCm GPU acceleration (Linux only)
309
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
310
+ # Or with Metal GPU acceleration for macOS systems only
311
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
312
+
313
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
314
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
315
+ pip install llama-cpp-python
316
+ ```
317
+
318
+ #### Simple llama-cpp-python example code
319
+
320
+ ```python
321
+ from llama_cpp import Llama
322
+
323
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
324
+ llm = Llama(
325
+ model_path="./stable-code-3b.Q4_K_M.gguf", # Download the model file first
326
+ n_ctx=16384, # The max sequence length to use - note that longer sequence lengths require much more resources
327
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
328
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
329
+ )
330
+
331
+ # Simple inference example
332
+ output = llm(
333
+ "{prompt}", # Prompt
334
+ max_tokens=512, # Generate up to 512 tokens
335
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
336
+ echo=True # Whether to echo the prompt
337
+ )
338
+
339
+ # Chat Completion API
340
+
341
+ llm = Llama(model_path="./stable-code-3b.Q4_K_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
342
+ llm.create_chat_completion(
343
+ messages = [
344
+ {"role": "system", "content": "You are a story writing assistant."},
345
+ {
346
+ "role": "user",
347
+ "content": "Write a story about llamas."
348
+ }
349
+ ]
350
+ )
351
+ ```
352
+
353
+ ## How to use with LangChain
354
+
355
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
356
+
357
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
358
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
359
+
360
+ <!-- README_GGUF.md-how-to-run end -->
361
+
362
+ <!-- footer start -->
363
+ <!-- 200823 -->
364
+ ## Discord
365
+
366
+ For further support, and discussions on these models and AI in general, join us at:
367
+
368
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
369
+
370
+ ## Thanks, and how to contribute
371
+
372
+ Thanks to the [chirper.ai](https://chirper.ai) team!
373
+
374
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
375
+
376
+ 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.
377
+
378
+ 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.
379
+
380
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
381
+
382
+ * Patreon: https://patreon.com/TheBlokeAI
383
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
384
+
385
+ **Special thanks to**: Aemon Algiz.
386
+
387
+ **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
388
+
389
+
390
+ Thank you to all my generous patrons and donaters!
391
+
392
+ And thank you again to a16z for their generous grant.
393
+
394
+ <!-- footer end -->
395
+
396
+ <!-- original-model-card start -->
397
+ # Original model card: Stability AI's Stable Code 3B
398
+
399
+ # `stable-code-3b`
400
+
401
+ ## Model Description
402
+
403
+ `stable-code-3b` is a 2.7B billion parameter decoder-only language model pre-trained on 1.3 trillion tokens of diverse textual and code datasets. `stable-code-3b` is trained on 18 programming languages (selected based on the 2023 StackOverflow Developer Survey) and demonstrates state-of-the-art performance (compared to models of similar size) on the MultiPL-E metrics across multiple programming languages tested using [BigCode's Evaluation Harness](https://github.com/bigcode-project/bigcode-evaluation-harness/tree/main).
404
+
405
+ ![spiderchart](stable_code_3b_spiderchart.svg)
406
+
407
+ | Model | Size | Python | C++ | Javascript | Java | PHP | Rust |
408
+ |------------------|------|--------|------|------------|------|------|------|
409
+ | **Stable Code** | 3B | 32.4% | 30.9%| 32.1% | 32.1%| 24.2%| 23.0%|
410
+ | CodeLLama | 7B | 30.0% | 28.2%| 32.5% | 31.1%| 25.7%| 26.3%|
411
+ | Deepseek Coder | 1.3B | 28.6% | 29.2%| 28.7% | 29.0%| 23.6%| 18.5%|
412
+ | Wizard Coder | 3B | 31.6% | 25.6%| 26.2% | 25.8%| 25.3%| 20.4%|
413
+ | StarCoder | 3B | 21.6% | 19.8%| 21.5% | 20.5%| 19.0%| 16.9%|
414
+ | Replit Code V1.5 | 3B | 23.0% | 25.9%| 26.2% | 23.6%| 23.2%| 21.5%|
415
+ | Deci Coder | 1B | 19.1% | 6.8% | 18.4% | 16.7%| 2.1% | 1.7% |
416
+
417
+ **Key Features**
418
+ * Fill in Middle Capability (FIM)
419
+ * Supports Long Context, trained with Sequences upto 16,384
420
+
421
+ ## Usage
422
+
423
+ Get started generating text with `stable-code-3b` by using the following code snippet:
424
+
425
+ ```python
426
+ import torch
427
+ from transformers import AutoModelForCausalLM, AutoTokenizer
428
+ tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b", trust_remote_code=True)
429
+ model = AutoModelForCausalLM.from_pretrained(
430
+ "stabilityai/stable-code-3b",
431
+ trust_remote_code=True,
432
+ torch_dtype="auto",
433
+ )
434
+ model.cuda()
435
+ inputs = tokenizer("import torch\nimport torch.nn as nn", return_tensors="pt").to(model.device)
436
+ tokens = model.generate(
437
+ **inputs,
438
+ max_new_tokens=48,
439
+ temperature=0.2,
440
+ do_sample=True,
441
+ )
442
+ print(tokenizer.decode(tokens[0], skip_special_tokens=True))
443
+ ```
444
+
445
+ ### Run with Fill in Middle (FIM) ⚡️
446
+
447
+ <details>
448
+ <summary> Click to expand </summary>
449
+
450
+ ```python
451
+ from transformers import AutoModelForCausalLM, AutoTokenizer
452
+ tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b", trust_remote_code=True)
453
+ model = AutoModelForCausalLM.from_pretrained(
454
+ "stabilityai/stable-code-3b",
455
+ trust_remote_code=True,
456
+ torch_dtype="auto",
457
+ + attn_implementation="flash_attention_2",
458
+ )
459
+ model.cuda()
460
+ inputs = tokenizer("<fim_prefix>def fib(n):<fim_suffix> else:\n return fib(n - 2) + fib(n - 1)<fim_middle>", return_tensors="pt").to(model.device)
461
+ tokens = model.generate(
462
+ **inputs,
463
+ max_new_tokens=48,
464
+ temperature=0.2,
465
+ do_sample=True,
466
+ )
467
+ print(tokenizer.decode(tokens[0], skip_special_tokens=True))
468
+ ```
469
+
470
+ </details>
471
+
472
+ ### Run with Flash Attention 2 ⚡️
473
+
474
+ <details>
475
+ <summary> Click to expand </summary>
476
+
477
+ ```python
478
+ from transformers import AutoModelForCausalLM, AutoTokenizer
479
+ tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b", trust_remote_code=True)
480
+ model = AutoModelForCausalLM.from_pretrained(
481
+ "stabilityai/stable-code-3b",
482
+ trust_remote_code=True,
483
+ torch_dtype="auto",
484
+ + attn_implementation="flash_attention_2",
485
+ )
486
+ model.cuda()
487
+ inputs = tokenizer("import torch\nimport torch.nn as nn", return_tensors="pt").to(model.device)
488
+ tokens = model.generate(
489
+ **inputs,
490
+ max_new_tokens=48,
491
+ temperature=0.2,
492
+ do_sample=True,
493
+ )
494
+ print(tokenizer.decode(tokens[0], skip_special_tokens=True))
495
+ ```
496
+
497
+ </details>
498
+
499
+
500
+ ## Model Details
501
+
502
+ * **Developed by**: [Stability AI](https://stability.ai/)
503
+ * **Model type**: `stable-code-3b` models are auto-regressive language models based on the transformer decoder architecture.
504
+ * **Language(s)**: English, Code
505
+ * **Library**: [GPT-NeoX](https://github.com/EleutherAI/gpt-neox)
506
+ * **License**: Other
507
+ * **Contact**: For questions and comments about the model, please email `lm@stability.ai`
508
+
509
+ ### Model Architecture
510
+
511
+ The model is a decoder-only transformer similar to the LLaMA ([Touvron et al., 2023](https://arxiv.org/abs/2307.09288)) architecture with the following modifications:
512
+
513
+ | Parameters | Hidden Size | Layers | Heads | Sequence Length |
514
+ |----------------|-------------|--------|-------|-----------------|
515
+ | 2,796,431,360 | 2560 | 32 | 32 | 16384 |
516
+
517
+ * **Position Embeddings**: Rotary Position Embeddings ([Su et al., 2021](https://arxiv.org/abs/2104.09864)) applied to the first 25% of head embedding dimensions for improved throughput following [Black et al. (2022)](https://arxiv.org/pdf/2204.06745.pdf).
518
+ * **Tokenizer**: We use a modified version of the GPTNeoX Tokenizer.[`NeoX`](https://github.com/EleutherAI/gpt-neox). We add special tokens to train for Fill in the Middle (FIM) capabilities like `<FIM_PREFIX>` and `<FIM_SUFFIX>` along with other special tokens.
519
+
520
+ ## Training
521
+
522
+ ### Training Dataset
523
+
524
+ The dataset is comprised of a filtered mixture of open-source large-scale datasets available on the [HuggingFace Hub](https://huggingface.co/datasets): Falcon RefinedWeb extract ([Penedo et al., 2023](https://huggingface.co/datasets/tiiuae/falcon-refinedweb)), along with [CommitPackFT](https://huggingface.co/datasets/bigcode/commitpackft) and [Github Issues](https://huggingface.co/datasets/bigcode/the-stack-github-issues) (BigCode., 2023), and StarCoder ([Li et al., 2023](https://arxiv.org/abs/2305.06161)). We further supplement our training with data from mathematical domains ([Azerbayev, Zhangir, et al., 2023](https://arxiv.org/abs/2310.10631) and, [Yu, Longhui, et al., 2023](https://arxiv.org/abs/2309.12284)).
525
+
526
+ Top 18 programming languages trained on:
527
+ - C
528
+ - CPP
529
+ - Java
530
+ - JavaScript
531
+ - CSS
532
+ - Go
533
+ - HTML
534
+ - Ruby
535
+ - Rust
536
+ - Markdown
537
+ - Shell
538
+ - Php
539
+ - Sql
540
+ - R
541
+ - Typescript
542
+ - Python
543
+ - Jupyter-Clean
544
+ - RestructuredText
545
+
546
+ ### Training Procedure
547
+
548
+ The model is pre-trained on the aforementioned datasets in `bfloat16` precision, optimized with AdamW.
549
+
550
+ ### Training Infrastructure
551
+
552
+ * **Hardware**: `stable-code-3b` was trained on the Stability AI cluster across 256 NVIDIA A100 40GB GPUs (AWS P4d instances).
553
+
554
+ * **Software**: We use a fork of `gpt-neox` ([EleutherAI, 2021](https://github.com/EleutherAI/gpt-neox)), train under 2D parallelism (Data and Tensor Parallel) with ZeRO-1 ([Rajbhandari et al., 2019](https://arxiv.org/abs/1910.02054v3)), and rely on flash-attention as well as SwiGLU and Rotary Embedding kernels from FlashAttention-2 ([Dao et al., 2023](https://tridao.me/publications/flash2/flash2.pdf))
555
+
556
+ ## Use and Limitations
557
+
558
+ ### Intended Use
559
+
560
+ The model is intended to be used as a foundational base model for application-specific fine-tuning. Developers must evaluate and fine-tune the model for safe performance in downstream applications.
561
+
562
+ ### Limitations and Bias
563
+
564
+ As a base model, this model may exhibit unreliable, unsafe, or other undesirable behaviors that must be corrected through evaluation and fine-tuning prior to deployment. The pre-training dataset may have contained offensive or inappropriate content, even after applying data cleansing filters, which can be reflected in the model-generated text. We recommend that users exercise caution when using these models in production systems. Do not use the models if they are unsuitable for your application, or for any applications that may cause deliberate or unintentional harm to others.
565
+
566
+ ## How to Cite
567
+
568
+ ```bibtex
569
+ @misc{stable-code-3b,
570
+ url={[https://huggingface.co/stabilityai/stable-code-3b](https://huggingface.co/stabilityai/stable-code-3b)},
571
+ title={Stable Code 3B},
572
+ author={Pinnaparaju, Nikhil and Adithyan, Reshinth and Phung, Duy and Tow, Jonathan and Baicoianu, James and and Cooper, Nathan}
573
+ }
574
+ ```
575
+
576
+ <!-- original-model-card end -->