当前位置:   article > 正文

Baichuan-13B-Chat huggingface主页

Baichuan-13B-Chat huggingface主页

Baichuan-13B-Chat

介绍

Baichuan-13B-Chat为Baichuan-13B系列模型中对齐后的版本,预训练模型可见Baichuan-13B-Base

Baichuan-13B 是由百川智能继 Baichuan-7B 之后开发的包含 130 亿参数的开源可商用的大规模语言模型,在权威的中文和英文 benchmark 上均取得同尺寸最好的效果。本次发布包含有预训练 (Baichuan-13B-Base) 和对齐 (Baichuan-13B-Chat) 两个版本。Baichuan-13B 有如下几个特点:

  1. 更大尺寸、更多数据:Baichuan-13B 在 Baichuan-7B 的基础上进一步扩大参数量到 130 亿,并且在高质量的语料上训练了 1.4 万亿 tokens,超过 LLaMA-13B 40%,是当前开源 13B 尺寸下训练数据量最多的模型。支持中英双语,使用 ALiBi 位置编码,上下文窗口长度为 4096。
  2. 同时开源预训练和对齐模型:预训练模型是适用开发者的“基座”,而广大普通用户对有对话功能的对齐模型具有更强的需求。因此本次开源我们同时发布了对齐模型(Baichuan-13B-Chat),具有很强的对话能力,开箱即用,几行代码即可简单的部署。
  3. 更高效的推理:为了支持更广大用户的使用,我们本次同时开源了 int8 和 int4 的量化版本,相对非量化版本在几乎没有效果损失的情况下大大降低了部署的机器资源门槛,可以部署在如 Nvidia 3090 这样的消费级显卡上。
  4. 开源免费可商用:Baichuan-13B 不仅对学术研究完全开放,开发者也仅需邮件申请并获得官方商用许可后,即可以免费商用。

Baichuan-13B-Chat is the aligned version in the Baichuan-13B series of models, and the pre-trained model can be found at Baichuan-13B-Base.

Baichuan-13B is an open-source, commercially usable large-scale language model developed by Baichuan Intelligence, following Baichuan-7B. With 13 billion parameters, it achieves the best performance in standard Chinese and English benchmarks among models of its size. This release includes two versions: pre-training (Baichuan-13B-Base) and alignment (Baichuan-13B-Chat). Baichuan-13B has the following features:

  1. Larger size, more data: Baichuan-13B further expands the parameter volume to 13 billion based on Baichuan-7B, and has trained 1.4 trillion tokens on high-quality corpora, exceeding LLaMA-13B by 40%. It is currently the model with the most training data in the open-source 13B size. It supports both Chinese and English, uses ALiBi position encoding, and has a context window length of 4096.
  2. 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 also released the alignment model (Baichuan-13B-Chat), which has strong dialogue capabilities and is ready to use. It can be easily deployed with just a few lines of code.
  3. More efficient inference: To support a wider range of users, we have open-sourced the INT8 and INT4 quantized versions. The model can be conveniently deployed on consumer GPUs like the Nvidia 3090 with almost no performance loss.
  4. Open-source, free, and commercially usable: Baichuan-13B is not only fully open to academic research, but developers can also use it for free commercially after applying for and receiving official commercial permission via email.

使用方式

如下是一个使用Baichuan-13B-Chat进行对话的示例,正确输出为"乔戈里峰。世界第二高峰———乔戈里峰西方登山者称其为k2峰,海拔高度是8611米,位于喀喇昆仑山脉的中巴边境上"

  1. import torch
  2. from transformers import AutoModelForCausalLM, AutoTokenizer
  3. from transformers.generation.utils import GenerationConfig
  4. tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan-13B-Chat", use_fast=False, trust_remote_code=True)
  5. model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-13B-Chat", device_map="auto", torch_dtype=torch.float16, trust_remote_code=True)
  6. model.generation_config = GenerationConfig.from_pretrained("baichuan-inc/Baichuan-13B-Chat")
  7. messages = []
  8. messages.append({"role": "user", "content": "世界上第二高的山峰是哪座"})
  9. response = model.chat(tokenizer, messages)
  10. print(response)

