Code review method based on large language model and related equipment

Through the code review method based on the large language model, the project's meta information and code change log are used to compress and integrate the code change files, which solves the problem of low accuracy of code review results in the existing technology, and achieves efficient and accurate code review.

CN119883358AActive Publication Date: 2025-04-25ZHEJIANG ZEEKR INTELLIGENT TECH CO LTD +1

Patent Information

Application Number
CN202411955512.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-28
Publication Date
2025-04-25
Estimated Expiration
2044-12-28

AI Technical Summary

Technical Problem

The existing code review methods have low accuracy of review results due to the large amount of code data to be reviewed and the performance limitations of code review tools.

Method used

The code review method based on the large language model is adopted. By obtaining multiple code change files, the points of each code change file are determined based on the project's meta information and code change log, and multiple code change files are compressed to ensure that they comply with the processing capabilities of the large language model and then reviewed.

Benefits of technology

Improve the accuracy and efficiency of code review, ensure that the large language model focuses on the review of important code, adapts to projects of different sizes and complexities, has good scalability, and improves the quality and efficiency of review results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883358A_ABST
    Figure CN119883358A_ABST
Patent Text Reader

Abstract

The invention provides a code review method based on a large language model and related equipment, and the code review method based on the large language model comprises the steps that a plurality of code change files are obtained, and each code change file in the code change files comprises a code change log; if the total mark number of the code change files is larger than the maximum mark receiving number of a preset large language model, the integral of each code change file is determined based on the meta-information of the updated project and the code change log of each code change file; compressing the plurality of code change files based on the integral and the meta-information to obtain a plurality of compressed code change files; and reviewing the plurality of compressed code change files based on a preset large language model to obtain a code review result. According to the method and the device, comprehensive, efficient and accurate review of code changes is realized, and the code review accuracy and efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a code review method and related equipment based on a large language model. Background Art

[0002] In the software project development process, code review is an indispensable link, which can effectively improve the overall code quality of the project and promptly discover possible problems in the code.

[0003] The relevant code review method usually directly inputs the code to be reviewed into the code review tool for processing to obtain the review result corresponding to the code to be reviewed. The accuracy of the review result may be low due to the huge amount of data of the code to be reviewed and the performance limitations of the code review tool. Summary of the invention

[0004] In view of the above, it is necessary to propose a code review method and related equipment based on a large language model to solve the technical problem that the review results of the existing code review method have low accuracy.

[0005] In a first aspect, the present application provides a code review method based on a large language model, the method comprising: obtaining multiple code change files, wherein each of the multiple code change files includes a code change log; if the total number of tags of the multiple code change files is greater than the maximum number of tags received by a preset large language model, determining the score of each code change file based on the updated meta information of the project and the code change log of each code change file; compressing the multiple code change files based on the score and the meta information to obtain multiple compressed code change files; and reviewing the compressed multiple code change files based on the preset large language model to obtain a code review result.

[0006] In the code review method based on the large language model of the above embodiment, first, multiple code change files are obtained, each code change file includes a code change log; then, if the total number of tags of the multiple code change files is greater than the maximum number of tags received by the preset large language model, based on the metadata of the updated project and the code change log of each code change file, the score of each code change file is determined; then, based on the score and the metadata, the multiple code change files are compressed to obtain multiple compressed code change files; then, based on the metadata and the compressed multiple code change files, the structural prompt words of the preset large language model are generated; finally, based on the preset large language model and the structural prompt words, the compressed multiple code change files are reviewed to obtain the code review result. Based on this, when the total number of tags in a code change file exceeds the processing capacity of a large language model, this application uses the project's metadata and code change log to compress multiple code change files, which can meet the processing capacity of a large language model while optimizing resource usage, reducing the interference of non-functional code changes on the reasoning of the large language model, ensuring that the large language model focuses on the review of important codes, improving the accuracy and relevance of the review, and being able to adapt to projects of different sizes and complexities, with good scalability. Based on the large language model, code is reviewed for multiple compressed code change files, which can utilize the excellent performance of the large language model and improve the quality and efficiency of the review results. In summary, this application achieves a comprehensive, efficient and accurate review of code changes, improves the accuracy and efficiency of code reviews, provides strong support for the software development process, and ensures the quality and security of software projects.

[0007] In some embodiments of the present application, compressing the multiple code change files based on the score and the meta information to obtain the compressed multiple code change files includes: deleting the specified excluded code change files indicated by the meta information in the multiple code change files to obtain the multiple code change files after initial compression; if the total number of tags in the multiple code change files after initial compression is greater than the maximum number of tags received by the preset large language model, deleting the code change files in the multiple code change files after initial compression that are lower than a preset score threshold to obtain the multiple code change files after secondary compression.

[0008] In some embodiments of the present application, compressing the multiple code change files based on the points and the meta-information to obtain the compressed multiple code change files also includes: if the total number of tags in the multiple code change files after the second compression is greater than the maximum number of tags received by the preset large language model, deleting the code with the change type of deletion in each code change file after the second compression, to obtain the multiple code change files after the third compression.

[0009] In some embodiments of the present application, compressing the multiple code change files based on the points and the meta-information to obtain the compressed multiple code change files also includes: if the total number of tags of the multiple code change files after three compressions is greater than the maximum number of tags received by a preset large language model, deleting the code with the change type of edit in each code change file after three compressions to obtain the multiple code change files after four compressions.

[0010] In some embodiments of the present application, determining the score of each code change file based on the meta information of the project and the code change log of each code change file includes: determining the usage percentage of each programming language of the updated project according to the meta information; determining a first score of each code change file according to the programming language of each code change file and the usage percentage; determining a second score of each code change file according to the code change log of each code change file; and determining the score of each code change file according to the first score and the second score.

[0011] In some embodiments of the present application, the reviewing the compressed multiple code change files based on the preset large language model to obtain the code review result includes: generating structural prompt words of the preset large language model according to the meta-information and the compressed multiple code change files; and reviewing the compressed multiple code change files based on the preset large language model and the structural prompt words to obtain the code review result.

[0012] In some embodiments of the present application, the compressed multiple code change files are reviewed based on the preset large language model and the structural prompt words to obtain the code review results, including: based on the preset large language model that has been fine-tuned and trained and the structural prompt words, the compressed multiple code change files are reviewed to obtain the code review results.

[0013] In some embodiments of the present application, the fine-tuning training method of the fine-tuned preset large language model includes: constructing a training data set according to the organization code and industry code corresponding to the project; fine-tuning the parameters of the preset large language model based on the training data set to obtain the fine-tuned preset large language model.

[0014] In some embodiments of the present application, generating structural prompt words of a preset large language model based on the meta-information and the compressed multiple code change files includes: determining the code information related to the project from a preset plug-in knowledge base based on the meta-information, wherein the preset plug-in knowledge base contains code specifications and best practices within the organization and a preset industry corresponding to the project; splicing the compressed multiple code change files and the code information to obtain the structural prompt words.

[0015] In a second aspect, the present application also provides a code review device based on a large language model, the device comprising: an acquisition module, used to acquire multiple code change files, wherein each of the multiple code change files includes a code change log; a determination module, used to determine the score of each code change file based on the updated project metadata and the code change log of each code change file if the total number of tags of the multiple code change files is greater than the maximum number of tags received by the preset large language model; a compression module, used to compress the multiple code change files based on the score and the metadata to obtain multiple compressed code change files; and a review module, used to review the compressed multiple code change files based on the preset large language model to obtain a code review result.

[0016] In a third aspect, the present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the code review method based on the large language model described in the above embodiment.

[0017] In a fourth aspect, the present application further provides a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the code review method based on a large language model described in the above embodiment are implemented.

[0018] It can be understood that the code review device based on the large language model of the second aspect, the electronic device of the third aspect, the computer-readable medium of the fourth aspect, and the computer program product of the fifth aspect provided above all correspond to the code review method based on the large language model of the first aspect. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects of the corresponding code review method based on the large language model provided above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 This is a schematic diagram of an application scenario of a code review method based on a large language model provided in an embodiment of the present application.

[0020] Figure 2It is a flowchart of a code review method based on a large language model provided in one embodiment of the present application.

[0021] Figure 3 yes Figure 2 The detailed flowchart of step S11 in the code review method based on the large language model is shown.

[0022] Figure 4 yes Figure 2 The detailed flowchart of step S12 in the code review method based on the large language model is shown.

[0023] Figure 5 yes Figure 2 The detailed flowchart of step S13 in the code review method based on the large language model is shown.

[0024] Figure 6 yes Figure 5 The detailed flowchart of step S130 in the code review method based on a large language model is shown.

[0025] Figure 7 It is a flowchart of a fine-tuning training method for a preset large language model provided in one embodiment of the present application.

[0026] Figure 8 It is a functional module diagram of a code review device based on a large language model provided in one embodiment of the present application.

[0027] Component Symbols

[0028] Electronic devices 10

[0029] Memory 11

[0030] Processor 12

[0031] Speaker 20

