The automated generation of code summaries is a vital technique that transforms source code into concise natural language descriptions, proving instrumental in enhancing program comprehension and streamlining maintenance tasks. Despite advancements in the field, existing methods still face challenges in capturing the deep semantics and structural similarities of code, often resulting in biased or inaccurate summaries. This paper proposes a novel two-stage approach: Siamese Networks and Graph Kernel for Retrieval-Augmented code Summarization (SGRAS). Our initial phase involves adapting CodeBERT, a programming language-specific pre-trained model, to our specific code dataset. This process enhances the model’s capabilities, resulting in a more effective code encoding mechanism. The second stage employs a twin neural network for semantic retrieval to identify the top k most semantically similar code snippets, and a shortest path graph kernel function for syntactic retrieval to find the most structurally similar code snippet. The trained encoder generates two vector representations, which are then combined via a fusion layer. Subsequently, a decoder generates the natural language summary based on the fused representation. Extensive experiments are conducted to evaluate the effectiveness of our approach. The results indicate that our approach substantially outperforms state-of-the-art methods, yielding summaries that are not only more precise but also more substantive in content.

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

Retrieval-Enhanced Method Using Siamese Networks and Graph Kernel Functions for Code Summarization

  • Yuxin Ding,
  • Jing Cao,
  • Ningxin Huang

摘要

The automated generation of code summaries is a vital technique that transforms source code into concise natural language descriptions, proving instrumental in enhancing program comprehension and streamlining maintenance tasks. Despite advancements in the field, existing methods still face challenges in capturing the deep semantics and structural similarities of code, often resulting in biased or inaccurate summaries. This paper proposes a novel two-stage approach: Siamese Networks and Graph Kernel for Retrieval-Augmented code Summarization (SGRAS). Our initial phase involves adapting CodeBERT, a programming language-specific pre-trained model, to our specific code dataset. This process enhances the model’s capabilities, resulting in a more effective code encoding mechanism. The second stage employs a twin neural network for semantic retrieval to identify the top k most semantically similar code snippets, and a shortest path graph kernel function for syntactic retrieval to find the most structurally similar code snippet. The trained encoder generates two vector representations, which are then combined via a fusion layer. Subsequently, a decoder generates the natural language summary based on the fused representation. Extensive experiments are conducted to evaluate the effectiveness of our approach. The results indicate that our approach substantially outperforms state-of-the-art methods, yielding summaries that are not only more precise but also more substantive in content.