Frontier Language Models Struggle to Copy: Text Can Be Better Viewed in 2D

LLM PTSAD Long Context ML TAVR Transformer
尽管大语言模型(LLMs)能在数秒内解决复杂的推理问题,但我们发现,即便是当前最先进的模型,也无法完成一项简单得多的任务:准确复制一段长度远在其上下文窗口容量之内的输入字符串。我们将这一失败归因于Transformer架构中位置编码的固有归纳偏置——该偏置倾向于通过匹配局部上下文的“捷径”来实现复制,而非精确地定位输入中对应的位置。为解决这一问题,我们提出了二维旋转位置编码(2D-RoPE):它将文本组织成二维网格结构,而非传统的一维序列,并为每个词元(token)分别赋予行编号(row ID)和列编号(column ID)。在此视角下,复制操作简化为在固定列偏移量处检索输入词元,从而显著降低了任务的学习难度。在合成复制实验中,采用2D-RoPE的浅层Transformer模型,在输入长度达到训练时所见长度数百倍的情况下仍能实现完美复制;而采用标准位置编码的模型则远远落后。我们进一步证明,在基于DCLM数据集的大规模预训练中,2D-RoPE语言模型在复制任务上的优势在高达14亿参数的模型规模下依然稳定保持。总体而言,我们的结果表明,以二维方式建模文本有助于提升语言建模能力;我们希望这项工作能够推动后续研究进一步探索二维位置编码的潜力。
While large language models (LLMs) can solve advanced reasoning problems in seconds, we show that even frontier models fail to perform a much simpler operation: exactly copying an input string that lies well within their context windows. We attribute this failure to positional encodings in Transformer architectures, whose inductive bias favors copying through a shortcut based on matching local contexts rather than carefully locating the corresponding input positions. To address this issue, we introduce 2D-RoPE, which organizes text into a 2D grid rather than a 1D sequence and assigns each token a row ID and a column ID. Under this view, copying becomes simply retrieving input tokens at a fixed column offset, which makes the task easy to learn. In synthetic copy experiments, shallow Transformers with 2D-RoPE achieve perfect copying at input lengths hundreds of times longer than those seen during training, whereas standard positional encodings fall far behind. We further show that the advantage of 2D-RoPE language models on copy tasks consistently holds in large-scale pretraining on DCLM with model sizes up to 1.4B parameters. Overall, our results suggest that viewing text in 2D can benefit language modeling, and we hope this encourages future work to further explore the potential of 2D positional encodings.
许愿