BERT下游任务finetune列表
finetune基于官方代码改造的模型基于pytorch/tensorflow双版本
*** 2019-10-24: 增加ERNIE1.0, google-bert-base, bert_wwm_ext_base部分结果, xlnet代码和相关结果 ***
*** 2019-10-17: 增加tensorflow多gpu并行 ***
*** 2019-10-16: 增加albert_xlarge结果 ***
*** 2019-10-15: 增加tensorflow(bert/roberta)在cmrc2018上的finetune代码(暂仅支持单卡) ***
*** 2019-10-14: 新增DRCD test结果 ***
*** 2019-10-12: pytorch支持albert ***
*** 2019-12-9: 新增cmrc2019 finetune google版albert, 新增CHID finetune代码***
*** 2019-12-22: 新增c3 finetune代码和CHID, c3的部分结果***
*** 2020-6-4: 新增pytorch转tf,tf转pb,以及pb测试demo***
模型及相关代码来源
关于pytorch的FP16
FP16的训练可以显著降低显存压力(如果有V100等GPU资源还能提高速度)。但是最新版编译的apex-FP16对并行的支持并不友好(https://github.com/NVIDIA/apex/issues/227)
实践下来bert相关任务的finetune任务对fp16的数值压力是比较小的,因此可以更多的以计算精度换取效率,所以我还是倾向于使用老版的FusedAdam+FP16_Optimizer的组合。
由于最新的apex已经舍弃这2个方法了,需要在编译apex的时候额外加入命令--deprecated_fused_adam
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" --global-option="--deprecated_fused_adam" ./
关于tensorflow的blocksparse
blocksparse(https://github.com/openai/blocksparse)
可以在tensorflow1.13版本直接pip安装,否则可以自己clone后编译。
其中fast_gelu以及self-attention中的softmax能够极大缓解显存压力。另外部分dropout位置我有所调整,整体显存占用下降大约30%~40%。
model
length
batch
memory
roberta_base_fp16
512
32
16GB
roberta_large_fp16