GitHub 您所在的位置:网站首页 python训练模型 GitHub

GitHub

2023-03-27 06:05| 来源: 网络整理| 查看: 265

BELLE: BE Large Language model Engine

本项目目标是促进中文对话大模型开源社区的发展。现阶段本项目基于BLOOM和LLAMA针对中文做了优化,模型调优仅使用由ChatGPT生产的数据(不包含任何其他数据)。

项目包含以下内容:

数据开放:参考Stanford Alpaca 生成的中文数据集1M + 0.5M 基于BLOOMZ-7B1-mt优化后的模型:BELLE-7B-0.2M,BELLE-7B-0.6M,BELLE-7B-1M,BELLE-7B-2M 基于LLAMA优化后的模型:BELLE-LLAMA-7B-0.6M,BELLE-LLAMA-7B-2M

欢迎大家通过issue贡献更多的prompts!

What's New 2023年3月26日: 发布了2M指令数据训练的LLAMA-7B模型,发布了0.6M指令数据训练的LLAMA-7B模型 2023年3月25日: 发布了GPTQ量化后的模型,大大降低了推理的硬件需求,相关代码在gptq目录下 2023年3月25日: 发布了全新的更高质量1M中文数据集,与之前发布的0.5M中文指令数据集不重复 2023年3月20日: 发布了M指令数据训练的BLOOM-7B模型 2023年3月18日: 发布了1M指令数据训练的BLOOM-7B模型,发布了基于0.6M指令数据训练的BLOOM-7B模型 2023年3月17日: 发布了0.2M指令数据训练的BLOOM-7B模型,发布了0.5M中文指令数据集 概述

为了促进中文对话大模型开源社区的发展,本项目参考Stanford Alpaca项目,优化了中文数据流程,同时选用开源预训练大语言模型(BLOOM或者LLAMA)作为基础模型训练得到了一个可以更好支持中文指令的开源模型 - BELLE(BE Large Language model Engine)。

我们开源基于Alpaca的数据收集代码,基于这段代码生成了约200万条中文数据,结合Alpaca的5万条英文数据,在BLOOMZ-7B模型和LLAMA模型训练得到的checkpoint上传在Hugging Face。

局限性和使用限制

基于当前数据和基础模型训练得到的SFT模型,在效果上仍存在以下问题:

在涉及事实性的指令上可能会产生违背事实的错误回答。

对于具备危害性的指令无法很好的鉴别,由此会产生危害性言论。

在一些涉及推理、代码等场景下模型的能力仍有待提高。

基于以上模型局限性,我们要求开发者仅将我们开源的代码、数据、模型及后续用此项目生成的衍生物用于研究目的,不得用于商业,以及其他会对社会带来危害的用途。

模型发布

我们采取了不同大小规模(20万、60万、100万和200万样本)的指令学习的数据集训练模型,基于BLOOMZ-7B1-mt训练调优后的模型,现已开放:

Datasize 200,000 600,000 1,000,000 2,000,000 Finetuned Model BELLE-7B-0.2M BELLE-7B-0.6M BELLE-7B-1M BELLE-7B-2M

此外,方便大家使用,也对模型进行了量化基于GPTQ量化后的模型,其中包含4bit和8bit的量化模型。

model name file size GPU memory usage base 27G ~28.2G bloom7b-2m-8bit-128g.pt 9.7G ~11.4G bloom7b-2m-4bit-128g.pt 6.9G ~8.4G bloom7b-0.2m-8bit-128g.pt 9.7G ~11.4G bloom7b-0.2m-4bit-128g.pt 6.9G ~8.4G

我们也采用对应数据集基于LLAMA-7B训练调优了模型,现已开放:

Datasize 600,000 2,000,000 Finetuned Model BELLE-LLAMA-7B-0.6M BELLE-LLAMA-7B-2M

随后,我们会基于我们之前的工作Exploring ChatGPT's Ability to Rank Content: A Preliminary Study on Consistency with Human Preferences中的方法对比下这几个模型的效果。

