arXiv:2605.14362cs.SEcs.AI2026-05

提出轻量级文件过滤框架,高效去除代码仓库中无关大文件,提升LLM开发工具的准确率。

Correctness-Aware Repository Filtering Under Maximum Effective Context Window Constraints

论文配图:Correctness-Aware Repository Filtering Under Maximum Effective Context Window Constraints
图 1 · 摘自论文原文
  • 基于文件大小和元数据预筛,无需索引,每文件决策耗时低于0.01毫秒。
  • 在22,046个文件上实现平均89.3%的令牌减少,文件级准确率从25%提升至72%。
  • 适合追求低延迟、高准确的LLM代码辅助工具开发者使用。

大型语言模型(LLM)驱动的开发工具面临上下文窗口效率的现实约束。研究表明,所有测试模型在达到标称上下文极限前便出现准确率下降,即最大有效上下文窗口(MECW)远小于理论值,使上下文构建成为质量问题而非成本问题。现代软件仓库常包含大量非代码内容,如编译数据集、二进制权重、压缩脚本及数GB日志文件,这些内容会挤占上下文,导致任务相关源码被排除。本文提出一种正确性感知的上下文清洁框架:一种预执行阶段的基于大小的启发式过滤器,在分词前拦截仓库扫描,仅依赖操作系统级stat()元数据,开销低于1毫秒。相比需索引与查询推理的语义检索方法(如RepoCoder、GraphRAG、AST切片),本框架无需索引,每文件决策时间低于0.01毫秒。在10个真实开源仓库(共22,046个文件,5种语言)上,大小阈值θ=1MB时,SizeFilter实现79.6%(±13.2%)的平均令牌减少,耗时0.30毫秒;HybridFilter则实现89.3%(±9.0%)的最高精度,方差最低。对2,688个文件的令牌密度研究显示,存在强线性相关(皮尔逊r=0.997,k=0.250 tokens/byte)。有限范围评估(18个任务,CodeLlama-7B-Instruct)表明,过滤后文件级准确率达72%,较基线25%显著提升;幻觉频率由61%降至17%。所有代码与数据均已公开以支持复现。

原文摘要 · Abstract (English)

Context window efficiency is a practical constraint in large language model (LLM)-based developer tools. Paulsen [12] shows that all tested models degrade in accuracy well before their advertised context limits the Maximum Effective Context Window (MECW) which makes context construction a quality problem, not just a cost one. Modern software repositories routinely contain large non-code artifacts compiled datasets, binary model weights, minified JavaScript bundles, and gigabyte-scale log files that overflow the context window and push out task-relevant source code. We present a correctness-aware context hygiene framework: a pre-execution, size-based heuristic filter that intercepts repository scans before tokenization, using only OS-level stat() metadata with sub-millisecond overhead. Semantic retrieval approaches such as RepoCoder, GraphRAG, and AST-based chunking require index construction and query-time inference before any filtering decision is reached. Our framework, by contrast, requires no indexing and operates at <0.01 ms per file decision. Across 10 real open-source repositories (22,046 files, 5 languages), the proposed SizeFilter at θ=1 MB achieves 79.6% (\pm13.2%) mean token reduction at 0.30 ms overhead: the HybridFilter achieves 89.3% (\pm9.0%) the lowest variance of any filter evaluated. A token-density study across 2,688 files confirms a strong linear correlation (Pearson r=0.997, k=0.250 tokens/byte). A limited-scope evaluation (18 tasks, CodeLlama-7B-Instruct) yields 72% file-level accuracy under filtering versus 25% at baseline; hallucination frequency declines from 61% to 17%. All code and data are released for reproducibility.

LLM代码工具上下文优化过滤

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