TheBloke commited on
Commit
87ac6d0
1 Parent(s): 53e957f

Upload README.md

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