用本地大模型分层总结代码,更懂企业业务意图。
Hierarchical Repository-Level Code Summarization for Business Applications Using Local LLMs
- 先分析语法定位小代码单元,再逐级聚合生成文件和包的摘要。
- 在电信业务系统上测试,覆盖范围提升,摘要更贴合业务场景。
- 适合需要理解企业级代码逻辑的开发与维护人员。
在大规模软件开发中,理解复杂代码库的功能与设计意图对高效开发与维护至关重要。尽管代码摘要已被广泛研究,但现有方法主要针对函数等小型代码单元,在处理文件、包等更大代码构件时表现不佳;且多数模型聚焦于底层实现细节,忽略真实应用中至关重要的领域与业务上下文。本文提出一种面向企业应用的两阶段分层摘要方法:首先通过语法分析识别函数、变量等小代码单元,并使用本地大模型生成摘要;随后将这些摘要聚合,形成更高层级的文件与包级摘要。为确保摘要贴近业务背景,我们设计了基于领域与问题上下文的定制化提示词,以捕捉代码构件的实际用途。在电信领域业务支撑系统(BSS)上的实验表明,基于语法分析的分层方法提升了摘要覆盖率,而结合业务上下文的提示设计显著增强了摘要的相关性。
原文摘要 · Abstract (English)
In large-scale software development, understanding the functionality and intent behind complex codebases is critical for effective development and maintenance. While code summarization has been widely studied, existing methods primarily focus on smaller code units, such as functions, and struggle with larger code artifacts like files and packages. Additionally, current summarization models tend to emphasize low-level implementation details, often overlooking the domain and business context that are crucial for real-world applications. This paper proposes a two-step hierarchical approach for repository-level code summarization, tailored to business applications. First, smaller code units such as functions and variables are identified using syntax analysis and summarized with local LLMs. These summaries are then aggregated to generate higher-level file and package summaries. To ensure the summaries are grounded in business context, we design custom prompts that capture the intended purpose of code artifacts based on the domain and problem context of the business application. We evaluate our approach on a business support system (BSS) for the telecommunications domain, showing that syntax analysis-based hierarchical summarization improves coverage, while business-context grounding enhances the relevance of the generated summaries.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。