<p>Code summarization aims to generate natural language descriptions of source code to support program comprehension and software maintenance. Traditional programming-language-processing (PLP) pipelines rely on syntax parsing and structural representations such as abstract syntax trees (ASTs). However, their strict separation of programming language (PL) and natural language (NL) often results in brittle generalization and limited adaptability. We introduce P2N2S, a fully NL-grounded framework that departs from the PLP paradigm. It operates in two stages: (1) PL2NL Conversion, where large language models (LLMs) actively translate code into line-level natural language annotations, producing semantically faithful and interpretable intermediate representations; and (2) NL2Summary Generation, where pre-trained natural language processing (NLP) summarizers refine these annotations into concise and coherent summaries. By integrating the LLM’s capability to capture detailed semantics with the NLP summarizer’s strengths in selective abstraction and stylistic coherence, P2N2S overcomes the rigid, structure-dependent limitations of PLP methods and produces summaries that remain concise, fluent, and accurate without relying on fragile program analyses. Experiments on two Java benchmarks show that P2N2S consistently outperforms state-of-the-art PLP and LLM baselines across four evaluation metrics. The framework also demonstrates strong robustness in automatic and human assessments, and offers practical deployability by relying solely on readily available LLM and NLP tools. Overall, P2N2S provides a stable, flexible, and accessible solution for advancing code summarization in real-world software engineering workflows.</p>

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

P2N2S: Bridging the gap between natural and programming languages for code summarization via large language models

  • Yijia Tang,
  • YaoShen Yu,
  • Zhiqiu Huang,
  • Bowei Xia,
  • Yukun Cao

摘要

Code summarization aims to generate natural language descriptions of source code to support program comprehension and software maintenance. Traditional programming-language-processing (PLP) pipelines rely on syntax parsing and structural representations such as abstract syntax trees (ASTs). However, their strict separation of programming language (PL) and natural language (NL) often results in brittle generalization and limited adaptability. We introduce P2N2S, a fully NL-grounded framework that departs from the PLP paradigm. It operates in two stages: (1) PL2NL Conversion, where large language models (LLMs) actively translate code into line-level natural language annotations, producing semantically faithful and interpretable intermediate representations; and (2) NL2Summary Generation, where pre-trained natural language processing (NLP) summarizers refine these annotations into concise and coherent summaries. By integrating the LLM’s capability to capture detailed semantics with the NLP summarizer’s strengths in selective abstraction and stylistic coherence, P2N2S overcomes the rigid, structure-dependent limitations of PLP methods and produces summaries that remain concise, fluent, and accurate without relying on fragile program analyses. Experiments on two Java benchmarks show that P2N2S consistently outperforms state-of-the-art PLP and LLM baselines across four evaluation metrics. The framework also demonstrates strong robustness in automatic and human assessments, and offers practical deployability by relying solely on readily available LLM and NLP tools. Overall, P2N2S provides a stable, flexible, and accessible solution for advancing code summarization in real-world software engineering workflows.