用傅里叶特征将数字编码为单个词元,提升大模型数理任务效率与准确率。
FoNE: Precise Single-Token Number Embeddings via Fourier Features
- 将数字直接映射到嵌入空间,每数字仅用两个维度的傅里叶特征表示。
- 6位十进制加法任务中,只需传统方法1/64数据达99%准确率,且用词元减少3~6倍。
- 唯一在十万+测试样本上实现加减乘全100%准确率的方法,适合高精度数理应用。
大语言模型通常用多个词元表示数字,导致训练和推理效率低,且影响数理任务表现。受预训练模型内部学习傅里叶类特征的启发,我们提出傅里叶数嵌入(FoNE),将数字直接映射到嵌入空间,以傅里叶特征编码,每个数字仅需每数字两位嵌入维度,实现无碎片化的单词元表示。该紧凑结构加速训练与推理。相比传统子词和逐位嵌入,FoNE不仅降低计算开销,还在加法、减法、乘法等任务中取得更高准确率。在6位十进制加法任务中,仅需传统方法1/64的数据即可达到99%准确率,且每数字所用词元分别减少3倍和6倍。此外,它是唯一在超过十万测试样本上对加减乘均实现100%准确率的方法。代码与可视化见 https://fouriernumber.github.io/。
原文摘要 · Abstract (English)
Large Language Models (LLMs) typically represent numbers using multiple tokens, which requires the model to aggregate these tokens to interpret numerical values. This fragmentation makes both training and inference less efficient and adversely affects the model's performance on number-related tasks. Inspired by the observation that pre-trained LLMs internally learn Fourier-like features for number tokens, we propose Fourier Number Embedding (FoNE), a novel method that directly maps numbers into the embedding space with their Fourier features. FoNE encodes each number as a single token with only two embedding dimensions per digit, effectively capturing numerical values without fragmentation. This compact representation accelerates both training and inference. Compared to traditional subword and digit-wise embeddings, FoNE not only reduces computational overhead but also achieves higher accuracy across various numerical tasks including addition, subtraction and multiplication. On 6-digit decimal addition, FoNE requires 64$\times$ less data to achieve 99% accuracy than subword and digit-wise embeddings while using 3$\times$ and 6$\times$ fewer tokens per number, respectively. Furthermore, FoNE is the only method that yields 100% accuracy on over 100,000 test examples for addition, subtraction, and multiplication. The codes and visualization are available at https://fouriernumber.github.io/.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。