上下文嵌入(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. Spring的学习与实战

    目录 一.Spring起步 学习路线图 Spring的基础知识 什么是Spring Spring框架核心模块 SpringBoot 第一个Spring应用DEMO 编写自己的第一个SpringMVC例 ...

  2. 数据可视化之powerBI基础(九)Power BI中的“新表”,你会用吗?

    https://zhuanlan.zhihu.com/p/64413703 通常情况下,在PowerBI进行分析的各种数据表都是从外部的各种数据源导入进来的,但并不总是如此,某些情况下在PowerBI ...

  3. 数据可视化之 图表篇(一)Power BI可视化,几张图表认识疫情现状

    ​近期国际疫情愈演愈烈,在这个特殊的时期,一方面仍要照顾好自己.不要为疫情防治添乱,另一方面,也可以利用疫情数据提升自己的数据分析和可视化技能. 下面是我制作的几个可视化图表,分别注释了每个可视化用到 ...

  4. 图解java方法的简单执行步骤

    图解java方法的简单执行步骤 1,找到该方法 2  传入对应的参数 3 执行方法体 4 返回结果

  5. Ethical Hacking - Web Penetration Testing(2)

    INFORMATION GATHERING IP address. Domain name Info. Technologies used. Other websites on the same se ...

  6. Python Hacking Tools - Password Sniffing

    Password Sniffing with Scapy 1. Download and install the Scapy first. pip install scapy https://scap ...

  7. ASP.NET CORE之中间件-自定义异常中间件

    参考资料:https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/middleware/?view=aspnetcore-3.1 1.一般A ...

  8. PG-跨库操作-dblink

    在PostgreSQL数据库之间进行跨库操作的方式 dblink postgres_fdw 本文先说说dblink:dblink是一个支持从数据库会话中连接到其他PostgreSQL数据库的插件.在其 ...

  9. C#中的类与对象

    类:说白了就是类型,是对具体事物的一种抽象总结. 对象:一个具体的事物. 类与对象的关系,类实例化就会得到一个对象,同样一个对象也应该属于某一个类.例如张三这个人,他是一个对象,同时他属于人类,在程序 ...

  10. C++语法小记---重载逻辑操作符

    重载逻辑操作符 不建议重载逻辑操作符 原因:无法实现逻辑操作符的短路功能(即:不需要计算完全部表达式就可以得出结果) 逻辑操作符:|| && 操作符重载本质上是函数调用,而进行函数调用 ...