The Position Curse: LLMs Struggle to Locate the Last Few Items in a List

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Zhang, Zhanqi, Xiong, Hua-Dong, Wilson, Robert C., Aoi, Mikio, Mattar, Marcelo G., Ji-An, Li
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911661314539520
author Zhang, Zhanqi
Xiong, Hua-Dong
Wilson, Robert C.
Aoi, Mikio
Mattar, Marcelo G.
Ji-An, Li
author_facet Zhang, Zhanqi
Xiong, Hua-Dong
Wilson, Robert C.
Aoi, Mikio
Mattar, Marcelo G.
Ji-An, Li
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2605_07127
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle The Position Curse: LLMs Struggle to Locate the Last Few Items in a List
Zhang, Zhanqi
Xiong, Hua-Dong
Wilson, Robert C.
Aoi, Mikio
Mattar, Marcelo G.
Ji-An, Li
Machine Learning
Computation and Language
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.
title The Position Curse: LLMs Struggle to Locate the Last Few Items in a List
topic Machine Learning
Computation and Language
url https://arxiv.org/abs/2605.07127