一种基于层次化上下文感知的代码摘要生成方法及系统
By constructing a function call graph and a hierarchical generation mechanism, the problem of insufficient context modeling in code comment generation of large language models is solved, generating accurate, consistent and understandable code comments, thus improving code maintainability and readability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU DIANZI UNIV
- Filing Date
- 2026-03-31
- Publication Date
- 2026-07-17
AI Technical Summary
Existing code annotation generation methods based on large language models are insufficient in project-level context modeling, resulting in poor semantic consistency of the generated annotations, an inability to deeply understand complex call structures, and a tendency to produce inaccurate descriptions when domain-related knowledge is lacking.
By constructing a function call graph to eliminate loop structures, identifying and classifying leaf nodes, calculating the importance score of child nodes, and combining it with a large language model to generate annotations, a hierarchical generation mechanism is adopted to generate annotations layer by layer from bottom to top. Class function descriptions are introduced as multi-source contexts to ensure the accuracy and consistency of annotations.
It significantly improves the accuracy and semantic consistency of annotations, overcomes the input length limitation of large language models, enhances the ability to model project-level contexts, generates annotations that are consistent with the code design intent, and has strong anti-interference capabilities.
Smart Images

Figure CN121957613B_ABST
Abstract
Citation Information
Patent Citations
Code abstract generation method fusing abstract syntax tree node features
CN116820557A
Adaptive code annotation updating method and system, terminal and storage medium
CN119576363A