AtakanTekparmak commited on
Commit
787056f
·
verified ·
1 Parent(s): ac782fe

feat: Added model card

Browse files
Files changed (1) hide show
  1. README.md +300 -0
README.md ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - zh
5
+ - en
6
+ pipeline_tag: text-generation
7
+ ---
8
+ <div align="center">
9
+ <img src="https://github.com/OpenBMB/MiniCPM/blob/main/assets/minicpm_logo.png?raw=true" width="500em" ></img>
10
+ </div>
11
+
12
+ <p align="center">
13
+ <a href="https://github.com/OpenBMB/MiniCPM/" target="_blank">MiniCPM Repo</a> |
14
+ <a href="https://arxiv.org/abs/2404.06395" target="_blank">MiniCPM Paper</a> |
15
+ <a href="https://github.com/OpenBMB/MiniCPM-V/" target="_blank">MiniCPM-V Repo</a> |
16
+ Join us in <a href="https://discord.gg/3cGQn9b3YM" target="_blank">Discord</a> and <a href="https://github.com/OpenBMB/MiniCPM/blob/main/assets/wechat.jpg" target="_blank">WeChat</a>
17
+
18
+ </p>
19
+
20
+ ## Disclaimer
21
+
22
+ This is a f16 GGUF version, original model card is copy & pasted as is below. Followed this [README](https://github.com/OpenBMB/MiniCPM/blob/main/README-en.md#llamacpp) for quantization.
23
+
24
+ ## Introduction
25
+ MiniCPM3-4B is the 3rd generation of MiniCPM series. The overall performance of MiniCPM3-4B surpasses Phi-3.5-mini-Instruct and GPT-3.5-Turbo-0125, being comparable with many recent 7B~9B models.
26
+
27
+ Compared to MiniCPM1.0/MiniCPM2.0, MiniCPM3-4B has a more powerful and versatile skill set to enable more general usage. MiniCPM3-4B supports function call, along with code interpreter. Please refer to [Advanced Features](https://github.com/OpenBMB/MiniCPM/tree/main?tab=readme-ov-file#%E8%BF%9B%E9%98%B6%E5%8A%9F%E8%83%BD) for usage guidelines.
28
+
29
+ MiniCPM3-4B has a 32k context window. Equipped with LLMxMapReduce, MiniCPM3-4B can handle infinite context theoretically, without requiring huge amount of memory.
30
+
31
+ ## Usage
32
+ ### Inference with Transformers
33
+ ```python
34
+ from transformers import AutoModelForCausalLM, AutoTokenizer
35
+ import torch
36
+
37
+ path = "openbmb/MiniCPM3-4B"
38
+ device = "cuda"
39
+
40
+ tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
41
+ model = AutoModelForCausalLM.from_pretrained(path, torch_dtype=torch.bfloat16, device_map=device, trust_remote_code=True)
42
+
43
+ messages = [
44
+ {"role": "user", "content": "推荐5个北京的景点。"},
45
+ ]
46
+ model_inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(device)
47
+
48
+ model_outputs = model.generate(
49
+ model_inputs,
50
+ max_new_tokens=1024,
51
+ top_p=0.7,
52
+ temperature=0.7
53
+ )
54
+
55
+ output_token_ids = [
56
+ model_outputs[i][len(model_inputs[i]):] for i in range(len(model_inputs))
57
+ ]
58
+
59
+ responses = tokenizer.batch_decode(output_token_ids, skip_special_tokens=True)[0]
60
+ print(responses)
61
+ ```
62
+
63
+ ### Inference with [vLLM](https://github.com/vllm-project/vllm)
64
+ ```python
65
+ from transformers import AutoTokenizer
66
+ from vllm import LLM, SamplingParams
67
+
68
+ model_name = "openbmb/MiniCPM3-4B"
69
+ prompt = [{"role": "user", "content": "推荐5个北京的景点。"}]
70
+
71
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
72
+ input_text = tokenizer.apply_chat_template(prompt, tokenize=False, add_generation_prompt=True)
73
+
74
+ llm = LLM(
75
+ model=model_name,
76
+ trust_remote_code=True,
77
+ tensor_parallel_size=1
78
+ )
79
+ sampling_params = SamplingParams(top_p=0.7, temperature=0.7, max_tokens=1024, repetition_penalty=1.02)
80
+
81
+ outputs = llm.generate(prompts=input_text, sampling_params=sampling_params)
82
+
83
+ print(outputs[0].outputs[0].text)
84
+ ```
85
+
86
+ ## Evaluation Results
87
+
88
+ <table>
89
+ <tr>
90
+ <td>Benchmark</td>
91
+ <td>Qwen2-7B-Instruct</td>
92
+ <td>GLM-4-9B-Chat</td>
93
+ <td>Gemma2-9B-it</td>
94
+ <td>Llama3.1-8B-Instruct</td>
95
+ <td>GPT-3.5-Turbo-0125</td>
96
+ <td>Phi-3.5-mini-Instruct(3.8B)</td>
97
+ <td>MiniCPM3-4B </td>
98
+ </tr>
99
+ <tr>
100
+ <td colspan="15" align="left"><strong>English</strong></td>
101
+ </tr>
102
+ <tr>
103
+ <td>MMLU</td>
104
+ <td>70.5</td>
105
+ <td>72.4</td>
106
+ <td>72.6</td>
107
+ <td>69.4</td>
108
+ <td>69.2</td>
109
+ <td>68.4</td>
110
+ <td>67.2 </td>
111
+ </tr>
112
+ <tr>
113
+ <td>BBH</td>
114
+ <td>64.9</td>
115
+ <td>76.3</td>
116
+ <td>65.2</td>
117
+ <td>67.8</td>
118
+ <td>70.3</td>
119
+ <td>68.6</td>
120
+ <td>70.2 </td>
121
+ </tr>
122
+ <tr>
123
+ <td>MT-Bench</td>
124
+ <td>8.41</td>
125
+ <td>8.35</td>
126
+ <td>7.88</td>
127
+ <td>8.28</td>
128
+ <td>8.17</td>
129
+ <td>8.60</td>
130
+ <td>8.41 </td>
131
+ </tr>
132
+ <tr>
133
+ <td>IFEVAL (Prompt Strict-Acc.)</td>
134
+ <td>51.0</td>
135
+ <td>64.5</td>
136
+ <td>71.9</td>
137
+ <td>71.5</td>
138
+ <td>58.8</td>
139
+ <td>49.4</td>
140
+ <td>68.4 </td>
141
+ </tr>
142
+ <tr>
143
+ <td colspan="15" align="left"><strong>Chinese</strong></td>
144
+ </tr>
145
+ <tr>
146
+ <td>CMMLU</td>
147
+ <td>80.9</td>
148
+ <td>71.5</td>
149
+ <td>59.5</td>
150
+ <td>55.8</td>
151
+ <td>54.5</td>
152
+ <td>46.9</td>
153
+ <td>73.3 </td>
154
+ </tr>
155
+ <tr>
156
+ <td>CEVAL</td>
157
+ <td>77.2</td>
158
+ <td>75.6</td>
159
+ <td>56.7</td>
160
+ <td>55.2</td>
161
+ <td>52.8</td>
162
+ <td>46.1</td>
163
+ <td>73.6 </td>
164
+ </tr>
165
+ <tr>
166
+ <td>AlignBench v1.1</td>
167
+ <td>7.10</td>
168
+ <td>6.61</td>
169
+ <td>7.10</td>
170
+ <td>5.68</td>
171
+ <td>5.82</td>
172
+ <td>5.73</td>
173
+ <td>6.74 </td>
174
+ </tr>
175
+ <tr>
176
+ <td>FollowBench-zh (SSR)</td>
177
+ <td>63.0</td>
178
+ <td>56.4</td>
179
+ <td>57.0</td>
180
+ <td>50.6</td>
181
+ <td>64.6</td>
182
+ <td>58.1</td>
183
+ <td>66.8 </td>
184
+ </tr>
185
+ <tr>
186
+ <td colspan="15" align="left"><strong>Math</strong></td>
187
+ </tr>
188
+ <tr>
189
+ <td>MATH</td>
190
+ <td>49.6</td>
191
+ <td>50.6</td>
192
+ <td>46.0</td>
193
+ <td>51.9</td>
194
+ <td>41.8</td>
195
+ <td>46.4</td>
196
+ <td>46.6 </td>
197
+ </tr>
198
+ <tr>
199
+ <td>GSM8K</td>
200
+ <td>82.3</td>
201
+ <td>79.6</td>
202
+ <td>79.7</td>
203
+ <td>84.5</td>
204
+ <td>76.4</td>
205
+ <td>82.7</td>
206
+ <td>81.1 </td>
207
+ </tr>
208
+ <tr>
209
+ <td>MathBench</td>
210
+ <td>63.4</td>
211
+ <td>59.4</td>
212
+ <td>45.8</td>
213
+ <td>54.3</td>
214
+ <td>48.9</td>
215
+ <td>54.9</td>
216
+ <td>65.6 </td>
217
+ </tr>
218
+ <tr>
219
+ <td colspan="15" align="left"><strong>Code</strong></td>
220
+ </tr>
221
+ <tr>
222
+ <td>HumanEval+</td>
223
+ <td>70.1</td>
224
+ <td>67.1</td>
225
+ <td>61.6</td>
226
+ <td>62.8</td>
227
+ <td>66.5</td>
228
+ <td>68.9</td>
229
+ <td>68.3 </td>
230
+ </tr>
231
+ <tr>
232
+ <td>MBPP+</td>
233
+ <td>57.1</td>
234
+ <td>62.2</td>
235
+ <td>64.3</td>
236
+ <td>55.3</td>
237
+ <td>71.4</td>
238
+ <td>55.8</td>
239
+ <td>63.2 </td>
240
+ </tr>
241
+ <tr>
242
+ <td>LiveCodeBench v3</td>
243
+ <td>22.2</td>
244
+ <td>20.2</td>
245
+ <td>19.2</td>
246
+ <td>20.4</td>
247
+ <td>24.0</td>
248
+ <td>19.6</td>
249
+ <td>22.6 </td>
250
+ </tr>
251
+ <tr>
252
+ <td colspan="15" align="left"><strong>Function Call</strong></td>
253
+ </tr>
254
+ <tr>
255
+ <td>BFCL v2</td>
256
+ <td>71.6</td>
257
+ <td>70.1</td>
258
+ <td>19.2</td>
259
+ <td>73.3</td>
260
+ <td>75.4</td>
261
+ <td>48.4</td>
262
+ <td>76.0 </td>
263
+ </tr>
264
+ <tr>
265
+ <td colspan="15" align="left"><strong>Overall</strong></td>
266
+ </tr>
267
+ <tr>
268
+ <td>Average</td>
269
+ <td>65.3</td>
270
+ <td>65.0</td>
271
+ <td>57.9</td>
272
+ <td>60.8</td>
273
+ <td>61.0</td>
274
+ <td>57.2</td>
275
+ <td><strong>66.3</strong></td>
276
+ </tr>
277
+ </table>
278
+
279
+
280
+ ## Statement
281
+ * As a language model, MiniCPM3-4B generates content by learning from a vast amount of text.
282
+ * However, it does not possess the ability to comprehend or express personal opinions or value judgments.
283
+ * Any content generated by MiniCPM3-4B does not represent the viewpoints or positions of the model developers.
284
+ * Therefore, when using content generated by MiniCPM3-4B, users should take full responsibility for evaluating and verifying it on their own.
285
+
286
+ ## LICENSE
287
+ * This repository is released under the [Apache-2.0](https://github.com/OpenBMB/MiniCPM/blob/main/LICENSE) License.
288
+ * The usage of MiniCPM3-4B model weights must strictly follow [MiniCPM Model License.md](https://github.com/OpenBMB/MiniCPM/blob/main/MiniCPM%20Model%20License.md).
289
+ * The models and weights of MiniCPM3-4B are completely free for academic research. after filling out a ["questionnaire"](https://modelbest.feishu.cn/share/base/form/shrcnpV5ZT9EJ6xYjh3Kx0J6v8g) for registration, are also available for free commercial use.
290
+
291
+ ## Citation
292
+
293
+ ```
294
+ @article{hu2024minicpm,
295
+ title={MiniCPM: Unveiling the Potential of Small Language Models with Scalable Training Strategies},
296
+ author={Hu, Shengding and Tu, Yuge and Han, Xu and He, Chaoqun and Cui, Ganqu and Long, Xiang and Zheng, Zhi and Fang, Yewei and Huang, Yuxiang and Zhao, Weilin and others},
297
+ journal={arXiv preprint arXiv:2404.06395},
298
+ year={2024}
299
+ }
300
+ ```