We propose a novel method for code summarization utilizing Heterogeneous Code Representations (HCRs) and our specially designed HierarchyNet. HCRs effectively capture essential code features at lexical, syntactic, and semantic levels by abstracting coarse-grained code elements and incorporating fine-grained program elements in a hierarchical structure. Our HierarchyNet method processes each layer of the HCR separately through a unique combination of the Heterogeneous Graph Transformer, a Tree-based CNN, and a Transformer Encoder. This approach preserves dependencies between code elements and captures relations through a novel Hierarchical-Aware Cross Attention layer. Our method surpasses current state-of-the-art techniques, such as PA-Former, CAST, and NeuralCodeSum.
翻译:我们提出了一种新颖的代码摘要方法,该方法利用异构代码表示(HCR)及我们专门设计的HierarchyNet。HCR通过抽象粗粒度代码元素并以层次结构融入细粒度程序元素,在词法、句法和语义层面有效捕获关键代码特征。我们的HierarchyNet方法通过异构图Transformer、基于树的CNN与Transformer编码器的独特组合,分别处理HCR的每一层。该方法通过新颖的层次感知交叉注意力层保持代码元素间的依赖关系并捕获其关联。我们的方法超越了当前最先进的技术,如PA-Former、CAST和NeuralCodeSum。