arXiv:2504.17426cs.SEcs.AI2025-04被引 1

用大模型生成代码摘要,再做主题建模,让代码结构更易懂。

Towards Leveraging Large Language Model Summaries for Topic Modeling in Source Code

  • 让大模型先总结代码,再用主题模型分析摘要
  • 生成的主题比仅看函数名或注释更语义丰富
  • 适合自动文档、代码搜索和大型项目知识挖掘

理解源代码是软件工程领域的重要课题,有助于程序员完成维护与复用等任务。近年来,大语言模型(LLM)展现出强大的程序理解能力,而基于Transformer的主题建模技术则能有效提取文本语义信息。本文提出一种新方法:利用大模型对Python代码进行摘要,再对摘要应用主题建模,以自动识别代码语料中的有意义主题。为评估提取主题的一致性,我们将其与仅基于函数名推断的主题、以及现有docstrings推导的主题进行对比。实验结果表明,借助大模型生成的摘要,可获得更具解释性和语义丰富性的代码结构表征。该方法在自动文档生成、代码标签、代码搜索、软件重构及大型代码库知识发现等任务中具有广泛应用前景。

原文摘要 · Abstract (English)

Understanding source code is a topic of great interest in the software engineering community, since it can help programmers in various tasks such as software maintenance and reuse. Recent advances in large language models (LLMs) have demonstrated remarkable program comprehension capabilities, while transformer-based topic modeling techniques offer effective ways to extract semantic information from text. This paper proposes and explores a novel approach that combines these strengths to automatically identify meaningful topics in a corpus of Python programs. Our method consists in applying topic modeling on the descriptions obtained by asking an LLM to summarize the code. To assess the internal consistency of the extracted topics, we compare them against topics inferred from function names alone, and those derived from existing docstrings. Experimental results suggest that leveraging LLM-generated summaries provides interpretable and semantically rich representation of code structure. The promising results suggest that our approach can be fruitfully applied in various software engineering tasks such as automatic documentation and tagging, code search, software reorganization and knowledge discovery in large repositories.

代码理解大模型主题建模自动化

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