用注意力机制提升代码变更影响分析的召回率,更准找到受影响文件。
Attention Mechanism and Heuristic Approach: Context-Aware File Ranking Using Multi-Head Self-Attention
- 引入多头自注意力动态调整特征权重,捕捉专家判断中的上下文关系。
- 在Top-50候选文件中召回率从62%-65%提升至78%-82%,最高达80%。
- 适合关注变更影响分析、代码维护效率的开发者与研究者。
在软件仓库中识别并排序受影响文件是变更影响分析的关键挑战。现有确定性方法结合启发式信号、语义相似度和基于图的中心性指标虽有效缩小候选范围,但召回率已达瓶颈。这源于将特征视为线性独立贡献,忽略了衡量指标间的上下文依赖关系,未能体现专家推理模式。为此,本文提出将多头自注意力作为后确定性评分优化机制,学习特征间的上下文加权关系,根据候选文件集的整体行为动态调整每项文件的重要性。注意力机制生成的上下文感知调整值与确定性分数相加,保留可解释性的同时,实现类似专家审查变更面的推理能力。我们聚焦召回率而非精确率,因漏报(遗漏受影响文件)比误报(无关文件可快速忽略)代价更高。在200个测试案例上的实证评估显示,引入自注意力使Top-50召回率从约62%-65%提升至78%-82%,在复杂结构仓库中达到80%。专家验证表明主观准确度从6.5/10提升至8.6/10。该方法弥合了确定性自动化与专家判断之间的推理差距,显著提升仓库感知下的工作量估算效果。
原文摘要 · Abstract (English)
The identification and ranking of impacted files within software reposi-tories is a key challenge in change impact analysis. Existing deterministic approaches that combine heuristic signals, semantic similarity measures, and graph-based centrality metrics have demonstrated effectiveness in nar-rowing candidate search spaces, yet their recall plateaus. This limitation stems from the treatment of features as linearly independent contributors, ignoring contextual dependencies and relationships between metrics that characterize expert reasoning patterns. To address this limitation, we propose the application of Multi-Head Self-Attention as a post-deterministic scoring refinement mechanism. Our approach learns contextual weighting between features, dynamically adjust-ing importance levels per file based on relational behavior exhibited across candidate file sets. The attention mechanism produces context-aware adjustments that are additively combined with deterministic scores, pre-serving interpretability while enabling reasoning similar to that performed by experts when reviewing change surfaces. We focus on recall rather than precision, as false negatives (missing impacted files) are far more costly than false positives (irrelevant files that can be quickly dismissed during review). Empirical evaluation on 200 test cases demonstrates that the introduc-tion of self-attention improves Top-50 recall from approximately 62-65% to between 78-82% depending on repository complexity and structure, achiev-ing 80% recall at Top-50 files. Expert validation yields improvement from 6.5/10 to 8.6/10 in subjective accuracy alignment. This transformation bridges the reasoning capability gap between deterministic automation and expert judgment, improving recall in repository-aware effort estimation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。