Baichuan AI/Dense

Baichuan2 7B

chatmultilingual
7B
Parameters
4K
Context length
2
Benchmarks
4
Quantizations
100K
HF downloads
Architecture
Dense
Released
2023-09-06
Layers
32
KV Heads
32
Head Dim
128
Family
baichuan

目录/Table of Contents

<span id="Introduction">模型介绍/Introduction</span>

Baichuan 2 是[百川智能]推出的新一代开源大语言模型,采用 2.6 万亿 Tokens 的高质量语料训练,在权威的中文和英文 benchmark 上均取得同尺寸最好的效果。本次发布包含有 7B、13B 的 Base 和 Chat 版本,并提供了 Chat 版本的 4bits 量化,所有版本不仅对学术研究完全开放,开发者也仅需[邮件申请]并获得官方商用许可后,即可以免费商用。具体发布版本和下载见下表:

Baichuan 2 is the new generation of large-scale open-source language models launched by Baichuan Intelligence inc.. It is trained on a high-quality corpus with 2.6 trillion tokens and has achieved the best performance in authoritative Chinese and English benchmarks of the same size. This release includes 7B and 13B versions for both Base and Chat models, along with a 4bits quantized version for the Chat model. All versions are fully open to academic research, and developers can also use them for free in commercial applications after obtaining an official commercial license through email request. The specific release versions and download links are listed in the table below:

Base ModelChat Model4bits Quantized Chat Model
7BBaichuan2-7B-BaseBaichuan2-7B-ChatBaichuan2-7B-Chat-4bits
13BBaichuan2-13B-BaseBaichuan2-13B-ChatBaichuan2-13B-Chat-4bits

<span id="Start">快速开始/Quick Start</span>

在Baichuan2系列模型中,我们为了加快推理速度使用了Pytorch2.0加入的新功能F.scaled_dot_product_attention,因此模型需要在Pytorch2.0环境下运行。

In the Baichuan 2 series models, we have utilized the new feature F.scaled_dot_product_attention introduced in PyTorch 2.0 to accelerate inference speed. Therefore, the model needs to be run in a PyTorch 2.0 environment.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.generation.utils import GenerationConfig
tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan2-7B-Chat", use_fast=False, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan2-7B-Chat", device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True)
model.generation_config = GenerationConfig.from_pretrained("baichuan-inc/Baichuan2-7B-Chat")
messages = []
messages.append({"role": "user", "content": "解释一下“温故而知新”"})
response = model.chat(tokenizer, messages)
print(response)
"温故而知新"是一句中国古代的成语,出自《论语·为政》篇。这句话的意思是:通过回顾过去,我们可以发现新的知识和理解。换句话说,学习历史和经验可以让我们更好地理解现在和未来。

这句话鼓励我们在学习和生活中不断地回顾和反思过去的经验,从而获得新的启示和成长。通过重温旧的知识和经历,我们可以发现新的观点和理解,从而更好地应对不断变化的世界和挑战。

<span id="Benchmark">Benchmark 结果/Benchmark Evaluation</span>

我们在[通用]、[法律]、[医疗]、[数学]、[代码]和[多语言翻译]六个领域的中英文权威数据集上对模型进行了广泛测试,更多详细测评结果可查看[GitHub]。

We have extensively tested the model on authoritative Chinese-English datasets across six domains: General, Legal, Medical, Mathematics, Code, and Multilingual Translation. For more detailed evaluation results, please refer to GitHub.

7B Model Results

C-EvalMMLUCMMLUGaokaoAGIEvalBBH
5-shot5-shot5-shot5-shot5-shot3-shot
GPT-468.4083.9370.3366.1563.2775.12
GPT-3.5 Turbo51.1068.5454.0647.0746.1361.59
LLaMA-7B27.1035.1026.7527.8128.1732.38
LLaMA2-7B28.9045.7331.3825.9726.5339.16
MPT-7B27.1527.9326.0026.5424.8335.20
Falcon-7B24.2326.0325.6624.2424.1028.77
ChatGLM2-6B50.2045.9049.0049.4445.2831.65
[Baichuan-7B]42.8042.3044.0236.3434.4432.48
[Baichuan2-7B-Base]54.0054.1657.0747.4742.7341.56

13B Model Results

C-EvalMMLUCMMLUGaokaoAGIEvalBBH
5-shot5-shot5-shot5-shot5-shot3-shot
GPT-468.4083.9370.3366.1563.2775.12
GPT-3.5 Turbo51.1068.5454.0647.0746.1361.59
LLaMA-13B28.5046.3031.1528.2328.2237.89
LLaMA2-13B35.8055.0937.9930.8332.2946.98
Vicuna-13B32.8052.0036.2830.1131.5543.04
Chinese-Alpaca-Plus-13B38.8043.9033.4334.7835.4628.94
XVERSE-13B53.7055.2158.4444.6942.5438.06
[Baichuan-13B-Base]52.4051.6055.3049.6943.2043.01
[Baichuan2-13B-Base]58.1059.1761.9754.3348.1748.78

