munish0838 commited on
Commit
f706475
1 Parent(s): b1acbfd

Create README.md

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