RichardErkhov commited on
Commit
d2bfd9d
1 Parent(s): 291f659

uploaded readme

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