commit c84bfab8c9b6f5472fd9fb45d453a695fccae158 Author: guoday Date: Mon Jun 17 20:12:50 2024 +0800 upload readme and paper diff --git a/LICENSE-CODE b/LICENSE-CODE new file mode 100644 index 0000000..d84f527 --- /dev/null +++ b/LICENSE-CODE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 DeepSeek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LICENSE-MODEL b/LICENSE-MODEL new file mode 100644 index 0000000..9489e95 --- /dev/null +++ b/LICENSE-MODEL @@ -0,0 +1,91 @@ +DEEPSEEK LICENSE AGREEMENT + +Version 1.0, 23 October 2023 + +Copyright (c) 2023 DeepSeek + +Section I: PREAMBLE + +Large generative models are being widely adopted and used, and have the potential to transform the way individuals conceive and benefit from AI or ML technologies. + +Notwithstanding the current and potential benefits that these artifacts can bring to society at large, there are also concerns about potential misuses of them, either due to their technical limitations or ethical considerations. + +In short, this license strives for both the open and responsible downstream use of the accompanying model. When it comes to the open character, we took inspiration from open source permissive licenses regarding the grant of IP rights. Referring to the downstream responsible use, we added use-based restrictions not permitting the use of the model in very specific scenarios, in order for the licensor to be able to enforce the license in case potential misuses of the Model may occur. At the same time, we strive to promote open and responsible research on generative models for content generation. + +Even though downstream derivative versions of the model could be released under different licensing terms, the latter will always have to include - at minimum - the same use-based restrictions as the ones in the original license (this license). We believe in the intersection between open and responsible AI development; thus, this agreement aims to strike a balance between both in order to enable responsible open-science in the field of AI. + +This License governs the use of the model (and its derivatives) and is informed by the model card associated with the model. + +NOW THEREFORE, You and DeepSeek agree as follows: + +1. Definitions +"License" means the terms and conditions for use, reproduction, and Distribution as defined in this document. +"Data" means a collection of information and/or content extracted from the dataset used with the Model, including to train, pretrain, or otherwise evaluate the Model. The Data is not licensed under this License. +"Output" means the results of operating a Model as embodied in informational content resulting therefrom. +"Model" means any accompanying machine-learning based assemblies (including checkpoints), consisting of learnt weights, parameters (including optimizer states), corresponding to the model architecture as embodied in the Complementary Material, that have been trained or tuned, in whole or in part on the Data, using the Complementary Material. +"Derivatives of the Model" means all modifications to the Model, works based on the Model, or any other model which is created or initialized by transfer of patterns of the weights, parameters, activations or output of the Model, to the other model, in order to cause the other model to perform similarly to the Model, including - but not limited to - distillation methods entailing the use of intermediate data representations or methods based on the generation of synthetic data by the Model for training the other model. +"Complementary Material" means the accompanying source code and scripts used to define, run, load, benchmark or evaluate the Model, and used to prepare data for training or evaluation, if any. This includes any accompanying documentation, tutorials, examples, etc, if any. +"Distribution" means any transmission, reproduction, publication or other sharing of the Model or Derivatives of the Model to a third party, including providing the Model as a hosted service made available by electronic or other remote means - e.g. API-based or web access. +"DeepSeek" (or "we") means Beijing DeepSeek Artificial Intelligence Fundamental Technology Research Co., Ltd., Hangzhou DeepSeek Artificial Intelligence Fundamental Technology Research Co., Ltd. and/or any of their affiliates. +"You" (or "Your") means an individual or Legal Entity exercising permissions granted by this License and/or making use of the Model for whichever purpose and in any field of use, including usage of the Model in an end-use application - e.g. chatbot, translator, etc. +"Third Parties" means individuals or legal entities that are not under common control with DeepSeek or You. + +Section II: INTELLECTUAL PROPERTY RIGHTS + +Both copyright and patent grants apply to the Model, Derivatives of the Model and Complementary Material. The Model and Derivatives of the Model are subject to additional terms as described in Section III. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, DeepSeek hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare, publicly display, publicly perform, sublicense, and distribute the Complementary Material, the Model, and Derivatives of the Model. + +3. Grant of Patent License. Subject to the terms and conditions of this License and where and as applicable, DeepSeek hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this paragraph) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Model and the Complementary Material, where such license applies only to those patent claims licensable by DeepSeek that are necessarily infringed by its contribution(s). If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Model and/or Complementary Material constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for the Model and/or works shall terminate as of the date such litigation is asserted or filed. + + +Section III: CONDITIONS OF USAGE, DISTRIBUTION AND REDISTRIBUTION + +4. Distribution and Redistribution. You may host for Third Party remote access purposes (e.g. software-as-a-service), reproduce and distribute copies of the Model or Derivatives of the Model thereof in any medium, with or without modifications, provided that You meet the following conditions: +a. Use-based restrictions as referenced in paragraph 5 MUST be included as an enforceable provision by You in any type of legal agreement (e.g. a license) governing the use and/or distribution of the Model or Derivatives of the Model, and You shall give notice to subsequent users You Distribute to, that the Model or Derivatives of the Model are subject to paragraph 5. This provision does not apply to the use of Complementary Material. +b. You must give any Third Party recipients of the Model or Derivatives of the Model a copy of this License; +c. You must cause any modified files to carry prominent notices stating that You changed the files; +d. You must retain all copyright, patent, trademark, and attribution notices excluding those notices that do not pertain to any part of the Model, Derivatives of the Model. +e. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions - respecting paragraph 4.a. – for use, reproduction, or Distribution of Your modifications, or for any such Derivatives of the Model as a whole, provided Your use, reproduction, and Distribution of the Model otherwise complies with the conditions stated in this License. + +5. Use-based restrictions. The restrictions set forth in Attachment A are considered Use-based restrictions. Therefore You cannot use the Model and the Derivatives of the Model for the specified restricted uses. You may use the Model subject to this License, including only for lawful purposes and in accordance with the License. Use may include creating any content with, finetuning, updating, running, training, evaluating and/or reparametrizing the Model. You shall require all of Your users who use the Model or a Derivative of the Model to comply with the terms of this paragraph (paragraph 5). + +6. The Output You Generate. Except as set forth herein, DeepSeek claims no rights in the Output You generate using the Model. You are accountable for the Output you generate and its subsequent uses. No use of the output can contravene any provision as stated in the License. + +Section IV: OTHER PROVISIONS + +7. Updates and Runtime Restrictions. To the maximum extent permitted by law, DeepSeek reserves the right to restrict (remotely or otherwise) usage of the Model in violation of this License. + +8. Trademarks and related. Nothing in this License permits You to make use of DeepSeek’ trademarks, trade names, logos or to otherwise suggest endorsement or misrepresent the relationship between the parties; and any rights not expressly granted herein are reserved by DeepSeek. + +9. Personal information, IP rights and related. This Model may contain personal information and works with IP rights. You commit to complying with applicable laws and regulations in the handling of personal information and the use of such works. Please note that DeepSeek's license granted to you to use the Model does not imply that you have obtained a legitimate basis for processing the related information or works. As an independent personal information processor and IP rights user, you need to ensure full compliance with relevant legal and regulatory requirements when handling personal information and works with IP rights that may be contained in the Model, and are willing to assume solely any risks and consequences that may arise from that. + +10. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, DeepSeek provides the Model and the Complementary Material on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Model, Derivatives of the Model, and the Complementary Material and assume any risks associated with Your exercise of permissions under this License. + +11. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall DeepSeek be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Model and the Complementary Material (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if DeepSeek has been advised of the possibility of such damages. + +12. Accepting Warranty or Additional Liability. While redistributing the Model, Derivatives of the Model and the Complementary Material thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of DeepSeek, and only if You agree to indemnify, defend, and hold DeepSeek harmless for any liability incurred by, or claims asserted against, DeepSeek by reason of your accepting any such warranty or additional liability. + +13. If any provision of this License is held to be invalid, illegal or unenforceable, the remaining provisions shall be unaffected thereby and remain valid as if such provision had not been set forth herein. + +14. Governing Law and Jurisdiction. This agreement will be governed and construed under PRC laws without regard to choice of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this agreement. The courts located in the domicile of Hangzhou DeepSeek Artificial Intelligence Fundamental Technology Research Co., Ltd. shall have exclusive jurisdiction of any dispute arising out of this agreement. + +END OF TERMS AND CONDITIONS + +Attachment A + +Use Restrictions + +You agree not to use the Model or Derivatives of the Model: + +- In any way that violates any applicable national or international law or regulation or infringes upon the lawful rights and interests of any third party; +- For military use in any way; +- For the purpose of exploiting, harming or attempting to exploit or harm minors in any way; +- To generate or disseminate verifiably false information and/or content with the purpose of harming others; +- To generate or disseminate inappropriate content subject to applicable regulatory requirements; +- To generate or disseminate personal identifiable information without due authorization or for unreasonable use; +- To defame, disparage or otherwise harass others; +- For fully automated decision making that adversely impacts an individual’s legal rights or otherwise creates or modifies a binding, enforceable obligation; +- For any use intended to or which has the effect of discriminating against or harming individuals or groups based on online or offline social behavior or known or predicted personal or personality characteristics; +- To exploit any of the vulnerabilities of a specific group of persons based on their age, social, physical or mental characteristics, in order to materially distort the behavior of a person pertaining to that group in a manner that causes or is likely to cause that person or another person physical or psychological harm; +- For any use intended to or which has the effect of discriminating against individuals or groups based on legally protected characteristics or categories. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5e349db --- /dev/null +++ b/README.md @@ -0,0 +1,315 @@ + + + + +
+ DeepSeek-V2 +
+
+
+ + Homepage + + + Chat + + + Hugging Face + +
+ +
+ + Discord + + + Wechat + + + Twitter Follow + +
+
+ + Code License + + + Model License + +
+

