aashish1904 commited on
Commit
a01887f
·
verified ·
1 Parent(s): 769a308

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +316 -0
README.md ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+
4
+ license: apache-2.0
5
+ language:
6
+ - zh
7
+ - en
8
+ pipeline_tag: text-generation
9
+ library_name: transformers
10
+
11
+ ---
12
+
13
+ [![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
14
+
15
+
16
+ # QuantFactory/MiniCPM3-4B-GGUF
17
+ This is quantized version of [openbmb/MiniCPM3-4B](https://huggingface.co/openbmb/MiniCPM3-4B) created using llama.cpp
18
+
19
+ # Original Model Card
20
+
21
+ <div align="center">
22
+ <img src="https://github.com/OpenBMB/MiniCPM/blob/main/assets/minicpm_logo.png?raw=true" width="500em" ></img>
23
+ </div>
24
+
25
+ <p align="center">
26
+ <a href="https://github.com/OpenBMB/MiniCPM/" target="_blank">MiniCPM Repo</a> |
27
+ <a href="https://arxiv.org/abs/2404.06395" target="_blank">MiniCPM Paper</a> |
28
+ <a href="https://github.com/OpenBMB/MiniCPM-V/" target="_blank">MiniCPM-V Repo</a> |
29
+ 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>
30
+
31
+ </p>
32
+
33
+ ## Introduction
34
+ 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.
35
+
36
+ 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.
37
+
38
+ MiniCPM3-4B has a 32k context window. Equipped with LLMxMapReduce, MiniCPM3-4B can handle infinite context theoretically, without requiring huge amount of memory.
39
+
40
+ ## Usage
41
+ ### Inference with Transformers
42
+ ```python
43
+ from transformers import AutoModelForCausalLM, AutoTokenizer
44
+ import torch
45
+
46
+ path = "openbmb/MiniCPM3-4B"
47
+ device = "cuda"
48
+
49
+ tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
50
+ model = AutoModelForCausalLM.from_pretrained(path, torch_dtype=torch.bfloat16, device_map=device, trust_remote_code=True)
51
+
52
+ messages = [
53
+ {"role": "user", "content": "推荐5个北京的景点。"},
54
+ ]
55
+ model_inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(device)
56
+
57
+ model_outputs = model.generate(
58
+ model_inputs,
59
+ max_new_tokens=1024,
60
+ top_p=0.7,
61
+ temperature=0.7
62
+ )
63
+
64
+ output_token_ids = [
65
+ model_outputs[i][len(model_inputs[i]):] for i in range(len(model_inputs))
66
+ ]
67
+
68
+ responses = tokenizer.batch_decode(output_token_ids, skip_special_tokens=True)[0]
69
+ print(responses)
70
+ ```
71
+
72
+ ### Inference with [vLLM](https://github.com/vllm-project/vllm)
73
+
74
+ For now, you need to install our forked version of vLLM.
75
+
76
+ ```bash
77
+ pip install git+https://github.com/OpenBMB/vllm.git@minicpm3
78
+ ```
79
+
80
+ ```python
81
+ from transformers import AutoTokenizer
82
+ from vllm import LLM, SamplingParams
83
+
84
+ model_name = "openbmb/MiniCPM3-4B"
85
+ prompt = [{"role": "user", "content": "推荐5个北京的景点。"}]
86
+
87
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
88
+ input_text = tokenizer.apply_chat_template(prompt, tokenize=False, add_generation_prompt=True)
89
+
90
+ llm = LLM(
91
+ model=model_name,
92
+ trust_remote_code=True,
93
+ tensor_parallel_size=1
94
+ )
95
+ sampling_params = SamplingParams(top_p=0.7, temperature=0.7, max_tokens=1024, repetition_penalty=1.02)
96
+
97
+ outputs = llm.generate(prompts=input_text, sampling_params=sampling_params)
98
+
99
+ print(outputs[0].outputs[0].text)
100
+ ```
101
+
102
+ ## Evaluation Results
103
+
104
+ <table>
105
+ <tr>
106
+ <td>Benchmark</td>
107
+ <td>Qwen2-7B-Instruct</td>
108
+ <td>GLM-4-9B-Chat</td>
109
+ <td>Gemma2-9B-it</td>
110
+ <td>Llama3.1-8B-Instruct</td>
111
+ <td>GPT-3.5-Turbo-0125</td>
112
+ <td>Phi-3.5-mini-Instruct(3.8B)</td>
113
+ <td>MiniCPM3-4B </td>
114
+ </tr>
115
+ <tr>
116
+ <td colspan="15" align="left"><strong>English</strong></td>
117
+ </tr>
118
+ <tr>
119
+ <td>MMLU</td>
120
+ <td>70.5</td>
121
+ <td>72.4</td>
122
+ <td>72.6</td>
123
+ <td>69.4</td>
124
+ <td>69.2</td>
125
+ <td>68.4</td>
126
+ <td>67.2 </td>
127
+ </tr>
128
+ <tr>
129
+ <td>BBH</td>
130
+ <td>64.9</td>
131
+ <td>76.3</td>
132
+ <td>65.2</td>
133
+ <td>67.8</td>
134
+ <td>70.3</td>
135
+ <td>68.6</td>
136
+ <td>70.2 </td>
137
+ </tr>
138
+ <tr>
139
+ <td>MT-Bench</td>
140
+ <td>8.41</td>
141
+ <td>8.35</td>
142
+ <td>7.88</td>
143
+ <td>8.28</td>
144
+ <td>8.17</td>
145
+ <td>8.60</td>
146
+ <td>8.41 </td>
147
+ </tr>
148
+ <tr>
149
+ <td>IFEVAL (Prompt Strict-Acc.)</td>
150
+ <td>51.0</td>
151
+ <td>64.5</td>
152
+ <td>71.9</td>
153
+ <td>71.5</td>
154
+ <td>58.8</td>
155
+ <td>49.4</td>
156
+ <td>68.4 </td>
157
+ </tr>
158
+ <tr>
159
+ <td colspan="15" align="left"><strong>Chinese</strong></td>
160
+ </tr>
161
+ <tr>
162
+ <td>CMMLU</td>
163
+ <td>80.9</td>
164
+ <td>71.5</td>
165
+ <td>59.5</td>
166
+ <td>55.8</td>
167
+ <td>54.5</td>
168
+ <td>46.9</td>
169
+ <td>73.3 </td>
170
+ </tr>
171
+ <tr>
172
+ <td>CEVAL</td>
173
+ <td>77.2</td>
174
+ <td>75.6</td>
175
+ <td>56.7</td>
176
+ <td>55.2</td>
177
+ <td>52.8</td>
178
+ <td>46.1</td>
179
+ <td>73.6 </td>
180
+ </tr>
181
+ <tr>
182
+ <td>AlignBench v1.1</td>
183
+ <td>7.10</td>
184
+ <td>6.61</td>
185
+ <td>7.10</td>
186
+ <td>5.68</td>
187
+ <td>5.82</td>
188
+ <td>5.73</td>
189
+ <td>6.74 </td>
190
+ </tr>
191
+ <tr>
192
+ <td>FollowBench-zh (SSR)</td>
193
+ <td>63.0</td>
194
+ <td>56.4</td>
195
+ <td>57.0</td>
196
+ <td>50.6</td>
197
+ <td>64.6</td>
198
+ <td>58.1</td>
199
+ <td>66.8 </td>
200
+ </tr>
201
+ <tr>
202
+ <td colspan="15" align="left"><strong>Math</strong></td>
203
+ </tr>
204
+ <tr>
205
+ <td>MATH</td>
206
+ <td>49.6</td>
207
+ <td>50.6</td>
208
+ <td>46.0</td>
209
+ <td>51.9</td>
210
+ <td>41.8</td>
211
+ <td>46.4</td>
212
+ <td>46.6 </td>
213
+ </tr>
214
+ <tr>
215
+ <td>GSM8K</td>
216
+ <td>82.3</td>
217
+ <td>79.6</td>
218
+ <td>79.7</td>
219
+ <td>84.5</td>
220
+ <td>76.4</td>
221
+ <td>82.7</td>
222
+ <td>81.1 </td>
223
+ </tr>
224
+ <tr>
225
+ <td>MathBench</td>
226
+ <td>63.4</td>
227
+ <td>59.4</td>
228
+ <td>45.8</td>
229
+ <td>54.3</td>
230
+ <td>48.9</td>
231
+ <td>54.9</td>
232
+ <td>65.6 </td>
233
+ </tr>
234
+ <tr>
235
+ <td colspan="15" align="left"><strong>Code</strong></td>
236
+ </tr>
237
+ <tr>
238
+ <td>HumanEval+</td>
239
+ <td>70.1</td>
240
+ <td>67.1</td>
241
+ <td>61.6</td>
242
+ <td>62.8</td>
243
+ <td>66.5</td>
244
+ <td>68.9</td>
245
+ <td>68.3 </td>
246
+ </tr>
247
+ <tr>
248
+ <td>MBPP+</td>
249
+ <td>57.1</td>
250
+ <td>62.2</td>
251
+ <td>64.3</td>
252
+ <td>55.3</td>
253
+ <td>71.4</td>
254
+ <td>55.8</td>
255
+ <td>63.2 </td>
256
+ </tr>
257
+ <tr>
258
+ <td>LiveCodeBench v3</td>
259
+ <td>22.2</td>
260
+ <td>20.2</td>
261
+ <td>19.2</td>
262
+ <td>20.4</td>
263
+ <td>24.0</td>
264
+ <td>19.6</td>
265
+ <td>22.6 </td>
266
+ </tr>
267
+ <tr>
268
+ <td colspan="15" align="left"><strong>Function Call</strong></td>
269
+ </tr>
270
+ <tr>
271
+ <td>BFCL v2</td>
272
+ <td>71.6</td>
273
+ <td>70.1</td>
274
+ <td>19.2</td>
275
+ <td>73.3</td>
276
+ <td>75.4</td>
277
+ <td>48.4</td>
278
+ <td>76.0 </td>
279
+ </tr>
280
+ <tr>
281
+ <td colspan="15" align="left"><strong>Overall</strong></td>
282
+ </tr>
283
+ <tr>
284
+ <td>Average</td>
285
+ <td>65.3</td>
286
+ <td>65.0</td>
287
+ <td>57.9</td>
288
+ <td>60.8</td>
289
+ <td>61.0</td>
290
+ <td>57.2</td>
291
+ <td><strong>66.3</strong></td>
292
+ </tr>
293
+ </table>
294
+
295
+
296
+ ## Statement
297
+ * As a language model, MiniCPM3-4B generates content by learning from a vast amount of text.
298
+ * However, it does not possess the ability to comprehend or express personal opinions or value judgments.
299
+ * Any content generated by MiniCPM3-4B does not represent the viewpoints or positions of the model developers.
300
+ * Therefore, when using content generated by MiniCPM3-4B, users should take full responsibility for evaluating and verifying it on their own.
301
+
302
+ ## LICENSE
303
+ * This repository is released under the [Apache-2.0](https://github.com/OpenBMB/MiniCPM/blob/main/LICENSE) License.
304
+ * 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).
305
+ * 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.
306
+
307
+ ## Citation
308
+
309
+ ```
310
+ @article{hu2024minicpm,
311
+ title={MiniCPM: Unveiling the Potential of Small Language Models with Scalable Training Strategies},
312
+ 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},
313
+ journal={arXiv preprint arXiv:2404.06395},
314
+ year={2024}
315
+ }
316
+ ```