百川智能是由百度前高管王小川创立的AI公司,推出了一系列百川(Baichuan)大模型,包括Baichuan-7B、Baichuan-13B、Baichuan-53B以及第二代Baichuan 2系列模型,是中文大模型领域的代表性工作之一。百川模型在开源社区非常受欢迎,以优秀的中文理解能力和可商用性著称。
Baichuan-7B是百川智能推出的第一代70亿参数开源大模型,具有以下特点:

通过上述优化,在千卡A800显卡上达到了182 TFLOPS的吞吐,GPU峰值算力利用率高达58.3%。
Baichuan-13B在7B基础上进一步升级,主要特点:
更大尺寸、更多数据:参数扩大到130亿,在高质量语料上训练了1.4万亿tokens,超过LLaMA-13B 40%,是当前开源13B尺寸下训练数据量最多的模型,支持中英双语,使用ALiBi位置编码,上下文窗口长度4096
同时开源预训练和对齐模型:
更高效的推理:同时开源int8和int4量化版本,几乎无效果损失的情况下大幅降低部署门槛,可在NVIDIA 3090等消费级显卡上部署
部署示例代码:
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from transformers.generation.utils import GenerationConfig
3
4tokenizer = AutoTokenizer.from_pretrained(
5 "baichuan-inc/Baichuan-13B-Chat",
6 use_fast=False,
7 trust_remote_code=True
8)
9model = AutoModelForCausalLM.from_pretrained(
10 "baichuan-inc/Baichuan-13B-Chat",
11 device_map="auto",
12 torch_dtype=torch.float16,
13 trust_remote_code=True
14)
15model.generation_config = GenerationConfig.from_pretrained(
16 "baichuan-inc/Baichuan-13B-Chat"
17)
18
19messages = [{"role": "user", "content": "世界上第二高的山峰是哪座"}]
20response = model.chat(tokenizer, messages)
21print(response)
22# 输出:乔戈里峰。世界第二高峰———乔戈里峰西方登山者称其为k2峰,海拔高度是8611米,位于喀喇昆仑山脉的中巴边境上量化部署:
1# int8量化
2model = AutoModelForCausalLM.from_pretrained(
3 "baichuan-inc/Baichuan-13B-Chat",
4 torch_dtype=torch.float16,
5 trust_remote_code=True
6)
7model = model.quantize(8).cuda()
8
9# int4量化
10model = model.quantize(4).cuda()Baichuan-53B是百川更大参数规模的模型,主要技术特点:
预训练数据优化:
搜索增强技术:
Baichuan 2是百川第二代模型,相比第一代有显著提升:

百川模型针对中文做了多方面优化:
数据层面:
分词层面:
训练层面:
微调配比: 根据实践,基于base预训练模型做微调时,领域数据:通用数据配比为1:5时效果最佳:

| 模型 | 参数 | 训练tokens | 上下文 | 主要特点 |
|---|---|---|---|---|
| Baichuan-7B | 7B | 1.2T | 4096 | 开源基座,中英双语 |
| Baichuan-13B | 13B | 1.4T | 4096 | 同时开源base和chat,支持量化 |
| Baichuan-53B | 53B | - | - | 搜索增强,更高质量 |
| Baichuan2-13B | 13B | - | - | 全面性能提升,更安全 |
百川模型相比原生LLaMA有哪些改进?
Baichuan-13B如何进行量化部署?有什么好处?
领域微调时,领域数据和通用数据的配比一般如何设置?
百川在训练优化上做了哪些工作提升训练效率?
Baichuan-53B的搜索增强技术主要包含哪些步骤?