[0032] Code review device 100 based on large language model

[0033] Acquisition module 110

[0034] Determination module 120

[0035] Compression module 130

[0036] Review Module 140

[0037] The following specific implementation methods will further illustrate the present application in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION

[0038] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.

[0039] In the embodiments of the present application, it should be noted that, unless otherwise clearly specified and limited, words such as "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "for example" is intended to present related concepts in a specific way.

[0040] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, an electrical connection, or mutual communication; it can be a direct connection, or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0041] In the description of the present application, it should be noted that, unless otherwise expressly specified and limited, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In addition, in the description of the present application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically limited.

[0042] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0043] See also Figure 1 , which is a schematic diagram of an application scenario of a code review method based on a large language model provided in an embodiment of the present application.

[0044] The embodiment of the present application provides a code review method based on a large language model, which can be applied to one or more electronic devices. The electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0045] Specifically, the electronic device 10 is used to: obtain multiple code change files, wherein each of the multiple code change files includes a code change log; if the total number of tags of the multiple code change files is greater than the maximum number of tags received by a preset large language model, determine the score of each code change file based on the updated project metadata and the code change log of each code change file; compress the multiple code change files based on the score and the metadata to obtain multiple compressed code change files; and review the compressed multiple code change files based on the preset large language model to obtain a code review result.

[0046] In some embodiments of the present application, the electronic device 10 can be communicatively connected to a desktop computer, a notebook, a PDA, a cloud server, or other devices.

[0047] In some embodiments of the present application, the electronic device 10 can perform human-computer interaction with the user through a keyboard, a mouse, a remote control, a touch pad, or a voice control device.

[0048] In some embodiments of the present application, the electronic device 10 may also include a network device and / or a client device. The network device includes but is not limited to a single network server, a server group consisting of multiple network servers, and a cloud server consisting of a large number of hosts or network servers based on cloud computing.

[0049] In some embodiments of the present application, the network where the electronic device 10 is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.

[0050] See also Figure 2 , which is a schematic diagram of the steps of a code review method based on a large language model provided in one embodiment of the present application.

[0051] Specifically, the code review method based on the large language model includes the following steps. According to different requirements, the order of some steps in the flowchart can be changed, and some steps can be omitted.

[0052] Step S10, obtaining multiple code modification files.

[0053] Specifically, each code change file includes a code change log between a first file and a second file, and the code change log records the difference code between the second file and the first file (for example, the code whose change type is deletion, addition, or editing). The first file represents the code file in the original project, and the second file represents the code file in the updated project corresponding to the first file.

[0054] It should be noted that in the field of software development, a project usually refers to a comprehensive task or product, which consists of multiple types of files, including but not limited to source code modification files, configuration files, and resource files. As the project progresses and requirements evolve, these files will change over time, including but not limited to the addition of new features, the modification or deletion of old features, and the update of configuration files or resource files;

[0055] In some embodiments of the present application, the electronic device 10 can use a version control system (such as Git) command to obtain multiple code change files. Specifically, after receiving a code merge request from the version control system, the electronic device 10 pulls the merge record corresponding to the above code merge request from the version control system, and queries multiple code change files based on the merge record. Among them, Git is a powerful distributed version control system that can manage the source code of large open source software, and can also manage private documents and source code.

[0056] In other embodiments, multiple code modification files may be pre-stored in a preset document, and the preset document may be stored on the electronic device 10. When code review is required, the electronic device 10 directly reads the content in the preset document to obtain the code modification files.

[0057] Step S11, if the total number of tags of multiple code change files is greater than the maximum number of tags received by the preset large language model, determine the score of each code change file based on the updated project meta information and the code change log of each code change file.

[0058] In some embodiments of the present application, before providing multiple code change files to a large language model for processing, each code change file needs to be converted into a readable text form. When we convert multiple code change files into text format for processing by a large language model, these files are decomposed into a series of basic processing units, namely tokens. Among them, each token can be a word, a character, or a word group or phrase in the code. The number of tokens of each code change file refers to the number of words, symbols, or word group and phrases that have been processed by word segmentation contained in each code change file after being converted into text form, that is, the number of tokens. Therefore, the total number of tokens of multiple code change files is the total number of tokens decomposed after the multiple code change files are converted into text form.

[0059] In some embodiments of the present application, the preset large language model may be a codeQwen1.5 model, which is an artificial intelligence model specially designed for processing and analyzing code. The purpose of the model is to receive code change files and structural prompt words used to guide the model to perform code review as input, and the output is the code review result of the code change file. Among them, the maximum number of tokens that the codeQwen1.5 model can process may be 2048 tokens, which means that the total number of words, symbols or code snippets that it can effectively process in a single reasoning does not exceed 2048 tokens.

[0060] In some embodiments of the present application, during the software development process, especially for large projects, the code changes between different versions may be very large, resulting in the total number of tokens in the code change files in the project far exceeding the processing capacity of the large language model, thereby interfering with the reasoning effect of the large language model and affecting the accuracy and efficiency of code review. For example, a complex software project may have thousands of lines of code changes in one update, which may exceed 100,000 after conversion into tokens. In addition, changes to non-functional code, such as configuration file updates, changes to images and binary files, will also significantly increase the number of tokens.

[0061] In order to solve the above problems, the present application proposes a sorting algorithm and a compression algorithm. First, each code change file is scored based on the metadata of the updated project, such as the main programming language, function description, project type, and a list of unimportant files. Then, after scoring, the number of tokens of each code change file and the total number of tokens of all code change files are calculated. According to the window requirements of the large language model, such as the limit of 2048 tokens, all code change files are intelligently compressed to ensure that the total number of tokens of all code change files does not exceed the processing capacity of the large language model. The specific embodiments are as follows:

[0062] In some embodiments of the present application, determining the score of each code change file based on the metadata of the updated project and the code change log of each code change file in step S11 specifically includes: determining the usage percentage of each programming language of the updated project according to the metadata; determining the first score of each code change file according to the programming language and usage percentage of each code change file; determining the second score of each code change file according to the code change log of each code change file; determining the score of each code change file according to the first score and the second score, for example, taking the sum of the first score and the second score as the score of each code change file.

[0063] Among them, the project's meta-information refers to some key information and contextual data about the project, such as programming language, function description, project type, list of unimportant files, code specifications, etc. This information helps to understand and handle project code changes.

[0064] In the above embodiment, by determining the usage ratio of each programming language in the project, the importance of the code change file can be more accurately evaluated, ensuring that changes in the main language receive more attention. By assigning a first score and a second score to each code change file, an automated scoring system is implemented, making the code review process more objective and quantitative. According to the score, the code change files can be prioritized, and those code changes that have the greatest impact on the project can be reviewed first. Through the score, key code changes can be quickly identified and processed, the efficiency of code review can be improved, the workload of the reviewer can be reduced, and review resources can be reasonably allocated to ensure that key codes are fully reviewed while reducing excessive attention to non-critical code. Combined with the first score and the second score, the impact of code changes can be more comprehensively evaluated, including the addition, deletion and editing of code. Through the score. By accurately evaluating code changes, it is helpful to promptly discover and correct potential problems, improve code quality and the overall stability of the project.

[0065] It should be noted that how to determine the score of each code change file in the subsequent Figure 3 The steps shown are described in detail and will not be repeated here to avoid repetition.

[0066] In other embodiments, if the total number of tags of the plurality of code modification files is less than or equal to the maximum number of tags received by the preset large language model, the code modification files do not need to be compressed, and the electronic device 10 directly executes step S13.

[0067] Step S12, compressing the multiple code-modified files based on the points and the meta-information to obtain multiple compressed code-modified files.

[0068] In some embodiments of the present application, step S12, compressing multiple code change files based on points and meta information to obtain multiple compressed code change files specifically includes: deleting the specified excluded code change files indicated by the meta information in the multiple code change files, to obtain multiple code change files after initial compression; if the total number of tags in the multiple code change files after initial compression is greater than the maximum number of tags received by the preset large language model, deleting the code change files in the multiple code change files after initial compression that are lower than a preset score threshold, to obtain multiple code change files after secondary compression.

[0069] In the above embodiment, the code change files marked as "specified exclusion" are deleted according to the instructions of the meta information. Files marked as "specified exclusion" may be because the content is repeated with other changes, are no longer needed, or have no substantial contribution to the overall progress of the project, or are external resource files. By deleting unnecessary code change files, the multiple code change files after the initial compression can be made more streamlined while avoiding the waste of computing power of the large language model in the subsequent code review process, thereby improving the efficiency of code review. Further, based on the points of the code change files, the code change files below the preset score threshold in the multiple code change files after the initial compression are deleted, which helps to reduce the interference of non-critical changes on the review process, so that the large language model can process the remaining critical code change files more efficiently, reducing the total number of tags that the large language model needs to process, thereby speeding up the reasoning speed of the large language model, improving the efficiency of code review and analysis, and ensuring that the large language model can give priority to those code change files with high scores and more important, which helps to identify and solve key problems more quickly.

