It has been found that Transformer-based language models have the ability to perform basic quantitative reasoning. In this paper, we propose a method for studying how these models internally represent numerical data, and use our proposal to analyze the ALBERT family of language models. Specifically, we extract the learned embeddings these models use to represent tokens that correspond to numbers and ordinals, and subject these embeddings to Principal Component Analysis (PCA). PCA results reveal that ALBERT models of different sizes, trained and initialized separately, consistently learn to use the axes of greatest variation to represent the approximate ordering of various numerical concepts. Numerals and their textual counterparts are represented in separate clusters, but increase along the same direction in 2D space. Our findings illustrate that language models, trained purely to model text, can intuit basic mathematical concepts, opening avenues for NLP applications that intersect with quantitative reasoning.
翻译:研究发现基于Transformer的语言模型具有执行基础定量推理的能力。本文提出了一种研究这些模型如何内部表示数值数据的方法,并运用该方法对ALBERT系列语言模型进行分析。具体而言,我们提取了模型用于表示数字与序数对应词符的习得嵌入,并对这些嵌入进行主成分分析。主成分分析结果表明,不同规模、经独立训练与初始化的ALBERT模型,均一致地利用最大变异方向轴来表示各类数值概念的近似顺序。数字符与其文本对应形式虽分属不同聚类,但在二维空间中沿同一方向递增。这一发现揭示了纯文本训练的语言模型能够直觉掌握基础数学概念,为涉及定量推理的自然语言处理应用开辟了新途径。