Large language models (LLMs) have exhibited impressive competency in various text-related tasks. However, their opaque internal mechanisms become a hindrance to leveraging them in mathematical problems. In this paper, we study a fundamental question: whether language models understand numbers, which play a basic element in mathematical problems. We assume that to solve mathematical problems, language models should be capable of understanding numbers and compressing these numbers in their hidden states. We construct a synthetic dataset comprising addition problems and utilize linear probes to read out input numbers from the hidden states of models. Experimental results demonstrate evidence supporting the existence of compressed numbers in the LLaMA-2 model family from early layers. However, the compression process seems to be not lossless, presenting difficulty in precisely reconstructing the original numbers. Further experiments show that language models can utilize the encoded numbers to perform arithmetic computations, and the computational ability scales up with the model size. Our preliminary research suggests that language models exhibit a partial understanding of numbers, offering insights into future investigations about the models' capability of solving mathematical problems.
翻译:大型语言模型(LLMs)在各种文本相关任务中展现出令人印象深刻的能力。然而,其不透明的内部机制阻碍了它们在数学问题中的应用。本文研究一个基础性问题:语言模型是否理解数字——数学问题中的基本元素。我们假设,要解决数学问题,语言模型需要具备理解数字并将其压缩至隐藏状态的能力。我们构建了一个包含加法问题的合成数据集,并利用线性探针从模型隐藏状态中读取输入数字。实验结果表明,LLaMA-2模型系列从早期层开始就存在数字压缩的证据。然而,压缩过程似乎并非无损,导致难以精确重建原始数字。进一步实验显示,语言模型能够利用编码后的数字执行算术计算,且计算能力随模型规模扩大而提升。我们的初步研究表明,语言模型展现出对数字的部分理解,这为未来探究模型解决数学问题能力的相关研究提供了启示。