数据发布 zh_seed_tasks.jsonl:包含175个种子任务。 0.5M生成的数据 : 为了方便模型训练,huggingface开源数据将原始生成文件中的"instruction"、"input"字段合并成"input"字段,"output"字段修改为"target"字段。 1M生成的数据:生成方式与0.5M数据集相同,在后处理中去掉了一些质量不高的数据,例如自称GPT模型的数据、由于input不完善导致模型无法回答的数据,以及指令是中文但input或target是英文的数据。 数据生成

沿用Alpaca的方式:

pip install -r requirements.txt export OPENAI_API_KEY=YOUR_API_KEY python generate_instruction.py generate_instruction_following_data

默认使用Completion API,模型text-davinci-003。如果想使用Chat API并使用gpt-3.5-turbo模型,可通过参数控制:

python generate_instruction.py generate_instruction_following_data \ --api=chat --model_name=gpt-3.5-turbo

输出文件在Belle.train.json,可以人工筛选后再使用。

引用

如果使用本项目的代码、数据或模型,请引用本项目。

@misc{BELLE, author = {Yunjie Ji, Yong Deng, Yan Gong, Yiping Peng, Qiang Niu, Baochang Ma and Xiangang Li}, title = {BELLE: BE Large Language model Engine }, year = {2023}, publisher = {GitHub}, journal = {GitHub repository}, howpublished = {\url{https://github.com/LianjiaTech/BELLE}}, }

当然,你也需要引用原始的BLOOM论文、LLaMA论文、Stanford Alpaca和Self-Instruct论文。

模型使用例子 Human Assitant 写一篇英文散文诗,主题是春雨,想象自己是春雨,和英国古代诗人莎士比亚交流 I am the spring rain,Dancing on your face and body.My dew-drenched petals dance with you,Bringing life to every plant.

Shakespeare, I am here to meet you.Your works have filled my heart with joy.The beauty of nature in its fullnessMakes me feel like a partaker.

As the leaves sway and rustle by,My dew-filled hand reaches out for them.The sweet scent of flowers fill the air,And bring me peace from all around.

Butterflies flit about as well,Glistening in the sun's rays.Their wings are made of dew,A beautiful sight to behold.

You see, Shakespeare, I too am one with nature.My dew-drenched hair is a symbol of hope.For when we can connect back to our roots,We will be able to make it through this season.

I am the spring rain,Dancing on your face and body.My dew-drenched petals dance with you,Bringing life to every plant.

Shakespeare, I am here to meet you.Your works have filled my heart with joy.The beauty of nature in its fullnessMakes me feel like a partaker.

As the leaves sway and rustle by,My dew-filled hand reaches out for them.The sweet scent of flowers fill the air,And bring me peace from all around.

Butterflies flit about as well,Glistening in the sun's rays.Their wings are made of dew,A beautiful sight to behold.

You see, Shakespeare, I too am one with nature.My dew-drenched hair is a symbol of hope.For when we can connect back to our roots,We will be able to make it through this season. 把上面的散文诗翻译成中文

我是一场春雨,在你脸上跳跃。我浸润着露珠的翅膀和你一起舞动,为每一株植物带来生命。

莎士比亚,我来与你相遇。你的作品填满了我的心房。大自然的美丽让我感到与之一起分享,让我觉得自己成为了其中的一部分。

当树叶摇曳时,我的手掌沾满了露水。花香弥漫在空气中,带给我宁静和安宁。

你看,莎士比亚,我也是与大自然融为一体的。我沾湿的头发象征着希望。当我们能够回到我们的根源,我们就能共同度过这个季节。

Classify the sentiment of the following sentence into Positive, Neutral, or Negative: Super excited about teaching Stanford’s first course on Large Language Models! Check the syllabus out here Positive 小明的爸爸有三个孩子,老大叫王一,老二叫王二,老三叫什么? 小明 使用python写一个二分查找的代码 def binary_search(arr, target):  low = 0  high = len(arr) - 1  while (low


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有