位置诅咒:LLM在列表中定位最后几个项目时表现不佳
The Position Curse: LLMs Struggle to Locate the Last Few Items in a List
AI总结:
LLM在定位长列表中单个相关项目时表现优异,但在短列表中最后几个项目定位上存在缺陷,即位置诅咒。通过构建PosBench数据集进行微调后,虽然提升了定位能力,但仍未达到理想水平。
摘要:
现代大型语言模型(LLM)在海量数据中定位单个相关事实时表现优异,但在短列表中最后几个项目的检索上却表现不佳,这种现象称为位置诅咒。例如,在两行代码片段中,Claude Opus 4.6经常错误识别倒数第二行。为研究此问题,我们评估了两种互补查询:给定序列中的位置(字母或单词),检索对应项;以及给定项,返回其位置。每个位置通过相对于锚点的正向或反向偏移指定,锚点可以是列表的端点或列表中的其他项。在开源和前沿闭源模型上,反向检索显著落后于正向检索。为测试是否可通过微调恢复此能力,我们构建了PosBench位置聚焦训练数据集。LoRA微调提高了正向和反向检索能力,并在 held-out 代码理解基准(PyIndex)上实现了泛化。然而,绝对性能仍远未饱和。随着 LLM 编码代理越来越多地处理大型代码库,精确索引对于代码理解和编辑至关重要,因此基于位置的检索成为未来预训练目标和模型设计的关键能力。
英文摘要:
Modern large language models (LLMs) can find a needle in a haystack (locating a single relevant fact buried among hundreds of thousands of irrelevant tokens) with near-saturated accuracy, yet fail to retrieve the last few items in a short list. We call this failure the Position Curse. For instance, even in a two-line code snippet, Claude Opus 4.6 misidentifies the second-to-last line most of the time. To characterize this failure, we evaluated two complementary queries: given a position in a sequence (of letters or words), retrieve the corresponding item; and given an item, return its position. Each position is specified as a forward or backward offset from an anchor, either an endpoint of the list (its start or end) or another item in the list. Across both open-source and frontier closed-source models, backward retrieval substantially lags forward retrieval. To test whether this capability can be rescued by post-training, we constructed PosBench, a position-focused training dataset. LoRA fine-tuning improves both forward and backward retrieval and generalizes to a held-out code-understanding benchmark (PyIndex), yet absolute performance remains far from saturated. As LLM coding agents increasingly operate over large codebases where precise indexing becomes essential for code understanding and editing, position-based retrieval emerges as a key capability for future pretraining objectives and model design.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。