训练过程模型/Training Dynamics

除了训练了 2.6 万亿 Tokens 的 Baichuan2-7B-Base 模型,我们还提供了在此之前的另外 11 个中间过程的模型(分别对应训练了约 0.2 ~ 2.4 万亿 Tokens)供社区研究使用 (训练过程checkpoint下载)。下图给出了这些 checkpoints 在 C-Eval、MMLU、CMMLU 三个 benchmark 上的效果变化:

In addition to the Baichuan2-7B-Base model trained on 2.6 trillion tokens, we also offer 11 additional intermediate-stage models for community research, corresponding to training on approximately 0.2 to 2.4 trillion tokens each (Intermediate Checkpoints Download). The graph below shows the performance changes of these checkpoints on three benchmarks: C-Eval, MMLU, and CMMLU.

<span id="Community">社区与生态/Community</span>

Intel 酷睿 Ultra 平台运行百川大模型

使用酷睿™/至强® 可扩展处理器或配合锐炫™ GPU等进行部署[Baichuan2-7B-Chat],[Baichuan2-13B-Chat]模型,推荐使用 BigDL-LLM([CPU], [GPU])以发挥更好推理性能。

详细支持信息可参考中文操作手册,包括用notebook支持,加载,优化,保存方法等。

...

Quantizations & VRAM

Q4_K_M4.5 bpw
4.4 GB
VRAM required
94%
Quality
Q6_K6.5 bpw
6.2 GB
VRAM required
97%
Quality
Q8_08 bpw
7.5 GB
VRAM required
100%
Quality
FP1616 bpw
14.5 GB
VRAM required
100%
Quality

Benchmarks (2)

MATH24.6
HumanEval18.3

GPUs that can run this model

At Q4_K_M quantization. Sorted by minimum VRAM.

NVIDIA Tesla K20c
5 GB VRAM • 208 GB/s
NVIDIA
NVIDIA Tesla K20m
5 GB VRAM • 208 GB/s
NVIDIA
NVIDIA Tesla K20s
5 GB VRAM • 208 GB/s
NVIDIA
NVIDIA GeForce GTX 1060 5 GB
5 GB VRAM • 160 GB/s
NVIDIA
NVIDIA P102-100
5 GB VRAM • 440 GB/s
NVIDIA
NVIDIA RTX 3050 6GB
6 GB VRAM • 168 GB/s
NVIDIA
$169
Intel Arc A380
6 GB VRAM • 186 GB/s
INTEL
$129
NVIDIA RTX 2060 6GB
6 GB VRAM • 336 GB/s
NVIDIA
$150
NVIDIA GTX 1660 SUPER
6 GB VRAM • 336 GB/s
NVIDIA
$150
NVIDIA GTX 1660 Ti
6 GB VRAM • 288 GB/s
NVIDIA
$140
NVIDIA GTX 1060 6GB
6 GB VRAM • 192 GB/s
NVIDIA
$80
NVIDIA Tesla C2070
6 GB VRAM • 143 GB/s
NVIDIA
NVIDIA Tesla C2075
6 GB VRAM • 150 GB/s
NVIDIA
NVIDIA Tesla C2090
6 GB VRAM • 177 GB/s
NVIDIA
NVIDIA Tesla M2070
6 GB VRAM • 150 GB/s
NVIDIA
NVIDIA Tesla M2070-Q
6 GB VRAM • 150 GB/s
NVIDIA
NVIDIA Tesla M2075
6 GB VRAM • 150 GB/s
NVIDIA
NVIDIA Tesla M2090
6 GB VRAM • 177 GB/s
NVIDIA
NVIDIA Tesla X2070
6 GB VRAM • 177 GB/s
NVIDIA
NVIDIA Tesla X2090
6 GB VRAM • 177 GB/s
NVIDIA
NVIDIA Tesla K20X
6 GB VRAM • 250 GB/s
NVIDIA
NVIDIA Tesla K20Xm
6 GB VRAM • 250 GB/s
NVIDIA
NVIDIA GeForce GTX 1060 6 GB
6 GB VRAM • 192 GB/s
NVIDIA
NVIDIA GeForce GTX 1060 6 GB 9Gbps
6 GB VRAM • 217 GB/s
NVIDIA
NVIDIA GeForce GTX 1060 6 GB GDDR5X
6 GB VRAM • 192 GB/s
NVIDIA
NVIDIA GeForce GTX 1060 6 GB GP104
6 GB VRAM • 192 GB/s
NVIDIA
NVIDIA GeForce GTX 1060 6 GB Rev. 2
6 GB VRAM • 192 GB/s
NVIDIA
NVIDIA GeForce GTX 1660
6 GB VRAM • 192 GB/s
NVIDIA
NVIDIA GeForce GTX 1660 SUPER
6 GB VRAM • 336 GB/s
NVIDIA
NVIDIA GeForce GTX 1660 Ti
6 GB VRAM • 288 GB/s
NVIDIA

Find the best GPU for Baichuan2 7B

Build Hardware for Baichuan2 7B