RichardErkhov commited on
Commit
5aa54c4
1 Parent(s): bddcd7e

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +185 -0
README.md ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ deepseek-coder-6.7b-base - bnb 4bits
11
+ - Model creator: https://huggingface.co/deepseek-ai/
12
+ - Original model: https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-base/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ license: other
20
+ license_name: deepseek-license
21
+ license_link: LICENSE
22
+ ---
23
+
24
+ <p align="center">
25
+ <img width="1000px" alt="DeepSeek Coder" src="https://github.com/deepseek-ai/DeepSeek-Coder/blob/main/pictures/logo.png?raw=true">
26
+ </p>
27
+ <p align="center"><a href="https://www.deepseek.com/">[🏠Homepage]</a> | <a href="https://coder.deepseek.com/">[🤖 Chat with DeepSeek Coder]</a> | <a href="https://discord.gg/Tc7c45Zzu5">[Discord]</a> | <a href="https://github.com/guoday/assert/blob/main/QR.png?raw=true">[Wechat(微信)]</a> </p>
28
+ <hr>
29
+
30
+
31
+ ### 1. Introduction of Deepseek Coder
32
+
33
+ Deepseek Coder is composed of a series of code language models, each trained from scratch on 2T tokens, with a composition of 87% code and 13% natural language in both English and Chinese. We provide various sizes of the code model, ranging from 1B to 33B versions. Each model is pre-trained on project-level code corpus by employing a window size of 16K and a extra fill-in-the-blank task, to support project-level code completion and infilling. For coding capabilities, Deepseek Coder achieves state-of-the-art performance among open-source code models on multiple programming languages and various benchmarks.
34
+
35
+ - **Massive Training Data**: Trained from scratch on 2T tokens, including 87% code and 13% linguistic data in both English and Chinese languages.
36
+
37
+ - **Highly Flexible & Scalable**: Offered in model sizes of 1.3B, 5.7B, 6.7B, and 33B, enabling users to choose the setup most suitable for their requirements.
38
+
39
+ - **Superior Model Performance**: State-of-the-art performance among publicly available code models on HumanEval, MultiPL-E, MBPP, DS-1000, and APPS benchmarks.
40
+
41
+ - **Advanced Code Completion Capabilities**: A window size of 16K and a fill-in-the-blank task, supporting project-level code completion and infilling tasks.
42
+
43
+
44
+
45
+ ### 2. Model Summary
46
+ deepseek-coder-6.7b-base is a 6.7B parameter model with Multi-Head Attention trained on 2 trillion tokens.
47
+ - **Home Page:** [DeepSeek](https://deepseek.com/)
48
+ - **Repository:** [deepseek-ai/deepseek-coder](https://github.com/deepseek-ai/deepseek-coder)
49
+ - **Chat With DeepSeek Coder:** [DeepSeek-Coder](https://coder.deepseek.com/)
50
+
51
+
52
+ ### 3. How to Use
53
+ Here give some examples of how to use our model.
54
+ #### 1)Code Completion
55
+ ```python
56
+ from transformers import AutoTokenizer, AutoModelForCausalLM
57
+ import torch
58
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
59
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
60
+ input_text = "#write a quick sort algorithm"
61
+ inputs = tokenizer(input_text, return_tensors="pt").cuda()
62
+ outputs = model.generate(**inputs, max_length=128)
63
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
64
+ ```
65
+
66
+ #### 2)Code Insertion
67
+ ```python
68
+ from transformers import AutoTokenizer, AutoModelForCausalLM
69
+ import torch
70
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
71
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
72
+ input_text = """<|fim▁begin|>def quick_sort(arr):
73
+ if len(arr) <= 1:
74
+ return arr
75
+ pivot = arr[0]
76
+ left = []
77
+ right = []
78
+ <|fim▁hole|>
79
+ if arr[i] < pivot:
80
+ left.append(arr[i])
81
+ else:
82
+ right.append(arr[i])
83
+ return quick_sort(left) + [pivot] + quick_sort(right)<|fim▁end|>"""
84
+ inputs = tokenizer(input_text, return_tensors="pt").cuda()
85
+ outputs = model.generate(**inputs, max_length=128)
86
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True)[len(input_text):])
87
+ ```
88
+
89
+ #### 3)Repository Level Code Completion
90
+ ```python
91
+ from transformers import AutoTokenizer, AutoModelForCausalLM
92
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True)
93
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base", trust_remote_code=True).cuda()
94
+
95
+ input_text = """#utils.py
96
+ import torch
97
+ from sklearn import datasets
98
+ from sklearn.model_selection import train_test_split
99
+ from sklearn.preprocessing import StandardScaler
100
+ from sklearn.metrics import accuracy_score
101
+
102
+ def load_data():
103
+ iris = datasets.load_iris()
104
+ X = iris.data
105
+ y = iris.target
106
+
107
+ # Standardize the data
108
+ scaler = StandardScaler()
109
+ X = scaler.fit_transform(X)
110
+
111
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
112
+
113
+ # Convert numpy data to PyTorch tensors
114
+ X_train = torch.tensor(X_train, dtype=torch.float32)
115
+ X_test = torch.tensor(X_test, dtype=torch.float32)
116
+ y_train = torch.tensor(y_train, dtype=torch.int64)
117
+ y_test = torch.tensor(y_test, dtype=torch.int64)
118
+
119
+ return X_train, X_test, y_train, y_test
120
+
121
+ def evaluate_predictions(y_test, y_pred):
122
+ return accuracy_score(y_test, y_pred)
123
+ #model.py
124
+ import torch
125
+ import torch.nn as nn
126
+ import torch.optim as optim
127
+ from torch.utils.data import DataLoader, TensorDataset
128
+
129
+ class IrisClassifier(nn.Module):
130
+ def __init__(self):
131
+ super(IrisClassifier, self).__init__()
132
+ self.fc = nn.Sequential(
133
+ nn.Linear(4, 16),
134
+ nn.ReLU(),
135
+ nn.Linear(16, 3)
136
+ )
137
+
138
+ def forward(self, x):
139
+ return self.fc(x)
140
+
141
+ def train_model(self, X_train, y_train, epochs, lr, batch_size):
142
+ criterion = nn.CrossEntropyLoss()
143
+ optimizer = optim.Adam(self.parameters(), lr=lr)
144
+
145
+ # Create DataLoader for batches
146
+ dataset = TensorDataset(X_train, y_train)
147
+ dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=True)
148
+
149
+ for epoch in range(epochs):
150
+ for batch_X, batch_y in dataloader:
151
+ optimizer.zero_grad()
152
+ outputs = self(batch_X)
153
+ loss = criterion(outputs, batch_y)
154
+ loss.backward()
155
+ optimizer.step()
156
+
157
+ def predict(self, X_test):
158
+ with torch.no_grad():
159
+ outputs = self(X_test)
160
+ _, predicted = outputs.max(1)
161
+ return predicted.numpy()
162
+ #main.py
163
+ from utils import load_data, evaluate_predictions
164
+ from model import IrisClassifier as Classifier
165
+
166
+ def main():
167
+ # Model training and evaluation
168
+ """
169
+ inputs = tokenizer(input_text, return_tensors="pt").cuda()
170
+ outputs = model.generate(**inputs, max_new_tokens=140)
171
+ print(tokenizer.decode(outputs[0]))
172
+ ```
173
+
174
+
175
+
176
+ ### 4. License
177
+ This code repository is licensed under the MIT License. The use of DeepSeek Coder models is subject to the Model License. DeepSeek Coder supports commercial use.
178
+
179
+ See the [LICENSE-MODEL](https://github.com/deepseek-ai/deepseek-coder/blob/main/LICENSE-MODEL) for more details.
180
+
181
+ ### 5. Contact
182
+
183
+ If you have any questions, please raise an issue or contact us at [agi_code@deepseek.com](mailto:agi_code@deepseek.com).
184
+
185
+