Code abstract generation method based on multi-granularity feature fusion

Through multi-grained feature fusion and cross-attention mechanisms, highly accurate and readable code summary is generated, which solves the problems of semantic extraction bias, poor expansion and information fragmentation in the prior art.

CN119739857AActive Publication Date: 2025-04-01NANJING UNIV OF INFORMATION SCI & TECH
5 Cites 0 Cited by

Patent Information

Application Number
CN202510260828.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-06
Publication Date
2025-04-01
Estimated Expiration
2045-03-06

AI Technical Summary

Technical Problem

The existing code summary generation methods have problems such as semantic extraction bias, poor scalability and information fragmentation, making it difficult to generate code summary with high accuracy and readability.

Method used

Using a method based on multi-grained feature fusion, the source code is preprocessed to obtain three granular features: word sequence, abstract syntax tree and control flow diagram, a multi-grained feature encoder is built, and feature fusion is achieved through the cross attention mechanism, and finally input it into the Transformer decoder to generate a code summary.

Benefits of technology

It improves the accuracy and readability of code summary, reduces computational overhead, and solves the problems of inaccurate keyword extraction and information fragmentation caused by single granularity processing.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

The invention provides a code abstract generation method based on multi-granularity feature fusion, which comprises the following steps of: 1, preprocessing samples in a data set to obtain overall semantic information of codes; 2, a source code multi-granularity feature encoder is built, and context vectors of all granularity features are obtained based on data scales and data structure differences of three granularity features of a lexical element sequence, an abstract syntax tree and a control flow graph; 3, realizing granularity feature fusion for the output of the encoders with different granularity features; and step 4, inputting the lexical sequence fusion feature and the control flow graph fusion feature obtained after fusion into a decoder based on Transform, outputting a current time step prediction word, and finally forming an abstract. According to the code abstract generation method based on multi-granularity feature fusion, key features of source codes can be effectively extracted, calculation overhead can be reduced as much as possible, and the problem of long-distance dependence of feature sequences is effectively relieved.
Need to check novelty before this filing date? Find Prior Art