论文笔记--DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter
论文笔记--DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter
- 1. 文章简介
- 2. 文章概括
- 3 文章重点技术
- 3.1 知识蒸馏
- 3.2 DistilBERT
- 4. 文章亮点
- 5. 原文传送门
- 6. References
1. 文章简介
- 标题:DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter
- 作者:Victor SANH, Lysandre DEBUT, Julien CHAUMOND, Thomas WOLF
- 日期:2019
- 期刊:arxiv preprint
2. 文章概括
文章给出了对BERT[1]模型进行知识蒸馏的方法,并训练得到了DistilBERT,参数量仅为BERT的40%,且在多个自然语言理解、分类任务上表现接近BERT。
3 文章重点技术
3.1 知识蒸馏
知识蒸馏是一种常用的压缩模型的方法,可以用更轻量级的模型达成几乎和原模型相同的效果。
随着NLP模型的发展(见上图),模型量级越来越大,实际使用时可能会收到时间、存储、硬件等限制。为此文章提出了用知识蒸馏来对BERT模型进行压缩。知识蒸馏中我们将原始的大模型称为教师模型Teacher model,我们要生成的小模型称为学生模型Student model。知识蒸馏分为两个步骤
- 监督学习:学生模型根据标注数据进行监督学习,在文本中此过程的损失函数即为BERT的
MLM(Masked Language Modeling)损失函数 L M L M L_{MLM} LMLM。 - Teacher模型学习:学生模型学习教师模型的行为,这里采用损失函数 L c e = ∑ i t i log ( s i ) L_{ce} = \sum_i t_i \log (s_i) Lce=∑itilog(si),其中 t i t_i ti和 s i s_i si分别代表教师模型和学生模型对当前输入的估计概率。另外在计算概率的时候增加蒸馏的温度 T T T,即 t i = exp ( z i ( t ) / T ) ∑ j exp ( z j ( t ) / T ) t_i = \frac {\exp (z_i^{(t)} / T)}{\sum_j \exp (z_j^{(t)} / T)} ti=∑jexp(zj(t)/T)exp(zi(t)/T)用于平滑分布,其中 z i ( t ) z_i^{(t)} zi(t)和 z i ( s ) z_i^{(s)} zi(s)分别表示教师模型和学生模型对类别 i i i的输出分值。注意到损失函数最小当且仅当教师和学生模型对每个类别的输出概率均相同,即损失函数是为了使学生模型学习到和教师模型相近的输出概率分布。此外温度 T T T越大,不同类别之间的差距越小,分布越平均,适当地增大温度可以增强模型对小概率事件的捕捉能力。
最后模型会把上述两个损失结合起来作为最终的损失。文章提出增加一个损失函数 L c o s L_{cos} Lcos表示学生模型和教师模型输出的隐藏层向量之间的cosine相似度,实验表明此损失函数效果很好。
3.2 DistilBERT
在上述知识蒸馏的基础上,文章训练得到了学生模型DistilBERT,其具体细节如下
- architecture:和BERT基本相同,移除token-type embeddings和pooler层
- size:层数较BERT减半
- 隐藏层:最后一层隐藏层的维度不变
- 初始化:由于DistilBERT的隐藏层维度不变,从而模型可以选择直接从BERT的输入层/隐藏层初始化。
- 蒸馏:参考RoBERTa[2]的分析,文章在较大的batch(4K)上进行知识蒸馏
- 训练目标:MLM,移除NSP(Next Sentence Prediction)目标
4. 文章亮点
文章通过 L c e , L M L M , L c o s L_{ce}, L_{MLM}, L_{cos} Lce,LMLM,Lcos三种损失函数的结合训练得到BERT的蒸馏模型DistilBERT,数值实验表明,DistilBERT在GLUE benchmark上达到了BERT效果的97%,且参数量仅为BERT的40%,在下游任务上表现与BERT只差约3个百分点。
DistilBERT的参数量仅为BERT的40%,推理速度比BERT快69%。在实际生活中可供一些受资源限制的场景使用,比如在线推理等。
5. 原文传送门
DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter
6. References
[1] 论文笔记–BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
[2] 论文笔记–RoBERTa: A Robustly Optimized BERT Pretraining Approach
论文笔记--DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter相关推荐
- 《DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter》(NeurIPS-2019)论文阅读
前言 论文地址:https://arxiv.org/abs/1910.01108 代码地址:https://github.com/huggingface/transformers Abstract 就 ...
- 《DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter》论文笔记
论文来源:NIPS-2019(hugging face发布) 论文链接:https://arxiv.org/abs/1910.01108 ⭐背景介绍: 近年来NLP领域,在大型预训练模型上进行迁移学 ...
- DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter(2019-10-2)
模型介绍 NLP预训练模型随着近几年的发展,参数量越来越大,受限于算力,在实际落地上线带来了困难,针对最近最为流行的BERT预训练模型,提出了DistilBERT,在保留97%的性能的前提下,模型大小 ...
- DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter学习
1. 总结 论文地址 论文写得很简单,但是引用量好高啊
- DistilBERT, a distilled version of BERT
1 简介 本文根据2020年<DistilBERT, a distilled version of BERT: smaller,faster, cheaper and lighter>翻译 ...
- Smaller, faster, cheaper, lighter: Introducing DistilBERT, a distilled version of BERT 翻译
paper: https://arxiv.org/pdf/1910.01108v2.pdf code: https://github.com/huggingface/transformers Time ...
- 【论文笔记】一种有效攻击BERT等模型的方法
Is BERT Really Robust? A Strong Baseline for Natural Language Attack on Text Classification and Enta ...
- 论文笔记:《DeepGBM: A Deep Learning Framework Distilled by GBDT for Online Prediction Tasks》
论文笔记:<DeepGBM: A Deep Learning Framework Distilled by GBDT for Online Prediction Tasks> 摘要 1. ...
- 论文笔记【A Comprehensive Study of Deep Video Action Recognition】
论文链接:A Comprehensive Study of Deep Video Action Recognition 目录 A Comprehensive Study of Deep Video A ...
最新文章
- 周期串java_求最小周期串
- 为 Hyper-V 配置外部网络
- MAC 下 安装redis 并配置 php redis 扩展
- Oracle 分组统计,抽取每组前十
- python 错误、调试、单元测试、文档测试
- 【译】A quick list of new enterprise features in iOS 13, iPadOS, and macOS 10.15 Catalina
- 浅谈Spring5 响应式编程
- EclipsePHP Studio 2008快捷方式
- 爱奇艺PPS如何登陆账号
- python求直角三角形斜边底下的数值怎么输_如何用用户输入的值求三角形的角,以及如何绘制i...
- iphone登录不了媒体服务_ios快捷指令一键登录校园网(桂航为例,哆点认证)
- endnote大客户版_Endnote软件的使用,有图有干货!
- 互联网大厂跳槽鄙视链
- 微信小程序微商城:开发者key获取
- 三妈式初音miku_【MMD模型】三妈式初音 Appearance Miku 原版
- 安卓手机上有什么好用的日程安排管理软件?
- DDS文档数据库服务
- 炼丹笔记三:数据增强
- 五种常用的绩效考核工具对比
- 乐鑫esp8266学习rtos3.0笔记第4篇:带你捋一捋微信公众号 airkiss 配网 esp8266 并绑定设备的过程,移植并成功实现在 esp8266 rtos3.1 sdk。(附带demo)