Commit 8eee5634 authored by hepj987's avatar hepj987
Browse files

标准格式

parent a2ce33be
# BERT-TF2 # bert_tensorflow
## 论文 ## 论文
...@@ -70,6 +70,8 @@ squad-v1.1 eval脚本:[evaluate-v1.1.py](https://github.com/allenai/bi-att-flo ...@@ -70,6 +70,8 @@ squad-v1.1 eval脚本:[evaluate-v1.1.py](https://github.com/allenai/bi-att-flo
``` ```
docker pull image.sourcefind.cn:5000/dcu/admin/base/tensorflow:2.7.0-centos7.6-dtk-22.10.1-py37-latest docker pull image.sourcefind.cn:5000/dcu/admin/base/tensorflow:2.7.0-centos7.6-dtk-22.10.1-py37-latest
docker run -dit --network=host --name=bert_tensorflow --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=16G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 image.sourcefind.cn:5000/dcu/admin/base/tensorflow:2.7.0-centos7.6-dtk-22.10.1-py37-latest
docker exec -it bert_tensorflow /bin/bash
``` ```
安装过程可能顶掉DCU版本的tensorflow,可以到[开发者社区](https://cancon.hpccube.com:65024/4/main/tensorflow/dtk22.10)下载DCU版本对应包 安装过程可能顶掉DCU版本的tensorflow,可以到[开发者社区](https://cancon.hpccube.com:65024/4/main/tensorflow/dtk22.10)下载DCU版本对应包
...@@ -78,9 +80,9 @@ docker pull image.sourcefind.cn:5000/dcu/admin/base/tensorflow:2.7.0-centos7.6-d ...@@ -78,9 +80,9 @@ docker pull image.sourcefind.cn:5000/dcu/admin/base/tensorflow:2.7.0-centos7.6-d
pip install requirements.txt pip install requirements.txt
``` ```
## MNLI分类训练 ## 训练
### 数据转化 ### 数据转化-MNLI
TF2.0版本读取数据需要转化为tf_record格式 TF2.0版本读取数据需要转化为tf_record格式
...@@ -106,7 +108,7 @@ python create_finetuning_data.py \ ...@@ -106,7 +108,7 @@ python create_finetuning_data.py \
--classification_task_name 分类任务名 --classification_task_name 分类任务名
``` ```
### 模型转化 ### 模型转化-MNLI
TF2.7.2与TF1.15.0模型存储、读取格式不同,官网给出的Bert一般是基于TF1.0的模型需要进行模型转化 TF2.7.2与TF1.15.0模型存储、读取格式不同,官网给出的Bert一般是基于TF1.0的模型需要进行模型转化
...@@ -125,7 +127,7 @@ python3 tf2_encoder_checkpoint_converter.py \ ...@@ -125,7 +127,7 @@ python3 tf2_encoder_checkpoint_converter.py \
bert_model.ckpt-1.index改为 bert_model.ckpt.index bert_model.ckpt-1.index改为 bert_model.ckpt.index
``` ```
### 单卡运行 ### 单卡运行-MNLI
``` ```
sh bert_class.sh sh bert_class.sh
...@@ -146,15 +148,13 @@ sh bert_class.sh ...@@ -146,15 +148,13 @@ sh bert_class.sh
--num_gpus 使用gpu数量 --num_gpus 使用gpu数量
``` ```
### 多卡运行 ### 多卡运行-MNLI
``` ```
sh bert_class_gpus.sh sh bert_class_gpus.sh
``` ```
## SQUAD1.1问答训练 ### 数据转化-SQUAD1.1
### 数据转化
TF2.0版本读取数据需要转化为tf_record格式 TF2.0版本读取数据需要转化为tf_record格式
...@@ -179,7 +179,7 @@ python3 create_finetuning_data.py \ ...@@ -179,7 +179,7 @@ python3 create_finetuning_data.py \
--max_seq_length 最大句子长度 --max_seq_length 最大句子长度
``` ```
### 模型转化 ### 模型转化-SQUAD1.1
``` ```
python3 tf2_encoder_checkpoint_converter.py \ python3 tf2_encoder_checkpoint_converter.py \
...@@ -196,7 +196,7 @@ python3 tf2_encoder_checkpoint_converter.py \ ...@@ -196,7 +196,7 @@ python3 tf2_encoder_checkpoint_converter.py \
bert_model.ckpt-1.index改为 bert_model.ckpt.index bert_model.ckpt-1.index改为 bert_model.ckpt.index
``` ```
### 单卡运行 ### 单卡运行-SQUAD1.1
``` ```
sh bert_squad.sh sh bert_squad.sh
...@@ -219,13 +219,13 @@ sh bert_squad.sh ...@@ -219,13 +219,13 @@ sh bert_squad.sh
--num_gpus 使用gpu数量 --num_gpus 使用gpu数量
``` ```
### 多卡运行 ### 多卡运行-SQUAD1.1
``` ```
sh bert_squad_gpus.sh sh bert_squad_gpus.sh
``` ```
## 模型精度 ## 精度
使用单张Z100收敛性如下所示: 使用单张Z100收敛性如下所示:
...@@ -234,22 +234,20 @@ sh bert_squad_gpus.sh ...@@ -234,22 +234,20 @@ sh bert_squad_gpus.sh
| MNLI-class(单卡) | val_accuracy: 0.7387 | | MNLI-class(单卡) | val_accuracy: 0.7387 |
| squad1.1(单卡) | F1-score:0.916378 | | squad1.1(单卡) | F1-score:0.916378 |
## 应用场景 # 应用场景
`文本分类、智能问答`
## 算法类别 ## 算法类别
`自然语言处理` `自然语言处理、文本分类、智能问答`
## 热点行业 ## 热点应用行业
`互联网` `互联网`
## 源码仓库及问题反馈 # 源码仓库及问题反馈
https://developer.hpccube.com/codes/modelzoo/bert-tf2 https://developer.hpccube.com/codes/modelzoo/bert-tf2
## 参考 # 参考
https://github.com/tensorflow/models/tree/v2.3.0/official/nlp https://github.com/tensorflow/models/tree/v2.3.0/official/nlp
# 模型唯一标识
modelCode=281
# 模型名称 # 模型名称
modelName=Bert-TF2 modelName=bert_tensorflow
# 模型描述 # 模型描述
modelDescription=Bert是一种预训练的语言表征模型。 modelDescription=bert是一种预训练的语言表征模型。
# 应用场景 # 应用场景
appScenario=训练,NLP,文本分类,文本问答 appScenario=训练,NLP,文本分类,文本问答
# 框架类型 # 框架类型
frameType=Tensorflow2 frameType=tensorflow
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