[0070] In some embodiments of the present application, step S12, compressing multiple code change files based on points and meta-information to obtain compressed multiple code change files specifically also includes: if the total number of tags in the multiple code change files after secondary compression is greater than the maximum number of tags received by the preset large language model, deleting the code with the change type of deletion in each code change file after secondary compression, to obtain multiple code change files after tertiary compression.

[0071] In the above embodiment, by deleting the code with the modification type of deletion, the amount of data that needs to be processed by the large language model is reduced, ensuring that the large language model focuses computing resources on more important code changes, that is, those newly added and edited codes, so that the computing power of the model can be more effectively utilized, and these changes can be analyzed and reviewed more deeply, thereby improving the quality and accuracy of code review. In addition, deleted code usually does not contain newly introduced logic or errors, so removing these codes from the review process helps reduce interference and makes the review process more focused.

[0072] In some embodiments of the present application, step S12, compressing multiple code change files based on points and meta-information to obtain compressed multiple code change files specifically also includes: if the total number of tags of the multiple code change files after three compressions is greater than the maximum number of tags received by the preset large language model, deleting the code with the change type of edit in each code change file after three compressions, to obtain multiple code change files after four compressions.

[0073] In the above embodiment, by preferentially deleting edit-type codes, it can be ensured that more important code changes (such as new function codes) are processed first, reducing the amount of data that needs to be processed by the large language model, which helps to improve the response speed and processing efficiency of the large language model. Especially when dealing with large projects, it can improve the accuracy of code review, especially in the review of key functions and main logic.

[0074] It should be noted that how to compress multiple code change files based on points and meta information, and obtain the compressed multiple code change files in the subsequent Figure 4 The steps shown are described in detail and will not be repeated here to avoid repetition.

[0075] Step S13, reviewing the compressed multiple code modification files based on a preset large language model to obtain a code review result.

[0076] In some embodiments of the present application, step S13, reviewing the compressed multiple code change files based on a preset large language model to obtain the code review result specifically includes: generating structural prompt words of the preset large language model according to the metadata and the compressed multiple code change files; reviewing the compressed multiple code change files based on the preset large language model and the structural prompt words to obtain the code review result.

[0077] Among them, the structural hint words are used to represent the review purpose of multiple code modification files.

[0078] In some embodiments of the present application, the structural prompt words may include: role information, which is used to indicate the role played by the large speech model; for example, the role information may indicate that the large language model plays the role of "code review assistant". Since senior software developers have good code review capabilities, the quality of code review can be improved by using the large language model to play the role of "code review assistant". Meta information of the project, which is used to indicate the basic information of the project; the basic information of the project may include but is not limited to information such as project language, code specifications, and change history. Change content, which is used to indicate the files that have been changed in the code base. Task information, which is used to indicate the review task of the large language model for code review; the review task may include but is not limited to code score, code quality, code change information, code change risk, and modification suggestions. For each review dimension, its specific content can be specified. For example, for code quality, the task information may include the structure, style, and ease of use of the review code. Review result feedback format information, which is used to indicate the feedback format of the large language model for the review result. Among them, different feedback formats can be designed for different review dimension information. For example, for code score, the feedback result can be specified as a value between 1 and 10, and for code quality, specific quality problems or no problems can be fed back.

[0079] In the above embodiment, customized structural prompt words are generated according to the project metadata and the compressed code change file, so that the large language model can better adapt to the knowledge of specific organizations and preset industry fields, thereby improving the applicability and accuracy of the large language model in specific organizations and preset industry fields. Furthermore, by including role information, project metadata, change content task information, and review result feedback format information in the structural prompt words, accurate prompt information can be provided for the large language model, which can improve the processing accuracy of the large language model, improve the accuracy of code review, and achieve comprehensiveness of code review.

[0080] It should be noted that how to review multiple compressed code modification files based on the preset large language model and obtain the code review results will be discussed later. Figure 5 The steps shown are described in detail and will not be repeated here to avoid repetition.

[0081] In some embodiments of the present application, although large language models perform well in general language processing tasks, they may not be able to accurately understand and generate code that meets the needs of specific organizations or industries. For example, different companies may have their own unique coding standards and best practices, and preset industries, such as the automotive industry, may have specific regulatory compliance and security requirements, which need to be considered by large language models when reviewing code.

[0082] In order to solve the above problems, the present application proposes a method for generating structural prompt words and a method for fine-tuning a large language model. First, the code specifications and best practices within the organization and the preset industry corresponding to the project are determined from the preset plug-in knowledge base based on the meta-information; secondly, the compressed multiple code change files are spliced ​​with the code specifications and best practices within the organization and the preset industry to obtain structural prompt words; then, according to the organization code and industry code corresponding to the project, a training data set is constructed; then, based on the training data set, the parameters of the preset large language model are fine-tuned, and then based on the fine-tuned and trained preset large language model and structural prompt words, the compressed multiple code change files are reviewed. Specific embodiments are as follows:

[0083] In some embodiments of the present application, generating structural prompt words of a preset large language model based on metadata and multiple compressed code change files specifically includes: determining project-related code information from a preset plug-in knowledge base based on the metadata, wherein the preset plug-in knowledge base contains code specifications and best practices within the organization and preset industry corresponding to the project; splicing the compressed multiple code change files and the code information to obtain structural prompt words.

[0084] Among them, code standards are a set of rules on how to write code, including naming conventions, code formats, comment standards, etc. For example, C++ code standards may include static variable naming rules, which help maintain code consistency and readability. Best practices refer to practices that are widely recognized and recommended in the software development process and are effective methods summarized based on experience. For example, best practices may include code review, unit testing, continuous integration, etc.

[0085] In the above embodiment, customized code review for specific organizations and industries is achieved by retrieving project-related code standards and best practices from the plug-in knowledge base, so that the large language model can more accurately understand and evaluate code changes, thereby improving the accuracy of code review. By generating customized structural prompt words based on the code standards and best practices within the organization and the preset industry, it is possible to provide background prompts for private code standards and preset industry fields, which helps to improve code quality and reduce potential defects and risks. The design of the plug-in knowledge base allows for easy addition or modification of project-related code information, and has good flexibility and scalability.

[0086] In some embodiments of the present application, based on a preset large language model and structural prompt words, multiple compressed code change files are reviewed to obtain code review results, which specifically includes: based on a preset large language model and structural prompt words that have been fine-tuned and trained, multiple compressed code change files are reviewed to obtain code review results.

[0087] Specifically, after generating the structural prompt words, the interface of the fine-tuned large language model is called, the structural prompt words are input, and the fine-tuned large language model outputs the code review results of multiple code modification files based on the structural prompt words.

[0088] In the above embodiment, the fine-tuned large language model can adapt to the specific needs of the organization and industry corresponding to the project, generate code review results that are more in line with the needs of the organization and industry corresponding to the project, and improve the accuracy of the code review of the project.

[0089] In some embodiments of the present application, the fine-tuning training method of the preset large language model includes: constructing a training data set according to the organization code and industry code corresponding to the project; fine-tuning the parameters of the preset large language model based on the training data set to obtain a preset large language model that has been fine-tuned and trained.

[0090] In other embodiments, after obtaining the code review result, the electronic device 10 may display it to the user through the client. The code review result may include a score. If there are defects or areas that can be improved in the code modification file, these defects may be displayed to the user in a form such as highlighting, so that the user can evaluate the code review result. Subsequently, the code review result obtained by the large language model may be directly used or manually corrected.

[0091] In the code review method based on a large language model in an embodiment of the present application, first, multiple code change files are obtained, each code change file includes a code change log; then, if the total number of tags of the multiple code change files is greater than the maximum number of tags received by the preset large language model, based on the updated metadata of the project and the code change log of each code change file, the score of each code change file is determined; then, based on the score and the metadata, the multiple code change files are compressed to obtain multiple compressed code change files; then, based on the metadata and the compressed multiple code change files, structural prompt words of the preset large language model are generated; finally, based on the preset large language model and the structural prompt words, the compressed multiple code change files are reviewed to obtain a code review result. Based on this, when the total number of tags in a code change file exceeds the processing capacity of a large language model, this application uses the project's metadata and code change log to compress multiple code change files, which can meet the processing capacity of a large language model while optimizing resource usage, reducing the interference of non-functional code changes on the reasoning of the large language model, ensuring that the large language model focuses on the review of important codes, improving the accuracy and relevance of the review, and being able to adapt to projects of different sizes and complexities, with good scalability. Based on the large language model, code is reviewed for multiple compressed code change files, which can utilize the excellent performance of the large language model and improve the quality and efficiency of the review results. In summary, this application achieves a comprehensive, efficient and accurate review of code changes, improves the accuracy and efficiency of code reviews, provides strong support for the software development process, and ensures the quality and security of software projects.

[0092] See also Figure 3 , which is a schematic diagram of the specific steps of step S11 in the code review method based on a large language model provided in one embodiment of the present application.

