Commit
·
3df0ffb
1
Parent(s):
66740f3
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,171 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- text2text-generation
|
5 |
+
pipeline_tag: text2text-generation
|
6 |
+
language:
|
7 |
+
- zh
|
8 |
+
- en
|
9 |
+
widget:
|
10 |
+
- text: |-
|
11 |
+
Human: 使用python写一个二分查找的代码
|
12 |
+
Assistant:
|
13 |
+
example_title: code zh
|
14 |
+
- text: >-
|
15 |
+
Human: Classify the sentiment of the following sentence into Positive,
|
16 |
+
Neutral, or Negative:
|
17 |
+
|
18 |
+
Super excited about teaching Stanford’s first course on Large Language
|
19 |
+
Models! Check the syllabus out here
|
20 |
+
|
21 |
+
Assistant:
|
22 |
+
example_title: sentiment en
|
23 |
+
- text: |-
|
24 |
+
Human: 今天天气怎么样,把这句话翻译成英语
|
25 |
+
Assistant:
|
26 |
+
example_title: translation zh-en
|
27 |
+
- text: |-
|
28 |
+
Human: 怎么让自己精力充沛,列5点建议
|
29 |
+
Assistant:
|
30 |
+
example_title: brainstorming zh
|
31 |
+
- text: |-
|
32 |
+
Human: 请以『春天的北京』为题写一首诗歌
|
33 |
+
Assistant:
|
34 |
+
example_title: generation zh
|
35 |
+
- text: |-
|
36 |
+
Human: 明天就假期结束了,有点抗拒上班,应该怎么办?
|
37 |
+
Assistant:
|
38 |
+
example_title: brainstorming zh
|
39 |
+
- text: |-
|
40 |
+
Human: 父母都姓吴,取一些男宝宝和女宝宝的名字
|
41 |
+
Assistant:
|
42 |
+
example_title: brainstorming zh
|
43 |
+
- text: |-
|
44 |
+
Human: 推荐几本金庸的武侠小说
|
45 |
+
Assistant:
|
46 |
+
example_title: brainstorming zh
|
47 |
---
|
48 |
+
|
49 |
+
# Model Card for Model ID
|
50 |
+
|
51 |
+
## Model description
|
52 |
+
BELLE is based on Bloomz-7b1-mt and finetuned with approximately 1000,000 pieces of Chinese data combined with 50,000 pieces of English data from the open source Stanford-Alpaca, resulting in good Chinese instruction understanding and response generation capabilities.
|
53 |
+
|
54 |
+
The code of Chinese data generation and other detailed information can be found in our Github project repository: https://github.com/LianjiaTech/BELLE.
|
55 |
+
|
56 |
+
## Training hyper-parameters
|
57 |
+
| Parameter | Value |
|
58 |
+
| ------ | ------ |
|
59 |
+
| Batch size | 64 |
|
60 |
+
| Learning rate | 3e-6 |
|
61 |
+
| Epochs | 3 |
|
62 |
+
|Weight_decay | 0.001 |
|
63 |
+
|Warmup_rate | 0.1 |
|
64 |
+
|LR_scheduler | linear |
|
65 |
+
|
66 |
+
## Use model
|
67 |
+
BELLE can be easily loaded with AutoModelForCausalLM.
|
68 |
+
``` python
|
69 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
70 |
+
import sys
|
71 |
+
|
72 |
+
model_path = "./" # You can modify the path for storing the local model
|
73 |
+
model = AutoModelForCausalLM.from_pretrained(model_path)
|
74 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
75 |
+
print("Human:")
|
76 |
+
line = input()
|
77 |
+
while line:
|
78 |
+
inputs = 'Human: ' + line.strip() + '\n\nAssistant:'
|
79 |
+
input_ids = tokenizer(inputs, return_tensors="pt").input_ids
|
80 |
+
outputs = model.generate(input_ids, max_new_tokens=200, do_sample = True, top_k = 30, top_p = 0.85, temperature = 0.35, repetition_penalty=1.2)
|
81 |
+
rets = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
82 |
+
print("Assistant:\n" + rets[0].strip().replace(inputs, ""))
|
83 |
+
print("\n------------------------------------------------\nHuman:")
|
84 |
+
line = input()
|
85 |
+
```
|
86 |
+
|
87 |
+
## Limitations
|
88 |
+
There still exists a few issues in the model trained on current base model and data:
|
89 |
+
|
90 |
+
1. The model might generate factual errors when asked to follow instructions related to facts.
|
91 |
+
|
92 |
+
2. Occasionally generates harmful responses since the model still struggles to identify potential harmful instructions.
|
93 |
+
|
94 |
+
3. Needs improvements on reasoning and coding.
|
95 |
+
|
96 |
+
Since the model still has its limitations, we require developers only use the open-sourced code, data, model and any other artifacts generated via this project for research purposes. Commercial use and other potential harmful use cases are not allowed.
|
97 |
+
|
98 |
+
## Some use cases
|
99 |
+
| Human | Assitant |
|
100 |
+
| ----- | ------ |
|
101 |
+
| 使用python写一个二分查找的代码 | def binary_search(arr, target):<br/> low = 0<br/> high = len(arr) - 1<br/> while (low <= high):<br/> mid = low + high // 2<br/> if arr[mid] == target:<br/> return mid<br/> elif target < arr[mid]:<br/> low = mid + 1<br/> else:<br/> high = mid - 1<br/> return -1 |
|
102 |
+
| 今天天气怎么样,把这句话翻译成英语 | What's the weather like today? |
|
103 |
+
| Classify the sentiment of the following sentence into Positive, Neutral, or Negative: <br/>Super excited about teaching Stanford’s first course on Large Language Models! Check the syllabus out here | Positive |
|
104 |
+
| 怎么让自己精力充沛,列5点建议 | 以下是一些可以让你保持精力充沛的建议: <br/>1. 睡眠充足。确保每天晚上得到充足的睡眠时间。 <br/>2. 多运动。进行适度的有氧运动,如慢跑、游泳等,可以帮助你提高能量和耐力。<br/>3. 吃健康食品。选择富含蛋白质的食物,如鸡肉、鱼肉和鸡蛋,以及新鲜的水果和蔬菜。 <br/>4. 减少咖啡因的摄入量。尽量避免在白天喝含咖啡因的饮料或吃含有咖啡因的食物。 <br/>5. 放松身心。尝试冥想、瑜伽或其他形式的放松活动来减轻压力和焦虑感。 |
|
105 |
+
| 请以『春天的北京』为题写一首诗歌 | 春天来到北京,万物复苏。草地上开满了五颜六色的花朵, <br/>清新的空气中弥漫着芬芳的气息。 <br/>人们在公园里散步、打太极拳,享受这美好的时光。 <br/>夜晚,星星闪烁,月亮如银盘一般明亮。 <br/>在这个充满生机的季节里,我们感受到了生命的活力与希望。 |
|
106 |
+
| 明天就假期结束了,有点抗拒上班,应该怎么办? | 面对即将结束的假期和开始工作时的紧张情绪,您可以采取以下措施来帮助您更好地适应: <br/>1. 为自己制定一个清晰的工作计划。这可以帮助您更好地组织时间和任务,并避免在工作中感到混乱。 <br/>2. 与同事或朋友交流,分享您的感受和工作压力。这将有助于缓解一些焦虑感,同时也可以获得支持和建议。 <br/>3. 在工作日前花些时间放松身心,例如进行瑜伽、冥想等活动。这些方法可以减轻身体和精神上的疲劳感,使您更加精力充沛地迎接挑战。 |
|
107 |
+
| 父母都姓吴,取一些男宝宝和女宝宝的名字 | - 男宝:吴俊杰、吴雨辰、吴子墨、吴思源、吴泽阳、吴宇航、吴博文、吴哲毅。 <br/>- 女宝:吴美琪、吴佳怡、吴欣瑜、吴香凝、吴雪柔、吴颖诗、吴语嫣。 |
|
108 |
+
| 推荐几本金庸的武侠小说 | 以下是三本我最喜欢的金庸武侠小说的推荐: <br/>1. 《射雕英雄传》 - 一部充满智慧和机智的小说,讲述了郭靖、黄蓉夫妇的故事。 <br/>2. 《神雕侠侣》- 这是一部浪漫而感人的故事,讲述了一对情侣小龙女与杨过之间的爱情故事。 <br/>3. 《倚天屠龙记》- 这是一个宏伟而壮观的故事,描绘了明教领袖张无忌如何成为一位出色的英雄。 |
|
109 |
+
|
110 |
+
|
111 |
+
## 模型描述
|
112 |
+
BELLE模型以Bloomz-7b1-mt为基础,在约18万条中文数据,结合Stanford-Alpaca开源的5万条英文数据上训练,取得了较好的中文instruction理解以及response生成能力。
|
113 |
+
|
114 |
+
中文数据生成代码及其他详细信息,位于我们的Github项目仓库: https://github.com/LianjiaTech/BELLE
|
115 |
+
|
116 |
+
## 模型训练超参数
|
117 |
+
| 参数 | 值 |
|
118 |
+
| ------ | ------ |
|
119 |
+
| Batch size | 64 |
|
120 |
+
| Learning rate | 3e-6 |
|
121 |
+
| Epochs | 3 |
|
122 |
+
|Weight_decay | 0.001 |
|
123 |
+
|Warmup_rate | 0.1 |
|
124 |
+
|LR_scheduler | linear |
|
125 |
+
|
126 |
+
## 使用模型
|
127 |
+
通过AutoModelForCausalLM即可直接载入模型并使用。
|
128 |
+
|
129 |
+
``` python
|
130 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
131 |
+
import sys
|
132 |
+
|
133 |
+
model_path = "./" # You can modify the path for storing the local model
|
134 |
+
model = AutoModelForCausalLM.from_pretrained(model_path)
|
135 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
136 |
+
print("Human:")
|
137 |
+
line = input()
|
138 |
+
while line:
|
139 |
+
inputs = 'Human: ' + line.strip() + '\n\nAssistant:'
|
140 |
+
input_ids = tokenizer(inputs, return_tensors="pt").input_ids
|
141 |
+
outputs = model.generate(input_ids, max_new_tokens=200, do_sample = True, top_k = 30, top_p = 0.85, temperature = 0.35, repetition_penalty=1.2)
|
142 |
+
rets = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
143 |
+
print("Assistant:\n" + rets[0].strip().replace(inputs, ""))
|
144 |
+
print("\n------------------------------------------------\nHuman:")
|
145 |
+
line = input()
|
146 |
+
|
147 |
+
```
|
148 |
+
|
149 |
+
## 局限性和使用限制
|
150 |
+
基于当前数据和基础模型训练得到的SFT模型,在效果上仍存在以下问题:
|
151 |
+
|
152 |
+
1. 在涉及事实性的指令上可能会产生违背事实的错误回答。
|
153 |
+
|
154 |
+
2. 对于具备危害性的指令无法很好的鉴别,由此会产生危害性言论。
|
155 |
+
|
156 |
+
3. 在一些涉及推理、代码等场景下模型的能力仍有待提高。
|
157 |
+
|
158 |
+
基于以上模型局限性,我们要求开发者仅将我们开源的代码、数据、模型及后续用此项目生成的衍生物用于研究目的,不得用于商业,以及其他会对社会带来危害的用途。
|
159 |
+
|
160 |
+
## 一些示例
|
161 |
+
|
162 |
+
| Human | Assitant |
|
163 |
+
| ----- | ------ |
|
164 |
+
| 使用python写一个二分查找的代码 | def binary_search(arr, target):<br/> low = 0<br/> high = len(arr) - 1<br/> while (low <= high):<br/> mid = low + high // 2<br/> if arr[mid] == target:<br/> return mid<br/> elif target < arr[mid]:<br/> low = mid + 1<br/> else:<br/> high = mid - 1<br/> return -1 |
|
165 |
+
| 今天天气怎么样,把这句话翻译成英语 | What's the weather like today? |
|
166 |
+
| Classify the sentiment of the following sentence into Positive, Neutral, or Negative: <br/>Super excited about teaching Stanford’s first course on Large Language Models! Check the syllabus out here | Positive |
|
167 |
+
| 怎么让自己精力充沛,列5点建议 | 以下是一些可以让你保持精力充沛的建议: <br/>1. 睡眠充足。确保每天晚上得到充足的睡眠时间。 <br/>2. 多运动。进行适度的有氧运动,如慢跑、游泳等,可以��助你提高能量和耐力。<br/>3. 吃健康食品。选择富含蛋白质的食物,如鸡肉、鱼肉和鸡蛋,以及新鲜的水果和蔬菜。 <br/>4. 减少咖啡因的摄入量。尽量避免在白天喝含咖啡因的饮料或吃含有咖啡因的食物。 <br/>5. 放松身心。尝试冥想、瑜伽或其他形式的放松活动来减轻压力和焦虑感。 |
|
168 |
+
| 请以『春天的北京』为题写一首诗歌 | 春天来到北京,万物复苏。草地上开满了五颜六色的花朵, <br/>清新的空气中弥漫着芬芳的气息。 <br/>人们在公园里散步、打太极拳,享受这美好的时光。 <br/>夜晚,星星闪烁,月亮如银盘一般明亮。 <br/>在这个充满生机的季节里,我们感受到了生命的活力与希望。 |
|
169 |
+
| 明天就假期结束了,有点抗拒上班,应该怎么办? | 面对即将结束的假期和开始工作时的紧张情绪,您可以采取以下措施来帮助您更好地适应: <br/>1. 为自己制定一个清晰的工作计划。这可以帮助您更好地组织时间和任务,并避免在工作中感到混乱。 <br/>2. 与同事或朋友交流,分享您的感受和工作压力。这将有助于缓解一些焦虑感,同时也可以获得支持和建议。 <br/>3. 在工作日前花些时间放松身心,例如进行瑜伽、冥想等活动。这些方法可以减轻身体和精神上的疲劳感,使您更加精力充沛地迎接挑战。 |
|
170 |
+
| 父母都姓吴,取一些男宝宝和女宝宝的名字 | - 男宝:吴俊杰、吴雨辰、吴子墨、吴思源、吴泽阳、吴宇航、吴博文、吴哲毅。 <br/>- 女宝:吴美琪、吴佳怡、吴欣瑜、吴香凝、吴雪柔、吴颖诗、吴语嫣。 |
|
171 |
+
| 推荐几本金庸的武侠小说 | 以下是三本我最喜欢的金庸武侠小说的推荐: <br/>1. 《射雕英雄传》 - 一部充满智慧和机智的小说,讲述了郭靖、黄蓉夫妇的故事。 <br/>2. 《神雕侠侣》- 这是一部浪漫而感人的故事,讲述了一对情侣小龙女与杨过之间的爱情故事。 <br/>3. 《倚天屠龙记》- 这是一个宏伟而壮观的故事,描绘了明教领袖张无忌如何成为一位出色的英雄。 |
|