munish0838
commited on
Commit
•
e8ef80e
1
Parent(s):
6097757
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: other
|
3 |
+
license_name: deepseek-license
|
4 |
+
license_link: LICENSE
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
base_model: deepseek-ai/DeepSeek-Coder-V2-Lite-Base
|
7 |
+
---
|
8 |
+
|
9 |
+
|
10 |
+
# QuantFactory/DeepSeek-Coder-V2-Lite-Base-GGUF
|
11 |
+
This is quantized version of [deepseek-ai/DeepSeek-Coder-V2-Lite-Base](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Base) created using llama.cpp
|
12 |
+
|
13 |
+
|
14 |
+
# Model Description
|
15 |
+
<!-- markdownlint-disable first-line-h1 -->
|
16 |
+
<!-- markdownlint-disable html -->
|
17 |
+
<!-- markdownlint-disable no-duplicate-header -->
|
18 |
+
|
19 |
+
<div align="center">
|
20 |
+
<img src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/logo.svg?raw=true" width="60%" alt="DeepSeek-V2" />
|
21 |
+
</div>
|
22 |
+
|
23 |
+
<p align="center">
|
24 |
+
<a href="https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/paper.pdf"><b>Paper Link</b>👁️</a>
|
25 |
+
</p>
|
26 |
+
|
27 |
+
# DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence
|
28 |
+
|
29 |
+
## 1. Introduction
|
30 |
+
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.
|
31 |
+
|
32 |
+
<p align="center">
|
33 |
+
<img width="100%" src="https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/figures/performance.png?raw=true">
|
34 |
+
</p>
|
35 |
+
|
36 |
+
|
37 |
+
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).
|
38 |
+
|
39 |
+
## 2. Model Downloads
|
40 |
+
|
41 |
+
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.
|
42 |
+
|
43 |
+
<div align="center">
|
44 |
+
|
45 |
+
| **Model** | **#Total Params** | **#Active Params** | **Context Length** | **Download** |
|
46 |
+
| :-----------------------------: | :---------------: | :----------------: | :----------------: | :----------------------------------------------------------: |
|
47 |
+
| DeepSeek-Coder-V2-Lite-Base | 16B | 2.4B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Base) |
|
48 |
+
| DeepSeek-Coder-V2-Lite-Instruct | 16B | 2.4B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct) |
|
49 |
+
| DeepSeek-Coder-V2-Base | 236B | 21B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Base) |
|
50 |
+
| DeepSeek-Coder-V2-Instruct | 236B | 21B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct) |
|
51 |
+
|
52 |
+
</div>
|
53 |
+
|
54 |
+
|
55 |
+
## 3. Chat Website
|
56 |
+
|
57 |
+
You can chat with the DeepSeek-Coder-V2 on DeepSeek's official website: [coder.deepseek.com](https://coder.deepseek.com/sign_in)
|
58 |
+
|
59 |
+
## 4. API Platform
|
60 |
+
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.
|
61 |
+
|
62 |
+
<p align="center">
|
63 |
+
<img width="40%" src="https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/figures/model_price.jpg?raw=true">
|
64 |
+
</p>
|
65 |
+
|
66 |
+
|
67 |
+
## 5. How to run locally
|
68 |
+
**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.**
|
69 |
+
|
70 |
+
### Inference with Huggingface's Transformers
|
71 |
+
You can directly employ [Huggingface's Transformers](https://github.com/huggingface/transformers) for model inference.
|
72 |
+
|
73 |
+
#### Code Completion
|
74 |
+
```python
|
75 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
76 |
+
import torch
|
77 |
+
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True)
|
78 |
+
model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
|
79 |
+
input_text = "#write a quick sort algorithm"
|
80 |
+
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
|
81 |
+
outputs = model.generate(**inputs, max_length=128)
|
82 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
83 |
+
```
|
84 |
+
|
85 |
+
#### Code Insertion
|
86 |
+
```python
|
87 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
88 |
+
import torch
|
89 |
+
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True)
|
90 |
+
model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
|
91 |
+
input_text = """<|fim▁begin|>def quick_sort(arr):
|
92 |
+
if len(arr) <= 1:
|
93 |
+
return arr
|
94 |
+
pivot = arr[0]
|
95 |
+
left = []
|
96 |
+
right = []
|
97 |
+
<|fim▁hole|>
|
98 |
+
if arr[i] < pivot:
|
99 |
+
left.append(arr[i])
|
100 |
+
else:
|
101 |
+
right.append(arr[i])
|
102 |
+
return quick_sort(left) + [pivot] + quick_sort(right)<|fim▁end|>"""
|
103 |
+
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
|
104 |
+
outputs = model.generate(**inputs, max_length=128)
|
105 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True)[len(input_text):])
|
106 |
+
```
|
107 |
+
|
108 |
+
#### Chat Completion
|
109 |
+
|
110 |
+
```python
|
111 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
112 |
+
import torch
|
113 |
+
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True)
|
114 |
+
model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
|
115 |
+
messages=[
|
116 |
+
{ 'role': 'user', 'content': "write a quick sort algorithm in python."}
|
117 |
+
]
|
118 |
+
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
119 |
+
# tokenizer.eos_token_id is the id of <|EOT|> token
|
120 |
+
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)
|
121 |
+
print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))
|
122 |
+
```
|
123 |
+
|
124 |
+
|
125 |
+
|
126 |
+
The complete chat template can be found within `tokenizer_config.json` located in the huggingface model repository.
|
127 |
+
|
128 |
+
An example of chat template is as belows:
|
129 |
+
|
130 |
+
```bash
|
131 |
+
<|begin▁of▁sentence|>User: {user_message_1}
|
132 |
+
|
133 |
+
Assistant: {assistant_message_1}<|end▁of▁sentence|>User: {user_message_2}
|
134 |
+
|
135 |
+
Assistant:
|
136 |
+
```
|
137 |
+
|
138 |
+
You can also add an optional system message:
|
139 |
+
|
140 |
+
```bash
|
141 |
+
<|begin▁of▁sentence|>{system_message}
|
142 |
+
|
143 |
+
User: {user_message_1}
|
144 |
+
|
145 |
+
Assistant: {assistant_message_1}<|end▁of▁sentence|>User: {user_message_2}
|
146 |
+
|
147 |
+
Assistant:
|
148 |
+
```
|
149 |
+
|
150 |
+
### Inference with vLLM (recommended)
|
151 |
+
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.
|
152 |
+
|
153 |
+
```python
|
154 |
+
from transformers import AutoTokenizer
|
155 |
+
from vllm import LLM, SamplingParams
|
156 |
+
|
157 |
+
max_model_len, tp_size = 8192, 1
|
158 |
+
model_name = "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct"
|
159 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
160 |
+
llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)
|
161 |
+
sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])
|
162 |
+
|
163 |
+
messages_list = [
|
164 |
+
[{"role": "user", "content": "Who are you?"}],
|
165 |
+
[{"role": "user", "content": "write a quick sort algorithm in python."}],
|
166 |
+
[{"role": "user", "content": "Write a piece of quicksort code in C++."}],
|
167 |
+
]
|
168 |
+
|
169 |
+
prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]
|
170 |
+
|
171 |
+
outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)
|
172 |
+
|
173 |
+
generated_text = [output.outputs[0].text for output in outputs]
|
174 |
+
print(generated_text)
|
175 |
+
```
|
176 |
+
|
177 |
+
|
178 |
+
|
179 |
+
## 6. Model License
|
180 |
+
|
181 |
+
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.
|
182 |
+
|
183 |
+
|
184 |
+
## 7. Model Contact
|
185 |
+
If you have any questions, please raise an issue or contact us at [service@deepseek.com](service@deepseek.com).
|