[0093] This embodiment is a specific description of step S11 in the above embodiment, and further describes how to determine the score of each code change file based on the updated project metadata and the code change log of each code change file. Specifically, it includes the following steps:

[0094] Step S110: determining the usage percentage of each programming language of the updated project according to the meta information.

[0095] In some embodiments of the present application, the usage ratio of each programming language used in the project, which file extensions in the project belong to external resources, the project type and other required meta information can be indicated in any configuration file of the project. For example, add main-lang:java (specify that the main programming language of the project is Java), external:.png.svg (specify that the image file extension in the project belongs to external resources), type:server (specify that the project type is a service project) and other required meta information in project.yaml (configuration file).

[0096] Specifically, the electronic device 10 may determine the meta information of the project according to the configuration file, and determine the usage ratio of each programming language of the updated project according to the meta information.

[0097] Step S111, determining a first score for each code-modified file according to the programming language and usage ratio of each code-modified file.

[0098] Specifically, the priority of each programming language of the updated project is determined based on the usage percentage of each programming language of the updated project. For example, the programming languages ​​used in the project are sorted in descending order of usage percentage as the first language, the second language, and the Nth language, wherein the first language is the main language of the project, that is, the language with the highest usage percentage in the project; the second language is the language with a usage percentage in the project that is only lower than the first language; and so on, the Nth language is the language with the lowest usage percentage in the project.

[0099] In some embodiments of the present application, if the programming language of the code modification file is consistent with the first language, the first score of the code modification file is determined to be 0.5 points; if the programming language of the code modification file is consistent with the second language, the first score of the code modification file is determined to be 0.3 points, and so on. If the programming language of the code modification file is consistent with the Nth language, the first score of the code modification file is determined to be 0.01 points. Among them, the first score is used to quantify and evaluate the consistency of the programming language of each code modification file with the programming language of the updated project. Code modification files with higher consistency may obtain higher first scores and will be reviewed first.

[0100] It should be noted that the size of the above-mentioned first integral is only an example and can be adjusted according to actual needs in practical applications. This application does not impose any restrictions on this.

[0101] Step S112: determining the second score of each code-changed file according to the code-changed log of each code-changed file.

[0102] Specifically, the difference code in each code file is determined according to the code change log of each code change file, such as deleted, added, and edited code, and the second score of each code change file is determined according to the type of the difference code contained in the code change log. The second score is used to quantify and evaluate the importance and impact of different types of code changes (such as addition, deletion, and editing) in each code change file on the updated project.

[0103] In some embodiments of the present application, if the code change file only contains new code or deleted code, the second score of the code change file is determined to be 0.3; if the code change file contains both new code and deleted code, the second score of the code change file is determined to be 0.5; if the code change file contains edited code, the second score of the code change file is determined to be the proportion of the edited code in all code change files*10, for example, the edited code in the main.java code change file accounts for 50% of all code change files, then the second score of the main.java code change file is 50%*10=0.5.

[0104] Step S113, determining the score of each code-modified file according to the first score and the second score.

[0105] In some embodiments of the present application, the first score and the second score are added to obtain the score of each code-modified file.

[0106] In an embodiment of the present application, by determining the usage ratio of each programming language in the project, the importance of the code change file can be more accurately evaluated, ensuring that changes in the main language receive more attention. By assigning a first score and a second score to each code change file, an automated scoring system is implemented, making the code review process more objective and quantitative. According to the score, the code change files can be prioritized, and those code changes that have the greatest impact on the project can be reviewed first. Through points, key code changes can be quickly identified and processed, the efficiency of code review can be improved, the workload of reviewers can be reduced, and review resources can be reasonably allocated to ensure that key codes are fully reviewed while reducing excessive attention to non-critical code. Combined with the first score and the second score, the impact of code changes can be more comprehensively evaluated, including the addition, deletion and editing of code. Through points. By accurately evaluating code changes, it is helpful to promptly discover and correct potential problems, improve code quality and the overall stability of the project.

[0107] See also Figure 4 , which is a schematic diagram of the specific steps of step S12 in the code review method based on a large language model provided in one embodiment of the present application.

[0108] This embodiment is a specific description of step S12 in the above embodiment, and further describes how to compress multiple code modification files based on points and meta information to obtain multiple compressed code modification files. Specifically, it includes the following steps:

[0109] Step S120, deleting the code-changed files that are designated to be excluded as indicated by the meta information from the multiple code-changed files, to obtain multiple code-changed files after the initial compression.

[0110] In some embodiments of the present application, the code modification files specified for exclusion indicated by the meta information are first deleted, for example, the specified external resource files in the meta information.

[0111] In the above embodiment, the code change files marked as "specified exclusion" are deleted according to the instructions of the meta information. Files marked as "specified exclusion" may be because the content is repeated with other changes, are no longer needed, or do not contribute substantially to the overall progress of the project, or are external resource files. By deleting unnecessary code change files, multiple code change files after the initial compression can be made more streamlined while avoiding the waste of computing power of the large language model in the subsequent code review process, thereby improving the efficiency of code review.

[0112] Step S121, if the total number of tags of the multiple code modification files after the initial compression is greater than the maximum number of tags received by the preset large language model, the code modification files below the preset score threshold among the multiple code modification files after the initial compression are deleted to obtain the multiple code modification files after the secondary compression.

[0113] In some embodiments of the present application, the score of a code change file is lower than a preset score threshold, indicating that the code change file is less important to the updated project. Therefore, after the total number of tags of the multiple code change files after the initial compression is still greater than the maximum number of tags received by the preset large language model, the code change files whose scores are lower than the preset score threshold are directly deleted from the multiple code change files after the initial compression. For example, the preset score threshold may be 2.

[0114] It should be noted that the preset integral threshold can be set according to actual needs, and this application does not impose any specific restrictions on this.

[0115] In the above embodiment, based on the scores of the code changed files, the code changed files with scores below a preset score threshold among the multiple code changed files after the initial compression are deleted, which helps to reduce the interference of non-critical changes on the review process, so that the large language model can process the remaining critical code changed files more efficiently, reducing the total number of tags that the large language model needs to process, thereby speeding up the reasoning speed of the large language model, improving the efficiency of code review and analysis, and ensuring that the large language model can give priority to those code changed files with high scores and more important, which helps to identify and solve key problems more quickly.

[0116] Step S122, if the total number of tags in the multiple code change files after the second compression is greater than the maximum number of tags received by the preset large language model, delete the code with the modification type of deletion in each code change file after the second compression to obtain multiple code change files after the third compression.

[0117] In some embodiments of the present application, if the total number of tags in the multiple code modification files after secondary compression is still greater than the maximum number of tags received by the preset large language model, the code with the modification type of deletion in each code modification file after secondary compression continues to be deleted.

[0118] In the above embodiment, by deleting the code with the modification type of deletion, the amount of data that needs to be processed by the large language model is reduced, ensuring that the large language model focuses computing resources on more important code changes, that is, those newly added and edited codes, so that the computing power of the model can be more effectively utilized, and these changes can be analyzed and reviewed more deeply, thereby improving the quality and accuracy of code review. In addition, deleted code usually does not contain newly introduced logic or errors, so removing these codes from the review process helps reduce interference and makes the review process more focused.

[0119] Step S123, if the total number of tags of the multiple code change files after three compressions is still greater than the maximum number of tags received by the preset large language model, delete the code with the modification type of edit in each code change file after three compressions to obtain multiple code change files after four compressions.

[0120] In some embodiments of the present application, if the total number of tags in multiple code modification files after three compressions is still greater than the maximum number of tags received by the preset large language model, the code with the modification type of edit in each code modification file after three compressions continues to be deleted.

[0121] In the above embodiment, by preferentially deleting edit-type codes, it can be ensured that more important code changes (such as new function codes) are processed first, reducing the amount of data that needs to be processed by the large language model, which helps to improve the response speed and processing efficiency of the large language model. Especially when dealing with large projects, it can improve the accuracy of code review, especially in the review of key functions and main logic.

[0122] In other embodiments, if the total number of tags of the multiple code change files after four compressions is still greater than the maximum number of tags received by the preset large language model, the corresponding code change files are deleted in order of the score of each code change file after four compressions from low to high until the total number of tags of the multiple code change files after compression is less than or equal to the maximum number of tags received by the preset large language model.

[0123] In an embodiment of the present application, when the total number of tags in a code change file exceeds the processing capacity of a large language model, the code change files (such as external resource files) specified for exclusion as indicated by the meta information are deleted first, thereby reducing unnecessary data processing and optimizing the utilization of resources of a large language model. Then, the code change files below the preset score threshold are deleted, focusing on more important code changes, thereby improving the efficiency of processing by the large language model. Then, the codes with a change type of deletion and a change type of editing are deleted in sequence, ensuring that the newly added key codes are processed first. After multiple compressions, if the total number of tags still exceeds the limit, the code change files are deleted in order of points, and the review scope is adjusted dynamically to ensure the flexibility and adaptability of the review process. In summary, by continuously compressing until the total number of tags in the code change file meets the maximum number of tags received by the large language model, it is ensured that the large language model can handle important code changes while avoiding exceeding its processing capacity, thereby improving the quality of code review, helping to discover and correct key issues, and being able to adapt to projects of different sizes and complexities, with good scalability.