Here is an example of a conversation using Baichuan-13B-Chat, the correct output is "K2. The world's second highest peak - K2, also known as Mount Godwin-Austen or Chhogori, with an altitude of 8611 meters, is located on the China-Pakistan border in the Karakoram Range."

  1. import torch
  2. from transformers import AutoModelForCausalLM, AutoTokenizer
  3. from transformers.generation.utils import GenerationConfig
  4. tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan-13B-Chat", use_fast=False, trust_remote_code=True)
  5. model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-13B-Chat", device_map="auto", torch_dtype=torch.float16, trust_remote_code=True)
  6. model.generation_config = GenerationConfig.from_pretrained("baichuan-inc/Baichuan-13B-Chat")
  7. messages = []
  8. messages.append({"role": "user", "content": "Which moutain is the second highest one in the world?"})
  9. response = model.chat(tokenizer, messages)
  10. print(response)

量化部署

Baichuan-13B 支持 int8 和 int4 量化,用户只需在推理代码中简单修改两行即可实现。请注意,如果是为了节省显存而进行量化,应加载原始精度模型到 CPU 后再开始量化;避免在 from_pretrained 时添加 device_map='auto' 或者其它会导致把原始精度模型直接加载到 GPU 的行为的参数。

Baichuan-13B supports int8 and int4 quantization, users only need to make a simple two-line change in the inference code to implement it. Please note, if quantization is done to save GPU memory, the original precision model should be loaded onto the CPU before starting quantization. Avoid adding parameters such as device_map='auto' or others that could cause the original precision model to be loaded directly onto the GPU when executing from_pretrained.

使用 int8 量化 (To use int8 quantization):

  1. model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-13B-Chat", torch_dtype=torch.float16, trust_remote_code=True)
  2. model = model.quantize(8).cuda()

同样的,如需使用 int4 量化 (Similarly, to use int4 quantization):

  1. model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-13B-Chat", torch_dtype=torch.float16, trust_remote_code=True)
  2. model = model.quantize(4).cuda()

模型详情

模型描述

  • Developed by: 百川智能(Baichuan Intelligent Technology)

  • Emailopensource@baichuan-inc.com

  • Language(s) (NLP): Chinese/English

  • License: 【Community License for Baichuan-13B Model】(ZHEN)

    商业用途(For commercial use): 请通过 Email 联系申请书面授权。(Contact us via Email above to apply for written authorization.)

模型结构

整体模型基于Baichuan-7B,为了获得更好的推理性能,Baichuan-13B 使用了 ALiBi 线性偏置技术,相对于 Rotary Embedding 计算量更小,对推理性能有显著提升;与标准的 LLaMA-13B 相比,生成 2000 个 tokens 的平均推理速度 (tokens/s),实测提升 31.6%

Modeltokens/s
LLaMA-13B19.4
Baichuan-13B25.4

具体参数和见下表

模型名称隐含层维度层数头数词表大小总参数量训练数据(tokens)位置编码最大长度
Baichuan-7B4,096323264,0007,000,559,6161.2万亿RoPE4,096
Baichuan-13B5,120404064,00013,264,901,1201.4万亿ALiBi4,096

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%:

Modeltokens/s
LLaMA-13B19.4
Baichuan-13B25.4

The specific parameters are as follows:

Model NameHidden SizeNum LayersNum Attention HeadsVocab SizeTotal ParamsTraining Dats(tokens)Position EmbeddingMax Length
Baichuan-7B4,096323264,0007,000,559,6161.2万亿RoPE4,096
Baichuan-13B5,120404064,00013,264,901,1201.4万亿ALiBi4,096

使用须知

免责声明

