语言: 中文
标签:
- structbert
- pytorch
- tf2.0
推理: 禁用
StructBERT:非官方复现版
官方仓库链接: https://github.com/alibaba/AliceMind/tree/main/StructBERT
免责声明
复现HuggingFace模型:
下载模型/分词器词表
wget https://raw.githubusercontent.com/alibaba/AliceMind/main/StructBERT/config/ch_large_bert_config.json && mv ch_large_bert_config.json config.json
wget https://raw.githubusercontent.com/alibaba/AliceMind/main/StructBERT/config/ch_vocab.txt
wget https://alice-open.oss-cn-zhangjiakou.aliyuncs.com/StructBERT/ch_model && mv ch_model pytorch_model.bin
from transformers import BertConfig, BertModel, BertTokenizer
config = BertConfig.from_pretrained("./config.json")
model = BertModel.from_pretrained("./", config=config)
tokenizer = BertTokenizer.from_pretrained("./")
model.push_to_hub("structbert-large-zh")
tokenizer.push_to_hub("structbert-large-zh")
论文链接
StructBERT:将语言结构融入预训练以实现深度语言理解
简介
我们通过将语言结构融入预训练过程,将BERT扩展为新模型StructBERT。具体而言,我们通过两个辅助任务进行预训练,充分利用词语和句子的顺序结构,分别在词语和句子层面利用语言结构。
预训练模型
模型 |
描述 |
参数量 |
下载地址 |
structbert.en.large |
采用BERT-large架构的英文StructBERT |
340M |
下载 |
structroberta.en.large |
基于RoBERTa继续训练的StructRoBERTa |
355M |
即将发布 |
structbert.ch.large |
中文StructBERT;BERT-large架构 |
330M |
下载 |
性能表现
GLUE和CLUE任务的结果可通过下文"使用示例"中的超参数复现。
structbert.en.large
GLUE基准测试
模型 |
MNLI |
QNLIv2 |
QQP |
SST-2 |
MRPC |
structbert.en.large |
86.86% |
93.04% |
91.67% |
93.23% |
86.51% |
structbert.ch.large
CLUE基准测试
模型 |
CMNLI |
OCNLI |
TNEWS |
AFQMC |
structbert.ch.large |
84.47% |
81.28% |
68.67% |
76.11% |
使用示例
环境要求与安装
pip install -r requirements.txt
微调MNLI任务
python run_classifier_multi_task.py \
--任务名称 MNLI \
--执行训练 \
--执行评估 \
--执行测试 \
--混合精度类型 O1 \
--学习率衰减因子 1 \
--丢弃率 0.1 \
--启用小写转换 \
--分离索引 -1 \
--核心编码器 bert \
--数据目录 glue数据路径 \
--词表文件 config/vocab.txt \
--BERT配置文件 config/large_bert_config.json \
--初始化检查点 预训练模型路径 \
--最大序列长度 128 \
--训练批大小 32 \
--学习率 2e-5 \
--训练轮数 3 \
--快速训练模式 \
--梯度累积步数 1 \
--输出目录 输出路径
引用
若使用本工作,请引用:
@article{wang2019structbert,
title={Structbert: 将语言结构融入预训练以实现深度语言理解},
author={王伟, 毕彬, 严明, 吴晨, 包子仪, 夏江南, 彭立威, 司罗},
journal={arXiv预印本 arXiv:1908.04577},
year={2019}
}