[0124] See also Figure 5 , which is a schematic diagram of the specific steps of step S13 in the code review method based on a large language model provided in one embodiment of the present application.

[0125] This embodiment is a specific description of step S13 in the above embodiment, and further describes how to review multiple compressed code modification files based on a preset large language model to obtain code review results. Specifically, the following steps are included:

[0126] Step S130 , generating structure prompt words of a preset large language model according to the meta information and the compressed multiple code modification files.

[0127] Among them, the structural hint words are used to represent the review purpose of multiple code modification files.

[0128] In some embodiments of the present application, the structural prompt words may include: role information, which is used to indicate the role played by the large speech model; for example, the role information may indicate that the large language model plays the role of "code review assistant". Since senior software developers have good code review capabilities, the quality of code review can be improved by using the large language model to play the role of "code review assistant". Meta information of the project, which is used to indicate the basic information of the project; the basic information of the project may include but is not limited to information such as project language, code specifications, and change history. Change content, which is used to indicate the files that have been changed in the code base. Task information, which is used to indicate the review task of the large language model for code review; the review task may include but is not limited to code score, code quality, code change information, code change risk, and modification suggestions. For each review dimension, its specific content can be specified. For example, for code quality, the task information may include the structure, style, and ease of use of the review code. Review result feedback format information, which is used to indicate the feedback format of the large language model for the review result. Among them, different feedback formats can be designed for different review dimension information. For example, for code score, the feedback result can be specified as a value between 1 and 10, and for code quality, specific quality problems or no problems can be fed back.

[0129] In some embodiments of the present application, although large language models perform well in general language processing tasks, they may not be able to accurately understand and generate code that meets the needs of specific organizations or industries. For example, different companies may have their own unique coding standards and best practices, and preset industries, such as the automotive industry, may have specific regulatory compliance and security requirements, which need to be considered by large language models when reviewing code.

[0130] In order to solve the above problems, the present application proposes a method for generating structural prompt words and a method for fine-tuning a large language model. First, the code specifications and best practices within the organization and the preset industry corresponding to the project are determined from the preset plug-in knowledge base based on the meta-information; secondly, the compressed multiple code change files are spliced ​​with the code specifications and best practices within the organization and the preset industry to obtain structural prompt words; then, according to the organization code and industry code corresponding to the project, a training data set is constructed; then, based on the training data set, the parameters of the preset large language model are fine-tuned, and then based on the fine-tuned and trained preset large language model and structural prompt words, the compressed multiple code change files are reviewed. Specific embodiments are as follows:

[0131] In some embodiments of the present application, step S130, generating structural prompt words of a preset large language model based on the metadata and the compressed multiple code change files, specifically includes: determining the project-related code information from a preset plug-in knowledge base based on the metadata, wherein the preset plug-in knowledge base contains the code specifications and best practices within the organization and the preset industry corresponding to the project; splicing the compressed multiple code change files and the code information to obtain structural prompt words.

[0132] Among them, code standards are a set of rules on how to write code, including naming conventions, code formats, comment standards, etc. For example, C++ code standards may include static variable naming rules, which help maintain code consistency and readability. Best practices refer to practices that are widely recognized and recommended in the software development process and are effective methods summarized based on experience. For example, best practices may include code review, unit testing, continuous integration, etc.

[0133] In the above embodiment, customized code review for specific organizations and industries is achieved by retrieving project-related code standards and best practices from the plug-in knowledge base, so that the large language model can more accurately understand and evaluate code changes, thereby improving the accuracy of code review. By generating customized structural prompt words based on the code standards and best practices within the organization and the preset industry, it is possible to provide background prompts for private code standards and preset industry fields, which helps to improve code quality and reduce potential defects and risks. The design of the plug-in knowledge base allows for easy addition or modification of project-related code information, and has good flexibility and scalability.

[0134] It should be noted that how to generate the structure prompt words of the preset large language model based on the meta information and the compressed multiple code modification files will be discussed in the following section. Figure 6 The steps shown are described in detail and will not be repeated here to avoid repetition.

[0135] Step S131 , based on a preset large language model and structure prompt words, the compressed plurality of code modification files are reviewed to obtain a code review result.

[0136] In some embodiments of the present application, step S131, based on a preset large language model and structural prompt words, reviewing multiple compressed code change files to obtain code review results specifically includes: based on a preset large language model and structural prompt words that have been fine-tuned and trained, reviewing multiple compressed code change files to obtain code review results.

[0137] Specifically, after generating the structural prompt words, the interface of the fine-tuned large language model is called, the structural prompt words are input, and the fine-tuned large language model outputs the code review results of multiple code modification files based on the structural prompt words.

[0138] In the above embodiment, the fine-tuned large language model can adapt to the specific needs of the organization and industry corresponding to the project, generate code review results that are more in line with the needs of the organization and industry corresponding to the project, and improve the accuracy of the code review of the project.

[0139] In some embodiments of the present application, the fine-tuning training method of the preset large language model includes: constructing a training data set according to the organization code and industry code corresponding to the project; fine-tuning the parameters of the preset large language model based on the training data set to obtain a preset large language model that has been fine-tuned and trained.

[0140] It should be noted that how to fine-tune the preset large language model will be discussed later. Figure 7 The steps shown are described in detail and will not be repeated here to avoid repetition.

[0141] In an embodiment of the present application, customized structural prompt words are generated based on project metadata and compressed code change files, so that the large language model can better adapt to the knowledge of specific organizations and preset industry fields, thereby improving the applicability and accuracy of the large language model in specific organizations and preset industry fields. Furthermore, by including role information, project metadata, change content task information, and review result feedback format information in the structural prompt words, accurate prompt information can be provided for the large language model, which can improve the processing accuracy of the large language model, improve the accuracy of code review, and achieve comprehensiveness of code review.

[0142] See also Figure 6 , which is a schematic diagram of specific steps of step S130 in the code review method based on a large language model provided in one embodiment of the present application.

[0143] This embodiment is a specific description of step S130 in the above embodiment, and further describes how to generate structure prompt words of a preset large language model based on the meta information and multiple compressed code modification files. Specifically, it includes the following steps:

[0144] Step S140, determining project-related code information from a preset plug-in knowledge base according to the meta information.

[0145] The plug-in knowledge base is pre-set, and the code specifications and best practices of the organization and the preset industry corresponding to the project are stored in the plug-in knowledge base. For example, the organization corresponding to the project can be the company where the project is located, and the preset industry corresponding to the project can be the automotive industry.

[0146] In some embodiments of the present application, the project-related code information may include, but is not limited to, code specifications and best practices within the organization and preset industry corresponding to the project.

[0147] Specifically, the main programming language and main logic of the project are determined based on the project's meta information. When reviewing code change files, the code standards and best practices related to the current code change files are recalled from the external knowledge database based on the main programming language and main logic of the project, ensuring that the code review can take into account the code standards and best practices within the company and the preset industry.

[0148] In other embodiments, codes and code specifications that frequently change with the business may also be stored in the plug-in knowledge base, so that these codes and code specifications can be updated at any time to adapt to changes in the business.

[0149] Step S141, concatenating the compressed multiple code modification files and code information to obtain structure prompt words.

[0150] Specifically, the recalled code standards and best practices within the relevant organization and preset industry are spliced ​​into the structural prompt words, which can provide prompts for private code standards and background of preset industry fields, and can improve the accuracy and relevance of code review.

[0151] In an embodiment of the present application, customized code review for specific organizations and industries is implemented by retrieving project-related code specifications and best practices from an external knowledge base, so that the large language model can more accurately understand and evaluate code changes, thereby improving the accuracy of code review. By generating customized structural prompt words based on the code specifications and best practices within the organization and the preset industry, it is possible to provide background prompts for private code specifications and preset industry fields, which helps to improve code quality and reduce potential defects and risks. The design of the external knowledge base allows for easy addition or modification of project-related code information, and has good flexibility and scalability.

[0152] See also Figure 7 , which is a flow chart of a fine-tuning training method for a large language model provided in one embodiment of the present application.

[0153] In some embodiments of the present application, although large language models perform well in general language processing tasks, they may not be able to accurately understand and generate code that meets the needs of specific organizations or industries. For example, different companies may have their own unique coding standards and best practices, and preset industries, such as the automotive industry, may have specific regulatory compliance and security requirements, which need to be considered by large language models when reviewing code.

[0154] In order to solve the above problems, this application proposes a method for fine-tuning a large language model. First, a training data set is constructed according to the organization code and industry code corresponding to the project; second, the parameters of the preset large language model are fine-tuned based on the training data set to obtain a fine-tuned preset large language model, and then based on the fine-tuned preset large language model and structural prompt words, multiple compressed code change files are reviewed.

