论文笔记 – Masked Language Modeling and the Distributional Hypothesis: Order Word Matters Pre-training for Little

1 简介

  • 来源:arXiv:2104.06644v1 [cs.CL] 14 Apr 2021
  • 机构:FAIR
  • 任务:探测用 MLM 任务得到的预训练模型,到底是学到了什么,使得它性能这么好

预训练模型为什么这么强?MLM 任务学到了什么?以往大家对这个问题有各种各样的讨论,有人说 MLM 任务学到了句法结构信息,有人说 MLM 学到了真正的语义。这篇文章通过一系列实验告诉我们:BERT 不过还是一个词袋模型罢了,它能在下游任务表现优异,这几乎可以全部归功于预训练中学到词的 co-occurrence 和 distribution 信息。(原文是 MLMs suc- ceed on downstream tasks almost entirely due to their ability to model higher-order word co-occurrence statistics. 我为了更清楚,将其分成了 co-occurrence 和 distribution 两部分)

2 实验

2.1 下游任务实验

目标:只有共现 & 分布有用,其它别人说什么“句法结构”等等都不是预训练学习的重点。

基本假设:词语的共现、词语的分布都与句子里面词的顺序无关

实验:将“词的共现分布”与“词的顺序”这两部分解耦。语法结构是和词的 order 有强烈关系的,因此打乱词,就可以避免预训练模型学到语法结构。于是以 RoBERTa 作为 backbone,设计了几个对照:

  1. $\mathcal{M}_N$:用正常数据给正常的 RoBERTa 做预训练
  2. $\mathcal{M}_1$:预训练句子内的词顺序要打乱,保证打乱之后,每个位置的词和原来不一样(有 $(n-1)!$ 种,只随机选一种);RoBERTa 是正常结构
  3. $\mathcal{M}_2$:句子里随机找相邻的两个绑定,不断绑定,直到都是绑定的 bi-gram,然后以这些 bi-gram 为单位,用 $\mathcal{M}_1$ 的方式随机打乱句子;RoBERTa 是正常结构
  4. $\mathcal{M}_3$:同上,只是换成绑定 3-gram;RoBERTa 是正常结构
  5. $\mathcal{M}_4$:同上,只是换成绑定 4-gram;RoBERTa 是正常结构
  6. $\mathcal{M}_{UG}$:unigram 直接从词表里面,按照词频随机 sample unigram(词或实体),组成句子(这样就完全不要 order 和 co-occurrence,只要 frequency)(注意,这里实体都是完整的)。这是一个只基于概率的机器学习模型,作者用它来表示
  7. $\mathcal{M}_{UF}$:unigram-frequency 直接从词表中,以同样的概率随机 sample 词或者实体,组成句子;RoBERTa 是正常结构
  8. $\mathcal{M}_{NP}$:no-position 正常数据;RoBERTa 里面直接去掉 position embedding
  9. $\mathcal{M}_{RI}$:random-init 随机初始化的 RoBERTa。作者认为,随机参数的模型恰恰就表示模型的 inductive bias(因为只有模型结构信息,这些结构是我们的先验)

