Kaguya-19 commited on
Commit
be8c7be
·
verified ·
1 Parent(s): ef347f9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +100 -162
README.md CHANGED
@@ -1,202 +1,140 @@
1
  ---
2
  base_model: openbmb/MiniCPM3-4B
3
  library_name: peft
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
 
 
 
11
 
12
- ## Model Details
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
 
 
 
17
 
 
18
 
 
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
- ## Uses
 
 
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
 
40
- ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
 
 
 
 
43
 
44
- [More Information Needed]
 
 
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
 
 
49
 
50
- [More Information Needed]
51
 
52
- ### Out-of-Scope Use
 
 
 
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
 
55
 
56
- [More Information Needed]
 
 
 
57
 
58
- ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
 
 
 
61
 
62
- [More Information Needed]
 
 
63
 
64
- ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
- ## How to Get Started with the Model
 
 
 
 
 
71
 
72
- Use the code below to get started with the model.
73
 
74
- [More Information Needed]
75
 
76
- ## Training Details
 
 
77
 
78
- ### Training Data
 
 
 
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
200
- ### Framework versions
201
-
202
- - PEFT 0.12.0
 
1
  ---
2
  base_model: openbmb/MiniCPM3-4B
3
  library_name: peft
4
+ license: apache-2.0
5
+ language:
6
+ - zh
7
+ - en
8
  ---
9
 
10
+ ## MiniCPM3-RAG-LoRA
11
 
