上下文嵌入(Bert词向量): 什么时候值得用?

ACL 2018

预训练词向量 (上下文嵌入Bert,上下文无关嵌入Glove, 随机)详细分析文章

1 背景



图1 Bert

优点 效果显著
缺点 成本昂贵 (Memory,Time,  Money) (GPT-3,1700亿的参数量)
困惑 线上环境,资源受限(内存 CPU GPU) bert不一定是最佳 选择
用word2vec, glove等词向量有时候也能取得近似效果
但什么时候可以近似,需要实验说明,于是作者设计了实验

2 三种词向量



图2 三种词向量

类型 说明 实验
上下文词嵌入 BERT XLNet 作者实验中选BERT 768维
上下文词无关嵌入 Glove Word2Vec FastText 作者实验中选Glove 300维
随机嵌入 n*d矩阵 (n是词汇量, d是嵌入维度) 作者实验中选循环随机嵌入 800维, 空间复杂度O(nd) => O(n)

3 实验和结论

任务 模型
命名实体识别 (NER) BiLSTM
情感分析 (sentiment analysis) TextCNN

3.1 影响因素一:训练数据规模



图3 影响因素一:训练数据规模 01



图4 影响因素一:训练数据规模 02

在许多任务中,供充足的数据,GloVe这些词向量可匹配BERT

3.2 影响因素二:语言的特性

3.2.1 Complexity of setence structure

NER: 实体占据几个token (George Washington)



图5 NER中的句子复杂度

Sentiment analysis:句子依存分析中依赖标记对之间的平均距离



图6 Sentiment analysis中的句子复杂度

3.2.2 Ambiguity in word usage

NER: 实体有几个标签(George Washington可以作为人名、地名、组织名)



图7 NER中的句子复杂度

Sentiment analysis:

\begin{array}{l}

H\left( {\frac{1}{{\left| S \right|}}\sum\limits_{w \in S} {p\left( { + 1\left| w \right.} \right)} } \right) \

{\rm{where }}H\left( p \right) = - p{\log _2}\left( p \right) - \left( {1 - p} \right){\log _2}\left( {1 - p} \right) \

\end{array}



图8 Sentiment analysis中的句子复杂度

3.2.3 Prevalence of unseen words

NER: token出现次数得倒数



图9 NER中的句子复杂度

Sentiment analysis:

给定一个句子,句子中未在训练集中出现token占比



图10 Sentiment analysis中的句子复杂度



图11 Bert和随机向量对比



图12 Bert和Glove对比

文本结构复杂度高和单词歧义性方面: BERT更好

未登录词方面: GloVe 更好

总结

大量训练数据和简单语言的任务中,考虑算力和设备等,GloVe 代表的 Non-Contextual embeddings 是个不错的选择

对于文本复杂度高和单词语义歧义比较大的任务,BERT代表的 Contextual embeddings 有明显的优势。

未登录词方面: GloVe 更好

ACL2020 Contextual Embeddings When Are They Worth It 精读的更多相关文章

  1. Attention-over-Attention Neural Networks for Reading Comprehension论文总结

    Attention-over-Attention Neural Networks for Reading Comprehension 论文地址:https://arxiv.org/pdf/1607.0 ...

  2. bert 硬件要求

    https://github.com/google-research/bert BERT ***** New May 31st, 2019: Whole Word Masking Models *** ...

  3. 论文翻译——Deep contextualized word representations

    Abstract We introduce a new type of deep contextualized word representation that models both (1) com ...

  4. 关于情感分类(Sentiment Classification)的文献整理

    最近对NLP中情感分类子方向的研究有些兴趣,在此整理下个人阅读的笔记(持续更新中): 1. Thumbs up? Sentiment classification using machine lear ...

  5. 论文阅读笔记:《Contextual String Embeddings for Sequence Labeling》

    文章引起我关注的主要原因是在CoNLL03 NER的F1值超过BERT达到了93.09左右,名副其实的state-of-art.考虑到BERT训练的数据量和参数量都极大,而该文方法只用一个GPU训了一 ...

  6. Word Embeddings: Encoding Lexical Semantics

    Word Embeddings: Encoding Lexical Semantics Getting Dense Word Embeddings Word Embeddings in Pytorch ...

  7. Word Embeddings: Encoding Lexical Semantics(译文)

    词向量:编码词汇级别的信息 url:http://pytorch.org/tutorials/beginner/nlp/word_embeddings_tutorial.html?highlight= ...

  8. Android Contextual Menus之二:contextual action mode

    Android Contextual Menus之二:contextual action mode 接上文:Android Contextual Menus之一:floating context me ...

  9. Android Contextual Menus之一:floating context menu

    Android Contextual Menus之一:floating context menu 上下文菜单 上下文相关的菜单(contextual menu)用来提供影响UI中特定item或者con ...

随机推荐

  1. Redux的理解与使用

    一.什么是Redux? Redux是一个第三方状态管理的js库,它不仅仅可以适用于react框架,还可以用于其他的vue,auglar等框架.只不过react的生态中不包括一个状态管理的库而已,所以与 ...

  2. mui div滚动阻止触发下拉刷新

    function orderListScroll () { var _orderObj = document.querySelector('.circulation-loan-list') //div ...

  3. JavaScript学习 Ⅵ (正则表达式)

    十三. 正则表达式 正则表达式用于定义一些字符串的规则,计算机可以根据正则表达式,来检查一个字符串是否符合规则,将字符串中符合规则的内容提取出来. 创建正则表达式对象 构造函数 var reg = n ...

  4. 数据可视化之分析篇(十)Power BI应用:如何计算在职员工数量?

    ​https://zhuanlan.zhihu.com/p/128652582 经常碰到的一类问题是,如何根据起止日期来计算某个时间点的数量,比如: 已知合同的生效日期和到期日期,特定日期的有效合同有 ...

  5. Resource exhausted: OOM when allocating tensor with shape[3,3,384,384] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0。。。。。

    报错信息: OP_REQUIRES failed at assign_op.h:111 : Resource exhausted: OOM when allocating tensor with sh ...

  6. java学习第七天2020/7/12

    一. java继承使用的关键字是  extend class 子类 extends 父类{} 举一个类的例子: public class person { public String name; pu ...

  7. unity-TextAsset

    定义: 当把Text files导到unity,将会变成TextAsset. 支持的格式: .txt .html .htm .xml .bytes .json .csv .yaml .fnt 注意 不 ...

  8. Unity-Editor

    Undo.RecordObject [MenuItem("Example/Random Rotate")] static void RandomRotate() { var tra ...

  9. 微信小程序随手笔记

    1.全局导入vant时build后有问题(只能页面引入) 2.微信小程序只能用:https开头,在微信公众号里还要修改下配置 3.微信小程序里textarea与vant的van-popup有问题,手机 ...

  10. Java应用服务器之tomcat基础配置(一)

    前文我们聊到了java相关重要组件和它们之间的关系以及jdk.tomcat部署回顾请参考https://www.cnblogs.com/qiuhom-1874/p/13302938.html:今天我们 ...