The invention discloses a
code annotation generation method based on a large
language model and multi-
modal comparative learning, which comprises the following steps: firstly, designing a universal prompt template to help the large
language model to generate similar code segments, and introducing the thought of gradually generating a thinking chain into the prompt template to effectively improve the accuracy of a generation result; meanwhile, the realization
modes and styles of the generated similar code segments and source codes are variable, and the quality is higher; secondly, aligning source codes, similar codes and annotations thereof through multi-
modal comparative learning, and enhancing the understanding and matching capability of the model on semantic relationships between the codes, the similar codes and the annotations by designing intra-
modal comparative learning and inter-modal comparative learning, so as to better capture deep association of the similar codes, the annotations and the source codes; and finally, designing an evaluation method based on a large
language model, and more comprehensively evaluating the quality of the generated annotations from four aspects of correlation, integrity,
clarity and understandability by means of the understanding ability of the large language model.