arXiv:2508.02455cs.SEcs.AI2025-08被引 1

用轻量树结构提升代码补全排序,让好建议更快被看到。

TreeRanker: Fast and Model-agnostic Ranking System for Code Suggestions in IDEs

  • 构建前缀树遍历所有合法补全项,单次贪婪解码获取精准得分
  • 无需束搜索或提示工程,支持现有代码补全模型直接集成
  • 速度快、不依赖模型架构,适合各类开发环境实时使用

令牌级代码补全是现代集成开发环境(IDE)中最重要的功能之一,通过在编码过程中建议相关标识符和API来辅助开发者。尽管补全结果通常来自静态分析,但其实用性高度依赖于排序质量,因为排在后面的正确预测很少被用户注意到。当前大多数系统依赖手工设计的启发式规则或基于用户日志训练的轻量机器学习模型,仍可进一步改进以捕捉上下文信息并跨项目和编程风格泛化。本文提出一种新的评分方法,以轻量且模型无关的方式利用语言模型对静态补全结果进行排序。该方法将所有有效补全组织成前缀树,并通过一次贪婪解码遍历完成令牌级得分收集,实现无需束搜索、提示工程或模型适配的精确令牌感知排序。该方法快速、架构无关,可与已部署的代码补全模型兼容。研究结果表明,这是一种将语言模型高效集成到现有IDE工具中的实用路径,最终为开发者提供更智能、更响应迅速的辅助能力。

原文摘要 · Abstract (English)

Token-level code completion is one of the most critical features in modern Integrated Development Environments (IDEs). It assists developers by suggesting relevant identifiers and APIs during coding. While completions are typically derived from static analysis, their usefulness depends heavily on how they are ranked, as correct predictions buried deep in the list are rarely seen by users. Most current systems rely on hand-crafted heuristics or lightweight machine learning models trained on user logs, which can be further improved to capture context information and generalize across projects and coding styles. In this work, we propose a new scoring approach to ranking static completions using language models in a lightweight and model-agnostic way. Our method organizes all valid completions into a prefix tree and performs a single greedy decoding pass to collect token-level scores across the tree. This enables a precise token-aware ranking without needing beam search, prompt engineering, or model adaptations. The approach is fast, architecture-agnostic, and compatible with already deployed models for code completion. These findings highlight a practical and effective pathway for integrating language models into already existing tools within IDEs, and ultimately providing smarter and more responsive developer assistance.

代码补全排序优化IDE工具

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