一些个人的疑惑:

  • 2-5 的方法的确能很好地、一步一步地减少 order 带来的影响,但是也会一样程度的影响 co-occurrence 吧?因此后面得到的结果为什么只说 order 没用呢?
  • 作者认为 9 表示模型本身的 inductive bias 能得到的性能(原文 A randomly initialized RoBERTa is a good baseline for seeing how far we can get using only the model architecture as the inductive bias):可能是我理解有问题,我以前一直以为 inductive bias 是由于人类对问题简化、设计先验,使得模型的性能上界就是符合这些简化了的先验,而不是实际问题要的复杂的分布,我以为 inductive bias 是个要克服的坏东西?
  • 作者说 6 provide a baseline of the limits of the inductive bias of the model alone in learning language。我理解就是说,6 只留下了词的 frequency,于是就将模型变成了一个纯粹的统计模型,而原先 order 和 co-occurrence 其实也可以看做是一些对分布的限制(就有点 CRF transition score 的意思?),或者看做一种 regularization。去掉 order 和 co-occurrence 之后,这个模型行不行就单纯看 inductive bias 了。(感觉可能是理解的不太对,作者为什么不把自己设计实验的整个思路详细地写出来啊喂!

以上所有改动数据都是只改预训练的数据,finetune 还是用的正常数据。那么从实验的设计上,如果不看结论,我们可以做出一些猜测:

  • 2-5 四个模型是在预训练模型可以学习的信息中,去掉 order 信息 —— 性能下降就应该代表 order 的贡献
  • 6 是去掉 order 和 co-occurrence 信息,但是保留了整个 entity span —— 跟 2-5 比,性能下降就应该代表 co-occurrence 的贡献;不过在需要实体的任务上,或许会好一些
  • 7 是把 order, co-occurrence 和 distribution 全去掉了 —— 性能肯定最差
  • 8 去掉 PE,就相当于输入一张全连接的图(?)—— 感觉和 6 应该是差不多的
  • 9 感觉肯定最差

因此我感觉,大体上性能排序应该是 $\mathcal{M}_N$ > $\mathcal{M}_4$ > $\mathcal{M}_3$ > $\mathcal{M}_2$ > $\mathcal{M}_1$ > $\mathcal{M}_{UG}$ ≈ $\mathcal{M}_{NP}$ > $\mathcal{M}_{UF}$ >> $\mathcal{M}_{RI}$

使用上述九种预训练,实际性能结果如下,指标都是 acc:(顺序和我的顺序不一样)

黑暗版本

其中任务大概分别是:Question NLI (QNLI), Recognizing Textual Entailment (RTE), Quora Question Pairs (QQP), Stanford Sentiment Treebank (SST), Microsoft Research Paragraph Corpus (MRPC), PAWS (whether a given pair of sentences are paraphrases), Multi-Genre NLI (MNLI), Corpus of Linguistic Acceptabil- ity (CoLA). 除了 PAWS,其他都是 GLUE 的任务。

第一行是全要,第二块是去掉 order,第三块是再去掉 co-occurrence 或者 frequency

结果里有这些现象:

  • 主要结论:order 对性能的影响不大,co-occurrence 和 distribution 影响才大,粗略地看,二者大约是 1:5 到 1:10。于是就得到了题目的结论。
  • $\mathcal{M}_{4}$ → $\mathcal{M}_{1}$ 性能逐渐下降,这个是符合预期的,因为 4-gram 比 1-gram 保留了更多 order 和 co-occurrence。
  • $\mathcal{M}_{UG} 和 $\mathcal{M}_{UF} 有实体信息,所以在 MNLI 比下面一块的另外两个好得多,也是符合预期的。
  • $\mathcal{M}_{NP}$ 和 $\mathcal{M}_{RI}$ 在大部分任务上都几乎一致,作者说 “a purely bag of words model performs comparably to a randomly intialized model”。这让我感觉还挺意外,作者没有给出解释,我无法理解
  • $\mathcal{M}_{2}$ 在有些任务上表现比较突出,好于 $\mathcal{M}_{3}$,$\mathcal{M}_{4}$。作者没有给出解释,我无法理解
  • CoLA 垃圾任务,对随机种子敏感,个人觉得没什么参考价值
  • $\mathcal{M}_1$ 比 $\mathcal{M}_{NP}$ 好一大截。这俩可以说都是完全乱序的,但是 $\mathcal{M}_{1}$ 有 position embedding。作者直接得到结论“positional embeddings are critical for MLM to learn, even when the word orders themselves are not natural.” 我很是迷惑,错的比没有要好?我觉得作者这里的结论太敷衍了,个人猜测主要因为 $\mathcal{M}_1$ 是按照词打乱的,而 $\mathcal{M}_{NP}$ 相当于是按照 subtoken 打乱,这个粒度是不一样的。【这里再补充一下,@arankomatsuzaki 说,可能是 position embedding 给句子中的每个词一个 unique id 比如句子里好几个 the 就可以根据 position embedding 区分开了,我觉得没啥用】

作者还做了 finetune 的实验:

这些图里面,横轴代表使用什么方式预训练,蓝色橘色表示使用好数据还是打乱的数据来 finetune。

结果里有这些现象:

  • QQP 和 QNLI 任务里,使用打乱的句子 finetune 对结果影响非常小,说明这俩任务对 order 没啥需求(所以这两个任务就不适合这篇文章,后面也就不分析这两个任务上的结果了(只是我的理解))
  • 其它六个任务里,使用打乱的句子 finetune 就有很大影响了,说明任务还是需要 order 的。这里作者就得出结论:finetune 还是得学学 order 信息。
  • 在使用乱序数据 finetune 的时候,有几任务上,$\mathcal{M}_1$ 比 $\mathcal{M}_N$ 好,作者认为这是因为预训练和 finetune 的数据分布不一致导致的,$\mathcal{M}_1$ 两步的分布是 consistent,所以表现好。

2.2 探针实验

分成两类,带参数的和不带参数的。

2.2.1 Pareto Probing

探究不要 order,还能不能学到句法结构。那显然,就在上面几种预训练得到的模型后面接 parsing 的模型看看效果。

作者还是更细致全面,做了三个和句法结构相关的任务:use the “difficult” probe: dependency parsing (DEP), as well as the “easy” probes: dependency arc labeling (DAL) and POS tag prediction (POS). 然后有 Unlabeled Attachment Score (UAS; for DEP) and accuracy (for POS and DAL) 这两个指标:

得到结果:

  • $\mathcal{M}_N$ > $\mathcal{M}_4$ > $\mathcal{M}_3$ > $\mathcal{M}_2$ > $\mathcal{M}_1$ ≈ $\mathcal{M}_{UG}$,与预期差不多
  • $\mathcal{M}_{UG}$ 有时候比 $\mathcal{M}_1$ 强。个人猜测,$\mathcal{M}_{UG}$ 少了 word frequency,但是在 order 上,它打乱的是 unigram,比 $\mathcal{M}_1$ 的 subtoken 要强。而 parsing 更需要 order,所以这两部分在这里可以抵消。

要详细了解,可见 Tiago Pimentel, Naomi Saphra, Adina Williams, and Ryan Cotterell. 2020a. Pareto Probing: Trading Off Accuracy for Complexity. arXiv:2010.02180 [cs].

2.2.2 SentEval Probes

这个任务我没太看懂,具体是干啥我也不知道,说是里面有十个任务,有的任务用来 probe surface information,有的是 syntactic information,有的是 semantic information。作者发现,order 只会影响 semantic tasks,而不会影响 lexical tasks. 于是得到结论 while natural word order is useful for at least some probing tasks, the distri- butional prior of sentence word order randomized models alone is enough to achieve a reasonably high accuracy on syntax sensitive probing. 具体说的啥我也不知道,大约就还是,没有 order 依然也有句法信息(?和 2.2.1 相反了)

要详细了解,可见 Alexis Conneau, German Kruszewski, Guillaume Lam- ple, Loïc Barrault, and Marco Baroni. 2018. What you can cram into a single $&!#* vector: Probing sentence embeddings for linguistic properties. In Proceedings of the 56th Annual Meeting of the As- sociation for Computational Linguistics (Volume 1:Long Papers), pages 2126–2136, Melbourne, Aus- tralia. Association for Computational Linguistics.

2.2.3 Non-Parametric Probing

the objective is for a pre-trained model to provide higher probability to a correct word than to an incorrect one. Since both the correct and incorrect option occupy the same sentential position, they are deemed “focus words”. In our experiments, we mask the focus words in the stimuli and compute the probability of the good and bad token respectively. the effectiveness of each stimulus is determined by the accuracy metric, computed as the number of times the probability of the cor- rect focus word is greater than that of the incor- rect word (P (good) > P (bad))

结果:the highest difference between probabilities of the correct and incorrect focus words for the model pretrained on the natural word order (MN). with each step from M1 to M4, the difference between probablities of correct and incorrect focus words increases, albeit marginally, showing that pre-trained models with fewer n-gram words perturbed capture more syntax

还是 $\mathcal{M}_N$ > $\mathcal{M}_4$ > $\mathcal{M}_3$ > $\mathcal{M}_2$ > $\mathcal{M}_1$ ≈ $\mathcal{M}_{UG}$ 的意思

3 分析

  1. 作者这里计算了 PPL,看看不同数据预训练出的模型的“好坏”:

就是互相作为基准和待评测的模型来计算。

结论:

  • $\mathcal{M}_N$ PPL 最低,其他的也是上述的 4-1 的递减
  • 似乎只有 $\mathcal{M}_1$ 不行,其他都还可以
  1. order 是不是在 the early stages of fine-tuning 有点用?作者用 Minimum Description Length 这个指标。MDL is designed to characterize the complexity of data as the length of the shortest program required to generate it. 具体是个啥玩意我也不知道,反正大概就表示模型的“学习能力”。

可以发现,用好数据预训练出来的预训练模型,学习能力最差!这里就验证了我在 2.1 的疑惑 3!作者没有明说,只是说 The present analyses, when taken in conjunction with our main results in §4.1, suggest that fine-tuning on large training datasets with complex classifiers in the pursuit of state-of-the-art results has mostly nullified the impact of word order in the pre-trained representations. Few shot (Bansal et al., 2019) and few sample (Zhang et al., 2021) learning and evaluation could poten- tially require more word order signal, and thereby encouraging the model to leverage its own learned syntax better. 这非常值得思考,唉,可惜我不做 FSL 了。

要详细了解 MDL,可见 Ethan Perez, Douwe Kiela, and Kyunghyun Cho. 2021. Rissanen Data Analysis: Examining Dataset Charac- teristics via Description Length. arXiv:2103.03872 [cs, stat]

4 升华

如果要是写卖萌屋的文章,最后正好有一些能用上的升华。(不过看我对这篇文章的理解水平,感觉还写不了,我也懒得看那些 probing 的文章)

Thus, our results seem to suggest that either we need to revisit what we mean by “linguistic struc- ture” and perhaps subsequently acknowledge that we may not need human-like linguistic abilities for most NLP tasks, or alternatively, we need harder and more comprehensive evaluations (cf. Bowman and Dahl 2021), if we genuinely want to measure linguistic abilities, however those are defined, in our models. Another interesting question revolves around whether this phenomenon is more pronounced for English than for other languages. It is natural to wonder whether more word-order flexible and/or more morphologically-rich languages would suf- fer from the same problem. One could imagine that the methods discussed in this work constitute a possible way for determining the degree of order- dependence for particular languages in general.

发表评论