Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- LICENSE +91 -0
- README.md +260 -0
- config.json +60 -0
- configuration_deepseek.py +206 -0
- generation_config.json +9 -0
- model-00001-of-000055.safetensors +3 -0
- model-00002-of-000055.safetensors +3 -0
- model-00003-of-000055.safetensors +3 -0
- model-00004-of-000055.safetensors +3 -0
- model-00005-of-000055.safetensors +3 -0
- model-00006-of-000055.safetensors +3 -0
- model-00007-of-000055.safetensors +3 -0
- model-00008-of-000055.safetensors +3 -0
- model-00009-of-000055.safetensors +3 -0
- model-00010-of-000055.safetensors +3 -0
- model-00011-of-000055.safetensors +3 -0
- model-00012-of-000055.safetensors +3 -0
- model-00013-of-000055.safetensors +3 -0
- model-00014-of-000055.safetensors +3 -0
- model-00015-of-000055.safetensors +3 -0
- model-00016-of-000055.safetensors +3 -0
- model-00017-of-000055.safetensors +3 -0
- model-00018-of-000055.safetensors +3 -0
- model-00019-of-000055.safetensors +3 -0
- model-00020-of-000055.safetensors +3 -0
- model-00021-of-000055.safetensors +3 -0
- model-00022-of-000055.safetensors +3 -0
- model-00023-of-000055.safetensors +3 -0
- model-00024-of-000055.safetensors +3 -0
- model-00025-of-000055.safetensors +3 -0
- model-00026-of-000055.safetensors +3 -0
- model-00027-of-000055.safetensors +3 -0
- model-00028-of-000055.safetensors +3 -0
- model-00029-of-000055.safetensors +3 -0
- model-00030-of-000055.safetensors +3 -0
- model-00031-of-000055.safetensors +3 -0
- model-00032-of-000055.safetensors +3 -0
- model-00033-of-000055.safetensors +3 -0
- model-00034-of-000055.safetensors +3 -0
- model-00035-of-000055.safetensors +3 -0
- model-00036-of-000055.safetensors +3 -0
- model-00037-of-000055.safetensors +3 -0
- model-00038-of-000055.safetensors +3 -0
- model-00039-of-000055.safetensors +3 -0
- model-00040-of-000055.safetensors +3 -0
- model-00041-of-000055.safetensors +3 -0
- model-00042-of-000055.safetensors +3 -0
- model-00043-of-000055.safetensors +3 -0
- model-00044-of-000055.safetensors +3 -0
- model-00045-of-000055.safetensors +3 -0
LICENSE
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
DEEPSEEK LICENSE AGREEMENT
|
2 |
+
|
3 |
+
Version 1.0, 23 October 2023
|
4 |
+
|
5 |
+
Copyright (c) 2023 DeepSeek
|
6 |
+
|
7 |
+
Section I: PREAMBLE
|
8 |
+
|
9 |
+
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.
|
10 |
+
|
11 |
+
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.
|
12 |
+
|
13 |
+
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.
|
14 |
+
|
15 |
+
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.
|
16 |
+
|
17 |
+
This License governs the use of the model (and its derivatives) and is informed by the model card associated with the model.
|
18 |
+
|
19 |
+
NOW THEREFORE, You and DeepSeek agree as follows:
|
20 |
+
|
21 |
+
1. Definitions
|
22 |
+
"License" means the terms and conditions for use, reproduction, and Distribution as defined in this document.
|
23 |
+
"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.
|
24 |
+
"Output" means the results of operating a Model as embodied in informational content resulting therefrom.
|
25 |
+
"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.
|
26 |
+
"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.
|
27 |
+
"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.
|
28 |
+
"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.
|
29 |
+
"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.
|
30 |
+
"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.
|
31 |
+
"Third Parties" means individuals or legal entities that are not under common control with DeepSeek or You.
|
32 |
+
|
33 |
+
Section II: INTELLECTUAL PROPERTY RIGHTS
|
34 |
+
|
35 |
+
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.
|
36 |
+
|
37 |
+
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.
|
38 |
+
|
39 |
+
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.
|
40 |
+
|
41 |
+
|
42 |
+
Section III: CONDITIONS OF USAGE, DISTRIBUTION AND REDISTRIBUTION
|
43 |
+
|
44 |
+
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:
|
45 |
+
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.
|
46 |
+
b. You must give any Third Party recipients of the Model or Derivatives of the Model a copy of this License;
|
47 |
+
c. You must cause any modified files to carry prominent notices stating that You changed the files;
|
48 |
+
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.
|
49 |
+
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.
|
50 |
+
|
51 |
+
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).
|
52 |
+
|
53 |
+
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.
|
54 |
+
|
55 |
+
Section IV: OTHER PROVISIONS
|
56 |
+
|
57 |
+
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.
|
58 |
+
|
59 |
+
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.
|
60 |
+
|
61 |
+
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.
|
62 |
+
|
63 |
+
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.
|
64 |
+
|
65 |
+
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.
|
66 |
+
|
67 |
+
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.
|
68 |
+
|
69 |
+
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.
|
70 |
+
|
71 |
+
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.
|
72 |
+
|
73 |
+
END OF TERMS AND CONDITIONS
|
74 |
+
|
75 |
+
Attachment A
|
76 |
+
|
77 |
+
Use Restrictions
|
78 |
+
|
79 |
+
You agree not to use the Model or Derivatives of the Model:
|
80 |
+
|
81 |
+
- 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;
|
82 |
+
- For military use in any way;
|
83 |
+
- For the purpose of exploiting, harming or attempting to exploit or harm minors in any way;
|
84 |
+
- To generate or disseminate verifiably false information and/or content with the purpose of harming others;
|
85 |
+
- To generate or disseminate inappropriate content subject to applicable regulatory requirements;
|
86 |
+
- To generate or disseminate personal identifiable information without due authorization or for unreasonable use;
|
87 |
+
- To defame, disparage or otherwise harass others;
|
88 |
+
- For fully automated decision making that adversely impacts an individual’s legal rights or otherwise creates or modifies a binding, enforceable obligation;
|
89 |
+
- 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;
|
90 |
+
- 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;
|
91 |
+
- For any use intended to or which has the effect of discriminating against individuals or groups based on legally protected characteristics or categories.
|
README.md
ADDED
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: other
|
3 |
+
license_name: deepseek
|
4 |
+
license_link: https://github.com/deepseek-ai/DeepSeek-V2/blob/main/LICENSE-MODEL
|
5 |
+
---
|
6 |
+
|
7 |
+
<!-- markdownlint-disable first-line-h1 -->
|
8 |
+
<!-- markdownlint-disable html -->
|
9 |
+
<!-- markdownlint-disable no-duplicate-header -->
|
10 |
+
|
11 |
+
<div align="center">
|
12 |
+
<img src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/logo.svg?raw=true" width="60%" alt="DeepSeek-V2" />
|
13 |
+
</div>
|
14 |
+
<hr>
|
15 |
+
<div align="center" style="line-height: 1;">
|
16 |
+
<a href="https://www.deepseek.com/" target="_blank" style="margin: 2px;">
|
17 |
+
<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;"/>
|
18 |
+
</a>
|
19 |
+
<a href="https://chat.deepseek.com/" target="_blank" style="margin: 2px;">
|
20 |
+
<img alt="Chat" src="https://img.shields.io/badge/🤖%20Chat-DeepSeek%20V2-536af5?color=536af5&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
|
21 |
+
</a>
|
22 |
+
<a href="https://huggingface.co/deepseek-ai" target="_blank" style="margin: 2px;">
|
23 |
+
<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;"/>
|
24 |
+
</a>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
<div align="center" style="line-height: 1;">
|
28 |
+
<a href="https://discord.gg/Tc7c45Zzu5" target="_blank" style="margin: 2px;">
|
29 |
+
<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;"/>
|
30 |
+
</a>
|
31 |
+
<a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/qr.jpeg?raw=true" target="_blank" style="margin: 2px;">
|
32 |
+
<img alt="Wechat" src="https://img.shields.io/badge/WeChat-DeepSeek%20AI-brightgreen?logo=wechat&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
|
33 |
+
</a>
|
34 |
+
<a href="https://twitter.com/deepseek_ai" target="_blank" style="margin: 2px;">
|
35 |
+
<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;"/>
|
36 |
+
</a>
|
37 |
+
</div>
|
38 |
+
|
39 |
+
<div align="center" style="line-height: 1;">
|
40 |
+
<a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/LICENSE-CODE" style="margin: 2px;">
|
41 |
+
<img alt="Code License" src="https://img.shields.io/badge/Code_License-MIT-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
|
42 |
+
</a>
|
43 |
+
<a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/LICENSE-MODEL" style="margin: 2px;">
|
44 |
+
<img alt="Model License" src="https://img.shields.io/badge/Model_License-Model_Agreement-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
|
45 |
+
</a>
|
46 |
+
</div>
|
47 |
+
|
48 |
+
<p align="center">
|
49 |
+
<a href="https://arxiv.org/abs/2405.04434"><b>Paper Link</b>👁️</a>
|
50 |
+
</p>
|
51 |
+
|
52 |
+
# DeepSeek-V2.5-1210
|
53 |
+
|
54 |
+
## 1. Introduction
|
55 |
+
|
56 |
+
DeepSeek-V2.5-1210 is an upgraded version of [DeepSeek-V2.5](https://huggingface.co/deepseek-ai/DeepSeek-V2.5), with improvements across various capabilities:
|
57 |
+
|
58 |
+
- Mathematical: Performance on the MATH-500 benchmark has improved from 74.8% to 82.8% .
|
59 |
+
- Coding: Accuracy on the LiveCodebench (08.01 - 12.01) benchmark has increased from 29.2% to 34.38% .
|
60 |
+
- Writing and Reasoning: Corresponding improvements have been observed in internal test datasets.
|
61 |
+
|
62 |
+
Additionally, the new version of the model has optimized the user experience for file upload and webpage summarization functionalities.
|
63 |
+
|
64 |
+
## 2. How to run locally
|
65 |
+
|
66 |
+
**To utilize DeepSeek-V2.5 in BF16 format for inference, 80GB*8 GPUs are required.**
|
67 |
+
### Inference with Huggingface's Transformers
|
68 |
+
You can directly employ [Huggingface's Transformers](https://github.com/huggingface/transformers) for model inference.
|
69 |
+
|
70 |
+
```python
|
71 |
+
import torch
|
72 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
|
73 |
+
|
74 |
+
model_name = "deepseek-ai/DeepSeek-V2.5-1210"
|
75 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
76 |
+
# `max_memory` should be set based on your devices
|
77 |
+
max_memory = {i: "75GB" for i in range(8)}
|
78 |
+
# `device_map` cannot be set to `auto`
|
79 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map="sequential", torch_dtype=torch.bfloat16, max_memory=max_memory, attn_implementation="eager")
|
80 |
+
model.generation_config = GenerationConfig.from_pretrained(model_name)
|
81 |
+
model.generation_config.pad_token_id = model.generation_config.eos_token_id
|
82 |
+
|
83 |
+
messages = [
|
84 |
+
{"role": "user", "content": "Write a piece of quicksort code in C++"}
|
85 |
+
]
|
86 |
+
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
|
87 |
+
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)
|
88 |
+
|
89 |
+
result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True)
|
90 |
+
print(result)
|
91 |
+
```
|
92 |
+
|
93 |
+
The complete chat template can be found within `tokenizer_config.json` located in the huggingface model repository.
|
94 |
+
|
95 |
+
**Note: The chat template has been updated compared to the previous DeepSeek-V2-Chat version.**
|
96 |
+
|
97 |
+
An example of chat template is as belows:
|
98 |
+
|
99 |
+
```bash
|
100 |
+
<|begin▁of▁sentence|><|User|>{user_message_1}<|Assistant|>{assistant_message_1}<|end▁of▁sentence|><|User|>{user_message_2}<|Assistant|>
|
101 |
+
```
|
102 |
+
|
103 |
+
You can also add an optional system message:
|
104 |
+
|
105 |
+
```bash
|
106 |
+
<|begin▁of▁sentence|>{system_message}<|User|>{user_message_1}<|Assistant|>{assistant_message_1}<|end▁of▁sentence|><|User|>{user_message_2}<|Assistant|>
|
107 |
+
```
|
108 |
+
|
109 |
+
### Inference with vLLM (recommended)
|
110 |
+
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.
|
111 |
+
|
112 |
+
```python
|
113 |
+
from transformers import AutoTokenizer
|
114 |
+
from vllm import LLM, SamplingParams
|
115 |
+
|
116 |
+
max_model_len, tp_size = 8192, 8
|
117 |
+
model_name = "deepseek-ai/DeepSeek-V2.5-1210"
|
118 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
119 |
+
llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)
|
120 |
+
sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])
|
121 |
+
|
122 |
+
messages_list = [
|
123 |
+
[{"role": "user", "content": "Who are you?"}],
|
124 |
+
[{"role": "user", "content": "Translate the following content into Chinese directly: DeepSeek-V2 adopts innovative architectures to guarantee economical training and efficient inference."}],
|
125 |
+
[{"role": "user", "content": "Write a piece of quicksort code in C++."}],
|
126 |
+
]
|
127 |
+
|
128 |
+
prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]
|
129 |
+
|
130 |
+
outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)
|
131 |
+
|
132 |
+
generated_text = [output.outputs[0].text for output in outputs]
|
133 |
+
print(generated_text)
|
134 |
+
```
|
135 |
+
|
136 |
+
### Function calling
|
137 |
+
|
138 |
+
Function calling allows the model to call external tools to enhance its capabilities.
|
139 |
+
|
140 |
+
Here is an example:
|
141 |
+
|
142 |
+
```python
|
143 |
+
# Assume that `model` and `tokenizer` are loaded
|
144 |
+
model.generation_config = GenerationConfig(do_sample=False, max_new_tokens=128, eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.eos_token_id)
|
145 |
+
|
146 |
+
tool_system_prompt = """You are a helpful Assistant.
|
147 |
+
|
148 |
+
## Tools
|
149 |
+
|
150 |
+
### Function
|
151 |
+
|
152 |
+
You have the following functions available:
|
153 |
+
|
154 |
+
- `get_current_weather`:
|
155 |
+
```json
|
156 |
+
{
|
157 |
+
"name": "get_current_weather",
|
158 |
+
"description": "Get the current weather in a given location",
|
159 |
+
"parameters": {
|
160 |
+
"type": "object",
|
161 |
+
"properties": {
|
162 |
+
"location": {
|
163 |
+
"type": "string",
|
164 |
+
"description": "The city and state, e.g. San Francisco, CA"
|
165 |
+
},
|
166 |
+
"unit": {
|
167 |
+
"type": "string",
|
168 |
+
"enum": [
|
169 |
+
"celsius",
|
170 |
+
"fahrenheit"
|
171 |
+
]
|
172 |
+
}
|
173 |
+
},
|
174 |
+
"required": [
|
175 |
+
"location"
|
176 |
+
]
|
177 |
+
}
|
178 |
+
}
|
179 |
+
```"""
|
180 |
+
|
181 |
+
tool_call_messages = [{"role": "system", "content": tool_system_prompt}, {"role": "user", "content": "What's the weather like in Tokyo and Paris?"}]
|
182 |
+
tool_call_inputs = tokenizer.apply_chat_template(tool_call_messages, add_generation_prompt=True, return_tensors="pt")
|
183 |
+
tool_call_outputs = model.generate(tool_call_inputs.to(model.device))
|
184 |
+
# Generated text: '<|tool▁calls▁begin|><|tool▁call▁begin|>function<|tool▁sep|>get_current_weather\n```json\n{"location": "Tokyo"}\n```<|tool▁call▁end|>\n<|tool▁call▁begin|>function<|tool▁sep|>get_current_weather\n```json\n{"location": "Paris"}\n```<|tool▁call▁end|><|tool▁calls▁end|><|end▁of▁sentence|>'
|
185 |
+
|
186 |
+
# Mock response of calling `get_current_weather`
|
187 |
+
tool_messages = [{"role": "tool", "content": '{"location": "Tokyo", "temperature": "10", "unit": null}'}, {"role": "tool", "content": '{"location": "Paris", "temperature": "22", "unit": null}'}]
|
188 |
+
tool_inputs = tokenizer.apply_chat_template(tool_messages, add_generation_prompt=False, return_tensors="pt")[:, 1:]
|
189 |
+
tool_inputs = torch.cat([tool_call_outputs, tool_inputs.to(model.device)], dim=1)
|
190 |
+
tool_outputs = model.generate(tool_inputs)
|
191 |
+
# Generated text: The current weather in Tokyo is 10 degrees, and in Paris, it is 22 degrees.<|end▁of▁sentence|>
|
192 |
+
```
|
193 |
+
|
194 |
+
### JSON output
|
195 |
+
|
196 |
+
You can use JSON Output Mode to ensure the model generates a valid JSON object. To active this mode, a special instruction should be appended to your system prompt.
|
197 |
+
|
198 |
+
```python
|
199 |
+
# Assume that `model` and `tokenizer` are loaded
|
200 |
+
model.generation_config = GenerationConfig(do_sample=False, max_new_tokens=128, eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.eos_token_id)
|
201 |
+
|
202 |
+
user_system_prompt = 'The user will provide some exam text. Please parse the "question" and "answer" and output them in JSON format.'
|
203 |
+
json_system_prompt = f"""{user_system_prompt}
|
204 |
+
|
205 |
+
## Response Format
|
206 |
+
|
207 |
+
Reply with JSON object ONLY."""
|
208 |
+
|
209 |
+
json_messages = [{"role": "system", "content": json_system_prompt}, {"role": "user", "content": "Which is the highest mountain in the world? Mount Everest."}]
|
210 |
+
json_inputs = tokenizer.apply_chat_template(json_messages, add_generation_prompt=True, return_tensors="pt")
|
211 |
+
json_outpus = model.generate(json_inputs.to(model.device))
|
212 |
+
# Generated text: '```json\n{\n "question": "Which is the highest mountain in the world?",\n "answer": "Mount Everest."\n}\n```<|end▁of▁sentence|>'
|
213 |
+
```
|
214 |
+
|
215 |
+
### FIM completion
|
216 |
+
|
217 |
+
In FIM (Fill In the Middle) completion, you can provide a prefix and an optional suffix, and the model will complete the content in between.
|
218 |
+
|
219 |
+
```python
|
220 |
+
# Assume that `model` and `tokenizer` are loaded
|
221 |
+
model.generation_config = GenerationConfig(do_sample=False, max_new_tokens=128, eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.eos_token_id)
|
222 |
+
|
223 |
+
prefix = """def quick_sort(arr):
|
224 |
+
if len(arr) <= 1:
|
225 |
+
return arr
|
226 |
+
pivot = arr[0]
|
227 |
+
left = []
|
228 |
+
right = []
|
229 |
+
"""
|
230 |
+
|
231 |
+
suffix = """
|
232 |
+
if arr[i] < pivot:
|
233 |
+
left.append(arr[i])
|
234 |
+
else:
|
235 |
+
right.append(arr[i])
|
236 |
+
return quick_sort(left) + [pivot] + quick_sort(right)"""
|
237 |
+
|
238 |
+
fim_prompt = f"<|fim▁begin|>{prefix}<|fim▁hole|>{suffix}<|fim▁end|>"
|
239 |
+
fim_inputs = tokenizer(fim_prompt, add_special_tokens=True, return_tensors="pt").input_ids
|
240 |
+
fim_outputs = model.generate(fim_inputs.to(model.device))
|
241 |
+
# Generated text: " for i in range(1, len(arr)):<|end▁of▁sentence|>"
|
242 |
+
```
|
243 |
+
|
244 |
+
## 3. License
|
245 |
+
This code repository is licensed under the MIT License. The use of DeepSeek-V2 Base/Chat models is subject to [the Model License](LICENSE). DeepSeek-V2 series (including Base and Chat) supports commercial use.
|
246 |
+
|
247 |
+
## 4. Citation
|
248 |
+
```
|
249 |
+
@misc{deepseekv2,
|
250 |
+
title={DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model},
|
251 |
+
author={DeepSeek-AI},
|
252 |
+
year={2024},
|
253 |
+
eprint={2405.04434},
|
254 |
+
archivePrefix={arXiv},
|
255 |
+
primaryClass={cs.CL}
|
256 |
+
}
|
257 |
+
```
|
258 |
+
|
259 |
+
## 5. Contact
|
260 |
+
If you have any questions, please raise an issue or contact us at [[email protected]]([email protected]).
|
config.json
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"DeepseekV2ForCausalLM"
|
4 |
+
],
|
5 |
+
"attention_bias": false,
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"auto_map": {
|
8 |
+
"AutoConfig": "configuration_deepseek.DeepseekV2Config",
|
9 |
+
"AutoModel": "modeling_deepseek.DeepseekV2Model",
|
10 |
+
"AutoModelForCausalLM": "modeling_deepseek.DeepseekV2ForCausalLM"
|
11 |
+
},
|
12 |
+
"aux_loss_alpha": 0.001,
|
13 |
+
"bos_token_id": 100000,
|
14 |
+
"eos_token_id": 100001,
|
15 |
+
"ep_size": 1,
|
16 |
+
"first_k_dense_replace": 1,
|
17 |
+
"hidden_act": "silu",
|
18 |
+
"hidden_size": 5120,
|
19 |
+
"initializer_range": 0.02,
|
20 |
+
"intermediate_size": 12288,
|
21 |
+
"kv_lora_rank": 512,
|
22 |
+
"max_position_embeddings": 163840,
|
23 |
+
"model_type": "deepseek_v2",
|
24 |
+
"moe_intermediate_size": 1536,
|
25 |
+
"moe_layer_freq": 1,
|
26 |
+
"n_group": 8,
|
27 |
+
"n_routed_experts": 160,
|
28 |
+
"n_shared_experts": 2,
|
29 |
+
"norm_topk_prob": false,
|
30 |
+
"num_attention_heads": 128,
|
31 |
+
"num_experts_per_tok": 6,
|
32 |
+
"num_hidden_layers": 60,
|
33 |
+
"num_key_value_heads": 128,
|
34 |
+
"pretraining_tp": 1,
|
35 |
+
"q_lora_rank": 1536,
|
36 |
+
"qk_nope_head_dim": 128,
|
37 |
+
"qk_rope_head_dim": 64,
|
38 |
+
"rms_norm_eps": 1e-06,
|
39 |
+
"rope_scaling": {
|
40 |
+
"beta_fast": 32,
|
41 |
+
"beta_slow": 1,
|
42 |
+
"factor": 40,
|
43 |
+
"mscale": 1.0,
|
44 |
+
"mscale_all_dim": 1.0,
|
45 |
+
"original_max_position_embeddings": 4096,
|
46 |
+
"type": "yarn"
|
47 |
+
},
|
48 |
+
"rope_theta": 10000,
|
49 |
+
"routed_scaling_factor": 16.0,
|
50 |
+
"scoring_func": "softmax",
|
51 |
+
"seq_aux": true,
|
52 |
+
"tie_word_embeddings": false,
|
53 |
+
"topk_group": 3,
|
54 |
+
"topk_method": "group_limited_greedy",
|
55 |
+
"torch_dtype": "bfloat16",
|
56 |
+
"transformers_version": "4.39.3",
|
57 |
+
"use_cache": true,
|
58 |
+
"v_head_dim": 128,
|
59 |
+
"vocab_size": 102400
|
60 |
+
}
|
configuration_deepseek.py
ADDED
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers.configuration_utils import PretrainedConfig
|
2 |
+
from transformers.utils import logging
|
3 |
+
|
4 |
+
logger = logging.get_logger(__name__)
|
5 |
+
|
6 |
+
DEEPSEEK_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
|
7 |
+
class DeepseekV2Config(PretrainedConfig):
|
8 |
+
r"""
|
9 |
+
This is the configuration class to store the configuration of a [`DeepseekV2Model`]. It is used to instantiate an DeepSeek
|
10 |
+
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
11 |
+
defaults will yield a similar configuration to that of the DeepSeek-V2.
|
12 |
+
|
13 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
14 |
+
documentation from [`PretrainedConfig`] for more information.
|
15 |
+
|
16 |
+
|
17 |
+
Args:
|
18 |
+
vocab_size (`int`, *optional*, defaults to 102400):
|
19 |
+
Vocabulary size of the Deep model. Defines the number of different tokens that can be represented by the
|
20 |
+
`inputs_ids` passed when calling [`DeepseekV2Model`]
|
21 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
22 |
+
Dimension of the hidden representations.
|
23 |
+
intermediate_size (`int`, *optional*, defaults to 11008):
|
24 |
+
Dimension of the MLP representations.
|
25 |
+
moe_intermediate_size (`int`, *optional*, defaults to 1407):
|
26 |
+
Dimension of the MoE representations.
|
27 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
28 |
+
Number of hidden layers in the Transformer decoder.
|
29 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
30 |
+
Number of attention heads for each attention layer in the Transformer decoder.
|
31 |
+
n_shared_experts (`int`, *optional*, defaults to None):
|
32 |
+
Number of shared experts, None means dense model.
|
33 |
+
n_routed_experts (`int`, *optional*, defaults to None):
|
34 |
+
Number of routed experts, None means dense model.
|
35 |
+
routed_scaling_factor (`float`, *optional*, defaults to 1.0):
|
36 |
+
Scaling factor or routed experts.
|
37 |
+
topk_method (`str`, *optional*, defaults to `gready`):
|
38 |
+
Topk method used in routed gate.
|
39 |
+
n_group (`int`, *optional*, defaults to None):
|
40 |
+
Number of groups for routed experts.
|
41 |
+
topk_group (`int`, *optional*, defaults to None):
|
42 |
+
Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups).
|
43 |
+
num_experts_per_tok (`int`, *optional*, defaults to None):
|
44 |
+
Number of selected experts, None means dense model.
|
45 |
+
moe_layer_freq (`int`, *optional*, defaults to 1):
|
46 |
+
The frequency of the MoE layer: one expert layer for every `moe_layer_freq - 1` dense layers.
|
47 |
+
first_k_dense_replace (`int`, *optional*, defaults to 0):
|
48 |
+
Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head).
|
49 |
+
\--k dense layers--/
|
50 |
+
norm_topk_prob (`bool`, *optional*, defaults to False):
|
51 |
+
Whether to normalize the weights of the routed experts.
|
52 |
+
scoring_func (`str`, *optional*, defaults to 'softmax'):
|
53 |
+
Method of computing expert weights.
|
54 |
+
aux_loss_alpha (`float`, *optional*, defaults to 0.001):
|
55 |
+
Auxiliary loss weight coefficient.
|
56 |
+
seq_aux = (`bool`, *optional*, defaults to True):
|
57 |
+
Whether to compute the auxiliary loss for each individual sample.
|
58 |
+
num_key_value_heads (`int`, *optional*):
|
59 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
60 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
61 |
+
`num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
62 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
63 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
64 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
|
65 |
+
`num_attention_heads`.
|
66 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
67 |
+
The non-linear activation function (function or string) in the decoder.
|
68 |
+
max_position_embeddings (`int`, *optional*, defaults to 2048):
|
69 |
+
The maximum sequence length that this model might ever be used with.
|
70 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
71 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
72 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
73 |
+
The epsilon used by the rms normalization layers.
|
74 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
75 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
76 |
+
relevant if `config.is_decoder=True`.
|
77 |
+
pad_token_id (`int`, *optional*):
|
78 |
+
Padding token id.
|
79 |
+
bos_token_id (`int`, *optional*, defaults to 1):
|
80 |
+
Beginning of stream token id.
|
81 |
+
eos_token_id (`int`, *optional*, defaults to 2):
|
82 |
+
End of stream token id.
|
83 |
+
pretraining_tp (`int`, *optional*, defaults to 1):
|
84 |
+
Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
|
85 |
+
document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
|
86 |
+
necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
|
87 |
+
issue](https://github.com/pytorch/pytorch/issues/76232).
|
88 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
89 |
+
Whether to tie weight embeddings
|
90 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
91 |
+
The base period of the RoPE embeddings.
|
92 |
+
rope_scaling (`Dict`, *optional*):
|
93 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
|
94 |
+
strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
|
95 |
+
`{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
|
96 |
+
`max_position_embeddings` to the expected new maximum.
|
97 |
+
attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
|
98 |
+
Whether to use a bias in the query, key, value and output projection layers during self-attention.
|
99 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
100 |
+
The dropout ratio for the attention probabilities.
|
101 |
+
|
102 |
+
```python
|
103 |
+
>>> from transformers import DeepseekV2Model, DeepseekV2Config
|
104 |
+
|
105 |
+
>>> # Initializing a Deepseek-V2 style configuration
|
106 |
+
>>> configuration = DeepseekV2Config()
|
107 |
+
|
108 |
+
>>> # Accessing the model configuration
|
109 |
+
>>> configuration = model.config
|
110 |
+
```"""
|
111 |
+
|
112 |
+
model_type = "deepseek_v2"
|
113 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
114 |
+
|
115 |
+
def __init__(
|
116 |
+
self,
|
117 |
+
vocab_size=102400,
|
118 |
+
hidden_size=4096,
|
119 |
+
intermediate_size=11008,
|
120 |
+
moe_intermediate_size = 1407,
|
121 |
+
num_hidden_layers=30,
|
122 |
+
num_attention_heads=32,
|
123 |
+
num_key_value_heads=32,
|
124 |
+
n_shared_experts = None,
|
125 |
+
n_routed_experts = None,
|
126 |
+
ep_size = 1,
|
127 |
+
routed_scaling_factor = 1.0,
|
128 |
+
kv_lora_rank = 512,
|
129 |
+
q_lora_rank = 1536,
|
130 |
+
qk_rope_head_dim = 64,
|
131 |
+
v_head_dim = 128,
|
132 |
+
qk_nope_head_dim = 128,
|
133 |
+
topk_method = 'gready',
|
134 |
+
n_group = None,
|
135 |
+
topk_group = None,
|
136 |
+
num_experts_per_tok = None,
|
137 |
+
moe_layer_freq = 1,
|
138 |
+
first_k_dense_replace = 0,
|
139 |
+
norm_topk_prob = False,
|
140 |
+
scoring_func = 'softmax',
|
141 |
+
aux_loss_alpha = 0.001,
|
142 |
+
seq_aux = True,
|
143 |
+
hidden_act="silu",
|
144 |
+
max_position_embeddings=2048,
|
145 |
+
initializer_range=0.02,
|
146 |
+
rms_norm_eps=1e-6,
|
147 |
+
use_cache=True,
|
148 |
+
pad_token_id=None,
|
149 |
+
bos_token_id=100000,
|
150 |
+
eos_token_id=100001,
|
151 |
+
pretraining_tp=1,
|
152 |
+
tie_word_embeddings=False,
|
153 |
+
rope_theta=10000.0,
|
154 |
+
rope_scaling=None,
|
155 |
+
attention_bias=False,
|
156 |
+
attention_dropout=0.0,
|
157 |
+
**kwargs,
|
158 |
+
):
|
159 |
+
self.vocab_size = vocab_size
|
160 |
+
self.max_position_embeddings = max_position_embeddings
|
161 |
+
self.hidden_size = hidden_size
|
162 |
+
self.intermediate_size = intermediate_size
|
163 |
+
self.moe_intermediate_size = moe_intermediate_size
|
164 |
+
self.num_hidden_layers = num_hidden_layers
|
165 |
+
self.num_attention_heads = num_attention_heads
|
166 |
+
self.n_shared_experts = n_shared_experts
|
167 |
+
self.n_routed_experts = n_routed_experts
|
168 |
+
self.ep_size = ep_size
|
169 |
+
self.routed_scaling_factor = routed_scaling_factor
|
170 |
+
self.kv_lora_rank = kv_lora_rank
|
171 |
+
self.q_lora_rank = q_lora_rank
|
172 |
+
self.qk_rope_head_dim = qk_rope_head_dim
|
173 |
+
self.v_head_dim = v_head_dim
|
174 |
+
self.qk_nope_head_dim = qk_nope_head_dim
|
175 |
+
self.topk_method = topk_method
|
176 |
+
self.n_group = n_group
|
177 |
+
self.topk_group = topk_group
|
178 |
+
self.num_experts_per_tok = num_experts_per_tok
|
179 |
+
self.moe_layer_freq = moe_layer_freq
|
180 |
+
self.first_k_dense_replace = first_k_dense_replace
|
181 |
+
self.norm_topk_prob = norm_topk_prob
|
182 |
+
self.scoring_func = scoring_func
|
183 |
+
self.aux_loss_alpha = aux_loss_alpha
|
184 |
+
self.seq_aux = seq_aux
|
185 |
+
# for backward compatibility
|
186 |
+
if num_key_value_heads is None:
|
187 |
+
num_key_value_heads = num_attention_heads
|
188 |
+
|
189 |
+
self.num_key_value_heads = num_key_value_heads
|
190 |
+
self.hidden_act = hidden_act
|
191 |
+
self.initializer_range = initializer_range
|
192 |
+
self.rms_norm_eps = rms_norm_eps
|
193 |
+
self.pretraining_tp = pretraining_tp
|
194 |
+
self.use_cache = use_cache
|
195 |
+
self.rope_theta = rope_theta
|
196 |
+
self.rope_scaling = rope_scaling
|
197 |
+
self.attention_bias = attention_bias
|
198 |
+
self.attention_dropout = attention_dropout
|
199 |
+
|
200 |
+
super().__init__(
|
201 |
+
pad_token_id=pad_token_id,
|
202 |
+
bos_token_id=bos_token_id,
|
203 |
+
eos_token_id=eos_token_id,
|
204 |
+
tie_word_embeddings=tie_word_embeddings,
|
205 |
+
**kwargs,
|
206 |
+
)
|
generation_config.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 100000,
|
4 |
+
"eos_token_id": 100001,
|
5 |
+
"do_sample": true,
|
6 |
+
"temperature": 0.3,
|
7 |
+
"top_p": 0.95,
|
8 |
+
"transformers_version": "4.39.3"
|
9 |
+
}
|
model-00001-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fb03bc9e84d248beca95756ac11adab800cd3c2c88e50cfe418a4b22ece5556f
|
3 |
+
size 8594017186
|
model-00002-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5ef04f290a6365f4a2afbf248350de88d53f0f6664317a5a810d89cdaadce64f
|
3 |
+
size 8604902394
|
model-00003-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:17e0e7e49e2c9e1700a91a2c1d59311466c34213df1e6c24c68f79da2ed027a1
|
3 |
+
size 8604902394
|
model-00004-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:50b7bf9c9438fd2bf24de9034ea990a368d7ab8b5d808e87d7255554f658aec8
|
3 |
+
size 8604902402
|
model-00005-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:432ab704cd960270da105c36cf768aa8bbc1bc7418cd2da2c2cb525d3a59af39
|
3 |
+
size 8590441833
|
model-00006-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1acd40f8095af5dff9ff4291abcbd8a2bfca40a3bf110abced76312ba2a70441
|
3 |
+
size 8604902329
|
model-00007-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4420365aea4cb9772c639b930733fc0855cec741baf36c9644e3c54e36309097
|
3 |
+
size 8604902352
|
model-00008-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2ea597c85ad417f8f0042b548d1232f259e656a7d790dfdfddba436cccb32b24
|
3 |
+
size 8604902352
|
model-00009-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8609b7b2653b52fbc3908f7d1da664e95f68edf579ac361249665f4f9e3a3da4
|
3 |
+
size 8604902538
|
model-00010-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8fc6a00d3757543e2c8c624b12a6011b11a3cbf5e6825b5afcb4b007cf40ddba
|
3 |
+
size 8604902887
|
model-00011-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:47a0bb9bf97b47074fca37e82967dcd36ebb76401ab0771f33d17d87de771e3f
|
3 |
+
size 8604902887
|
model-00012-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3f8e2c5eb392d20fd70cb11ea59027eaf59c1757892285814df297782856bb8f
|
3 |
+
size 8604902888
|
model-00013-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cf83013f939210d1a592aead3aa2f1ec1b5476af7d69e20558e8a8a341af074c
|
3 |
+
size 8604902929
|
model-00014-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:133952fdddbb828eafb712aaa8d2cbb5f9b5ef17e07583f0cc2e8e989bfc35b0
|
3 |
+
size 8604902929
|
model-00015-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:049e81396ae409ee96b77c29d0ac6e3bab2f63cff9445c7a252785eed54553ab
|
3 |
+
size 8604902929
|
model-00016-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:03f4ac299014343b9c3eddebfbf45d461605d617a6753ea8591728f0586976a2
|
3 |
+
size 8604902933
|
model-00017-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c5da6a6ca89a69063a1bdda9c2335aa298fb2c5002fa4ecc4dd8fd6716fb8d23
|
3 |
+
size 8590442357
|
model-00018-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4a9f8566aaf849e3c537533cee45cf9b1860e9d23b4c740a9ccd1fde8d70a93d
|
3 |
+
size 8604902862
|
model-00019-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:286bf71dccd0c727526a8d6d91eb9737872e3e4ace9e7b17734b5e69546add4e
|
3 |
+
size 8604902887
|
model-00020-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1f26580faea56a51a0c08968ede3ba9bfe592bad795ad988ba44215d804c9ce8
|
3 |
+
size 8604902887
|
model-00021-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:431db5c0fa8875fd2940719e54323b6f080a8e2efef92e2b6ecba55bdc0e4234
|
3 |
+
size 8604902887
|
model-00022-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4e5103482e2b0cab9ad422cdcf73e27d727b30f7d103af036a8420d9dc17de40
|
3 |
+
size 8604902887
|
model-00023-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4a50082c95c083e3bca9cba2de4b5ef9eee8f8947f612ff1d56b83bbd08276a3
|
3 |
+
size 8604902887
|
model-00024-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bb55c702821188f67d682ce9389fae22c51be1783383a10f46231d4f95a01736
|
3 |
+
size 8604902887
|
model-00025-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a945a677124fee4fe863b07fdc2c1b95a27f200d013608b73dff4e72d2626602
|
3 |
+
size 8604902928
|
model-00026-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:af3e48c34463928e085758dd6e785da40cc7c8a9f9918925222ea0c7f76a2e6e
|
3 |
+
size 8604902929
|
model-00027-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2b379d66dfa98a9d456758913e18d49d320d9059b4e066033c77e2b3f54a7876
|
3 |
+
size 8604902929
|
model-00028-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ee355e2d6c09b117ec0dc0c6bc7f5d1bcb5b83e040d3aad7d56e78da3859c3d1
|
3 |
+
size 8604902929
|
model-00029-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1ea6dbaefc42e3f70205a8f65a9cee8885367b5d80bd8d76d8209a99e76697a1
|
3 |
+
size 8590442363
|
model-00030-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:228cb561287ee24c9b8225ac9a0ce0e4eed201c2b27efe9d79bde24a917a692e
|
3 |
+
size 8604902860
|
model-00031-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f6a32596416cb7064c00011aa92619e0b874f618cb12c9d2be5b7cf79c6c7c17
|
3 |
+
size 8604902887
|
model-00032-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7bd653a7fd019edd9910988d59234e28bbd5773482d0c5395cf607ffbbc479d5
|
3 |
+
size 8604902887
|
model-00033-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:320637bf82dc79c7ddb6cf39688043b5131c657f17ef7dda3d633251b786f827
|
3 |
+
size 8604902887
|
model-00034-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ee0481aca2f959254581ef0e3c9648c71478cc6384de0d3e37e913576036fb06
|
3 |
+
size 8604902887
|
model-00035-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:114be46d150388bb0acc99a8639610a2adec288bcfc3af6475c50982c1145184
|
3 |
+
size 8604902887
|
model-00036-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e247c3f1cc811689c87d05db80c250d066ea70f3459324db51c8bf0de95f447e
|
3 |
+
size 8604902887
|
model-00037-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:44457e0942b37c46c16708e15fbfcbed3a25ec378cc7cebfa6dbf2668f96192d
|
3 |
+
size 8604902926
|
model-00038-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cde4b9997c8ba6c768e9ce448928543b39d9aaf09adb8d15aab5d99a6f28492e
|
3 |
+
size 8604902929
|
model-00039-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:37b2c750cc6e9400b9ba0472e88a5506e20ed364063e4a3c330e16f2470a5a41
|
3 |
+
size 8604902929
|
model-00040-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:78a541ff861dbdba1bbcba5b03f06b4afac9f75798c12dd8fd812b5debb4a39b
|
3 |
+
size 8604902927
|
model-00041-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c69cc858b3bd707ba8e355084cfc3bd3b9dd4aa49c6a34c9c52f95b5dfef2f23
|
3 |
+
size 8590442367
|
model-00042-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8ed7ca0b9d4bf68754689b4bbfc15fb5da92d6f972ca798440a7d94eae095b9c
|
3 |
+
size 8604902858
|
model-00043-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7fa9ce54eb78a1e89e1e27d642163cee5b70ecd099af2de3e79a8e2b3bb8c783
|
3 |
+
size 8604902887
|
model-00044-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7fcf008afbf3daa16888e963958b5721db25409da18d2925ffb78f82de1bf92f
|
3 |
+
size 8604902887
|
model-00045-of-000055.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:41889ced7b349b7e64d0df2a226ba215567eab9f015c6a8109d9ac42363d8de4
|
3 |
+
size 8604902887
|