我们在此声明,我们的开发团队并未基于 Baichuan-13B 模型开发任何应用,无论是在 iOS、Android、网页或任何其他平台。我们强烈呼吁所有使用者,不要利用 Baichuan-13B 模型进行任何危害国家社会安全或违法的活动。另外,我们也要求使用者不要将 Baichuan-13B 模型用于未经适当安全审查和备案的互联网服务。我们希望所有的使用者都能遵守这个原则,确保科技的发展能在规范和合法的环境下进行。

我们已经尽我们所能,来确保模型训练过程中使用的数据的合规性。然而,尽管我们已经做出了巨大的努力,但由于模型和数据的复杂性,仍有可能存在一些无法预见的问题。因此,如果由于使用 Baichuan-13B 开源模型而导致的任何问题,包括但不限于数据安全问题、公共舆论风险,或模型被误导、滥用、传播或不当利用所带来的任何风险和问题,我们将不承担任何责任。

We hereby declare that our development team has not developed any applications based on the Baichuan-13B model, whether on iOS, Android, the web, or any other platform. We strongly urge all users not to use the Baichuan-13B model for any activities that harm national social security or are illegal. In addition, we also ask users not to use the Baichuan-13B model for internet services that have not undergone appropriate security review and filing. We hope that all users will adhere to this principle to ensure that technological development takes place in a regulated and legal environment.

We have done our utmost to ensure the compliance of the data used in the model training process. However, despite our great efforts, due to the complexity of the model and data, there may still be some unforeseen issues. Therefore, we will not take any responsibility for any issues arising from the use of the Baichuan-13B open-source model, including but not limited to data security issues, public opinion risks, or any risks and problems arising from the model being misled, misused, disseminated, or improperly exploited.

训练详情

训练具体设置参见Baichuan-13B

For specific training settings, please refer to Baichuan-13B.

测评结果

C-Eval

Model 5-shotSTEMSocial SciencesHumanitiesOthersAverage
Baichuan-7B38.252.046.239.342.8
Chinese-Alpaca-Plus-13B35.245.640.038.238.8
Vicuna-13B30.538.232.532.532.8
Chinese-LLaMA-Plus-13B30.338.032.929.132.1
Ziya-LLaMA-13B-Pretrain27.634.432.028.630.0
LLaMA-13B27.033.627.727.628.5
moss-moon-003-base (16B)27.029.127.226.927.4
Baichuan-13B-Base45.963.557.249.352.4
Baichuan-13B-Chat43.764.656.249.251.5

MMLU

Model 5-shotSTEMSocial SciencesHumanitiesOthersAverage
Vicuna-13B40.460.549.558.452.0
LLaMA-13B36.153.044.052.846.3
Chinese-Alpaca-Plus-13B36.948.940.550.543.9
Ziya-LLaMA-13B-Pretrain35.647.640.149.442.9
Baichuan-7B35.648.938.448.142.3
Chinese-LLaMA-Plus-13B33.142.837.044.639.2
moss-moon-003-base (16B)22.422.824.224.423.6
Baichuan-13B-Base41.660.947.458.551.6
Baichuan-13B-Chat40.960.948.859.052.1

说明:我们采用了 MMLU 官方的评测方案

CMMLU

Model 5-shotSTEMHumanitiesSocial SciencesOthersChina SpecificAverage
Baichuan-7B34.447.547.646.644.344.0
Vicuna-13B31.836.237.639.534.336.3
Chinese-Alpaca-Plus-13B29.833.433.237.932.133.4
Chinese-LLaMA-Plus-13B28.133.135.435.133.533.0
Ziya-LLaMA-13B-Pretrain29.030.733.834.431.932.1
LLaMA-13B29.230.831.633.030.531.2
moss-moon-003-base (16B)27.230.428.832.628.729.6
Baichuan-13B-Base41.761.159.859.056.455.3
Baichuan-13B-Chat42.862.659.759.056.155.8

说明:CMMLU 是一个综合性的中文评估基准,专门用于评估语言模型在中文语境下的知识和推理能力。我们采用了其官方的评测方案

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/367697
推荐阅读
相关标签
  

闽ICP备14008679号