[0155] This embodiment further illustrates how to fine-tune a large language model. Specifically, the following steps are included:

[0156] Step S150, constructing a training data set according to the organization code and industry code corresponding to the project.

[0157] Specifically, collect and organize the organization codes corresponding to the project. These assembly codes are usually relatively stable and do not change frequently, such as the login process related to cars and specific component codes that do not change frequently within the company. Collect codes for preset industries, such as data models for the automotive industry. Integrate the organization codes and industry codes corresponding to the project into a training data set for subsequent fine-tuning training of the large language model.

[0158] In some embodiments of the present application, the codeQwen1.5 large language model is used for fine-tuning training.

[0159] Step S151, fine-tuning parameters of the preset large language model based on the training data set to obtain a preset large language model that has been fine-tuned and trained.

[0160] Specifically, the codeQwen1.5 large language model is fine-tuned based on the organization code and industry code corresponding to the project as the training data set. During the fine-tuning process, the parameters of the large language model are adjusted to better adapt to the code style and structure in the training data set. Through fine-tuning, the large language model can learn the specific programming patterns and best practices of organizations and industries.

[0161] In the embodiment of the present application, the large language model is fine-tuned according to the organization code and industry code corresponding to the project. The fine-tuned large language model can adapt to the specific needs of the organization and industry corresponding to the project, generate code review results that are more in line with the organization and industry needs corresponding to the project, and improve the accuracy of the code review of the project. The fine-tuned large language model can also more accurately identify potential defects and security vulnerabilities in the code, provide more specific code improvement suggestions, and thus improve the code quality.

[0162] See also Figure 8 , which is a functional module diagram of a code review device 100 based on a large language model provided in one embodiment of the present application.

[0163] In this embodiment, based on the above Figure 2 The present application also provides a code review device 100 based on a large language model, which can be used to execute the above-mentioned code review method based on a large language model, based on the same concept as the code review method based on a large language model in the illustrated embodiment. For ease of explanation, the schematic diagram of the composition of the embodiment of the code review device 100 based on a large language model only shows the parts related to the embodiment of the present application. Those skilled in the art can understand that the schematic structure does not constitute a limitation on the code review device 100 based on a large language model, and may include more or fewer components than shown in the diagram, or combine certain components, or arrange the components differently.

[0164] Specifically, the code review device 100 based on the large language model provided in the embodiment of the present application includes an acquisition module 110, a determination module 120, a compression module 130, and a review module 140.

[0165] The acquisition module 110 is used to acquire multiple code modification files.

[0166] Specifically, each code change file includes a code change log between a first file and a second file, and the code change log records the difference code between the second file and the first file (for example, the code whose change type is deletion, addition, or editing). The first file represents the code file in the original project, and the second file represents the code file in the updated project corresponding to the first file.

[0167] It should be noted that in the field of software development, a project usually refers to a comprehensive task or product, which consists of multiple types of files, including but not limited to source code modification files, configuration files, and resource files. As the project progresses and requirements evolve, these files will change over time, including but not limited to the addition of new features, the modification or deletion of old features, and the update of configuration files or resource files;

[0168] In some embodiments of the present application, the electronic device 10 can use a version control system (such as Git) command to obtain multiple code change files. Specifically, after receiving a code merge request from the version control system, the electronic device 10 pulls the merge record corresponding to the above code merge request from the version control system, and queries multiple code change files based on the merge record. Among them, Git is a powerful distributed version control system that can manage the source code of large open source software, and can also manage private documents and source code.

[0169] In other embodiments, multiple code modification files may be pre-stored in a preset document, and the preset document may be stored on the electronic device 10. When code review is required, the electronic device 10 directly reads the content in the preset document to obtain the code modification files.

[0170] The determination module 120 is used to determine the score of each code change file based on the updated project metadata and the code change log of each code change file if the total number of tags of multiple code change files is greater than the maximum number of tags received by the preset large language model.

[0171] In some embodiments of the present application, before providing multiple code change files to a large language model for processing, each code change file needs to be converted into a readable text form. When we convert multiple code change files into text format for processing by a large language model, these files are decomposed into a series of basic processing units, namely tokens. Among them, each token can be a word, a character, or a word group or phrase in the code. The number of tokens of each code change file refers to the number of words, symbols, or word group and phrases that have been processed by word segmentation contained in each code change file after being converted into text form, that is, the number of tokens. Therefore, the total number of tokens of multiple code change files is the total number of tokens decomposed after the multiple code change files are converted into text form.

[0172] In some embodiments of the present application, the preset large language model may be a codeQwen1.5 model, which is an artificial intelligence model specially designed for processing and analyzing code. The purpose of the model is to receive code change files and structural prompt words used to guide the model to perform code review as input, and the output is the code review result of the code change file. Among them, the maximum number of tokens that the codeQwen1.5 model can process may be 2048 tokens, which means that the total number of words, symbols or code snippets that it can effectively process in a single reasoning does not exceed 2048 tokens.

[0173] In some embodiments of the present application, during the software development process, especially for large projects, the code changes between different versions may be very large, resulting in the total number of tokens in the code change files in the project far exceeding the processing capacity of the large language model, thereby interfering with the reasoning effect of the large language model and affecting the accuracy and efficiency of code review. For example, a complex software project may have thousands of lines of code changes in one update, which may exceed 100,000 after conversion into tokens. In addition, changes to non-functional code, such as configuration file updates, changes to images and binary files, will also significantly increase the number of tokens.

[0174] In order to solve the above problems, the present application proposes a sorting algorithm and a compression algorithm. First, each code change file is scored based on the metadata of the updated project, such as the main programming language, function description, project type, and a list of unimportant files. Then, after scoring, the number of tokens of each code change file and the total number of tokens of all code change files are calculated. According to the window requirements of the large language model, such as the limit of 2048 tokens, all code change files are intelligently compressed to ensure that the total number of tokens of all code change files does not exceed the processing capacity of the large language model. The specific embodiments are as follows:

[0175] In some embodiments of the present application, determining the score of each code change file based on the metadata of the updated project and the code change log of each code change file specifically includes: determining the usage percentage of each programming language of the updated project according to the metadata; determining a first score of each code change file according to the programming language and usage percentage of each code change file; determining a second score of each code change file according to the code change log of each code change file; determining the score of each code change file according to the first score and the second score, for example, taking the sum of the first score and the second score as the score of each code change file.

[0176] Among them, the project's meta-information refers to some key information and contextual data about the project, such as programming language, function description, project type, list of unimportant files, code specifications, etc. This information helps to understand and handle project code changes.

[0177] In the above embodiment, by determining the usage ratio of each programming language in the project, the importance of the code change file can be more accurately evaluated, ensuring that changes in the main language receive more attention. By assigning a first score and a second score to each code change file, an automated scoring system is implemented, making the code review process more objective and quantitative. According to the score, the code change files can be prioritized, and those code changes that have the greatest impact on the project can be reviewed first. Through the score, key code changes can be quickly identified and processed, the efficiency of code review can be improved, the workload of the reviewer can be reduced, and review resources can be reasonably allocated to ensure that key codes are fully reviewed while reducing excessive attention to non-critical code. Combined with the first score and the second score, the impact of code changes can be more comprehensively evaluated, including the addition, deletion and editing of code. Through the score. By accurately evaluating code changes, it is helpful to promptly discover and correct potential problems, improve code quality and the overall stability of the project.

[0178] In other embodiments, if the total number of tags of multiple code change files is less than or equal to the maximum number of tags received by the preset large language model, there is no need to compress the code change files. The review module 140 directly reviews the compressed multiple code change files based on the preset large language model to obtain the code review results.

[0179] The compression module 130 is used to compress the multiple code modification files based on the points and the meta information to obtain the multiple compressed code modification files.

[0180] In some embodiments of the present application, compressing multiple code change files based on points and meta information to obtain the compressed multiple code change files specifically includes: deleting the specified excluded code change files indicated by the meta information in the multiple code change files to obtain the multiple code change files after the initial compression; if the total number of tags in the multiple code change files after the initial compression is greater than the maximum number of tags received by the preset large language model, deleting the code change files in the multiple code change files after the initial compression that are lower than the preset score threshold to obtain the multiple code change files after the second compression.

[0181] In the above embodiment, the code change files marked as "specified exclusion" are deleted according to the instructions of the meta information. Files marked as "specified exclusion" may be because the content is repeated with other changes, are no longer needed, or have no substantial contribution to the overall progress of the project, or are external resource files. By deleting unnecessary code change files, the multiple code change files after the initial compression can be made more streamlined while avoiding the waste of computing power of the large language model in the subsequent code review process, thereby improving the efficiency of code review. Further, based on the points of the code change files, the code change files below the preset score threshold in the multiple code change files after the initial compression are deleted, which helps to reduce the interference of non-critical changes on the review process, so that the large language model can process the remaining critical code change files more efficiently, reducing the total number of tags that the large language model needs to process, thereby speeding up the reasoning speed of the large language model, improving the efficiency of code review and analysis, and ensuring that the large language model can give priority to those code change files with high scores and more important, which helps to identify and solve key problems more quickly.

