qwp4w3hyb commited on
Commit
430d25c
1 Parent(s): 28ad598

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +228 -0
README.md ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: deepseek-license
4
+ license_link: LICENSE
5
+ ---
6
+
7
+ # Quant Infos
8
+
9
+ - quants done with an importance matrix for improved quantization loss
10
+ - ggufs & imatrix generated from bf16 for "optimal" accuracy loss
11
+ - Wide coverage of different gguf quant types from Q\_8\_0 down to IQ1\_S
12
+ - Quantized with [llama.cpp](https://github.com/ggerganov/llama.cpp) commit [4bfe50f741479c1df1c377260c3ff5702586719e](https://github.com/ggerganov/llama.cpp/commit/4bfe50f741479c1df1c377260c3ff5702586719e) (master as of 2024-06-11)
13
+ - Imatrix generated with [this](https://gist.github.com/bartowski1182/eb213dccb3571f863da82e99418f81e8) multi-purpose dataset by [bartowski](https://huggingface.co/bartowski).
14
+ ```
15
+ ./imatrix -c 512 -m $model_name-bf16.gguf -f calibration_datav3.txt -o $model_name.imatrix
16
+ ```
17
+
18
+
19
+ # Original Model Card
20
+ <!-- markdownlint-disable first-line-h1 -->
21
+ <!-- markdownlint-disable html -->
22
+ <!-- markdownlint-disable no-duplicate-header -->
23
+
24
+ <div align="center">
25
+ <img src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/logo.svg?raw=true" width="60%" alt="DeepSeek-V2" />
26
+ </div>
27
+ <hr>
28
+ <div align="center" style="line-height: 1;">
29
+ <a href="https://www.deepseek.com/" target="_blank" style="margin: 2px;">
30
+ <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;"/>
31
+ </a>
32
+ <a href="https://chat.deepseek.com/" target="_blank" style="margin: 2px;">
33
+ <img alt="Chat" src="https://img.shields.io/badge/🤖%20Chat-DeepSeek%20V2-536af5?color=536af5&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
34
+ </a>
35
+ <a href="https://huggingface.co/deepseek-ai" target="_blank" style="margin: 2px;">
36
+ <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;"/>
37
+ </a>
38
+ </div>
39
+
40
+ <div align="center" style="line-height: 1;">
41
+ <a href="https://discord.gg/Tc7c45Zzu5" target="_blank" style="margin: 2px;">
42
+ <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;"/>
43
+ </a>
44
+ <a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/qr.jpeg?raw=true" target="_blank" style="margin: 2px;">
45
+ <img alt="Wechat" src="https://img.shields.io/badge/WeChat-DeepSeek%20AI-brightgreen?logo=wechat&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
46
+ </a>
47
+ <a href="https://twitter.com/deepseek_ai" target="_blank" style="margin: 2px;">
48
+ <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;"/>
49
+ </a>
50
+ </div>
51
+
52
+ <div align="center" style="line-height: 1;">
53
+ <a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/LICENSE-CODE" style="margin: 2px;">
54
+ <img alt="Code License" src="https://img.shields.io/badge/Code_License-MIT-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
55
+ </a>
56
+ <a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/LICENSE-MODEL" style="margin: 2px;">
57
+ <img alt="Model License" src="https://img.shields.io/badge/Model_License-Model_Agreement-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
58
+ </a>
59
+ </div>
60
+ <p align="center">
61
+ <a href="#4-api-platform">API Platform</a> |
62
+ <a href="#5-how-to-run-locally">How to Use</a> |
63
+ <a href="#6-license">License</a> |
64
+ </p>
65
+
66
+
67
+ <p align="center">
68
+ <a href="https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/paper.pdf"><b>Paper Link</b>👁️</a>
69
+ </p>
70
+
71
+ # DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence
72
+
73
+ ## 1. Introduction
74
+ 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.
75
+
76
+ <p align="center">
77
+ <img width="100%" src="https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/figures/performance.png?raw=true">
78
+ </p>
79
+
80
+
81
+ 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).
82
+
83
+ ## 2. Model Downloads
84
+
85
+ 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.
86
+
87
+ <div align="center">
88
+
89
+ | **Model** | **#Total Params** | **#Active Params** | **Context Length** | **Download** |
90
+ | :-----------------------------: | :---------------: | :----------------: | :----------------: | :----------------------------------------------------------: |
91
+ | DeepSeek-Coder-V2-Lite-Base | 16B | 2.4B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Base) |
92
+ | DeepSeek-Coder-V2-Lite-Instruct | 16B | 2.4B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct) |
93
+ | DeepSeek-Coder-V2-Base | 236B | 21B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Base) |
94
+ | DeepSeek-Coder-V2-Instruct | 236B | 21B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct) |
95
+
96
+ </div>
97
+
98
+
99
+ ## 3. Chat Website
100
+
101
+ You can chat with the DeepSeek-Coder-V2 on DeepSeek's official website: [coder.deepseek.com](https://coder.deepseek.com/sign_in)
102
+
103
+ ## 4. API Platform
104
+ 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.
105
+ <p align="center">
106
+ <img width="40%" src="https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/figures/model_price.jpg?raw=true">
107
+ </p>
108
+
109
+
110
+ ## 5. How to run locally
111
+ **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.**
112
+
113
+ ### Inference with Huggingface's Transformers
114
+ You can directly employ [Huggingface's Transformers](https://github.com/huggingface/transformers) for model inference.
115
+
116
+ #### Code Completion
117
+ ```python
118
+ from transformers import AutoTokenizer, AutoModelForCausalLM
119
+ import torch
120
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True)
121
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
122
+ input_text = "#write a quick sort algorithm"
123
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
124
+ outputs = model.generate(**inputs, max_length=128)
125
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
126
+ ```
127
+
128
+ #### Code Insertion
129
+ ```python
130
+ from transformers import AutoTokenizer, AutoModelForCausalLM
131
+ import torch
132
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True)
133
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
134
+ input_text = """<|fim▁begin|>def quick_sort(arr):
135
+ if len(arr) <= 1:
136
+ return arr
137
+ pivot = arr[0]
138
+ left = []
139
+ right = []
140
+ <|fim▁hole|>
141
+ if arr[i] < pivot:
142
+ left.append(arr[i])
143
+ else:
144
+ right.append(arr[i])
145
+ return quick_sort(left) + [pivot] + quick_sort(right)<|fim▁end|>"""
146
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
147
+ outputs = model.generate(**inputs, max_length=128)
148
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True)[len(input_text):])
149
+ ```
150
+
151
+ #### Chat Completion
152
+
153
+ ```python
154
+ from transformers import AutoTokenizer, AutoModelForCausalLM
155
+ import torch
156
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True)
157
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
158
+ messages=[
159
+ { 'role': 'user', 'content': "write a quick sort algorithm in python."}
160
+ ]
161
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
162
+ # tokenizer.eos_token_id is the id of <|EOT|> token
163
+ 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)
164
+ print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))
165
+ ```
166
+
167
+
168
+
169
+ The complete chat template can be found within `tokenizer_config.json` located in the huggingface model repository.
170
+
171
+ An example of chat template is as belows:
172
+
173
+ ```bash
174
+ <|begin▁of▁sentence|>User: {user_message_1}
175
+
176
+ Assistant: {assistant_message_1}<|end▁of▁sentence|>User: {user_message_2}
177
+
178
+ Assistant:
179
+ ```
180
+
181
+ You can also add an optional system message:
182
+
183
+ ```bash
184
+ <|begin▁of▁sentence|>{system_message}
185
+
186
+ User: {user_message_1}
187
+
188
+ Assistant: {assistant_message_1}<|end▁of▁sentence|>User: {user_message_2}
189
+
190
+ Assistant:
191
+ ```
192
+
193
+ ### Inference with vLLM (recommended)
194
+ 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.
195
+
196
+ ```python
197
+ from transformers import AutoTokenizer
198
+ from vllm import LLM, SamplingParams
199
+
200
+ max_model_len, tp_size = 8192, 1
201
+ model_name = "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct"
202
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
203
+ llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)
204
+ sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])
205
+
206
+ messages_list = [
207
+ [{"role": "user", "content": "Who are you?"}],
208
+ [{"role": "user", "content": "write a quick sort algorithm in python."}],
209
+ [{"role": "user", "content": "Write a piece of quicksort code in C++."}],
210
+ ]
211
+
212
+ prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]
213
+
214
+ outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)
215
+
216
+ generated_text = [output.outputs[0].text for output in outputs]
217
+ print(generated_text)
218
+ ```
219
+
220
+
221
+
222
+ ## 6. License
223
+
224
+ 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.
225
+
226
+
227
+ ## 7. Contact
228
+ If you have any questions, please raise an issue or contact us at [service@deepseek.com](service@deepseek.com).