Visualizing and Measuring the Geometry of BERT
Andy Coenen, Emily Reif, Ann Yuan Been Kim, Adam Pearce, Fernanda Viégas, Martin Wattenberg Google Brain Cambridge, MA Equal contribution
Abstract
Transformer architectures show significant promise for natural language processing. Given that a single pretrained model can be fine-tuned to perform well on many different tasks, these networks appear to extract generally useful linguistic features. How do such networks represent this information internally? This paper describes qualitative and quantitative investigations of one particularly effective model, BERT. At a high level, linguistic features seem to be represented in separate semantic and syntactic subspaces. We find evidence of a fine-grained geometric representation of word senses. We also present empirical descriptions of syntactic representations in both attention matrices and individual word embeddings, as well as a mathematical argument to explain the geometry of these representations.
中文速览
研究人员想弄清楚BERT这类预训练语言模型到底把语言信息"藏在"内部的什么地方、以什么几何形式存放。他们从语法和语义两个角度入手:一方面用线性探针(linear probe)测试注意力矩阵(attention matrices)能否识别词与词之间的依存句法关系,另一方面用可视化方法观察不同语境下同一单词的上下文向量(context embeddings)如何分布。结果发现,注意力向量能以85%以上的准确率区分依存关系,说明句法信息已直接编码在注意力权重中;同时他们还给出了一个数学定理,证明用欧氏距离的平方来表示树距离(即"毕达哥拉斯嵌入")是嵌入树形结构最自然、最简洁的方式,从理论上解释了前人的实验发现;在语义层面,可视化结果显示BERT能以极细的粒度区分词义(如"bark"的不同含义),且这些语义信息主要集中在一个相对低维的子空间里。这项工作让我们对BERT的内部运作机制有了更清晰的几何图景,对理解和改进大型预训练模型具有重要参考价值。
原文 arXiv:1906.02715;中英对照 + 大白话阅读 https://aha.fim.ai/paper/1906.02715v2