上下文嵌入(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. day11 文件操作(上)

    目录 一.什么是文件 二.为何要用文件 三.如何使用文件 3.1文件操作的基本流程 3.2资源回收with上下文管理 3.3指定操作文本的字符编码 四.文件的操作模式 4.1控制文件读写操作的模式(t ...

  2. flutter学习01-flutter起步安装配置(window, vscode开发)

    从零开始配置flutter环境,如果直接去看官方文档配置的话,太过复杂,其实正式没有那么多步骤,记录一下: 1.首先,前往下面这个网站,下载flutter sdk  https://flutter.d ...

  3. 武汉百得思维Java面试总结

    武汉百得思维Java面试总结 在一个愉快的下午,我们并不十分愉快地参加了宣讲会.那是国庆的前两天,大家正在为放假的愉悦所兴奋也在为找工作而紧张. 在听过一阵胡吹乱侃之后,大家都昏昏欲睡,于是终于迎来了 ...

  4. sass-loader安装+Failed to resolve loader: sass-loader You may need to install it.解决方法

    方式一: 通过 cnpm 安装node-sass cnpm install node-sass --save 方式二: 通过npm 安装 1.安装sass-loader npm install sas ...

  5. Web_php_unserialize解题思路

    分析一下 __construct:当使用 new 操作符创建一个类的实例时,构造方法将会自动调用 __destuct:在销毁一个类之前执行执行 __wakeup,unserialize()` 会检查是 ...

  6. 数据分析04 /基于pandas的DateFrame进行股票分析、双均线策略制定

    数据分析04 /基于pandas的DateFrame进行股票分析.双均线策略制定 目录 数据分析04 /基于pandas的DateFrame进行股票分析.双均线策略制定 需求1:对茅台股票分析 需求2 ...

  7. Navicat连接数据库报错2059 - authentication plugin...错误解决方法

    今天使用Navicat 连接MySQL数据库出现错误:2059 - authentication plugin 'caching_sha2_password'. 出现这个错误的原因是因为MySQL8. ...

  8. Python Ethical Hacking - Malware Analysis(3)

    Stealing WiFi Password Saved on a Computer #!/usr/bin/env python import smtplib import subprocess im ...

  9. 食用Win系统自带的PowerShell登录服务器

    运行powershell输入ssh root@你的服务器ip -p你的端口 切换rm ~/.ssh/known_hosts cmd 运行 ping 你的ip -t一直ping ctrl+c停止 tra ...

  10. [jvm] -- 类加载过程篇

    类加载过程 系统加载 Class 类型的文件主要三步 加载 通过全类名获取定义此类的二进制字节流 将字节流所代表的静态存储结构转换为方法区的运行时数据结构 在内存中生成一个代表该类的 Class对象, ...