+ Model Download | + Evaluation Results | + API Platform | + How to Use | + License | + Citation +

+ + + +

+ Paper Link👁️ +

+ + +# DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence + +## 1. Introduction +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 DeepSeek-Coder-V2-Base with 6 trillion tokens sourced from a high-quality and multi-source corpus. Through this continued pre-training, DeepSeek-Coder-V2 substantially enhances the coding and mathematical reasoning capabilities of DeepSeek-Coder-V2-Base, while maintaining comparable performance in general language tasks. Compared to DeepSeek-Coder, 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. + +

+ +

+ + +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 in the paper. + +## 2. Model Downloads + +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. + +
+ +| **Model** | **#Total Params** | **#Active Params** | **Context Length** | **Download** | +| :-----------------------------: | :---------------: | :----------------: | :----------------: | :----------------------------------------------------------: | +| DeepSeek-Coder-V2-Lite-Base | 16B | 2.4B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Base) | +| DeepSeek-Coder-V2-Lite-Instruct | 16B | 2.4B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct) | +| DeepSeek-Coder-V2-Base | 236B | 21B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Base) | +| DeepSeek-Coder-V2-Instruct | 236B | 21B | 128k | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct) | + +
+ + + +## 3. Evaluation Results +### 3.1 Code Generation + + +| | #TP | #AP | HumanEval | MBPP+ | LiveCodeBench | USACO | +|:------------|:--------:|:--------:|:--------:|:--------:|:--------:|:-----------:| +| **Closed-Source Models** | | | | | | | +| **Gemini-1.5-Pro** | - | - | 83.5 | **74.6** | 34.1 | 4.9 | +| **Claude-3-Opus** | - | - | 84.2 | 72.0 | 34.6 | 7.8 | +| **GPT-4-Turbo-1106** | - | - | 87.8 | 69.3 | 37.1 | 11.1 | +| **GPT-4-Turbo-0409** | - | - | 88.2 | 72.2 | **45.7** | 12.3 | +| **GPT-4o-0513** | - | - | **91.0** | 73.5 | 43.4 | **18.8** | +| **Open-Source Models** | | | | | | | +| **CodeStral** | 22B | 22B | 78.1 | 68.2 | 31.0 | 4.6 | +| **DeepSeek-Coder-Instruct** | 33B | 33B | 79.3 | 70.1 | 22.5 | 4.2 | +| **Llama3-Instruct** | 70B | 70B | 81.1 | 68.8 | 28.7 | 3.3 | +| **DeepSeek-Coder-V2-Lite-Instruct** | 16B | 2.4B | 81.1 | 68.8 | 24.3 | 6.5 | +| **DeepSeek-Coder-V2-Instruct** | 236B | 21B | **90.2** | **76.2** | **43.4** | **12.1** | + +### 3.2 Code Completion + + +| Model | #TP | #AP | RepoBench (Python) | RepoBench (Java) | HumanEval FIM | +| :------------------------------ | :--: | :--: | :----------------: | :--------------: | :-----------: | +| **CodeStral** | 22B | 22B | **46.1** | **45.7** | 83.0 | +| **DeepSeek-Coder-Base** | 7B | 7B | 36.2 | 43.3 | 86.1 | +| **DeepSeek-Coder-Base** | 33B | 33B | 39.1 | 44.8 | **86.4** | +| **DeepSeek-Coder-V2-Lite-Base** | 16B | 2.4B | 38.9 | 43.3 | **86.4** | + +### 3.3 Code Fixing + + +| | #TP | #AP | Defects4J | SWE-Bench | Aider | +| ----------------------------------- | :--: | :--: | :-------: | :-------: | :------: | +| **Closed-Source Models** | | | | | | +| **Gemini-1.5-Pro** | - | - | 18.6 | 19.3 | 57.1 | +| **Claude-3-Opus** | - | - | 25.5 | 11.7 | 68.4 | +| **GPT-4-Turbo-1106** | - | - | 22.8 | 22.7 | 65.4 | +| **GPT-4-Turbo-0409** | - | - | 24.3 | 18.3 | 63.9 | +| **GPT-4o-0513** | - | - | **26.1** | **26.7** | **72.9** | +| **Open-Source Models** | | | | | | +| **CodeStral** | 22B | 22B | 17.8 | 2.7 | 51.1 | +| **DeepSeek-Coder-Instruct** | 33B | 33B | 11.3 | 0.0 | 54.5 | +| **Llama3-Instruct** | 70B | 70B | 16.2 | - | 49.2 | +| **DeepSeek-Coder-V2-Lite-Instruct** | 16B | 2.4B | 9.2 | 0.0 | 44.4 | +| **DeepSeek-Coder-V2-Instruct** | 236B | 21B | **21.0** | **12.7** | **73.7** | + +### 3.4 Mathematical Reasoning + + +| | #TP | #AP | GSM8K | MATH | AIME 2024 | Math Odyssey | +| ----------------------------------- | :--: | :--: | :------: | :------: | :-------: | :----------: | +| **Closed-Source Models** | | | | | | | +| **Gemini-1.5-Pro** | - | - | 90.8 | 67.7 | 2/30 | 45.0 | +| **Claude-3-Opus** | - | - | 95.0 | 60.1 | 2/30 | 40.6 | +| **GPT-4-Turbo-1106** | - | - | 91.4 | 64.3 | 1/30 | 49.1 | +| **GPT-4-Turbo-0409** | - | - | 93.7 | 73.4 | **3/30** | 46.8 | +| **GPT-4o-0513** | - | - | **95.8** | **76.6** | 2/30 | **53.2** | +| **Open-Source Models** | | | | | | | +| **Llama3-Instruct** | 70B | 70B | 93.0 | 50.4 | 1/30 | 27.9 | +| **DeepSeek-Coder-V2-Lite-Instruct** | 16B | 2.4B | 86.4 | 61.8 | 0/30 | 44.4 | +| **DeepSeek-Coder-V2-Instruct** | 236B | 21B | **94.9** | **75.7** | **4/30** | **53.7** | + +### 3.5 General Natural Language + +| Benchmark | Domain | DeepSeek-V2-Lite Chat | DeepSeek-Coder-V2-Lite Instruct | DeepSeek-V2 Chat | DeepSeek-Coder-V2 Instruct | +| :------------------: | :-----: | :-------------------: | :-----------------------------: | :--------------: | :------------------------: | +| **BBH** | English | 48.1 | 61.2 | 79.7 | **83.9** | +| **MMLU** | English | 55.7 | 60.1 | 78.1 | **79.2** | +| **ARC-Easy** | English | 86.1 | 88.9 | **98.1** | 97.4 | +| **ARC-Challenge** | English | 73.4 | 77.4 | 92.3 | **92.8** | +| **TriviaQA** | English | 65.2 | 59.5 | **86.7** | 82.3 | +| **NaturalQuestions** | English | 35.5 | 30.8 | **53.4** | 47.5 | +| **AGIEval** | English | 42.8 | 28.7 | **61.4** | 60 | +| **CLUEWSC** | Chinese | 80.0 | 76.5 | **89.9** | 85.9 | +| **C-Eval** | Chinese | 60.1 | 61.6 | 78.0 | **79.4** | +| **CMMLU** | Chinese | 62.5 | 62.7 | **81.6** | 80.9 | +| **Arena-Hard** | - | 11.4 | 38.1 | 41.6 | **65.0** | +| **AlpaceEval 2.0** | - | 16.9 | 17.7 | **38.9** | 36.9 | +| **MT-Bench** | - | 7.37 | 7.81 | **8.97** | 8.77 | +| **Alignbench** | - | 6.02 | 6.83 | **7.91** | 7.84 | + +### 3.6 Context Window + +