[0182] In some embodiments of the present application, multiple code change files are compressed based on points and meta-information to obtain the compressed multiple code change files, which specifically includes: if the total number of tags in the multiple code change files after secondary compression is greater than the maximum number of tags received by a preset large language model, the code with the change type of deletion in each code change file after secondary compression is deleted to obtain the multiple code change files after tertiary compression.

[0183] In the above embodiment, by deleting the code with the modification type of deletion, the amount of data that needs to be processed by the large language model is reduced, ensuring that the large language model focuses computing resources on more important code changes, that is, those newly added and edited codes, so that the computing power of the model can be more effectively utilized, and these changes can be analyzed and reviewed more deeply, thereby improving the quality and accuracy of code review. In addition, deleted code usually does not contain newly introduced logic or errors, so removing these codes from the review process helps reduce interference and makes the review process more focused.

[0184] In some embodiments of the present application, multiple code change files are compressed based on points and meta-information to obtain the compressed multiple code change files, which specifically includes: if the total number of tags of the multiple code change files after three compressions is greater than the maximum number of tags received by a preset large language model, the code with the change type of edit in each code change file after three compressions is deleted to obtain the multiple code change files after four compressions.

[0185] In the above embodiment, by preferentially deleting edit-type codes, it can be ensured that more important code changes (such as new function codes) are processed first, reducing the amount of data that needs to be processed by the large language model, which helps to improve the response speed and processing efficiency of the large language model. Especially when dealing with large projects, it can improve the accuracy of code review, especially in the review of key functions and main logic.

[0186] The review module 140 is used to review the compressed multiple code modification files based on a preset large language model to obtain a code review result.

[0187] In some embodiments of the present application, multiple compressed code change files are reviewed based on a preset large language model to obtain code review results, which specifically include: generating structural prompt words of the preset large language model based on metadata and the multiple compressed code change files; and reviewing the multiple compressed code change files based on the preset large language model and the structural prompt words to obtain code review results.

[0188] Among them, the structural hint words are used to represent the review purpose of multiple code modification files.

[0189] In some embodiments of the present application, the structural prompt words may include: role information, which is used to indicate the role played by the large speech model; for example, the role information may indicate that the large language model plays the role of "code review assistant". Since senior software developers have good code review capabilities, the quality of code review can be improved by using the large language model to play the role of "code review assistant". Meta information of the project, which is used to indicate the basic information of the project; the basic information of the project may include but is not limited to information such as project language, code specifications, and change history. Change content, which is used to indicate the files that have been changed in the code base. Task information, which is used to indicate the review task of the large language model for code review; the review task may include but is not limited to code score, code quality, code change information, code change risk, and modification suggestions. For each review dimension, its specific content can be specified. For example, for code quality, the task information may include the structure, style, and ease of use of the review code. Review result feedback format information, which is used to indicate the feedback format of the large language model for the review result. Among them, different feedback formats can be designed for different review dimension information. For example, for code score, the feedback result can be specified as a value between 1 and 10, and for code quality, specific quality problems or no problems can be fed back.

[0190] In the above embodiment, customized structural prompt words are generated according to the project metadata and the compressed code change file, so that the large language model can better adapt to the knowledge of specific organizations and preset industry fields, thereby improving the applicability and accuracy of the large language model in specific organizations and preset industry fields. Furthermore, by including role information, project metadata, change content task information, and review result feedback format information in the structural prompt words, accurate prompt information can be provided for the large language model, which can improve the processing accuracy of the large language model, improve the accuracy of code review, and achieve comprehensiveness of code review.

[0191] In some embodiments of the present application, although large language models perform well in general language processing tasks, they may not be able to accurately understand and generate code that meets the needs of specific organizations or industries. For example, different companies may have their own unique coding standards and best practices, and preset industries, such as the automotive industry, may have specific regulatory compliance and security requirements, which need to be considered by large language models when reviewing code.

[0192] In order to solve the above problems, the present application proposes a method for generating structural prompt words and a method for fine-tuning a large language model. First, the code specifications and best practices within the organization and the preset industry corresponding to the project are determined from the preset plug-in knowledge base based on the meta-information; secondly, the compressed multiple code change files are spliced ​​with the code specifications and best practices within the organization and the preset industry to obtain structural prompt words; then, according to the organization code and industry code corresponding to the project, a training data set is constructed; then, based on the training data set, the parameters of the preset large language model are fine-tuned, and then based on the fine-tuned and trained preset large language model and structural prompt words, the compressed multiple code change files are reviewed. Specific embodiments are as follows:

[0193] In some embodiments of the present application, generating structural prompt words of a preset large language model based on metadata and multiple compressed code change files specifically includes: determining project-related code information from a preset plug-in knowledge base based on the metadata, wherein the preset plug-in knowledge base contains code specifications and best practices within the organization and preset industry corresponding to the project; splicing the compressed multiple code change files and the code information to obtain structural prompt words.

[0194] Among them, code standards are a set of rules on how to write code, including naming conventions, code formats, comment standards, etc. For example, C++ code standards may include static variable naming rules, which help maintain code consistency and readability. Best practices refer to practices that are widely recognized and recommended in the software development process and are effective methods summarized based on experience. For example, best practices may include code review, unit testing, continuous integration, etc.

[0195] In the above embodiment, customized code review for specific organizations and industries is achieved by retrieving project-related code standards and best practices from the plug-in knowledge base, so that the large language model can more accurately understand and evaluate code changes, thereby improving the accuracy of code review. By generating customized structural prompt words based on the code standards and best practices within the organization and the preset industry, it is possible to provide background prompts for private code standards and preset industry fields, which helps to improve code quality and reduce potential defects and risks. The design of the plug-in knowledge base allows for easy addition or modification of project-related code information, and has good flexibility and scalability.

[0196] In some embodiments of the present application, based on a preset large language model and structural prompt words, multiple compressed code change files are reviewed to obtain code review results, which specifically includes: based on a preset large language model and structural prompt words that have been fine-tuned and trained, multiple compressed code change files are reviewed to obtain code review results.

[0197] Specifically, after generating the structural prompt words, the interface of the fine-tuned large language model is called, the structural prompt words are input, and the fine-tuned large language model outputs the code review results of multiple code modification files based on the structural prompt words.

[0198] In the above embodiment, the fine-tuned large language model can adapt to the specific needs of the organization and industry corresponding to the project, generate code review results that are more in line with the needs of the organization and industry corresponding to the project, and improve the accuracy of the code review of the project.

[0199] In some embodiments of the present application, the fine-tuning training method of the preset large language model includes: constructing a training data set according to the organization code and industry code corresponding to the project; fine-tuning the parameters of the preset large language model based on the training data set to obtain a preset large language model that has been fine-tuned and trained.

[0200] In other embodiments, after obtaining the code review result, the electronic device 10 may display it to the user through the client. The code review result may include a score. If there are defects or areas that can be improved in the code modification file, these defects may be displayed to the user in a form such as highlighting, so that the user can evaluate the code review result. Subsequently, the code review result obtained by the large language model may be directly used or manually corrected.

[0201] In the code review device 100 based on the large language model of the above embodiment, multiple code change files are obtained through the acquisition module 110, wherein each of the multiple code change files includes a code change log; if the total number of tags of the multiple code change files is greater than the maximum number of tags received by the preset large language model, the determination module 120 determines the score of each code change file based on the metadata of the updated project and the code change log of each code change file; the compression module 130 compresses the multiple code change files based on the score and the metadata to obtain multiple compressed code change files; the review module 140 generates the structural prompt words of the preset large language model based on the metadata and the compressed multiple code change files. Based on this, when the total number of tags in a code change file exceeds the processing capacity of a large language model, this application uses the project's metadata and code change log to compress multiple code change files, which can meet the processing capacity of a large language model while optimizing resource usage, reducing the interference of non-functional code changes on the reasoning of the large language model, ensuring that the large language model focuses on the review of important codes, improving the accuracy and relevance of the review, and being able to adapt to projects of different sizes and complexities, with good scalability. Based on the large language model, code is reviewed for multiple compressed code change files, which can utilize the excellent performance of the large language model and improve the quality and efficiency of the review results. In summary, this application achieves a comprehensive, efficient and accurate review of code changes, improves the accuracy and efficiency of code reviews, provides strong support for the software development process, and ensures the quality and security of software projects.

[0202] Combination Figure 1 As shown, in some embodiments of the present application, the electronic device 10 includes, but is not limited to, a memory 11, a processor 12, and a computer program stored in the memory 11 and executable on the processor 12, such as a code review program. When the computer program is executed by the processor, a code review method based on a large language model as in the above-mentioned embodiment is implemented.

[0203] Figure 1 Only the electronic device 10 having the memory 11 and the processor 12 is shown, and those skilled in the art can understand that Figure 1 The structure shown does not constitute a limitation on the electronic device 10 , and the electronic device 10 may include fewer or more components than shown in the figure, or combine some components, or arrange the components differently.

