TheBloke commited on
Commit
39cc66e
1 Parent(s): 27e6f46

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +492 -0
README.md ADDED
@@ -0,0 +1,492 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 - AWQ
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 AWQ model files for [DeepSeek's Deepseek Coder 6.7B Base](https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-base).
42
+
43
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
44
+
45
+
46
+ ### About AWQ
47
+
48
+ AWQ is an efficient, accurate and blazing-fast low-bit weight quantization method, currently supporting 4-bit quantization. Compared to GPTQ, it offers faster Transformers-based inference with equivalent or better quality compared to the most commonly used GPTQ settings.
49
+
50
+ It is supported by:
51
+
52
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
53
+ - [vLLM](https://github.com/vllm-project/vllm) - Llama and Mistral models only
54
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
55
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
56
+
57
+ <!-- description end -->
58
+ <!-- repositories-available start -->
59
+ ## Repositories available
60
+
61
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-AWQ)
62
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-GPTQ)
63
+ * [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)
64
+ <!-- repositories-available end -->
65
+
66
+ <!-- prompt-template start -->
67
+ ## Prompt template: None
68
+
69
+ ```
70
+ {prompt}
71
+
72
+ ```
73
+
74
+ <!-- prompt-template end -->
75
+ <!-- licensing start -->
76
+ ## Licensing
77
+
78
+ The creator of the source model has listed its license as `other`, and this quantization has therefore used that same license.
79
+
80
+ 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.
81
+
82
+ 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).
83
+ <!-- licensing end -->
84
+ <!-- README_AWQ.md-provided-files start -->
85
+ ## Provided files, and AWQ parameters
86
+
87
+ For my first release of AWQ models, I am releasing 128g models only. I will consider adding 32g as well if there is interest, and once I have done perplexity and evaluation comparisons, but at this time 32g models are still not fully tested with AutoAWQ and vLLM.
88
+
89
+ Models are released as sharded safetensors files.
90
+
91
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
92
+ | ------ | ---- | -- | ----------- | ------- | ---- |
93
+ | [main](https://huggingface.co/TheBloke/deepseek-coder-6.7B-base-AWQ/tree/main) | 4 | 128 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 8192 | 3.89 GB
94
+
95
+ <!-- README_AWQ.md-provided-files end -->
96
+
97
+ <!-- README_AWQ.md-text-generation-webui start -->
98
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
99
+
100
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
101
+
102
+ 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.
103
+
104
+ 1. Click the **Model tab**.
105
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/deepseek-coder-6.7B-base-AWQ`.
106
+ 3. Click **Download**.
107
+ 4. The model will start downloading. Once it's finished it will say "Done".
108
+ 5. In the top left, click the refresh icon next to **Model**.
109
+ 6. In the **Model** dropdown, choose the model you just downloaded: `deepseek-coder-6.7B-base-AWQ`
110
+ 7. Select **Loader: AutoAWQ**.
111
+ 8. Click Load, and the model will load and is now ready for use.
112
+ 9. 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.
113
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
114
+ <!-- README_AWQ.md-text-generation-webui end -->
115
+
116
+ <!-- README_AWQ.md-use-from-vllm start -->
117
+ ## Multi-user inference server: vLLM
118
+
119
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
120
+
121
+ - Please ensure you are using vLLM version 0.2 or later.
122
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
123
+
124
+ For example:
125
+
126
+ ```shell
127
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/deepseek-coder-6.7B-base-AWQ --quantization awq
128
+ ```
129
+
130
+ - When using vLLM from Python code, again set `quantization=awq`.
131
+
132
+ For example:
133
+
134
+ ```python
135
+ from vllm import LLM, SamplingParams
136
+
137
+ prompts = [
138
+ "Tell me about AI",
139
+ "Write a story about llamas",
140
+ "What is 291 - 150?",
141
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
142
+ ]
143
+ prompt_template=f'''{prompt}
144
+ '''
145
+
146
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
147
+
148
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
149
+
150
+ llm = LLM(model="TheBloke/deepseek-coder-6.7B-base-AWQ", quantization="awq", dtype="auto")
151
+
152
+ outputs = llm.generate(prompts, sampling_params)
153
+
154
+ # Print the outputs.
155
+ for output in outputs:
156
+ prompt = output.prompt
157
+ generated_text = output.outputs[0].text
158
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
159
+ ```
160
+ <!-- README_AWQ.md-use-from-vllm start -->
161
+
162
+ <!-- README_AWQ.md-use-from-tgi start -->
163
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
164
+
165
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
166
+
167
+ Example Docker parameters:
168
+
169
+ ```shell
170
+ --model-id TheBloke/deepseek-coder-6.7B-base-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
171
+ ```
172
+
173
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
174
+
175
+ ```shell
176
+ pip3 install huggingface-hub
177
+ ```
178
+
179
+ ```python
180
+ from huggingface_hub import InferenceClient
181
+
182
+ endpoint_url = "https://your-endpoint-url-here"
183
+
184
+ prompt = "Tell me about AI"
185
+ prompt_template=f'''{prompt}
186
+ '''
187
+
188
+ client = InferenceClient(endpoint_url)
189
+ response = client.text_generation(prompt,
190
+ max_new_tokens=128,
191
+ do_sample=True,
192
+ temperature=0.7,
193
+ top_p=0.95,
194
+ top_k=40,
195
+ repetition_penalty=1.1)
196
+
197
+ print(f"Model output: ", response)
198
+ ```
199
+ <!-- README_AWQ.md-use-from-tgi end -->
200
+
201
+ <!-- README_AWQ.md-use-from-python start -->
202
+ ## Inference from Python code using AutoAWQ
203
+
204
+ ### Install the AutoAWQ package
205
+
206
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.1 or later.
207
+
208
+ ```shell
209
+ pip3 install autoawq
210
+ ```
211
+
212
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
213
+
214
+ ```shell
215
+ pip3 uninstall -y autoawq
216
+ git clone https://github.com/casper-hansen/AutoAWQ
217
+ cd AutoAWQ
218
+ pip3 install .
219
+ ```
220
+
221
+ ### AutoAWQ example code
222
+
223
+ ```python
224
+ from awq import AutoAWQForCausalLM
225
+ from transformers import AutoTokenizer
226
+
227
+ model_name_or_path = "TheBloke/deepseek-coder-6.7B-base-AWQ"
228
+
229
+ # Load tokenizer
230
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
231
+ # Load model
232
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
233
+ trust_remote_code=False, safetensors=True)
234
+
235
+ prompt = "Tell me about AI"
236
+ prompt_template=f'''{prompt}
237
+ '''
238
+
239
+ print("*** Running model.generate:")
240
+
241
+ token_input = tokenizer(
242
+ prompt_template,
243
+ return_tensors='pt'
244
+ ).input_ids.cuda()
245
+
246
+ # Generate output
247
+ generation_output = model.generate(
248
+ token_input,
249
+ do_sample=True,
250
+ temperature=0.7,
251
+ top_p=0.95,
252
+ top_k=40,
253
+ max_new_tokens=512
254
+ )
255
+
256
+ # Get the tokens from the output, decode them, print them
257
+ token_output = generation_output[0]
258
+ text_output = tokenizer.decode(token_output)
259
+ print("LLM output: ", text_output)
260
+
261
+ """
262
+ # Inference should be possible with transformers pipeline as well in future
263
+ # But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
264
+ from transformers import pipeline
265
+
266
+ print("*** Pipeline:")
267
+ pipe = pipeline(
268
+ "text-generation",
269
+ model=model,
270
+ tokenizer=tokenizer,
271
+ max_new_tokens=512,
272
+ do_sample=True,
273
+ temperature=0.7,
274
+ top_p=0.95,
275
+ top_k=40,
276
+ repetition_penalty=1.1
277
+ )
278
+
279
+ print(pipe(prompt_template)[0]['generated_text'])
280
+ """
281
+ ```
282
+ <!-- README_AWQ.md-use-from-python end -->
283
+
284
+ <!-- README_AWQ.md-compatibility start -->
285
+ ## Compatibility
286
+
287
+ The files provided are tested to work with:
288
+
289
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
290
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
291
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
292
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
293
+
294
+ <!-- README_AWQ.md-compatibility end -->
295
+
296
+ <!-- footer start -->
297
+ <!-- 200823 -->
298
+ ## Discord
299
+
300
+ For further support, and discussions on these models and AI in general, join us at:
301
+
302
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
303
+
304
+ ## Thanks, and how to contribute
305
+
306
+ Thanks to the [chirper.ai](https://chirper.ai) team!
307
+
308
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
309
+
310
+ 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.
311
+
312
+ 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.
313
+
314
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
315
+
316
+ * Patreon: https://patreon.com/TheBlokeAI
317
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
318
+
319
+ **Special thanks to**: Aemon Algiz.
320
+
321
+ **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
322
+
323
+
324
+ Thank you to all my generous patrons and donaters!
325
+
326
+ And thank you again to a16z for their generous grant.
327
+
328
+ <!-- footer end -->
329
+
330
+ # Original model card: DeepSeek's Deepseek Coder 6.7B Base
331
+
332
+
333
+ <p align="center">
334
+ <img width="1000px" alt="DeepSeek Coder" src="https://github.com/deepseek-ai/DeepSeek-Coder/blob/main/pictures/logo.png?raw=true">
335
+ </p>
336
+ <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>
337
+ <hr>
338
+
339
+
340
+ ### 1. Introduction of Deepseek Coder
341
+
342
+ 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.
343
+
344
+ - **Massive Training Data**: Trained on 2T tokens, including 87% code and 13% linguistic data in both English and Chinese languages.
345
+
346
+ - **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.
347
+
348
+ - **Superior Model Performance**: State-of-the-art performance among publicly available code models on HumanEval, MultiPL-E, MBPP, DS-1000, and APPS benchmarks.
349
+
350
+ - **Advanced Code Completion Capabilities**: A window size of 16K and a fill-in-the-blank task, supporting project-level code completion and infilling tasks.
351
+
352
+
353
+
354
+ ### 2. Model Summary
355
+ deepseek-coder-6.7b-base is a 6.7B parameter model with Multi-Head Attention trained on 2 trillion tokens.
356
+ - **Home Page:** [DeepSeek](https://deepseek.com/)
357
+ - **Repository:** [deepseek-ai/deepseek-coder](https://github.com/deepseek-ai/deepseek-coder)
358
+ - **Chat With DeepSeek Coder:** [DeepSeek-Coder](https://coder.deepseek.com/)
359
+
360
+
361
+ ### 3. How to Use
362
+ Here give some examples of how to use our model.
363
+ #### 1)Code Completion
364
+ ```python
365
+ from transformers import AutoTokenizer, AutoModelForCausalLM
366
+ import torch
367
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
368
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
369
+ input_text = "#write a quick sort algorithm"
370
+ inputs = tokenizer(input_text, return_tensors="pt").cuda()
371
+ outputs = model.generate(**inputs, max_length=128)
372
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
373
+ ```
374
+
375
+ #### 2)Code Insertion
376
+ ```python
377
+ from transformers import AutoTokenizer, AutoModelForCausalLM
378
+ import torch
379
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
380
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
381
+ input_text = """<|fim▁begin|>def quick_sort(arr):
382
+ if len(arr) <= 1:
383
+ return arr
384
+ pivot = arr[0]
385
+ left = []
386
+ right = []
387
+ <|fim▁hole|>
388
+ if arr[i] < pivot:
389
+ left.append(arr[i])
390
+ else:
391
+ right.append(arr[i])
392
+ return quick_sort(left) + [pivot] + quick_sort(right)<|fim▁end|>"""
393
+ inputs = tokenizer(input_text, return_tensors="pt").cuda()
394
+ outputs = model.generate(**inputs, max_length=128)
395
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True)[len(input_text):])
396
+ ```
397
+
398
+ #### 3)Repository Level Code Completion
399
+ ```python
400
+ from transformers import AutoTokenizer, AutoModelForCausalLM
401
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
402
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
403
+
404
+ input_text = """#utils.py
405
+ import torch
406
+ from sklearn import datasets
407
+ from sklearn.model_selection import train_test_split
408
+ from sklearn.preprocessing import StandardScaler
409
+ from sklearn.metrics import accuracy_score
410
+
411
+ def load_data():
412
+ iris = datasets.load_iris()
413
+ X = iris.data
414
+ y = iris.target
415
+
416
+ # Standardize the data
417
+ scaler = StandardScaler()
418
+ X = scaler.fit_transform(X)
419
+
420
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
421
+
422
+ # Convert numpy data to PyTorch tensors
423
+ X_train = torch.tensor(X_train, dtype=torch.float32)
424
+ X_test = torch.tensor(X_test, dtype=torch.float32)
425
+ y_train = torch.tensor(y_train, dtype=torch.int64)
426
+ y_test = torch.tensor(y_test, dtype=torch.int64)
427
+
428
+ return X_train, X_test, y_train, y_test
429
+
430
+ def evaluate_predictions(y_test, y_pred):
431
+ return accuracy_score(y_test, y_pred)
432
+ #model.py
433
+ import torch
434
+ import torch.nn as nn
435
+ import torch.optim as optim
436
+ from torch.utils.data import DataLoader, TensorDataset
437
+
438
+ class IrisClassifier(nn.Module):
439
+ def __init__(self):
440
+ super(IrisClassifier, self).__init__()
441
+ self.fc = nn.Sequential(
442
+ nn.Linear(4, 16),
443
+ nn.ReLU(),
444
+ nn.Linear(16, 3)
445
+ )
446
+
447
+ def forward(self, x):
448
+ return self.fc(x)
449
+
450
+ def train_model(self, X_train, y_train, epochs, lr, batch_size):
451
+ criterion = nn.CrossEntropyLoss()
452
+ optimizer = optim.Adam(self.parameters(), lr=lr)
453
+
454
+ # Create DataLoader for batches
455
+ dataset = TensorDataset(X_train, y_train)
456
+ dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=True)
457
+
458
+ for epoch in range(epochs):
459
+ for batch_X, batch_y in dataloader:
460
+ optimizer.zero_grad()
461
+ outputs = self(batch_X)
462
+ loss = criterion(outputs, batch_y)
463
+ loss.backward()
464
+ optimizer.step()
465
+
466
+ def predict(self, X_test):
467
+ with torch.no_grad():
468
+ outputs = self(X_test)
469
+ _, predicted = outputs.max(1)
470
+ return predicted.numpy()
471
+ #main.py
472
+ from utils import load_data, evaluate_predictions
473
+ from model import IrisClassifier as Classifier
474
+
475
+ def main():
476
+ # Model training and evaluation
477
+ """
478
+ inputs = tokenizer(input_text, return_tensors="pt").cuda()
479
+ outputs = model.generate(**inputs, max_new_tokens=140)
480
+ print(tokenizer.decode(outputs[0]))
481
+ ```
482
+
483
+
484
+
485
+ ### 4. License
486
+ 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.
487
+
488
+ See the [LICENSE-MODEL](https://github.com/deepseek-ai/deepseek-coder/blob/main/LICENSE-MODEL) for more details.
489
+
490
+ ### 5. Contact
491
+
492
+ If you have any questions, please raise an issue or contact us at [agi_code@deepseek.com](mailto:agi_code@deepseek.com).