12
+ **MiniCPM3-RAG-LoRA** 由面壁智能与清华大学自然语言处理实验室(THUNLP)共同开发,采用直接偏好优化(DPO)方法对 [MiniCPM3](https://huggingface.co/openbmb/MiniCPM3-4B) 进行 LoRA 微调,仅基于两万余条开放域问答和逻辑推理任务的开源数据,在通用评测数据集上实现了模型性能平均提升 13%。
13
 
14
+ 欢迎关注 `MiniCPM3` 与 RAG 套件系列:
15
 
16
+ - 生成模型:[MiniCPM3](https://huggingface.co/openbmb/MiniCPM3-4B)
17
+ - 检索模型:[RankCPM-E](https://huggingface.co/openbmb/RankCPM-E)
18
+ - 重排模型:[RankCPM-R](https://huggingface.co/openbmb/RankCPM-R)
19
+ - 面向 RAG 场景的 LoRA 插件:[MiniCPM3-RAG-LoRA](https://huggingface.co/openbmb/MiniCPM3-RAG-LoRA)
20
 
21
+ **MiniCPM3-RAG-LoRA** developed by ModelBest Inc. and THUNLP, utilizes the Direct Preference Optimization (DPO) method to fine-tune [MiniCPM3](https://huggingface.co/openbmb/MiniCPM3-4B) with LoRA. By training on just over 20,000 open-source data points from open-domain question answering and logical reasoning tasks, the model achieved an average performance improvement of 13% on general benchmark datasets.
22
 
23
+ We also invite you to explore MiniCPM3 and the RAG toolkit series:
24
 
25
+ - Generation Model: [MiniCPM3](https://huggingface.co/openbmb/MiniCPM3-4B)
26
+ - Retrieval Model: [RankCPM-E](https://huggingface.co/openbmb/RankCPM-E)
27
+ - Re-ranking Model: [RankCPM-R](https://huggingface.co/openbmb/RankCPM-R)
28
+ - LoRA Plugin for RAG scenarios: [MiniCPM3-RAG-LoRA](https://huggingface.co/openbmb/MiniCPM3-RAG-LoRA)
29
 
30
+ ## 模型信息 Model Information
31
 
32
+ - 模型大小:4B
33
+ - Model Size: 2.4B
34
 
35
+ ## 模型使用 Usage
 
 
 
 
 
 
36
 
37
+ ### 输入格式 Input Format
38
 
39
+ MiniCPM3-RAG-LoRA 模型遵循格式如下:
40
 
41
+ MiniCPM3-RAG-LoRA supports instructions in the following format:
 
 
42
 
43
+ ```
44
+ Background: {{ passages }} Query: {{ query }}
45
+ ```
46
 
47
+ 例如:
48
 
49
+ For example:
50
 
51
+ ```
52
+ Background:
53
+ ["In the novel 'The Silent Watcher,' the lead character is named Alex Carter. Alex is a private detective who uncovers a series of mysterious events in a small town.",
54
+ "Set in a quiet town, 'The Silent Watcher' follows Alex Carter, a former police officer turned private investigator, as he unravels the town's dark secrets.",
55
+ "'The Silent Watcher' revolves around Alex Carter's journey as he confronts his past while solving complex cases in his hometown."]
56
 
57
+ Query:
58
+ "What is the name of the lead character in the novel 'The Silent Watcher'?"
59
+ ```
60
 
61
+ ### 环境要求 Requirements
62
 
63
+ ```
64
+ transformers>=4.36.0
65
+ ```
66
 
67
+ ### 示例脚本 Demo
68
 
69
+ ```python
70
+ from transformers import AutoModelForCausalLM, AutoTokenizer
71
+ import torch
72
+ torch.manual_seed(0)
73
 
74
+ path = 'openbmb/MiniCPM3-RAG-LoRA'
75
+ tokenizer = AutoTokenizer.from_pretrained(path)
76
+ model = AutoModelForCausalLM.from_pretrained(path, torch_dtype=torch.bfloat16, device_map='cuda', trust_remote_code=True)
77
 
78
+ passages = ["In the novel 'The Silent Watcher,' the lead character is named Alex Carter. Alex is a private detective who uncovers a series of mysterious events in a small town.",
79
+ "Set in a quiet town, 'The Silent Watcher' follows Alex Carter, a former police officer turned private investigator, as he unravels the town's dark secrets.",
80
+ "'The Silent Watcher' revolves around Alex Carter's journey as he confronts his past while solving complex cases in his hometown."]
81
+ query = "What is the name of the lead character in the novel 'The Silent Watcher'?"
82
 
83
+ input_text = 'Background:\n' + str(passages) + '\n\n' + 'Query:\n' + str(query) + '\n\n'
84
 
85
+ messages = [
86
+ {"role": "system", "content": "You are a helpful assistant."},
87
+ {"role": "user", "content": input_text},
88
+ ]
89
+ prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
90
 
91
+ outputs = model.chat(tokenizer, prompt, temperature=0.8, top_p=0.8)
92
+ print(outputs[0]) # The lead character in the novel 'The Silent Watcher' is named Alex Carter.
93
+ ```
94
 
95
+ ## 实验结果 Evaluation Results
96
 
97
+ 经过针对RAG场景的LoRA训练后,MiniCPM3-RAG-LoRA在开放域问答(NQ、TQA、MARCO)、多跳问答(HotpotQA)、对话(WoW)、事实核查(FEVER)和信息填充(T-REx)等多项任务上的性能表现,超越Llama3-8B和Baichuan2-13B等业内优秀模型。
98
 
99
+ After being fine-tuned with LoRA for RAG scenarios, MiniCPM3-RAG-LoRA outperforms leading industry models like Llama3-8B and Baichuan2-13B across various tasks, including open-domain question answering (NQ, TQA, MARCO), multi-hop question answering (HotpotQA), dialogue (WoW), fact checking (FEVER), and information filling (T-REx).
100
 
101
+ | | NQ(Acc) | TQA(Acc) | MARCO(ROUGE) | HotpotQA(Acc) | WoW(F1) | FEVER(Acc) | T-REx(Acc) |
102
+ | :---------------: | :-----: | :------: | :----------: | :-----------: | :-----: | :--------: | :--------: |
103
+ | Llama3-8B | 45.36 | 83.15 | 20.81 | 28.52 | 10.96 | 78.08 | 26.62 |
104
+ | Baichuan2-13B | 43.36 | 77.76 | 14.28 | 27.59 | 13.34 | 31.37 | 27.46 |
105
+ | MiniCPM3 | 43.21 | 80.77 | 16.06 | 26.00 | 14.60 | 87.22 | 26.26 |
106
+ | MiniCPM3-RAG-LoRA | 48.36 | 82.40 | 27.68 | 31.61 | 16.29 | 85.81 | 40.76 |
107
 
 
108
 
109
+ ## 许可证 License
110
 
111
+ - 本仓库中代码依照 [Apache-2.0 协议](https://github.com/OpenBMB/MiniCPM/blob/main/LICENSE)开源。
112
+ - RankCPM-R 模型权重的使用则需要遵循 [MiniCPM 模型协议](https://github.com/OpenBMB/MiniCPM/blob/main/MiniCPM%20Model%20License.md)。
113
+ - RankCPM-R 模型权重对学术研究完全开放。如需将模型用于商业用途,请填写[此问卷](https://modelbest.feishu.cn/share/base/form/shrcnpV5ZT9EJ6xYjh3Kx0J6v8g)。
114
 
115
+ * The code in this repo is released under the [Apache-2.0](https://github.com/OpenBMB/MiniCPM/blob/main/LICENSE) License.
116
+ * The usage of RankCPM-R model weights must strictly follow [MiniCPM Model License.md](https://github.com/OpenBMB/MiniCPM/blob/main/MiniCPM%20Model%20License.md).
117
+ * The models and weights of RankCPM-R are completely free for academic research. After filling out a ["questionnaire"](https://modelbest.feishu.cn/share/base/form/shrcnpV5ZT9EJ6xYjh3Kx0J6v8g) for registration, RankCPM-R weights are also available for free commercial use.
118
+ <!-- ### 测试集介绍:
119
 
120
+ - **Natural Questions (NQ, Accuracy):**
121
+ - **简介**: Natural Questions 是一个开放域问答数据集,由真实用户在Google搜索中提出的问题组成。数据集中每个问题都有一个长文档作为上下文,并包含短答案和长答案。
122
+ - **评价指标**: 准确率(Accuracy)用于衡量模型是否能够正确地识别出与问题相关的短答案。
123
+ - **TriviaQA (TQA, Accuracy):**
124
+ - **简介:** TriviaQA 是一个涵盖广泛主题的问答数据集,问题和答案从各类问答网站和百科全书中收集而来。
125
+ - **评价指标:** 准确率(Accuracy)用于衡量模型能否正确地回答这些问题。
126
+ - **MS MARCO (ROUGE):**
127
+ - **简介:** MS MARCO 是一个大规模的开放域问答数据集,主要由Bing搜索引擎用户的查询和相应的答案组成。数据集包含简短答案和相关段落,广泛用于信息检索和生成任务。由于MS MARCO数据集规模庞大,我们从中选取了3000条数据进行本次评测。
128
+ - **评价指标:** ROUGE 用于评估模型生成的答案与参考答案之间的重叠程度,衡量生成答案的质量。
129
+ - **HotpotQA (Accuracy):**
130
+ - **简介:** HotpotQA 是一个多跳问答数据集,要求模型通过跨越多个文档的推理来回答复杂问题。该数据集不仅测试模型的答案生成能力,还考察其推理过程的可解释性。
131
+ - **评价指标:** 准确率(Accuracy)用于衡量模型能否正确地回答需要多跳推理的问题。
132
+ - **Wizard of Wikipedia (WoW, F1 Score):**
133
+ - **简介:** Wizard of Wikipedia 是一个对话数据集,专注于知识型对话场景,要求模型能够在对话中生成与主题相关的、丰富的信息,每个对话轮次都有对应的知识库条目作为支持。
134
+ - **评价指标:** F1 值用于衡量模型生成的回答与参考答案在词级别上的重合情况,评估回答的准确性和全面性。
135
+ - **FEVER (Accuracy):**
136
+ - **简介:** FEVER 是一个事实核查数据集,包含大量的陈述句,模型需要根据给定的文档来判断这些陈述句是否为真或假,该数据集旨在测试模型的事实核查能力。
137
+ - **评价指标:** 准确率(Accuracy)用于评估模型在判断陈述句的真实性方面的表现。
138
+ - **T-REx (Accuracy):**
139
+ - **简介:** T-REx 是一个知识库槽填充数据集,包含从维基百科中提取的实体-关系对。模型需要根据上下文信息填充缺失的槽值,测试其对知识库关系的理解和填充能力。
140
+ - **评价指标:** 准确率(Accuracy)用于衡量模型在正确填充缺失槽值方面的表现。 -->