TheBloke commited on
Commit
b24abb5
1 Parent(s): a7759b1

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +524 -0
README.md ADDED
@@ -0,0 +1,524 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: deepseek-ai/deepseek-coder-6.7b-base
3
+ inference: false
4
+ license: other
5
+ license_link: LICENSE
6
+ license_name: deepseek-license
7
+ model_creator: DeepSeek
8
+ model_name: Deepseek Coder 6.7B Base
9
+ model_type: llama
10
+ prompt_template: '{prompt}
11
+
12
+ '
13
+ quantized_by: TheBloke
14
+ ---
15
+ <!-- markdownlint-disable MD041 -->
16
+
17
+ <!-- header start -->
18
+ <!-- 200823 -->
19
+ <div style="width: auto; margin-left: auto; margin-right: auto">
20
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
21
+ </div>
22
+ <div style="display: flex; justify-content: space-between; width: 100%;">
23
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
24
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
25
+ </div>
26
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
27
+ <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>
28
+ </div>
29
+ </div>
30
+ <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>
31
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
32
+ <!-- header end -->
33
+
34
+ # Deepseek Coder 6.7B Base - GPTQ
35
+ - Model creator: [DeepSeek](https://huggingface.co/deepseek-ai)
36
+ - Original model: [Deepseek Coder 6.7B Base](https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-base)
37
+
38
+ <!-- description start -->
39
+ ## Description
40
+
41
+ This repo contains GPTQ model files for [DeepSeek's Deepseek Coder 6.7B Base](https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-base).
42
+
43
+ Multiple GPTQ parameter permutations are provided; see Provided Files below for details of the options provided, their parameters, and the software used to create them.
44
+
45
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
46
+
47
+ <!-- description end -->
48
+ <!-- repositories-available start -->
49
+ ## Repositories available
50
+
51
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-AWQ)
52
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-GPTQ)
53
+ * [DeepSeek's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-base)
54
+ <!-- repositories-available end -->
55
+
56
+ <!-- prompt-template start -->
57
+ ## Prompt template: None
58
+
59
+ ```
60
+ {prompt}
61
+
62
+ ```
63
+
64
+ <!-- prompt-template end -->
65
+ <!-- licensing start -->
66
+ ## Licensing
67
+
68
+ The creator of the source model has listed its license as `other`, and this quantization has therefore used that same license.
69
+
70
+ 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.
71
+
72
+ In the meantime, any questions regarding licensing, and in particular how these two licenses might interact, should be directed to the original model repository: [DeepSeek's Deepseek Coder 6.7B Base](https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-base).
73
+ <!-- licensing end -->
74
+
75
+ <!-- README_GPTQ.md-compatible clients start -->
76
+ ## Known compatible clients / servers
77
+
78
+ These GPTQ models are known to work in the following inference servers/webuis.
79
+
80
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
81
+ - [KoboldAI United](https://github.com/henk717/koboldai)
82
+ - [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui)
83
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
84
+
85
+ This may not be a complete list; if you know of others, please let me know!
86
+ <!-- README_GPTQ.md-compatible clients end -->
87
+
88
+ <!-- README_GPTQ.md-provided-files start -->
89
+ ## Provided files, and GPTQ parameters
90
+
91
+ Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
92
+
93
+ Each separate quant is in a different branch. See below for instructions on fetching from different branches.
94
+
95
+ Most GPTQ files are made with AutoGPTQ. Mistral models are currently made with Transformers.
96
+
97
+ <details>
98
+ <summary>Explanation of GPTQ parameters</summary>
99
+
100
+ - Bits: The bit size of the quantised model.
101
+ - GS: GPTQ group size. Higher numbers use less VRAM, but have lower quantisation accuracy. "None" is the lowest possible value.
102
+ - Act Order: True or False. Also known as `desc_act`. True results in better quantisation accuracy. Some GPTQ clients have had issues with models that use Act Order plus Group Size, but this is generally resolved now.
103
+ - Damp %: A GPTQ parameter that affects how samples are processed for quantisation. 0.01 is default, but 0.1 results in slightly better accuracy.
104
+ - GPTQ dataset: The calibration dataset used during quantisation. Using a dataset more appropriate to the model's training can improve quantisation accuracy. Note that the GPTQ calibration dataset is not the same as the dataset used to train the model - please refer to the original model repo for details of the training dataset(s).
105
+ - Sequence Length: The length of the dataset sequences used for quantisation. Ideally this is the same as the model sequence length. For some very long sequence models (16+K), a lower sequence length may have to be used. Note that a lower sequence length does not limit the sequence length of the quantised model. It only impacts the quantisation accuracy on longer inference sequences.
106
+ - ExLlama Compatibility: Whether this file can be loaded with ExLlama, which currently only supports Llama and Mistral models in 4-bit.
107
+
108
+ </details>
109
+
110
+ | Branch | Bits | GS | Act Order | Damp % | GPTQ Dataset | Seq Len | Size | ExLlama | Desc |
111
+ | ------ | ---- | -- | --------- | ------ | ------------ | ------- | ---- | ------- | ---- |
112
+ | [main](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-GPTQ/tree/main) | 4 | 128 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 3.90 GB | Yes | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. |
113
+ | [gptq-4bit-32g-actorder_True](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-GPTQ/tree/gptq-4bit-32g-actorder_True) | 4 | 32 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 4.28 GB | Yes | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. |
114
+ | [gptq-8bit--1g-actorder_True](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-GPTQ/tree/gptq-8bit--1g-actorder_True) | 8 | None | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 7.02 GB | No | 8-bit, with Act Order. No group size, to lower VRAM requirements. |
115
+ | [gptq-8bit-128g-actorder_True](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-GPTQ/tree/gptq-8bit-128g-actorder_True) | 8 | 128 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 7.16 GB | No | 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy. |
116
+ | [gptq-8bit-32g-actorder_True](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-GPTQ/tree/gptq-8bit-32g-actorder_True) | 8 | 32 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 7.62 GB | No | 8-bit, with group size 32g and Act Order for maximum inference quality. |
117
+ | [gptq-4bit-64g-actorder_True](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-GPTQ/tree/gptq-4bit-64g-actorder_True) | 4 | 64 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 4.03 GB | Yes | 4-bit, with Act Order and group size 64g. Uses less VRAM than 32g, but with slightly lower accuracy. |
118
+
119
+ <!-- README_GPTQ.md-provided-files end -->
120
+
121
+ <!-- README_GPTQ.md-download-from-branches start -->
122
+ ## How to download, including from branches
123
+
124
+ ### In text-generation-webui
125
+
126
+ To download from the `main` branch, enter `TheBloke/deepseek-coder-6.7B-base-GPTQ` in the "Download model" box.
127
+
128
+ To download from another branch, add `:branchname` to the end of the download name, eg `TheBloke/deepseek-coder-6.7B-base-GPTQ:gptq-4bit-32g-actorder_True`
129
+
130
+ ### From the command line
131
+
132
+ I recommend using the `huggingface-hub` Python library:
133
+
134
+ ```shell
135
+ pip3 install huggingface-hub
136
+ ```
137
+
138
+ To download the `main` branch to a folder called `deepseek-coder-6.7B-base-GPTQ`:
139
+
140
+ ```shell
141
+ mkdir deepseek-coder-6.7B-base-GPTQ
142
+ huggingface-cli download TheBloke/deepseek-coder-6.7B-base-GPTQ --local-dir deepseek-coder-6.7B-base-GPTQ --local-dir-use-symlinks False
143
+ ```
144
+
145
+ To download from a different branch, add the `--revision` parameter:
146
+
147
+ ```shell
148
+ mkdir deepseek-coder-6.7B-base-GPTQ
149
+ huggingface-cli download TheBloke/deepseek-coder-6.7B-base-GPTQ --revision gptq-4bit-32g-actorder_True --local-dir deepseek-coder-6.7B-base-GPTQ --local-dir-use-symlinks False
150
+ ```
151
+
152
+ <details>
153
+ <summary>More advanced huggingface-cli download usage</summary>
154
+
155
+ If you remove the `--local-dir-use-symlinks False` parameter, the files will instead be stored in the central Hugging Face cache directory (default location on Linux is: `~/.cache/huggingface`), and symlinks will be added to the specified `--local-dir`, pointing to their real location in the cache. This allows for interrupted downloads to be resumed, and allows you to quickly clone the repo to multiple places on disk without triggering a download again. The downside, and the reason why I don't list that as the default option, is that the files are then hidden away in a cache folder and it's harder to know where your disk space is being used, and to clear it up if/when you want to remove a download model.
156
+
157
+ The cache location can be changed with the `HF_HOME` environment variable, and/or the `--cache-dir` parameter to `huggingface-cli`.
158
+
159
+ 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).
160
+
161
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
162
+
163
+ ```shell
164
+ pip3 install hf_transfer
165
+ ```
166
+
167
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
168
+
169
+ ```shell
170
+ mkdir deepseek-coder-6.7B-base-GPTQ
171
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/deepseek-coder-6.7B-base-GPTQ --local-dir deepseek-coder-6.7B-base-GPTQ --local-dir-use-symlinks False
172
+ ```
173
+
174
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
175
+ </details>
176
+
177
+ ### With `git` (**not** recommended)
178
+
179
+ To clone a specific branch with `git`, use a command like this:
180
+
181
+ ```shell
182
+ git clone --single-branch --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-GPTQ
183
+ ```
184
+
185
+ Note that using Git with HF repos is strongly discouraged. It will be much slower than using `huggingface-hub`, and will use twice as much disk space as it has to store the model files twice (it stores every byte both in the intended target folder, and again in the `.git` folder as a blob.)
186
+
187
+ <!-- README_GPTQ.md-download-from-branches end -->
188
+ <!-- README_GPTQ.md-text-generation-webui start -->
189
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
190
+
191
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
192
+
193
+ It is strongly recommended to use the text-generation-webui one-click-installers unless you're sure you know how to make a manual install.
194
+
195
+ 1. Click the **Model tab**.
196
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/deepseek-coder-6.7B-base-GPTQ`.
197
+
198
+ - To download from a specific branch, enter for example `TheBloke/deepseek-coder-6.7B-base-GPTQ:gptq-4bit-32g-actorder_True`
199
+ - see Provided Files above for the list of branches for each option.
200
+
201
+ 3. Click **Download**.
202
+ 4. The model will start downloading. Once it's finished it will say "Done".
203
+ 5. In the top left, click the refresh icon next to **Model**.
204
+ 6. In the **Model** dropdown, choose the model you just downloaded: `deepseek-coder-6.7B-base-GPTQ`
205
+ 7. The model will automatically load, and is now ready for use!
206
+ 8. If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
207
+
208
+ - Note that you do not need to and should not set manual GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
209
+
210
+ 9. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
211
+
212
+ <!-- README_GPTQ.md-text-generation-webui end -->
213
+
214
+ <!-- README_GPTQ.md-use-from-tgi start -->
215
+ ## Serving this model from Text Generation Inference (TGI)
216
+
217
+ It's recommended to use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
218
+
219
+ Example Docker parameters:
220
+
221
+ ```shell
222
+ --model-id TheBloke/deepseek-coder-6.7B-base-GPTQ --port 3000 --quantize gptq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
223
+ ```
224
+
225
+ Example Python code for interfacing with TGI (requires huggingface-hub 0.17.0 or later):
226
+
227
+ ```shell
228
+ pip3 install huggingface-hub
229
+ ```
230
+
231
+ ```python
232
+ from huggingface_hub import InferenceClient
233
+
234
+ endpoint_url = "https://your-endpoint-url-here"
235
+
236
+ prompt = "Tell me about AI"
237
+ prompt_template=f'''{prompt}
238
+ '''
239
+
240
+ client = InferenceClient(endpoint_url)
241
+ response = client.text_generation(prompt,
242
+ max_new_tokens=128,
243
+ do_sample=True,
244
+ temperature=0.7,
245
+ top_p=0.95,
246
+ top_k=40,
247
+ repetition_penalty=1.1)
248
+
249
+ print(f"Model output: {response}")
250
+ ```
251
+ <!-- README_GPTQ.md-use-from-tgi end -->
252
+ <!-- README_GPTQ.md-use-from-python start -->
253
+ ## How to use this GPTQ model from Python code
254
+
255
+ ### Install the necessary packages
256
+
257
+ Requires: Transformers 4.33.0 or later, Optimum 1.12.0 or later, and AutoGPTQ 0.4.2 or later.
258
+
259
+ ```shell
260
+ pip3 install transformers optimum
261
+ pip3 install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/ # Use cu117 if on CUDA 11.7
262
+ ```
263
+
264
+ If you have problems installing AutoGPTQ using the pre-built wheels, install it from source instead:
265
+
266
+ ```shell
267
+ pip3 uninstall -y auto-gptq
268
+ git clone https://github.com/PanQiWei/AutoGPTQ
269
+ cd AutoGPTQ
270
+ git checkout v0.4.2
271
+ pip3 install .
272
+ ```
273
+
274
+ ### You can then use the following code
275
+
276
+ ```python
277
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
278
+
279
+ model_name_or_path = "TheBloke/deepseek-coder-6.7B-base-GPTQ"
280
+ # To use a different branch, change revision
281
+ # For example: revision="gptq-4bit-32g-actorder_True"
282
+ model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
283
+ device_map="auto",
284
+ trust_remote_code=False,
285
+ revision="main")
286
+
287
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
288
+
289
+ prompt = "Tell me about AI"
290
+ prompt_template=f'''{prompt}
291
+ '''
292
+
293
+ print("\n\n*** Generate:")
294
+
295
+ input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
296
+ output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)
297
+ print(tokenizer.decode(output[0]))
298
+
299
+ # Inference can also be done using transformers' pipeline
300
+
301
+ print("*** Pipeline:")
302
+ pipe = pipeline(
303
+ "text-generation",
304
+ model=model,
305
+ tokenizer=tokenizer,
306
+ max_new_tokens=512,
307
+ do_sample=True,
308
+ temperature=0.7,
309
+ top_p=0.95,
310
+ top_k=40,
311
+ repetition_penalty=1.1
312
+ )
313
+
314
+ print(pipe(prompt_template)[0]['generated_text'])
315
+ ```
316
+ <!-- README_GPTQ.md-use-from-python end -->
317
+
318
+ <!-- README_GPTQ.md-compatibility start -->
319
+ ## Compatibility
320
+
321
+ The files provided are tested to work with Transformers. For non-Mistral models, AutoGPTQ can also be used directly.
322
+
323
+ [ExLlama](https://github.com/turboderp/exllama) is compatible with Llama and Mistral models in 4-bit. Please see the Provided Files table above for per-file compatibility.
324
+
325
+ For a list of clients/servers, please see "Known compatible clients / servers", above.
326
+ <!-- README_GPTQ.md-compatibility end -->
327
+
328
+ <!-- footer start -->
329
+ <!-- 200823 -->
330
+ ## Discord
331
+
332
+ For further support, and discussions on these models and AI in general, join us at:
333
+
334
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
335
+
336
+ ## Thanks, and how to contribute
337
+
338
+ Thanks to the [chirper.ai](https://chirper.ai) team!
339
+
340
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
341
+
342
+ 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.
343
+
344
+ 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.
345
+
346
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
347
+
348
+ * Patreon: https://patreon.com/TheBlokeAI
349
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
350
+
351
+ **Special thanks to**: Aemon Algiz.
352
+
353
+ **Patreon special mentions**: Brandon Frisco, LangChain4j, Spiking Neurons AB, transmissions 11, Joseph William Delisle, Nitin Borwankar, Willem Michiel, Michael Dempsey, vamX, Jeffrey Morgan, zynix, jjj, Omer Bin Jawed, Sean Connelly, jinyuan sun, Jeromy Smith, Shadi, Pawan Osman, Chadd, Elijah Stavena, Illia Dulskyi, Sebastain Graf, Stephen Murray, terasurfer, Edmond Seymore, Celu Ramasamy, Mandus, Alex, biorpg, Ajan Kanaga, Clay Pascal, Raven Klaugh, 阿明, K, ya boyyy, usrbinkat, Alicia Loh, John Villwock, ReadyPlayerEmma, Chris Smitley, Cap'n Zoog, fincy, GodLy, S_X, sidney chen, Cory Kujawski, OG, Mano Prime, AzureBlack, Pieter, Kalila, Spencer Kim, Tom X Nguyen, Stanislav Ovsiannikov, Michael Levine, Andrey, Trailburnt, Vadim, Enrico Ros, Talal Aujan, Brandon Phillips, Jack West, Eugene Pentland, Michael Davis, Will Dee, webtim, Jonathan Leane, Alps Aficionado, Rooh Singh, Tiffany J. Kim, theTransient, Luke @flexchar, Elle, Caitlyn Gatomon, Ari Malik, subjectnull, Johann-Peter Hartmann, Trenton Dambrowitz, Imad Khwaja, Asp the Wyvern, Emad Mostaque, Rainer Wilmers, Alexandros Triantafyllidis, Nicholas, Pedro Madruga, SuperWojo, Harry Royden McLaughlin, James Bentley, Olakabola, David Ziegler, Ai Maven, Jeff Scroggin, Nikolai Manek, Deo Leter, Matthew Berman, Fen Risland, Ken Nordquist, Manuel Alberto Morcote, Luke Pendergrass, TL, Fred von Graf, Randy H, Dan Guido, NimbleBox.ai, Vitor Caleffi, Gabriel Tamborski, knownsqashed, Lone Striker, Erik Bjäreholt, John Detwiler, Leonard Tan, Iucharbius
354
+
355
+
356
+ Thank you to all my generous patrons and donaters!
357
+
358
+ And thank you again to a16z for their generous grant.
359
+
360
+ <!-- footer end -->
361
+
362
+ # Original model card: DeepSeek's Deepseek Coder 6.7B Base
363
+
364
+
365
+ <p align="center">
366
+ <img width="1000px" alt="DeepSeek Coder" src="https://github.com/deepseek-ai/DeepSeek-Coder/blob/main/pictures/logo.png?raw=true">
367
+ </p>
368
+ <p align="center"><a href="https://www.deepseek.com/">[🏠Homepage]</a> | <a href="https://coder.deepseek.com/">[🤖 Chat with DeepSeek Coder]</a> | <a href="https://discord.gg/Tc7c45Zzu5">[Discord]</a> | <a href="https://github.com/guoday/assert/blob/main/QR.png?raw=true">[Wechat(微信)]</a> </p>
369
+ <hr>
370
+
371
+
372
+ ### 1. Introduction of Deepseek Coder
373
+
374
+ Deepseek Coder comprises a series of code language models trained on both 87% code and 13% natural language in English and Chinese, with each model pre-trained on 2T tokens. We provide various sizes of the code model, ranging from 1B to 33B versions. Each model is pre-trained on project-level code corpus by employing a window size of 16K and a extra fill-in-the-blank task, to support project-level code completion and infilling. For coding capabilities, Deepseek Coder achieves state-of-the-art performance among open-source code models on multiple programming languages and various benchmarks.
375
+
376
+ - **Massive Training Data**: Trained on 2T tokens, including 87% code and 13% linguistic data in both English and Chinese languages.
377
+
378
+ - **Highly Flexible & Scalable**: Offered in model sizes of 1.3B, 5.7B, 6.7B, and 33B, enabling users to choose the setup most suitable for their requirements.
379
+
380
+ - **Superior Model Performance**: State-of-the-art performance among publicly available code models on HumanEval, MultiPL-E, MBPP, DS-1000, and APPS benchmarks.
381
+
382
+ - **Advanced Code Completion Capabilities**: A window size of 16K and a fill-in-the-blank task, supporting project-level code completion and infilling tasks.
383
+
384
+
385
+
386
+ ### 2. Model Summary
387
+ deepseek-coder-6.7b-base is a 6.7B parameter model with Multi-Head Attention trained on 2 trillion tokens.
388
+ - **Home Page:** [DeepSeek](https://deepseek.com/)
389
+ - **Repository:** [deepseek-ai/deepseek-coder](https://github.com/deepseek-ai/deepseek-coder)
390
+ - **Chat With DeepSeek Coder:** [DeepSeek-Coder](https://coder.deepseek.com/)
391
+
392
+
393
+ ### 3. How to Use
394
+ Here give some examples of how to use our model.
395
+ #### 1)Code Completion
396
+ ```python
397
+ from transformers import AutoTokenizer, AutoModelForCausalLM
398
+ import torch
399
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
400
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
401
+ input_text = "#write a quick sort algorithm"
402
+ inputs = tokenizer(input_text, return_tensors="pt").cuda()
403
+ outputs = model.generate(**inputs, max_length=128)
404
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
405
+ ```
406
+
407
+ #### 2)Code Insertion
408
+ ```python
409
+ from transformers import AutoTokenizer, AutoModelForCausalLM
410
+ import torch
411
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
412
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
413
+ input_text = """<|fim▁begin|>def quick_sort(arr):
414
+ if len(arr) <= 1:
415
+ return arr
416
+ pivot = arr[0]
417
+ left = []
418
+ right = []
419
+ <|fim▁hole|>
420
+ if arr[i] < pivot:
421
+ left.append(arr[i])
422
+ else:
423
+ right.append(arr[i])
424
+ return quick_sort(left) + [pivot] + quick_sort(right)<|fim▁end|>"""
425
+ inputs = tokenizer(input_text, return_tensors="pt").cuda()
426
+ outputs = model.generate(**inputs, max_length=128)
427
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True)[len(input_text):])
428
+ ```
429
+
430
+ #### 3)Repository Level Code Completion
431
+ ```python
432
+ from transformers import AutoTokenizer, AutoModelForCausalLM
433
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
434
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
435
+
436
+ input_text = """#utils.py
437
+ import torch
438
+ from sklearn import datasets
439
+ from sklearn.model_selection import train_test_split
440
+ from sklearn.preprocessing import StandardScaler
441
+ from sklearn.metrics import accuracy_score
442
+
443
+ def load_data():
444
+ iris = datasets.load_iris()
445
+ X = iris.data
446
+ y = iris.target
447
+
448
+ # Standardize the data
449
+ scaler = StandardScaler()
450
+ X = scaler.fit_transform(X)
451
+
452
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
453
+
454
+ # Convert numpy data to PyTorch tensors
455
+ X_train = torch.tensor(X_train, dtype=torch.float32)
456
+ X_test = torch.tensor(X_test, dtype=torch.float32)
457
+ y_train = torch.tensor(y_train, dtype=torch.int64)
458
+ y_test = torch.tensor(y_test, dtype=torch.int64)
459
+
460
+ return X_train, X_test, y_train, y_test
461
+
462
+ def evaluate_predictions(y_test, y_pred):
463
+ return accuracy_score(y_test, y_pred)
464
+ #model.py
465
+ import torch
466
+ import torch.nn as nn
467
+ import torch.optim as optim
468
+ from torch.utils.data import DataLoader, TensorDataset
469
+
470
+ class IrisClassifier(nn.Module):
471
+ def __init__(self):
472
+ super(IrisClassifier, self).__init__()
473
+ self.fc = nn.Sequential(
474
+ nn.Linear(4, 16),
475
+ nn.ReLU(),
476
+ nn.Linear(16, 3)
477
+ )
478
+
479
+ def forward(self, x):
480
+ return self.fc(x)
481
+
482
+ def train_model(self, X_train, y_train, epochs, lr, batch_size):
483
+ criterion = nn.CrossEntropyLoss()
484
+ optimizer = optim.Adam(self.parameters(), lr=lr)
485
+
486
+ # Create DataLoader for batches
487
+ dataset = TensorDataset(X_train, y_train)
488
+ dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=True)
489
+
490
+ for epoch in range(epochs):
491
+ for batch_X, batch_y in dataloader:
492
+ optimizer.zero_grad()
493
+ outputs = self(batch_X)
494
+ loss = criterion(outputs, batch_y)
495
+ loss.backward()
496
+ optimizer.step()
497
+
498
+ def predict(self, X_test):
499
+ with torch.no_grad():
500
+ outputs = self(X_test)
501
+ _, predicted = outputs.max(1)
502
+ return predicted.numpy()
503
+ #main.py
504
+ from utils import load_data, evaluate_predictions
505
+ from model import IrisClassifier as Classifier
506
+
507
+ def main():
508
+ # Model training and evaluation
509
+ """
510
+ inputs = tokenizer(input_text, return_tensors="pt").cuda()
511
+ outputs = model.generate(**inputs, max_new_tokens=140)
512
+ print(tokenizer.decode(outputs[0]))
513
+ ```
514
+
515
+
516
+
517
+ ### 4. License
518
+ This code repository is licensed under the MIT License. The use of DeepSeek Coder models is subject to the Model License. DeepSeek Coder supports commercial use.
519
+
520
+ See the [LICENSE-MODEL](https://github.com/deepseek-ai/deepseek-coder/blob/main/LICENSE-MODEL) for more details.
521
+
522
+ ### 5. Contact
523
+
524
+ If you have any questions, please raise an issue or contact us at [[email protected]](mailto:[email protected]).