Upload README.md
Browse files
README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
- 开源了8个灵智模型:`Lingzhi-0.5B-chat`, `Lingzhi-0.8B-chat`, `Lingzhi-1.5B-chat`, `Lingzhi-2.7B-chat`, `Lingzhi-7B-chat`, `Lingzhi-10B-chat`, `Lingzhi-57MOE14B-chat`, `Lingzhi-72B-chat`.
|
10 |
|
11 |
## 📄 摘要
|
12 |
-
在实际应用中,当预训练数据不可用时,进行**持续训练**是很常见的。然而,持续训练往往会在增强领域特定技能的同时导致大语言模型(LLMs
|
13 |
|
14 |
## 📘 介绍
|
15 |
大语言模型(LLMs)近年来因其在各种实际下游任务中的出色表现而备受关注。实际上,尽管现有的LLMs在通用领域表现良好,但由于在预训练或指令微调期间缺乏特定领域的专业暴露,它们可能在用户需要的特定领域(如会计、法律、金融)中表现不佳。
|
@@ -20,6 +20,87 @@
|
|
20 |
|
21 |
为了解决这个问题,我们进行了实证研究,探索了各种持续学习范式并总结了它们的优缺点。最终,在实证研究之后,我们选择了最佳的学习范式和训练数据,基于Qwen2-base进行持续学习,衍生出我们的灵智系列模型。经过大量实验,灵智能够在多个特定领域中表现出色,同时在通用能力方面也表现出与原始Qwen2-chat模型相当的性能。
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
## 📊 结果
|
24 |
|
25 |
> 备注:Baselines中Qwen2的所有结果均是在我们统一的环境下进行评测的。
|
@@ -35,11 +116,11 @@
|
|
35 |
| Qwen2-57MOE14B-chat | | | | | | | | | | | |
|
36 |
| Qwen2-72B-chat | | | | | | | | | | | |
|
37 |
| ***Lingzhi Models*** | | | | | | | | | | | |
|
38 |
-
| Lingzhi-0\.5B-
|
39 |
| Lingzhi-0\.8B-chat | 42\.93 | 27\.77 | 53\.34 | 50\.98 | 21\.00 | 28\.84 | 28\.66 | 18\.00 | 24\.49 | 40\.85 | 33\.69 |
|
40 |
-
| Lingzhi-1\.5B-
|
41 |
| Lingzhi-2\.7B-chat | 53\.65 | 36\.77 | 67\.09 | 67\.39 | 46\.02 | 34\.51 | 40\.85 | 30\.00 | 38\.10 | 60\.98 | 47\.54 |
|
42 |
-
| Lingzhi-7B-
|
43 |
| Lingzhi-10B-chat | 69\.37 | 64\.37 | 81\.50 | 82\.27 | 76\.19 | 46\.00 | 60\.98 | 50\.40 | 70\.07 | 82\.93 | 68\.41 |
|
44 |
| Lingzhi-57MOE14B-chat | | | | | | | | | | | |
|
45 |
| Lingzhi-72B-chat | | | | | | | | | | | |
|
|
|
9 |
- 开源了8个灵智模型:`Lingzhi-0.5B-chat`, `Lingzhi-0.8B-chat`, `Lingzhi-1.5B-chat`, `Lingzhi-2.7B-chat`, `Lingzhi-7B-chat`, `Lingzhi-10B-chat`, `Lingzhi-57MOE14B-chat`, `Lingzhi-72B-chat`.
|
10 |
|
11 |
## 📄 摘要
|
12 |
+
在实际应用中,当预训练数据不可用时,进行**持续训练**是很常见的。然而,持续训练往往会在增强领域特定技能的同时导致大语言模型(LLMs)灾难性地遗忘其通用能力。在本文中,我们首先对常见的持续训练范式进行了实证研究,然后选择了最佳范式来训练灵智系列模型。实验表明,灵智能够在保持通用能力的同时增强领域特定的性能。我们已经开源了所有模型、训练数据和基准测试,用户可以将它们应用到自己的领域特定区域。
|
13 |
|
14 |
## 📘 介绍
|
15 |
大语言模型(LLMs)近年来因其在各种实际下游任务中的出色表现而备受关注。实际上,尽管现有的LLMs在通用领域表现良好,但由于在预训练或指令微调期间缺乏特定领域的专业暴露,它们可能在用户需要的特定领域(如会计、法律、金融)中表现不佳。
|
|
|
20 |
|
21 |
为了解决这个问题,我们进行了实证研究,探索了各种持续学习范式并总结了它们的优缺点。最终,在实证研究之后,我们选择了最佳的学习范式和训练数据,基于Qwen2-base进行持续学习,衍生出我们的灵智系列模型。经过大量实验,灵智能够在多个特定领域中表现出色,同时在通用能力方面也表现出与原始Qwen2-chat模型相当的性能。
|
22 |
|
23 |
+
## 📋 示例
|
24 |
+
1. huggingface示例代码
|
25 |
+
```python
|
26 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
27 |
+
import torch
|
28 |
+
|
29 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
30 |
+
|
31 |
+
lingzhi_model_path = "Lingzhi-AI/Lingzhi-7B-chat"
|
32 |
+
|
33 |
+
model = AutoModelForCausalLM.from_pretrained(
|
34 |
+
lingzhi_model_path,
|
35 |
+
torch_dtype="auto",
|
36 |
+
device_map="auto"
|
37 |
+
)
|
38 |
+
tokenizer = AutoTokenizer.from_pretrained(lingzhi_model_path)
|
39 |
+
|
40 |
+
prompt = "帮我介绍一下灵智大模型。"
|
41 |
+
messages = [
|
42 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
43 |
+
{"role": "user", "content": prompt}
|
44 |
+
]
|
45 |
+
text = tokenizer.apply_chat_template(
|
46 |
+
messages,
|
47 |
+
tokenize=False,
|
48 |
+
add_generation_prompt=True
|
49 |
+
)
|
50 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
51 |
+
|
52 |
+
generated_ids = model.generate(
|
53 |
+
model_inputs.input_ids,
|
54 |
+
max_new_tokens=512
|
55 |
+
)
|
56 |
+
generated_ids = [
|
57 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
58 |
+
]
|
59 |
+
|
60 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
61 |
+
print(response)
|
62 |
+
```
|
63 |
+
|
64 |
+
2. modelscope示例代码
|
65 |
+
```python
|
66 |
+
from modelscope import AutoModelForCausalLM, AutoTokenizer
|
67 |
+
import torch
|
68 |
+
|
69 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
70 |
+
|
71 |
+
lingzhi_model_path = "LingzhiLLM/Lingzhi-7B-chat"
|
72 |
+
|
73 |
+
model = AutoModelForCausalLM.from_pretrained(
|
74 |
+
lingzhi_model_path,
|
75 |
+
torch_dtype="auto",
|
76 |
+
device_map="auto"
|
77 |
+
)
|
78 |
+
tokenizer = AutoTokenizer.from_pretrained(lingzhi_model_path)
|
79 |
+
|
80 |
+
prompt = "帮我介绍一下灵智大模型。"
|
81 |
+
messages = [
|
82 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
83 |
+
{"role": "user", "content": prompt}
|
84 |
+
]
|
85 |
+
text = tokenizer.apply_chat_template(
|
86 |
+
messages,
|
87 |
+
tokenize=False,
|
88 |
+
add_generation_prompt=True
|
89 |
+
)
|
90 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
91 |
+
|
92 |
+
generated_ids = model.generate(
|
93 |
+
model_inputs.input_ids,
|
94 |
+
max_new_tokens=512
|
95 |
+
)
|
96 |
+
generated_ids = [
|
97 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
98 |
+
]
|
99 |
+
|
100 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
101 |
+
print(response)
|
102 |
+
```
|
103 |
+
|
104 |
## 📊 结果
|
105 |
|
106 |
> 备注:Baselines中Qwen2的所有结果均是在我们统一的环境下进行评测的。
|
|
|
116 |
| Qwen2-57MOE14B-chat | | | | | | | | | | | |
|
117 |
| Qwen2-72B-chat | | | | | | | | | | | |
|
118 |
| ***Lingzhi Models*** | | | | | | | | | | | |
|
119 |
+
| Lingzhi-0\.5B-chat | 44\.25 | 25\.65 | 55\.05 | 53\.74 | 29\.34 | 29\.18 | 25\.00 | 22\.40 | 25\.85 | 40\.24 | 35\.07 |
|
120 |
| Lingzhi-0\.8B-chat | 42\.93 | 27\.77 | 53\.34 | 50\.98 | 21\.00 | 28\.84 | 28\.66 | 18\.00 | 24\.49 | 40\.85 | 33\.69 |
|
121 |
+
| Lingzhi-1\.5B-chat | 55\.35 | 33\.67 | 69\.47 | 69\.10 | 49\.58 | 35\.31 | 39\.02 | 31\.00 | 37\.41 | 42\.68 | 46\.26 |
|
122 |
| Lingzhi-2\.7B-chat | 53\.65 | 36\.77 | 67\.09 | 67\.39 | 46\.02 | 34\.51 | 40\.85 | 30\.00 | 38\.10 | 60\.98 | 47\.54 |
|
123 |
+
| Lingzhi-7B-chat | 69\.06 | 58\.95 | 82\.69 | 83\.05 | 74\.22 | 45\.59 | 56\.10 | 49\.80 | 72\.79 | 89\.02 | 68\.13 |
|
124 |
| Lingzhi-10B-chat | 69\.37 | 64\.37 | 81\.50 | 82\.27 | 76\.19 | 46\.00 | 60\.98 | 50\.40 | 70\.07 | 82\.93 | 68\.41 |
|
125 |
| Lingzhi-57MOE14B-chat | | | | | | | | | | | |
|
126 |
| Lingzhi-72B-chat | | | | | | | | | | | |
|