The invention discloses an automatic code defect repairing method based on a code attribute graph and a
large model, which comprises the following steps: collecting a code sample, analyzing a
source code, generating the code attribute graph fusing an
abstract syntax tree, a
control flow graph and a data flow graph, and then carrying out dynamic
pruning according to node importance calculated based on node degrees,
PageRank and data propagation dependency, so as to obtain a
large model; key nodes are reserved to improve the graph learning efficiency; extracting features of the optimized graph through GAT, introducing multi-scale coding, and generating a
graph embedding vector; in combination with node importance, high-value Tokens are screened, semantic embedding of structure
perception is carried out, and more accurate text representation is obtained; generating a comprehensive feature by fusing the image and the text vector, and then inserting a
mask at a position with weak dependence or high risk; performing
fine tuning optimization on the
mask position; and inputting the comprehensive features and the
mask source codes into a pre-training
language model to generate patches, performing multi-task evaluation and reordering, and selecting an optimal patch to complete repair.