+ +

+ + +Evaluation results on the ``Needle In A Haystack`` (NIAH) tests. DeepSeek-Coder-V2 performs well across all context window lengths up to **128K**. + +## 4. Chat Website + +You can chat with the DeepSeek-Coder-V2 on DeepSeek's official website: [coder.deepseek.com](https://coder.deepseek.com/sign_in) + +## 5. API Platform +We also provide OpenAI-Compatible API at DeepSeek Platform: [platform.deepseek.com](https://platform.deepseek.com/). Sign up for over millions of free tokens. And you can also pay-as-you-go at an unbeatable price. + +

+ +

+ + +## 6. How to run locally +**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.** + +### Inference with Huggingface's Transformers +You can directly employ [Huggingface's Transformers](https://github.com/huggingface/transformers) for model inference. + +#### Code Completion +```python +from transformers import AutoTokenizer, AutoModelForCausalLM +import torch +tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True) +model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda() +input_text = "#write a quick sort algorithm" +inputs = tokenizer(input_text, return_tensors="pt").to(model.device) +outputs = model.generate(**inputs, max_length=128) +print(tokenizer.decode(outputs[0], skip_special_tokens=True)) +``` + +#### Code Insertion +```python +from transformers import AutoTokenizer, AutoModelForCausalLM +import torch +tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True) +model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda() +input_text = """<|fim▁begin|>def quick_sort(arr): + if len(arr) <= 1: + return arr + pivot = arr[0] + left = [] + right = [] +<|fim▁hole|> + if arr[i] < pivot: + left.append(arr[i]) + else: + right.append(arr[i]) + return quick_sort(left) + [pivot] + quick_sort(right)<|fim▁end|>""" +inputs = tokenizer(input_text, return_tensors="pt").to(model.device) +outputs = model.generate(**inputs, max_length=128) +print(tokenizer.decode(outputs[0], skip_special_tokens=True)[len(input_text):]) +``` + +#### Chat Completion + +```python +from transformers import AutoTokenizer, AutoModelForCausalLM +import torch +tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True) +model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda() +messages=[ + { 'role': 'user', 'content': "write a quick sort algorithm in python."} +] +inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device) +# tokenizer.eos_token_id is the id of <|EOT|> token +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) +print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)) +``` + + + +The complete chat template can be found within `tokenizer_config.json` located in the huggingface model repository. + +An example of chat template is as belows: + +```bash +<|begin▁of▁sentence|>User: {user_message_1} + +Assistant: {assistant_message_1}<|end▁of▁sentence|>User: {user_message_2} + +Assistant: +``` + +You can also add an optional system message: + +```bash +<|begin▁of▁sentence|>{system_message} + +User: {user_message_1} + +Assistant: {assistant_message_1}<|end▁of▁sentence|>User: {user_message_2} + +Assistant: +``` + +### Inference with vLLM (recommended) +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. + +```python +from transformers import AutoTokenizer +from vllm import LLM, SamplingParams + +max_model_len, tp_size = 8192, 1 +model_name = "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct" +tokenizer = AutoTokenizer.from_pretrained(model_name) +llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True) +sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id]) + +messages_list = [ + [{"role": "user", "content": "Who are you?"}], + [{"role": "user", "content": "write a quick sort algorithm in python."}], + [{"role": "user", "content": "Write a piece of quicksort code in C++."}], +] + +prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list] + +outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params) + +generated_text = [output.outputs[0].text for output in outputs] +print(generated_text) +``` + + + +## 7. License + +This code repository is licensed under [the MIT License](LICENSE-CODE). The use of DeepSeek-Coder-V2 Base/Instruct models is subject to [the Model License](LICENSE-MODEL). DeepSeek-Coder-V2 series (including Base and Instruct) supports commercial use. + +## 8. Citation +```latex +@article{deepseek-coder-v2, + author={Qihao Zhu and Daya Guo and Zhihong Shao and Dejian Yang and Peiyi Wang and Runxin Xu and Y. Wu and Yukun Li and Huazuo Gao and Shirong Ma and Wangding Zeng and Xiao Bi and Zihui Gu and Hanwei Xu and Damai Dai and Kai Dong and Liyue Zhang and Yishi Piao and Zhibin Gou and Zhenda Xie and Zhewen Hao and Bingxuan Wang and Junxiao Song and Deli Chen and Xin Xie and Kang Guan and Yuxiang You and Aixin Liu and Qiushi Du and Wenjun Gao and Xuan Lu and Qinyu Chen and Yaohui Wang and Chengqi Deng and Jiashi Li and Chenggang Zhao and Chong Ruan and Fuli Luo and Wenfeng Liang}, + title={DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence}, + year={2024}, + url={https://github.com/deepseek-ai/DeepSeek-Coder-V2/blob/main/paper.pdf} +} +``` + +## 9. Contact +If you have any questions, please raise an issue or contact us at [service@deepseek.com](service@deepseek.com). diff --git a/figures/badge.svg b/figures/badge.svg new file mode 100644 index 0000000..1551f56 --- /dev/null +++ b/figures/badge.svg @@ -0,0 +1 @@ +DeepSeek: HomepageDeepSeekHomepage diff --git a/figures/logo.svg b/figures/logo.svg new file mode 100644 index 0000000..4254944 --- /dev/null +++ b/figures/logo.svg @@ -0,0 +1,22 @@ + + + Created with Pixso. + + + + + + + + + + + + + + + + + + + diff --git a/figures/long_context.png b/figures/long_context.png new file mode 100644 index 0000000..cba13ca Binary files /dev/null and b/figures/long_context.png differ diff --git a/figures/model_price.jpg b/figures/model_price.jpg new file mode 100644 index 0000000..ef07144 Binary files /dev/null and b/figures/model_price.jpg differ diff --git a/figures/performance.png b/figures/performance.png new file mode 100644 index 0000000..f6b6762 Binary files /dev/null and b/figures/performance.png differ diff --git a/figures/qr.jpeg b/figures/qr.jpeg new file mode 100644 index 0000000..d0152d1 Binary files /dev/null and b/figures/qr.jpeg differ diff --git a/paper.pdf b/paper.pdf new file mode 100644 index 0000000..a169b7a Binary files /dev/null and b/paper.pdf differ