Commit 6f1edadb authored by yuguo's avatar yuguo
Browse files

update

parent 4e40bada
# BigScience Large Open-science Open-access Multilingual Language Model(BLOOM) # BLOOM
## 模型介绍
## 论文
`BLOOM: A 176B-Parameter Open-Access Multilingual Language Model`
- [https://arxiv.org/abs/2211.05100](https://arxiv.org/abs/2211.05100)
## 模型结构
Bloom是一个开源的支持最多59种语言和176B参数的大语言模型。它是在Megatron-LM GPT2的基础上修改训练出来的,主要使用了解码器唯一结构,对词嵌入层的归一化,使用GeLU激活函数的线性偏差注意力位置编码等技术。它的训练集包含了45种自然语言和12种编程语言,1.5TB的预处理文本转化为了350B的唯一token。bigscience在hugging face上发布的bloom模型包含多个参数多个版本。 Bloom是一个开源的支持最多59种语言和176B参数的大语言模型。它是在Megatron-LM GPT2的基础上修改训练出来的,主要使用了解码器唯一结构,对词嵌入层的归一化,使用GeLU激活函数的线性偏差注意力位置编码等技术。它的训练集包含了45种自然语言和12种编程语言,1.5TB的预处理文本转化为了350B的唯一token。bigscience在hugging face上发布的bloom模型包含多个参数多个版本。
## BLOOM-Inference
## 算法原理
当模型规模过于庞大,单个 GPU 设备无法容纳大规模模型参数时,便捷好用的分布式训练和推理需求就相继出现,业内也随之推出相应的工具。 当模型规模过于庞大,单个 GPU 设备无法容纳大规模模型参数时,便捷好用的分布式训练和推理需求就相继出现,业内也随之推出相应的工具。
基于 OneFlow 构建的 LiBai 模型库让分布式上手难度降到最低,用户不需要关注模型如何分配在不同的显卡设备,只需要修改几个配置数据就可以设置不同的分布式策略。当然,加速性能更是出众。 基于 OneFlow 构建的 LiBai 模型库让分布式上手难度降到最低,用户不需要关注模型如何分配在不同的显卡设备,只需要修改几个配置数据就可以设置不同的分布式策略。当然,加速性能更是出众。
...@@ -46,14 +55,25 @@ class Linear1D(nn.Module): ...@@ -46,14 +55,25 @@ class Linear1D(nn.Module):
所以,根据 LiBai 中各种 layer 的设计原理以及基于 OneFlow 中 tensor 自带的 SBP 和 Placement 属性的天然优势,使得用户搭建的模型能够很简单地就实现数据并行、模型并行以及流水并行操作。 所以,根据 LiBai 中各种 layer 的设计原理以及基于 OneFlow 中 tensor 自带的 SBP 和 Placement 属性的天然优势,使得用户搭建的模型能够很简单地就实现数据并行、模型并行以及流水并行操作。
## BLOOMZ-7B1推理 ## 环境配置
### 环境配置
### Docker
提供[光源](https://www.sourcefind.cn/#/service-details)拉取的训练以及推理的docker镜像:image.sourcefind.cn:5000/dcu/admin/base/oneflow:0.9.1-centos7.6-dtk-22.10.1-py39-latest 提供[光源](https://www.sourcefind.cn/#/service-details)拉取的训练以及推理的docker镜像:image.sourcefind.cn:5000/dcu/admin/base/oneflow:0.9.1-centos7.6-dtk-22.10.1-py39-latest
cd libai docker pull image.sourcefind.cn:5000/dcu/admin/base/oneflow:0.9.1-centos7.6-dtk-22.10.1-py39-latest
# <Your Image ID>用上面拉取docker镜像的ID替换
docker run --shm-size 16g --network=host --name=bert_oneflow --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/bloom_oneflow:/home/bloom_oneflow -it <Your Image ID> bash
cd bloom_oneflow
pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
pip3 install pybind11 -i https://mirrors.aliyun.com/pypi/simple pip3 install pybind11 -i https://mirrors.aliyun.com/pypi/simple
pip3 install -e . -i https://mirrors.aliyun.com/pypi/simple pip3 install -e . -i https://mirrors.aliyun.com/pypi/simple
## 数据集
在下面脚本中生成。
## 权重
需要先准备好模型权重:https://huggingface.co/bigscience/bloomz-7b1/tree/main 需要先准备好模型权重:https://huggingface.co/bigscience/bloomz-7b1/tree/main
### bloomz-7b1的文件结构 ### bloomz-7b1的文件结构
...@@ -68,11 +88,11 @@ path/to/bloomz-7b1 ...@@ -68,11 +88,11 @@ path/to/bloomz-7b1
└── pytorch_model.bin └── pytorch_model.bin
``` ```
### 推理 ## BLOOMZ-7B1推理
采用1节点,4张DCU-Z100-16G,采用tp=4,pp=1的并行配置。 采用1节点,4张DCU-Z100-16G,采用tp=4,pp=1的并行配置。
运行以下代码: 将模型权重放置与demo.py同一目录下,运行以下代码:
cd projects/BLOOM cd projects/BLOOM
# 运行前修改 configs/bloom_inference.py 中 `min_length=64` # 运行前修改 configs/bloom_inference.py 中 `min_length=64`
...@@ -127,14 +147,23 @@ demo.py如下: ...@@ -127,14 +147,23 @@ demo.py如下:
if dist.is_main_process(): if dist.is_main_process():
print(res) print(res)
### 输出
输出:
``` ```
>>> >>>
How to improve sleep quality? keep your bedroom dark and quiet. Avoid electronics and bright lights. Keep your bedroom cool. Use a white noise machine. Use a humidifier. Use a diffuser. Use essential oils. Use a sleep aid. Try acupuncture. Try hypnotherapy. Try acupressure.</s> How to improve sleep quality? keep your bedroom dark and quiet. Avoid electronics and bright lights. Keep your bedroom cool. Use a white noise machine. Use a humidifier. Use a diffuser. Use essential oils. Use a sleep aid. Try acupuncture. Try hypnotherapy. Try acupressure.</s>
``` ```
## 应用场景
### 算法类别
`自然语言处理`
### 热点应用行业
`nlp,智能聊天助手,科研,文学创作`
## 源码仓库及问题反馈 ## 源码仓库及问题反馈
- https://developer.hpccube.com/codes/modelzoo/bloom_oneflow - https://developer.hpccube.com/codes/modelzoo/bloom_oneflow
......
# 模型唯一标识
modelCode=74
# 模型名称 # 模型名称
modelName=BLOOM_OneFlow modelName=BLOOM_OneFlow
# 模型描述 # 模型描述
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment