qwp4w3hyb commited on
Commit
e8d573e
1 Parent(s): a073256

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +231 -0
README.md ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: deepseek-license
4
+ license_link: LICENSE
5
+ base_model: deepseek-ai/DeepSeek-Coder-V2-Instruct
6
+ ---
7
+
8
+ # Quant Infos
9
+
10
+ - quants done with an importance matrix for improved quantization loss
11
+ - ggufs & imatrix generated from bf16 for "optimal" accuracy loss
12
+ - Wide coverage of different gguf quant types from Q\_8\_0 down to IQ1\_S
13
+ - Quantized with [llama.cpp](https://github.com/ggerganov/llama.cpp) commit [d62e4aaa02540c89be8b59426340b909d02bbc9e](https://github.com/ggerganov/llama.cpp/commit/d62e4aaa02540c89be8b59426340b909d02bbc9e) (master as of 2024-06-24)
14
+ - Imatrix generated with [this](https://gist.github.com/bartowski1182/eb213dccb3571f863da82e99418f81e8) multi-purpose dataset by [bartowski](https://huggingface.co/bartowski).
15
+ ```
16
+ ./imatrix -c 512 -m $model_name-bf16.gguf -f calibration_datav3.txt -o $model_name.imatrix
17
+ ```
18
+
19
+
20
+
21
+ # Original Model Card:
22
+
23
+ <!-- markdownlint-disable first-line-h1 -->
24
+ <!-- markdownlint-disable html -->
25
+ <!-- markdownlint-disable no-duplicate-header -->
26
+
27
+ <div align="center">
28
+ <img src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/logo.svg?raw=true" width="60%" alt="DeepSeek-V2" />
29
+ </div>
30
+ <hr>
31
+ <div align="center" style="line-height: 1;">
32
+ <a href="https://www.deepseek.com/" target="_blank" style="margin: 2px;">
33
+ <img alt="Homepage" src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/badge.svg?raw=true" style="display: inline-block; vertical-align: middle;"/>
34
+ </a>
35
+ <a href="https://chat.deepseek.com/" target="_blank" style="margin: 2px;">
36
+ <img alt="Chat" src="https://img.shields.io/badge/🤖%20Chat-DeepSeek%20V2-536af5?color=536af5&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
37
+ </a>
38
+ <a href="https://huggingface.co/deepseek-ai" target="_blank" style="margin: 2px;">
39
+ <img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-DeepSeek%20AI-ffc107?color=ffc107&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
40
+ </a>
41
+ </div>
42
+
43
+ <div align="center" style="line-height: 1;">
44
+ <a href="https://discord.gg/Tc7c45Zzu5" target="_blank" style="margin: 2px;">
45
+ <img alt="Discord" src="https://img.shields.io/badge/Discord-DeepSeek%20AI-7289da?logo=discord&logoColor=white&color=7289da" style="display: inline-block; vertical-align: middle;"/>
46
+ </a>
47
+ <a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/qr.jpeg?raw=true" target="_blank" style="margin: 2px;">
48
+ <img alt="Wechat" src="https://img.shields.io/badge/WeChat-DeepSeek%20AI-brightgreen?logo=wechat&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
49
+ </a>
50
+ <a href="https://twitter.com/deepseek_ai" target="_blank" style="margin: 2px;">
51
+ <img alt="Twitter Follow" src="https://img.shields.io/badge/Twitter-deepseek_ai-white?logo=x&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
52
+ </a>
53
+ </div>
54
+
55
+ <div align="center" style="line-height: 1;">
56
+ <a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/LICENSE-CODE" style="margin: 2px;">
57
+ <img alt="Code License" src="https://img.shields.io/badge/Code_License-MIT-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
58
+ </a>
59
+ <a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/LICENSE-MODEL" style="margin: 2px;">
60
+ <img alt="Model License" src="https://img.shields.io/badge/Model_License-Model_Agreement-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
61
+ </a>
62
+ </div>
63
+ <p align="center">
64
+ <a href="#4-api-platform">API Platform</a> |
65
+ <a href="#5-how-to-run-locally">How to Use</a> |
66
+ <a href="#6-license">License</a> |
67
+ </p>
68
+
69
+
70
+ <p align="center">
71
+ <a href="https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/paper.pdf"><b>Paper Link</b>👁️</a>
72
+ </p>
73
+
74
+ # DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence
75
+
76
+ ## 1. Introduction
77
+ We present DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model that achieves performance comparable to GPT4-Turbo in code-specific tasks. Specifically, DeepSeek-Coder-V2 is further pre-trained from an intermediate checkpoint of DeepSeek-V2 with additional 6 trillion tokens. Through this continued pre-training, DeepSeek-Coder-V2 substantially enhances the coding and mathematical reasoning capabilities of DeepSeek-V2, while maintaining comparable performance in general language tasks. Compared to DeepSeek-Coder-33B, DeepSeek-Coder-V2 demonstrates significant advancements in various aspects of code-related tasks, as well as reasoning and general capabilities. Additionally, DeepSeek-Coder-V2 expands its support for programming languages from 86 to 338, while extending the context length from 16K to 128K.
78
+
79
+ <p align="center">
80
+ <img width="100%" src="https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/figures/performance.png?raw=true">
81
+ </p>
82
+
83
+
84
+ In standard benchmark evaluations, DeepSeek-Coder-V2 achieves superior performance compared to closed-source models such as GPT4-Turbo, Claude 3 Opus, and Gemini 1.5 Pro in coding and math benchmarks. The list of supported programming languages can be found [here](https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/supported_langs.txt).
85
+
86
+ ## 2. Model Downloads
87
+
88
+ We release the DeepSeek-Coder-V2 with 16B and 236B parameters based on the [DeepSeekMoE](https://arxiv.org/pdf/2401.06066) framework, which has actived parameters of only 2.4B and 21B , including base and instruct models, to the public.
89
+
90
+ <div align="center">
91
+
92
+ | **Model** | **#Total Params** | **#Active Params** | **Context Length** | **Download** |
93
+ | :-----------------------------: | :---------------: | :----------------: | :----------------: | :----------------------------------------------------------: |
94
+ | DeepSeek-Coder-V2-Lite-Base | 16B | 2.4B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Base) |
95
+ | DeepSeek-Coder-V2-Lite-Instruct | 16B | 2.4B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct) |
96
+ | DeepSeek-Coder-V2-Base | 236B | 21B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Base) |
97
+ | DeepSeek-Coder-V2-Instruct | 236B | 21B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct) |
98
+
99
+ </div>
100
+
101
+
102
+ ## 3. Chat Website
103
+
104
+ You can chat with the DeepSeek-Coder-V2 on DeepSeek's official website: [coder.deepseek.com](https://coder.deepseek.com/sign_in)
105
+
106
+ ## 4. API Platform
107
+ We also provide OpenAI-Compatible API at DeepSeek Platform: [platform.deepseek.com](https://platform.deepseek.com/), and you can also pay-as-you-go at an unbeatable price.
108
+ <p align="center">
109
+ <img width="40%" src="https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/figures/model_price.jpg?raw=true">
110
+ </p>
111
+
112
+
113
+ ## 5. How to run locally
114
+ **Here, we provide some examples of how to use DeepSeek-Coder-V2-Lite model. If you want to utilize DeepSeek-Coder-V2 in BF16 format for inference, 80GB*8 GPUs are required.**
115
+
116
+ ### Inference with Huggingface's Transformers
117
+ You can directly employ [Huggingface's Transformers](https://github.com/huggingface/transformers) for model inference.
118
+
119
+ #### Code Completion
120
+ ```python
121
+ from transformers import AutoTokenizer, AutoModelForCausalLM
122
+ import torch
123
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True)
124
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
125
+ input_text = "#write a quick sort algorithm"
126
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
127
+ outputs = model.generate(**inputs, max_length=128)
128
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
129
+ ```
130
+
131
+ #### Code Insertion
132
+ ```python
133
+ from transformers import AutoTokenizer, AutoModelForCausalLM
134
+ import torch
135
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True)
136
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
137
+ input_text = """<|fim▁begin|>def quick_sort(arr):
138
+ if len(arr) <= 1:
139
+ return arr
140
+ pivot = arr[0]
141
+ left = []
142
+ right = []
143
+ <|fim▁hole|>
144
+ if arr[i] < pivot:
145
+ left.append(arr[i])
146
+ else:
147
+ right.append(arr[i])
148
+ return quick_sort(left) + [pivot] + quick_sort(right)<|fim▁end|>"""
149
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
150
+ outputs = model.generate(**inputs, max_length=128)
151
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True)[len(input_text):])
152
+ ```
153
+
154
+ #### Chat Completion
155
+
156
+ ```python
157
+ from transformers import AutoTokenizer, AutoModelForCausalLM
158
+ import torch
159
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True)
160
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
161
+ messages=[
162
+ { 'role': 'user', 'content': "write a quick sort algorithm in python."}
163
+ ]
164
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
165
+ # tokenizer.eos_token_id is the id of <|EOT|> token
166
+ outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, top_k=50, top_p=0.95, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
167
+ print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))
168
+ ```
169
+
170
+
171
+
172
+ The complete chat template can be found within `tokenizer_config.json` located in the huggingface model repository.
173
+
174
+ An example of chat template is as belows:
175
+
176
+ ```bash
177
+ <|begin▁of▁sentence|>User: {user_message_1}
178
+
179
+ Assistant: {assistant_message_1}<|end▁of▁sentence|>User: {user_message_2}
180
+
181
+ Assistant:
182
+ ```
183
+
184
+ You can also add an optional system message:
185
+
186
+ ```bash
187
+ <|begin▁of▁sentence|>{system_message}
188
+
189
+ User: {user_message_1}
190
+
191
+ Assistant: {assistant_message_1}<|end▁of▁sentence|>User: {user_message_2}
192
+
193
+ Assistant:
194
+ ```
195
+
196
+ ### Inference with vLLM (recommended)
197
+ To utilize [vLLM](https://github.com/vllm-project/vllm) for model inference, please merge this Pull Request into your vLLM codebase: https://github.com/vllm-project/vllm/pull/4650.
198
+
199
+ ```python
200
+ from transformers import AutoTokenizer
201
+ from vllm import LLM, SamplingParams
202
+
203
+ max_model_len, tp_size = 8192, 1
204
+ model_name = "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct"
205
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
206
+ llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)
207
+ sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])
208
+
209
+ messages_list = [
210
+ [{"role": "user", "content": "Who are you?"}],
211
+ [{"role": "user", "content": "write a quick sort algorithm in python."}],
212
+ [{"role": "user", "content": "Write a piece of quicksort code in C++."}],
213
+ ]
214
+
215
+ prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]
216
+
217
+ outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)
218
+
219
+ generated_text = [output.outputs[0].text for output in outputs]
220
+ print(generated_text)
221
+ ```
222
+
223
+
224
+
225
+ ## 6. License
226
+
227
+ This code repository is licensed under [the MIT License](https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/LICENSE-CODE). The use of DeepSeek-Coder-V2 Base/Instruct models is subject to [the Model License](https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/LICENSE-MODEL). DeepSeek-Coder-V2 series (including Base and Instruct) supports commercial use.
228
+
229
+
230
+ ## 7. Contact
231
+ If you have any questions, please raise an issue or contact us at [[email protected]]([email protected]).