arXiv:2607.01538cs.CL2026-07

大模型在百万级文档中直接检索,效果逼近传统方法。

Can Language Models Actually Retrieve In-Context? Drowning in Documents at Million Token Scale

  • 设计新模型BlockSearch,支持超长文本上下文且能泛化到十倍长度。
  • 百万级文档检索上媲美密集检索,在MS MARCO等数据集表现优异。
  • 解决注意力稀释问题,适合需要语义相似性而非关键词匹配的任务。

语言模型(LMs)为检索提供了一种替代向量检索的新思路:通过在上下文中引入语料库并直接生成相关答案。然而,以往研究多集中于专有系统或小规模重排序任务,对大规模语料的上下文检索仍缺乏探索。本文首次系统研究了在百万级标记和超出训练长度的泛化场景下的上下文检索。我们提出BlockSearch,一个0.6B参数的检索模型,其架构与训练方式改进使其实现高达10倍于训练长度的泛化能力。尽管如此,在极端外推时仍出现性能崩溃。我们发现根本原因是注意力稀释:随着语料增长,无关文档主导softmax分母,即使正确文档的原始得分很高,其归一化权重仍被稀释。基于此分析,我们引入长度感知的softmax调整与文档级稀疏注意力机制。实验表明,在百万级语料下,该模型在主流基准(如MS MARCO、NQ)上达到与密集检索相当的效果,且优于同期模型MSA(参数仅为后者1/7)。此外,在要求全新相似性定义的任务(如LIMIT)上,其表现显著超越密集检索,分数提升3倍。结果表明,上下文检索是经典检索的有力替代方案,同时强调了在极长上下文下注意力控制的新挑战。

原文摘要 · Abstract (English)

Language models (LMs) raise an intriguing alternative to vector-based retrieval: conditioning on an in-context corpus and directly generating a relevant answer. However, prior work has largely focused on proprietary systems or the smaller-scale reranking task, leaving corpus-scale in-context retrieval largely unexplored. In this work, we present the first systematic study of in-context retrieval on two scales practical retrievers demand: million-token corpora and length-generalization far beyond training-time sizes. We first introduce BlockSearch, a 0.6B LM retriever whose architectural and training modifications improve over prior LM baselines and length-generalize up to 10 times beyond its training regime. Nevertheless, retrieval still collapses under more extreme extrapolation. We trace this failure to an attention dilution effect: as the corpus grows, irrelevant documents dominate the softmax denominator, reducing the normalized mass on the gold document even when its pre-softmax score stays high. Motivated by this analysis, we introduce length-aware adjustments to the attention softmax and document-level sparse attention. With these modifications, at the million-token scale, our model matches dense retrieval on widely studied benchmarks (e.g, MS MARCO and NQ), while outperforming the concurrent model MSA despite being 7 times smaller. Furthermore, it significantly outperforms dense retrieval on tasks requiring entirely different notions of similarity, such as LIMIT, achieving a 3 times higher score. Together, our results position in-context retrieval a promising alternative to classical retrieval while emphasizing attention control under extreme context growth as a new challenge.

上下文检索大模型注意力机制信息检索

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。