结合静态代码分析和大语言模型提高算法识别的正确性和性能
Combining Static Code Analysis and Large Language Models Improves Correctness and Performance of Algorithm Recognition
AI总结:
本文研究了结合大语言模型与静态代码分析在算法识别中的效果,发现该方法能显著降低运行时间并提升F1分数,同时验证了模型在标识符混淆下的鲁棒性。
摘要:
本文研究了将大语言模型与静态代码分析结合在算法识别中的效果,发现该方法能显著降低运行时间并提升F1分数,同时验证了模型在标识符混淆下的鲁棒性。
英文摘要:
Context: Since it is well-established that developers spend a substantial portion of their time understanding source code, the ability to automatically identify algorithms within source code presents a valuable opportunity. This capability can support program comprehension, facilitate maintenance, and enhance overall software quality. Objective: We empirically evaluate how combining LLMs with static code analysis can improve the automated recognition of algorithms, while also evaluating their standalone performance and dependence on identifier names. Method: We perform multiple experiments evaluating the combination of LLMs with static analysis using different filter patterns. We compare this combined approach against their standalone performance under various prompting strategies and investigate the impact of systematic identifier obfuscation on classification performance and runtime. Results: The combination of LLMs with lightweight static analysis performs surprisingly well, reducing required LLM calls by 72.39-97.50% depending on the filter pattern. This not only lowers runtime significantly but also improves F1-scores by up to 12 percentage points (pp) compared to the baseline. Regarding the different prompting strategies, in-context learning with two examples provides an effective trade-off between classification performance and runtime efficiency, achieving F1-scores of 75-77% with only a modest increase in inference time. Lastly, we find that LLMs are not solely dependent on name-information as they are still able to identify most algorithm implementations when identifiers are obfuscated. Conclusion: By combining LLMs with static analysis, we achieve substantial reductions in runtime while simultaneously improving F1-scores, underscoring the value of a hybrid approach.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。