BigDong commited on
Commit
6262af8
Β·
1 Parent(s): 52969e3

update README.md

Browse files
Files changed (1) hide show
  1. README.md +108 -9
README.md CHANGED
@@ -12,14 +12,14 @@ library_name: transformers
12
 
13
  <p align="center">
14
  <a href="https://github.com/OpenBMB/MiniCPM/" target="_blank">GitHub Repo</a> |
15
- <a href="TODO" target="_blank">Technical Report</a>
16
  </p>
17
  <p align="center">
18
  πŸ‘‹ Join us on <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>
19
  </p>
20
 
21
  ## What's New
22
- - [2025.06.06] **MiniCPM4** series are released! This model achieves ultimate efficiency improvements while maintaining optimal performance at the same scale! It can achieve over 5x generation acceleration on typical end-side chips! You can find technical report on [arXiv](TODO).πŸ”₯πŸ”₯πŸ”₯
23
 
24
  ## MiniCPM4 Series
25
  MiniCPM4 series are highly efficient large language models (LLMs) designed explicitly for end-side devices, which achieves this efficiency through systematic innovation in four key dimensions: model architecture, training data, training algorithms, and inference systems.
@@ -30,7 +30,7 @@ MiniCPM4 series are highly efficient large language models (LLMs) designed expli
30
  - [BitCPM4-0.5B](https://huggingface.co/openbmb/BitCPM4-0.5B): Extreme ternary quantization applied to MiniCPM4-0.5B compresses model parameters into ternary values, achieving a 90% reduction in bit width.
31
  - [BitCPM4-1B](https://huggingface.co/openbmb/BitCPM4-1B): Extreme ternary quantization applied to MiniCPM3-1B compresses model parameters into ternary values, achieving a 90% reduction in bit width.
32
  - [MiniCPM4-Survey](https://huggingface.co/openbmb/MiniCPM4-Survey): Based on MiniCPM4-8B, accepts users' quiries as input and autonomously generate trustworthy, long-form survey papers.
33
- - [MiniCPM4-MCP](https://huggingface.co/openbmb/MiniCPM4-MCP): Based on MiniCPM4-8B, accepts users' queries and available MCP tools as input and autonomously calls relevant MCP tools to satisfy user requirements.
34
 
35
  ## Introduction
36
  MiniCPM 4 is an extremely efficient edge-side large model that has undergone efficient optimization across four dimensions: model architecture, learning algorithms, training data, and inference systems, achieving ultimate efficiency improvements.
@@ -53,8 +53,106 @@ MiniCPM 4 is an extremely efficient edge-side large model that has undergone eff
53
 
54
  ## Usage
55
  ### Inference with Transformers
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  ### Inference with [vLLM](https://github.com/vllm-project/vllm)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  ## Evaluation Results
60
  On two typical end-side chips, Jetson AGX Orin and RTX 4090, MiniCPM4 demonstrates significantly faster processing speed compared to similar-size models in long text processing tasks. As text length increases, MiniCPM4's efficiency advantage becomes more pronounced. On the Jetson AGX Orin platform, compared to Qwen3-8B, MiniCPM4 achieves approximately 7x decoding speed improvement.
@@ -78,14 +176,15 @@ MiniCPM4 is pre-trained on 32K long texts and achieves length extension through
78
  - Therefore, when using content generated by MiniCPM, users should take full responsibility for evaluating and verifying it on their own.
79
 
80
  ## LICENSE
81
- - This repository is released under the [Apache-2.0](https://github.com/OpenBMB/MiniCPM/blob/main/LICENSE) License.
82
- - The usage of MiniCPM model weights must strictly follow [MiniCPM Model License](https://github.com/OpenBMB/MiniCPM/blob/main/MiniCPM%20Model%20License.md).
83
- - The models and weights of MiniCPM 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.
84
 
85
  ## Citation
86
-
87
- - Please cite our [paper](TODO) if you find our work valuable.
88
 
89
  ```bibtex
90
- TODO
 
 
 
 
91
  ```
 
12
 
13
  <p align="center">
14
  <a href="https://github.com/OpenBMB/MiniCPM/" target="_blank">GitHub Repo</a> |
15
+ <a href="https://github.com/OpenBMB/MiniCPM/tree/main/report/MiniCPM_4_Technical_Report.pdf" target="_blank">Technical Report</a>
16
  </p>
17
  <p align="center">
18
  πŸ‘‹ Join us on <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>
19
  </p>
20
 
21
  ## What's New
22
+ - [2025.06.06] **MiniCPM4** series are released! This model achieves ultimate efficiency improvements while maintaining optimal performance at the same scale! It can achieve over 5x generation acceleration on typical end-side chips! You can find technical report [here](https://github.com/OpenBMB/MiniCPM/tree/main/report/MiniCPM_4_Technical_Report.pdf).πŸ”₯πŸ”₯πŸ”₯
23
 
24
  ## MiniCPM4 Series
25
  MiniCPM4 series are highly efficient large language models (LLMs) designed explicitly for end-side devices, which achieves this efficiency through systematic innovation in four key dimensions: model architecture, training data, training algorithms, and inference systems.
 
30
  - [BitCPM4-0.5B](https://huggingface.co/openbmb/BitCPM4-0.5B): Extreme ternary quantization applied to MiniCPM4-0.5B compresses model parameters into ternary values, achieving a 90% reduction in bit width.
31
  - [BitCPM4-1B](https://huggingface.co/openbmb/BitCPM4-1B): Extreme ternary quantization applied to MiniCPM3-1B compresses model parameters into ternary values, achieving a 90% reduction in bit width.
32
  - [MiniCPM4-Survey](https://huggingface.co/openbmb/MiniCPM4-Survey): Based on MiniCPM4-8B, accepts users' quiries as input and autonomously generate trustworthy, long-form survey papers.
33
+ - [MiniCPM4-MCP](https://huggingface.co/openbmb/MiniCPM4-MCP): Based on MiniCPM4-8B, accepts users' queries and available MCP tools as input and autonomously calls relevant MCP tools to satisfy users' requirements.
34
 
35
  ## Introduction
36
  MiniCPM 4 is an extremely efficient edge-side large model that has undergone efficient optimization across four dimensions: model architecture, learning algorithms, training data, and inference systems, achieving ultimate efficiency improvements.
 
53
 
54
  ## Usage
55
  ### Inference with Transformers
56
+ ```python
57
+ from transformers import AutoModelForCausalLM, AutoTokenizer
58
+ import torch
59
+ torch.manual_seed(0)
60
+
61
+ path = 'openbmb/MiniCPM4-0.5B'
62
+ device = "cuda"
63
+ tokenizer = AutoTokenizer.from_pretrained(path)
64
+ model = AutoModelForCausalLM.from_pretrained(path, torch_dtype=torch.bfloat16, device_map=device, trust_remote_code=True)
65
+
66
+ # User can directly use the chat interface
67
+ responds, history = model.chat(tokenizer, "Write an article about Artificial Intelligence.", temperature=0.7, top_p=0.7)
68
+ print(responds)
69
+
70
+ # User can also use the generate interface
71
+ # messages = [
72
+ # {"role": "user", "content": "Write an article about Artificial Intelligence."},
73
+ # ]
74
+ # model_inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(device)
75
+
76
+ # model_outputs = model.generate(
77
+ # model_inputs,
78
+ # max_new_tokens=1024,
79
+ # top_p=0.7,
80
+ # temperature=0.7
81
+ # )
82
+ # output_token_ids = [
83
+ # model_outputs[i][len(model_inputs[i]):] for i in range(len(model_inputs))
84
+ # ]
85
+
86
+ # responses = tokenizer.batch_decode(output_token_ids, skip_special_tokens=True)[0]
87
+ # print(responses)
88
+ ```
89
+
90
+ ### Inference with [SGLang](https://github.com/sgl-project/sglang)
91
+
92
+ For now, you need to install our forked version of SGLang.
93
+ ```bash
94
+ git clone -b openbmb https://github.com/OpenBMB/sglang.git
95
+ cd sglang
96
+
97
+ pip install --upgrade pip
98
+ pip install -e "python[all]"
99
+ ```
100
+
101
+ You can start the inference server by running the following command:
102
+ ```bash
103
+ python -m sglang.launch_server --model openbmb/MiniCPM4-8B --trust-remote-code --port 30000 --chat-template chatml
104
+ ```
105
+
106
+ Then you can use the chat interface by running the following command:
107
+ ```python
108
+ import openai
109
+
110
+ client = openai.Client(base_url=f"http://localhost:30000/v1", api_key="None")
111
+
112
+ response = client.chat.completions.create(
113
+ model="openbmb/MiniCPM4-8B",
114
+ messages=[
115
+ {"role": "user", "content": "Write an article about Artificial Intelligence."},
116
+ ],
117
+ temperature=0.7,
118
+ max_tokens=1024,
119
+ )
120
+
121
+ print(response.choices[0].message.content)
122
+ ```
123
 
124
  ### Inference with [vLLM](https://github.com/vllm-project/vllm)
125
+ For now, you need to install the latest version of vLLM.
126
+ ```
127
+ pip install -U vllm \
128
+ --pre \
129
+ --extra-index-url https://wheels.vllm.ai/nightly
130
+ ```
131
+
132
+ Then you can inference MiniCPM4-8B with vLLM:
133
+ ```python
134
+ from transformers import AutoTokenizer
135
+ from vllm import LLM, SamplingParams
136
+
137
+ model_name = "openbmb/MiniCPM4-8B"
138
+ prompt = [{"role": "user", "content": "Please recommend 5 tourist attractions in Beijing. "}]
139
+
140
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
141
+ input_text = tokenizer.apply_chat_template(prompt, tokenize=False, add_generation_prompt=True)
142
+
143
+ llm = LLM(
144
+ model=model_name,
145
+ trust_remote_code=True,
146
+ max_num_batched_tokens=32768,
147
+ dtype="bfloat16",
148
+ gpu_memory_utilization=0.8,
149
+ )
150
+ sampling_params = SamplingParams(top_p=0.7, temperature=0.7, max_tokens=1024, repetition_penalty=1.02)
151
+
152
+ outputs = llm.generate(prompts=input_text, sampling_params=sampling_params)
153
+
154
+ print(outputs[0].outputs[0].text)
155
+ ```
156
 
157
  ## Evaluation Results
158
  On two typical end-side chips, Jetson AGX Orin and RTX 4090, MiniCPM4 demonstrates significantly faster processing speed compared to similar-size models in long text processing tasks. As text length increases, MiniCPM4's efficiency advantage becomes more pronounced. On the Jetson AGX Orin platform, compared to Qwen3-8B, MiniCPM4 achieves approximately 7x decoding speed improvement.
 
176
  - Therefore, when using content generated by MiniCPM, users should take full responsibility for evaluating and verifying it on their own.
177
 
178
  ## LICENSE
179
+ - This repository and MiniCPM models are released under the [Apache-2.0](https://github.com/OpenBMB/MiniCPM/blob/main/LICENSE) License.
 
 
180
 
181
  ## Citation
182
+ - Please cite our [paper](https://github.com/OpenBMB/MiniCPM/tree/main/report/MiniCPM_4_Technical_Report.pdf) if you find our work valuable.
 
183
 
184
  ```bibtex
185
+ @article{minicpm4,
186
+ title={{MiniCPM4}: Ultra-Efficient LLMs on End Devices},
187
+ author={MiniCPM Team},
188
+ year={2025}
189
+ }
190
  ```