[0204] The memory 11 in the electronic device 10 stores multiple computer-readable instructions to implement a code review method based on a large language model, and the processor 12 can execute the multiple instructions to achieve: obtaining multiple code change files, wherein each of the multiple code change files includes a code change log; if the total number of tags of the multiple code change files is greater than the maximum number of tags received by the preset large language model, based on the updated metadata of the project and the code change log of each code change file, determining the score of each code change file; compressing the multiple code change files based on the score and the metadata to obtain multiple compressed code change files; reviewing the compressed multiple code change files based on the preset large language model to obtain a code review result.

[0205] Specifically, the specific implementation method of the processor 12 for the above instructions can refer to Figure 2 The description of the relevant steps in the corresponding embodiments will not be repeated here.

[0206] Those skilled in the art will appreciate that the schematic diagram is merely an example of the electronic device 10 and does not constitute a limitation on the electronic device 10. The electronic device 10 may be a bus-type structure or a star-type structure. The electronic device 10 may also include more or less other hardware or software than shown in the figure, or a different arrangement of components. For example, the electronic device 10 may also include input and output devices, network access devices, etc.

[0207] It should be noted that the electronic device 10 is only an example, and other existing or future electronic products that are suitable for the present application should also be included in the protection scope of the present application and included here by reference.

[0208] Among them, the memory 11 includes at least one type of computer-readable medium, and the computer-readable medium can be non-volatile or volatile. Computer-readable media include flash memory, mobile hard disk, multimedia card, card-type memory (such as SD memory, DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of the electronic device 10, such as a mobile hard disk of the electronic device 10. In other embodiments, the memory 11 can also be an external storage device of the electronic device 10, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 10. The memory 11 can not only be used to store application software and various types of data installed in the electronic device 10, such as the code of a code review program, etc., but also can be used to temporarily store data that has been output or is to be output.

[0209] In some embodiments, the processor 12 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 12 is the control core (Control Unit) of the electronic device 10, and uses various interfaces and lines to connect various components of the entire electronic device 10, and executes various functions and processes data of the electronic device 10 by running or executing programs or modules stored in the memory 11 (for example, executing a code review program, etc.), and calling data stored in the memory 11.

[0210] The processor 12 executes the operating system of the electronic device 10 and various installed applications. The processor 12 executes the application to implement the steps in the above-mentioned embodiment of the code review method based on a large language model, for example Figure 2-Figure 7 Steps shown.

[0211] Exemplarily, the computer program may be divided into one or more modules / units, one or more modules / units are stored in the memory 11, and executed by the processor 12 to complete the present application. One or more modules / units may be a series of computer-readable instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device 10. For example, the computer program may be divided into an acquisition module 110, a determination module 120, a compression module 130, and a review module 140.

[0212] An embodiment of the present application also provides a computer-readable medium, in which computer-readable instructions are stored. The computer-readable instructions are executed by a processor in the electronic device 10 to implement a code review method based on a large language model in any of the above embodiments.

[0213] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a computer-readable medium, including a number of instructions for enabling a computer device (which can be a personal computer, a computer device or a network device, etc.) or a processor 12 to execute a part of a code review method based on a large language model in various embodiments of the present application.

[0214] If the module / unit integrated in the electronic device 10 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware devices through a computer program. The computer program can be stored in a computer-readable medium, and when the computer program is executed by the processor 12, the steps of each of the above-mentioned method embodiments can be implemented.

[0215] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. Computer readable media may include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory and other memory, etc.

[0216] Furthermore, the computer-readable medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.

[0217] The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. Figure 1 Only one arrow is used in the figure, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 11 and at least one processor 12, etc.

[0218] It should be noted that the computer-readable medium of the embodiments of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above.

[0219] In some embodiments of the present application, a computer-readable medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device. In an embodiment of the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device.

[0220] In the several embodiments provided in this application, it should be understood that the disclosed methods and related devices can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation.

[0221] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0222] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0223] In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the specification can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any specific order.

[0224] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.

Claims

1. A code review method based on a large language model, characterized in that: The method comprises: Acquire a plurality of code change files, wherein each of the plurality of code change files comprises a code change log; If the total number of tags of the plurality of code-changed files is greater than the maximum number of tags received by the preset large language model, determining the score of each code-changed file based on the updated meta information of the project and the code-changed log of each code-changed file; Compressing the multiple code-modified files based on the points and the meta-information to obtain multiple compressed code-modified files; The compressed multiple code modification files are reviewed based on a preset large language model to obtain a code review result.

2. The code review method based on a large language model according to claim 1, characterized in that: The compressing the multiple code modification files based on the points and the meta information to obtain the compressed multiple code modification files comprises: Deleting the code-changed files that are designated for exclusion as indicated by the meta information from the plurality of code-changed files, to obtain a plurality of code-changed files that have been initially compressed; If the total number of tags of the multiple code-modified files after the initial compression is greater than the maximum number of tags received by the preset large language model, the code-modified files whose scores are lower than a preset score threshold among the multiple code-modified files after the initial compression are deleted to obtain the multiple code-modified files after the secondary compression.

3. The code review method based on a large language model as claimed in claim 2, characterized in that: The step of compressing the plurality of code modification files based on the points and the meta information to obtain the plurality of compressed code modification files further comprises: If the total number of tags in the multiple code modification files after the second compression is greater than the maximum number of tags received by the preset large language model, the code with the modification type of deletion in each code modification file after the second compression is deleted to obtain the multiple code modification files after the third compression.

4. The code review method based on a large language model as claimed in claim 3, characterized in that: The step of compressing the plurality of code modification files based on the points and the meta information to obtain the plurality of compressed code modification files further comprises: If the total number of tags in the multiple code modification files after the three compressions is greater than the maximum number of tags received by the preset large language model, the code with the modification type of edit in each code modification file after the three compressions is deleted to obtain the multiple code modification files after the four compressions.

5. The code review method based on a large language model according to claim 1, characterized in that: The determining the score of each code-changed file based on the meta-information of the project and the code-changed log of each code-changed file comprises: Determine, based on the meta information, a usage percentage of each programming language of the updated project; Determining a first score for each of the modified code files according to the programming language of each of the modified code files and the usage ratio; Determine a second score of each code-modified file according to the code-modified log of each code-modified file; The score of each code-modified file is determined according to the first score and the second score.

6. The code review method based on a large language model according to claim 1, characterized in that: The code review result obtained by reviewing the compressed multiple code modification files based on the preset large language model includes: generating structure prompt words of the preset large language model according to the meta information and the compressed multiple code modification files; Based on the preset large language model and the structural prompt words, the compressed multiple code modification files are reviewed to obtain code review results.

7. The code review method based on a large language model according to claim 6, characterized in that: The code review result obtained by reviewing the compressed multiple code modification files based on the preset large language model and the structural prompt words includes: Based on the preset large language model that has been fine-tuned and trained and the structural prompt words, the compressed multiple code change files are reviewed to obtain the code review result.

8. The code review method based on a large language model as claimed in claim 7, characterized in that: The fine-tuning training method of the preset large language model that has undergone fine-tuning training includes: Construct a training data set according to the organization code and industry code corresponding to the project; Fine-tune the parameters of the preset large language model based on the training data set to obtain the fine-tuned preset large language model.

9. The code review method based on a large language model as claimed in claim 6, characterized in that: The generating of the structure prompt words of the preset large language model according to the meta information and the compressed multiple code modification files comprises: Determine the code information related to the project from a preset plug-in knowledge base according to the meta information, wherein the preset plug-in knowledge base contains code specifications and best practices within the organization and preset industry corresponding to the project; The compressed multiple code modification files and the code information are spliced ​​to obtain the structure prompt word.

10. A code review device based on a large language model, characterized in that: The device comprises: An acquisition module, configured to acquire a plurality of code change files, wherein each of the plurality of code change files comprises a code change log; a determination module, configured to determine a score of each code change file based on updated project meta information and a code change log of each code change file if the total number of tags of the plurality of code change files is greater than a maximum number of tags received by a preset large language model; A compression module, used for compressing the multiple code modification files based on the points and the meta information to obtain multiple compressed code modification files; The review module is used to review the compressed multiple code modification files based on a preset large language model to obtain a code review result.

11. An electronic device, characterized in that: The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the steps of the code review method based on a large language model as described in any one of claims 1 to 9 are implemented.

12. A computer-readable medium, characterized in that The computer-readable medium stores a computer program, which, when executed by a processor, implements the steps of the code review method based on a large language model as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Code review method and device, electronic equipment and medium

    CN117648931A

  • Rich text code review method and system based on large language model and medium

    CN118152287A

  • Code review method and system

    CN118349454A

  • Automatic code review method and system based on code large model

    CN119025120A

  • Code review method and device

    CN119201210A

Cited By

  • Software development system management method and system based on big data

    CN120523442A

  • A hybrid intelligent code review system and method based on model agent layer packaging

    CN122816599A