Update README.md
Browse files
README.md
CHANGED
@@ -1,69 +1,20 @@
|
|
1 |
-
---
|
2 |
-
title: chinese-alpaca-plus-7b
|
3 |
-
emoji: 📚
|
4 |
-
colorFrom: gray
|
5 |
-
colorTo: red
|
6 |
-
language:
|
7 |
-
- zh
|
8 |
-
tags:
|
9 |
-
- chatglm
|
10 |
-
- pytorch
|
11 |
-
- zh
|
12 |
-
- Text2Text-Generation
|
13 |
-
license: "other"
|
14 |
-
widget:
|
15 |
-
- text: "为什么天空是蓝色的?"
|
16 |
-
---
|
17 |
|
18 |
-
# Chinese Alpaca Plus 7B Model
|
19 |
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
推出中文LLaMA, Alpaca Plus版(7B),相比基础版本的改进点如下:
|
24 |
-
|
25 |
-
- 进一步扩充了训练数据,其中LLaMA扩充至120G文本(通用领域),Alpaca扩充至4M指令数据(重点增加了STEM相关数据)
|
26 |
-
- Alpaca训练时采用了更大的rank,相比原版具有更低的验证集损失
|
27 |
-
- 评测结果显示,Alpaca-Plus-7B相比基础版Alpaca-7B效果更优,部分任务接近或超过13B版本
|
28 |
-
- 这一轮比拼:7B获得65.3分,13B获得70.9分,Plus-7B效果75.3分,具体评测结果请参考[效果评测](https://github.com/ymcui/Chinese-LLaMA-Alpaca/blob/main/examples/README.md)
|
29 |
-
|
30 |
-
本模型是`原生LLaMA-7B`合并`中文LLaMA LoRA`和`中文Alpaca LoRA`后的模型权重`chinese-alpaca-plus-7b-hf`,并转化为HuggingFace版本权重(.bin文件),可以直接使用或者继续训练。
|
31 |
-
|
32 |
-
13b-hf权重链接:https://huggingface.co/shibing624/chinese-alpaca-plus-13b-hf
|
33 |
|
34 |
test case:
|
35 |
|
36 |
|input_text|predict|
|
37 |
|:-- |:--- |
|
38 |
-
|
39 |
|
40 |
|
41 |
-
## release model weight
|
42 |
|
43 |
-
- chinese-llama-plus-7b 模型权重链接:https://huggingface.co/minlik/chinese-llama-plus-7b-merged
|
44 |
-
- chinese-alpaca-plus-7b 模型权重链接:https://huggingface.co/shibing624/chinese-alpaca-plus-7b-hf
|
45 |
-
- chinese-llama-plus-13b 模型权重链接:https://huggingface.co/shibing624/chinese-llama-plus-13b-hf
|
46 |
-
- chinese-aplaca-plus-13b 模型权重链接:https://huggingface.co/shibing624/chinese-alpaca-plus-13b-hf
|
47 |
|
48 |
## Usage
|
49 |
|
50 |
-
本项目开源在textgen项目:[textgen](https://github.com/shibing624/textgen),可支持llama模型,通过如下命令调用:
|
51 |
-
|
52 |
-
Install package:
|
53 |
-
```shell
|
54 |
-
pip install -U textgen
|
55 |
-
```
|
56 |
-
|
57 |
-
```python
|
58 |
-
from textgen import LlamaModel
|
59 |
-
model = LlamaModel("llama", "shibing624/chinese-alpaca-plus-7b-hf")
|
60 |
-
r = model.predict(["用一句话描述地球为什么是独一无二的。"])
|
61 |
-
print(r) # ['地球是独一无二的,因为它拥有独特的大气层、水循环、生物多样性以及其他自然资源,这些都使它成为一个独特的生命支持系统。']
|
62 |
-
```
|
63 |
-
|
64 |
-
## Usage (HuggingFace Transformers)
|
65 |
-
Without [textgen](https://github.com/shibing624/textgen), you can use the model like this:
|
66 |
-
|
67 |
First, you pass your input through the transformer model, then you get the generated sentence.
|
68 |
|
69 |
Install package:
|
@@ -85,12 +36,12 @@ def generate_prompt(text):
|
|
85 |
|
86 |
### Response:"""
|
87 |
|
88 |
-
|
89 |
-
tokenizer = LlamaTokenizer.from_pretrained(
|
90 |
-
model = LlamaForCausalLM.from_pretrained(
|
91 |
model.eval()
|
92 |
|
93 |
-
text = '
|
94 |
prompt = generate_prompt(text)
|
95 |
input_ids = tokenizer.encode(prompt, return_tensors='pt').to('cuda')
|
96 |
|
@@ -98,9 +49,9 @@ input_ids = tokenizer.encode(prompt, return_tensors='pt').to('cuda')
|
|
98 |
with torch.no_grad():
|
99 |
output_ids = model.generate(
|
100 |
input_ids=input_ids,
|
101 |
-
max_new_tokens=
|
102 |
temperature=1,
|
103 |
-
top_k=
|
104 |
top_p=0.9,
|
105 |
repetition_penalty=1.15
|
106 |
).cuda()
|
@@ -111,16 +62,12 @@ print(output.replace(text, '').strip())
|
|
111 |
|
112 |
output:
|
113 |
```shell
|
114 |
-
|
115 |
-
|
116 |
```
|
117 |
|
118 |
## 模型来源
|
119 |
-
release
|
120 |
-
|
121 |
-
基于 [多LoRA权重合并(适用于Chinese-Alpaca-Plus )](https://github.com/ymcui/Chinese-LLaMA-Alpaca/wiki/%E6%89%8B%E5%8A%A8%E6%A8%A1%E5%9E%8B%E5%90%88%E5%B9%B6%E4%B8%8E%E8%BD%AC%E6%8D%A2#%E5%A4%9Alora%E6%9D%83%E9%87%8D%E5%90%88%E5%B9%B6%E9%80%82%E7%94%A8%E4%BA%8Echinese-alpaca-plus-)方法手动合并而成,具体是使用 [decapoda-research/llama-7b-hf](https://huggingface.co/decapoda-research/llama-7b-hf)
|
122 |
-
底座模型 合并 Chinese-LLaMA-Plus-LoRA和Chinese-Alpaca-Plus-LoRA 两个LoRA权重 得到,并转化为HuggingFace版本权重(.bin文件)。
|
123 |
-
|
124 |
|
125 |
HuggingFace版本权重(.bin文件)可用于:
|
126 |
- 使用Transformers进行训练和推理
|
@@ -129,12 +76,11 @@ HuggingFace版本权重(.bin文件)可用于:
|
|
129 |
PyTorch版本权重(.pth文件)可用于:
|
130 |
- 使用llama.cpp工具进行量化和部署
|
131 |
|
132 |
-
PyTorch版本权重(.pth文件)链接,8-bit量化版的Alpaca-Plus-7B:[Billsfriend/chinese-Alpaca-7b-plus-ggml-q8_0](https://huggingface.co/Billsfriend/chinese-Alpaca-7b-plus-ggml-q8_0/tree/main)
|
133 |
|
134 |
|
135 |
模型文件组成:
|
136 |
```
|
137 |
-
|
138 |
config.json
|
139 |
generation_config.json
|
140 |
pytorch_model-00001-of-00002.bin
|
@@ -150,8 +96,8 @@ chinese-alpaca-plus-7b-hf
|
|
150 |
|
151 |
### 微调数据集
|
152 |
|
153 |
-
1. xx万条文本数据集(用于领域内预训练):[DUOMO-Lab/TransGPT-pt](https://huggingface.co/datasets/DUOMO-Lab/TransGPT-pt)
|
154 |
-
2.
|
155 |
|
156 |
|
157 |
如果需要训练LLaMA模型,请参考[https://github.com/DUOMO/TransGPT](https://github.com/DUOMO/TransGPT)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
|
|
2 |
|
3 |
+
# TransGPT
|
4 |
|
5 |
+
**发布中文TransGPT(7B)模型**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
test case:
|
8 |
|
9 |
|input_text|predict|
|
10 |
|:-- |:--- |
|
11 |
+
|我想了解如何申请和更新驾驶证?|xx|
|
12 |
|
13 |
|
|
|
14 |
|
|
|
|
|
|
|
|
|
15 |
|
16 |
## Usage
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
First, you pass your input through the transformer model, then you get the generated sentence.
|
19 |
|
20 |
Install package:
|
|
|
36 |
|
37 |
### Response:"""
|
38 |
|
39 |
+
checkpoint="DUOMO-Lab/TransGPT-v0"
|
40 |
+
tokenizer = LlamaTokenizer.from_pretrained(checkpoint)
|
41 |
+
model = LlamaForCausalLM.from_pretrained(checkpoint).half().cuda()
|
42 |
model.eval()
|
43 |
|
44 |
+
text = '我想了解如何申请和更新驾驶证?'
|
45 |
prompt = generate_prompt(text)
|
46 |
input_ids = tokenizer.encode(prompt, return_tensors='pt').to('cuda')
|
47 |
|
|
|
49 |
with torch.no_grad():
|
50 |
output_ids = model.generate(
|
51 |
input_ids=input_ids,
|
52 |
+
max_new_tokens=1024,
|
53 |
temperature=1,
|
54 |
+
top_k=20,
|
55 |
top_p=0.9,
|
56 |
repetition_penalty=1.15
|
57 |
).cuda()
|
|
|
62 |
|
63 |
output:
|
64 |
```shell
|
65 |
+
我想了解如何申请和更新驾驶证?
|
66 |
+
|
67 |
```
|
68 |
|
69 |
## 模型来源
|
70 |
+
release合并后的模型权重。
|
|
|
|
|
|
|
|
|
71 |
|
72 |
HuggingFace版本权重(.bin文件)可用于:
|
73 |
- 使用Transformers进行训练和推理
|
|
|
76 |
PyTorch版本权重(.pth文件)可用于:
|
77 |
- 使用llama.cpp工具进行量化和部署
|
78 |
|
|
|
79 |
|
80 |
|
81 |
模型文件组成:
|
82 |
```
|
83 |
+
TransGPT
|
84 |
config.json
|
85 |
generation_config.json
|
86 |
pytorch_model-00001-of-00002.bin
|
|
|
96 |
|
97 |
### 微调数据集
|
98 |
|
99 |
+
1. ~xx万条文本数据集(用于领域内预训练):[DUOMO-Lab/TransGPT-pt](https://huggingface.co/datasets/DUOMO-Lab/TransGPT-pt)
|
100 |
+
2. ~5.6万条对话数据(用于微调):[finetune_data](https://huggingface.co/data/finetune)
|
101 |
|
102 |
|
103 |
如果需要训练LLaMA模型,请参考[https://github.com/DUOMO/TransGPT](https://github.com/DUOMO/TransGPT)
|