s-JoL commited on
Commit
e8a79d8
1 Parent(s): 59d1f6c

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +182 -0
README.md ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - zh
4
+ - en
5
+ pipeline_tag: text-generation
6
+ inference: false
7
+ ---
8
+ # Baichuan-13B
9
+
10
+ <!-- Provide a quick summary of what the model is/does. -->
11
+
12
+ ## 介绍
13
+ Baichuan-13B 是由百川智能继 [Baichuan-7B](https://github.com/baichuan-inc/baichuan-7B) 之后开发的包含 130 亿参数的开源可商用的大规模语言模型,在标准的中文和英文 benchmark上均取得同尺寸最好的效果。本次发布包含有预训练 (Baichuan-13B-Base) 和对齐 (Baichuan-13B-Chat) 两个版本。Baichuan-13B 有如下几个特点:
14
+
15
+ 1. **开源可商用百亿级别中文语言模型**:Baichuan-13B-Base 是免费开源可商用的百亿级别中文预训练语言模型。包含有130亿参数,没有经过任何 Instruction Tuning 或者针对 benchmark 的优化,纯净、高可定制。弥补了在中文领域缺乏 100 亿以上高可用中文预训练大模型的短板。
16
+ 2. **更大尺寸、更多数据**:在 Baichuan-7B 的基础上进一步扩大参数量到 130 亿,并且在高质量的语料上训练了 1.4 万亿 tokens,是当前开源 13B 尺寸下训练数据量最多的模型。支持中英双语,使用 [ALiBi](https://arxiv.org/abs/2108.12409) 位置编码,上下文窗口长度为 4096。
17
+ 3. **同时开源预训练和对齐模型**:预训练模型是适用开发者的”基座“,而广大普通用户对有对话功能的对齐模型具有更强的需求。因此本次开源我们同时发布了对齐模型(Baichuan-13B-Chat),具有很强的对话能力,开箱即用,支持很简单的部署。
18
+ 4. **更高效的推理**:为了支持更广大用户的使用,我们本次同时开源了 int8 和 int4 的量化版本,在几乎没有效果损失的情况下可以很方便的将模型部署在低显存机器上。
19
+
20
+ ## Introduction
21
+ Baichuan-13B is an open-source, commercially available large-scale language model with 130 billion parameters developed by Baichuan Intelligence following [Baichuan-7B](https://github.com/baichuan-inc/baichuan-7B). It achieves the best performance in standard Chinese and English benchmarks of the same size. This release includes two versions: pre-training (Baichuan-13B-Base) and alignment (Baichuan-13B-Chat). Baichuan-13B has the following features:
22
+
23
+ 1. **Open-source, commercially available billion-level Chinese language model**: Baichuan-13B-Base is a free, open-source, commercially available billion-level Chinese pre-training language model. It contains 130 billion parameters, has not undergone any Instruction Tuning or optimization for benchmarks, and is pure and highly customizable. It fills the gap in the lack of over 10 billion high-availability Chinese pre-training large models in the Chinese field.
24
+
25
+ 2. **Larger size, more data**: On the basis of Baichuan-7B, the parameter volume is further expanded to 130 billion, and 1.4 trillion tokens have been trained on high-quality corpora, making it the model with the most training data in the open-source 13B size. It supports both Chinese and English, uses [ALiBi](https://arxiv.org/abs/2108.12409) position encoding, and has a context window length of 4096.
26
+
27
+ 3. **Open-source pre-training and alignment models simultaneously**: The pre-training model is a "base" suitable for developers, while the general public has a stronger demand for alignment models with dialogue capabilities. Therefore, in this open-source release, we have also released an alignment model (Baichuan-13B-Chat) which has strong dialogue capabilities, is ready to use, and supports simple deployment.
28
+
29
+ 4. **More efficient inference**: To support a wider range of users, we have also open-sourced the int8 and int4 quantized versions this time. With almost no loss of effect, the model can be easily deployed on low-memory machines.
30
+
31
+ ## How to Get Started with the Model
32
+
33
+ 如下是一个使用Baichuan-13B进行1-shot推理的任务,根据作品给出作者名,正确输出为"夜雨寄北->李商隐"
34
+ ```python
35
+ from transformers import AutoModelForCausalLM, AutoTokenizer
36
+
37
+ tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan-13B", trust_remote_code=True)
38
+ model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-13B", device_map="auto", trust_remote_code=True)
39
+ inputs = tokenizer('登鹳雀楼->王之涣\n夜雨寄北->', return_tensors='pt')
40
+ inputs = inputs.to('cuda:0')
41
+ pred = model.generate(**inputs, max_new_tokens=64,repetition_penalty=1.1)
42
+ print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
43
+ ```
44
+
45
+ The following is a task of performing 1-shot inference using Baichuan-13B, where the author's name is given based on the work, with the correct output being "One Hundred Years of Solitude->Gabriel Garcia Marquez"
46
+ ```python
47
+ from transformers import AutoModelForCausalLM, AutoTokenizer
48
+
49
+ tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan-13B", trust_remote_code=True)
50
+ model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-13B", device_map="auto", trust_remote_code=True)
51
+ inputs = tokenizer('Hamlet->Shakespeare\nOne Hundred Years of Solitude->', return_tensors='pt')
52
+ inputs = inputs.to('cuda:0')
53
+ pred = model.generate(**inputs, max_new_tokens=64,repetition_penalty=1.1)
54
+ print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
55
+ ```
56
+
57
+ ## Model Details
58
+
59
+ ### Model Description
60
+
61
+ <!-- Provide a longer summary of what this model is. -->
62
+
63
+ - **Developed by:** 百川智能(Baichuan Intelligent Technology)
64
+ - **Email**: opensource@baichuan-inc.com
65
+ - **Language(s) (NLP):** Chinese/English
66
+ - **License:** [Baichuan-13B License]()
67
+
68
+ ### Model Sources
69
+
70
+ <!-- Provide the basic links for the model. -->
71
+
72
+ 整体模型基于Baichuan-7B,为了获得更好的推理性能,Baichuan-13B 使用了 ALiBi 线性偏置技术,相对于 Rotary Embedding 计算量更小,对推理性能有显著提升;与标准的 LLaMA-13B 相比,生成 2000 个 tokens 的平均推理速度 (tokens/s),实测提升 31.6%:
73
+
74
+ | Model | tokens/s |
75
+ |-------------|----------|
76
+ | LLaMA-13B | 19.4 |
77
+ | Baichuan-13B| 25.4 |
78
+
79
+ 具体参数和见下表
80
+ | 模型名称 | 隐含层维度 | 层数 | 头数 |词表大小 | 总参数量 | 训练数据(tokens) | 位置编码 | 最大长度 |
81
+ |-------------------------|-------|------------|------------|-----------------|--------|--------|----------------|---------|
82
+ | Baichuan-7B | 4,096 | 32 | 32 | 64,000 | 7,000,559,616 | 1.2万亿 | [RoPE](https://arxiv.org/abs/2104.09864) | 4,096 |
83
+ | Baichuan-13B | 5,120 | 40 | 40 | 64,000 | 13,264,901,120 | 1.4万亿 | [ALiBi](https://arxiv.org/abs/2108.12409) | 4,096
84
+
85
+ The overall model is based on Baichuan-7B. In order to achieve better inference performance, Baichuan-13B uses ALiBi linear bias technology, which has a smaller computational load compared to Rotary Embedding, and significantly improves inference performance. Compared with the standard LLaMA-13B, the average inference speed (tokens/s) for generating 2000 tokens has been tested to increase by 31.6%:
86
+
87
+ | Model | tokens/s |
88
+ |-------------|----------|
89
+ | LLaMA-13B | 19.4 |
90
+ | Baichuan-13B| 25.4 |
91
+
92
+ The specific parameters are as follows:
93
+ | Model Name | Hidden Size | Num Layers | Num Attention Heads |Vocab Size | Total Params | Training Dats(tokens) | Position Embedding | Max Length |
94
+ |-------------------------|-------|------------|------------|-----------------|--------|--------|----------------|---------|
95
+ | Baichuan-7B | 4,096 | 32 | 32 | 64,000 | 7,000,559,616 | 1.2万亿 | [RoPE](https://arxiv.org/abs/2104.09864) | 4,096 |
96
+ | Baichuan-13B | 5,120 | 40 | 40 | 64,000 | 13,264,901,120 | 1.4万亿 | [ALiBi](https://arxiv.org/abs/2108.12409) | 4,096
97
+
98
+ ## Uses
99
+
100
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
101
+
102
+ ### Downstream Use
103
+
104
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
105
+ 我们同时开源出了和本模型配套的训练代码,允许进行高效的Finetune用于下游任务,具体参见[Baichuan-13B](https://github.com/baichuan-inc/Baichuan-13B)。
106
+
107
+ We have also open-sourced the training code that accompanies this model, allowing for efficient finetuning for downstream tasks. For more details, please refer to [baichuan-13B](https://github.com/baichuan-inc/baichuan-13B).
108
+
109
+ ### Out-of-Scope Use
110
+
111
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
112
+ 在没有充分评估风险和采取缓解措施的情况下投入生产使用;任何可能被视为不负责任或有害的使用案例。
113
+
114
+ Production use without adequate assessment of risks and mitigation; any use cases which may be considered irresponsible or harmful.
115
+
116
+ ## Bias, Risks, and Limitations
117
+
118
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
119
+
120
+ Baichuan-13B可能会产生事实上不正确的输出,不应依赖它产生事实上准确的信息。Baichuan-13B是在各种公共数据集上进行训练的。尽管我们已经做出了巨大的努力来清洗预训练数据,但这个模型可能会生成淫秽、偏见或其他冒犯性的输出。
121
+
122
+ Baichuan-13B can produce factually incorrect output, and should not be relied on to produce factually accurate information. Baichuan-13B was trained on various public datasets. While great efforts have been taken to clean the pretraining data, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
123
+
124
+ ## Training Details
125
+
126
+ 训练具体设置参见[Baichuan-13B](https://github.com/baichuan-inc/Baichuan-13B)。
127
+
128
+ For specific training settings, please refer to [Baichuan-13B](https://github.com/baichuan-inc/Baichuan-13B).
129
+
130
+ ## Evaluation
131
+
132
+ # Benchmark结果
133
+
134
+ 我们在各个 benchmark 下进行了`5-shot`评测,所采用的方法和 [Baichuan-7B](https://github.com/baichuan-inc/Baichuan-7B/) 项目中相同。结果如下:
135
+
136
+ We conducted a `5-shot` evaluation under various benchmarks, using the same method as in the [Baichuan-7B](https://github.com/baichuan-inc/Baichuan-7B/) project. The results are as follows:
137
+ ## C-Eval
138
+
139
+ | Model 5-shot | STEM | Social Sciences | Humanities | Others | Average |
140
+ |-------------------------|-------|-----------------|------------|--------|---------|
141
+ | ChatGLM2-6B | 45.9 | 61.6 | 49.7 | 48.2 | 50.2 |
142
+ | InternLM-7B<sup>*</sup> | 40.1 | 55.7 | 49.4 | 37.9 | 44.6 |
143
+ | Baichuan-7B | 38.2 | 52.0 | 46.2 | 39.3 | 42.8 |
144
+ | Ziya-LLaMA-13B-Pretrain | 27.6 | 34.4 | 32.0 | 28.6 | 30.0 |
145
+ | LLaMA-13B | 27.0 | 33.6 | 27.7 | 27.6 | 28.5 |
146
+ | moss-moon-003-base (16B)| 27.0 | 29.1 | 27.2 | 26.9 | 27.4 |
147
+ | vicuna-13B | 22.8 | 24.8 | 22.3 | 18.5 | 22.2 |
148
+ | **Baichuan-13B-Base** | **45.9** | **63.5** | **57.2** | **49.3** | **52.4** |
149
+ | **Baichuan-13B-Chat** | **43.7** | **64.6** | **56.2** | **49.2** | **51.5** |
150
+ > *说明:表中各个模型的结果是使用统一的评估代码得到。[InternLM-7B](https://huggingface.co/internlm/internlm-7b) 汇报使用 [OpenCompass](https://opencompass.org.cn/rank) 工具评估的C-Eval平均值为 53.4,我们使用 OpenCompass 评估 InternLM-7B 的平均值为 51.6
151
+
152
+ ## MMLU
153
+
154
+ | Model 5-shot | STEM | Social Sciences | Humanities | Others | Average |
155
+ |-------------------------|-------|-----------------|------------|--------|---------|
156
+ | LLaMA-13B | 36.1 | 53.0 | 44.0 | 52.8 | 46.3 |
157
+ | ChatGLM2-6B | 38.2 | 52.5 | 43.2 | 50.8 | 45.9 |
158
+ | InternLM-7B | 38.0 | 51.1 | 39.2 | 50.2 | 44.1 |
159
+ | Ziya-LLaMA-13B-Pretrain | 35.6 | 47.6 | 40.1 | 49.4 | 42.9 |
160
+ | Baichuan-7B | 35.6 | 48.9 | 38.4 | 48.1 | 42.3 |
161
+ | vicuna-13B | 24.2 | 24.1 | 24.6 | 26.8 | 24.9 |
162
+ | moss-moon-003-base (16B)| 22.4 | 22.8 | 24.2 | 24.4 | 23.6 |
163
+ | **Baichuan-13B-Base** | **41.6** | **60.9** | **47.4** | **58.5** | **51.6** |
164
+ | **Baichuan-13B-Chat** | **40.9** | **60.9** | **48.8** | **59.0** | **52.1** |
165
+
166
+
167
+ ## CMMLU
168
+
169
+ | Model 5-shot | STEM | Humanities | Social Sciences | Others | China Specific | Average |
170
+ |-------------------------|-------|------------|-----------------|--------|----------------|---------|
171
+ | InternLM-7B | 41.7 | 54.4 | 56.4 | 55.4 | 53.1 | 52.1 |
172
+ | ChatGLM2-6B | 42.5 | 51.4 | 51.4 | 50.7 | 48.4 | 49.0 |
173
+ | Baichuan-7B | 34.4 | 47.5 | 47.6 | 46.6 | 44.3 | 44.0 |
174
+ | Ziya-LLaMA-13B-Pretrain | 29.0 | 30.7 | 33.8 | 34.4 | 31.9 | 32.1 |
175
+ | LLaMA-13B | 29.2 | 30.8 | 31.6 | 33.0 | 30.5 | 31.2 |
176
+ | moss-moon-003-base (16B)| 27.2 | 30.4 | 28.8 | 32.6 | 28.7 | 29.6 |
177
+ | vicuna-13B | 24.0 | 25.4 | 25.3 | 25.0 | 25.0 | 24.9 |
178
+ | **Baichuan-13B-Base** | **41.7** | **61.1** | **59.8** | **59.0** | **56.4** | **55.3** |
179
+ | **Baichuan-13B-Chat** | **42.8** | **62.6** | **59.7** | **59.0** | **56.1** | **55.8** |
180
+
181
+ ## Our Group
182
+ ![WeChat](https://github.com/baichuan-inc/baichuan-7B/blob/main/media/wechat.jpeg?raw=true)