Code auditing method, system and equipment based on large model and medium
Through the multimodal large model to conduct basic code logic review and multi-dimensional standard review, combined with the server-side compatibility review, the problem of the inability to guarantee the quality of code after generation in the existing technology is solved, and the code quality is guaranteed and the development efficiency is improved.
Patent Information
- Application Number
- CN202510852115.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-24
- Publication Date
- 2025-10-17
AI Technical Summary
Existing programming assistance tools lack an effective review mechanism after code generation, resulting in the inability to guarantee the quality of the generated code and making it difficult to adapt to the needs of complex development scenarios.
Through the multimodal large model, basic code logic review and multi-dimensional standard review are carried out, combined with the compatibility review on the server side, an end-to-end intelligent programming assistance framework is built to achieve comprehensive and multi-dimensional review of the generated code.
Ensure that the generated code meets project requirements, improve code quality and development efficiency, and ensure the stability and reliability of software development in complex scenarios.
Smart Images

Figure CN120803524A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of software development, in particular to a code review method, system, device and medium based on a large model. BACKGROUND
[0002] With the rapid development of artificial intelligence technology, intelligent programming assistance tools have gradually become a research hotspot in the field of software development. From early code completion plug-ins to code generation models based on statistical machine learning, and to large code models based on deep learning in recent years, programming assistance technology has undergone a paradigm shift from rule-driven to data-driven. However, existing programming assistance tools still have significant defects in code generation accuracy, multi-modal context understanding, dynamic quality review, and adaptive optimization, which restrict their widespread application in complex development scenarios.
[0003] Currently, traditional programming assistance tools mainly rely on static syntax rule libraries and limited pattern matching techniques. The core problems include weak context understanding, such as when dealing with complex requirements involving multi-module interaction, the tool cannot associate interface definitions and function logic scattered in the project, resulting in significant deviation of completion suggestions from the developer's true intentions; lack of multi-modal data processing, such as existing tools usually only process pure text code, ignoring the naturally existing multi-modal information in the software development process; and rigid static review mechanism, such as code quality review generally relies on pre-defined rules, making it difficult to adapt to dynamic code programming requirements.
[0004] Based on the above problems, existing technologies introduce large models containing multi-modal encoders to fuse and process different modal information of code, such as syntax, semantics, control flow, and data flow, in order to improve the large model's understanding of code structure. However, this type of technology is mostly optimized for the code generation stage, lacks further review after code generation, and does not further verify the generated code, i.e., does not incorporate a self-evolution review scheme to optimize the output results, and cannot guarantee the code quality of the generated results. Therefore, existing technologies lack a review mechanism for large model generated code to ensure the reliability of the generated code. SUMMARY
[0005] Therefore, the present application provides a code review method, system, device and medium based on a large model to solve the problem that existing technologies ignore effective review of large model generated code, thereby affecting the quality of generated code, failing to adapt to user's auxiliary coding tool scene requirements, and being difficult to guarantee software development efficiency and generated code quality in complex scenarios.
[0006] In a first aspect, the present application provides a code review method based on a large model, applied to a local end, the method comprising:
[0007] obtaining a first code, the first code being generated by a multi-modal large model based on a project code requirement;
[0008] performing a basic code logic audit on the first code, and updating the first code based on a basic code logic audit result to obtain a second code;
[0009] performing a multi-dimensional standard audit on the second code based on the project code requirement, and submitting the second code to a server based on a multi-dimensional standard audit result, so that the server performs a compatibility audit on the second code, and merges the second code with associated code based on a compatibility audit result, the associated code being code associated with the second code in terms of the project code requirement.
[0010] The code audit method based on a large model of the present application is applied to a local end, and specifically obtains a first code generated by a multi-modal large model based on a project code requirement, performs a basic code logic audit on the first code to improve the basic quality of the first code, and further adapts to project specifications in combination with a multi-dimensional standard audit to ensure the standardization and compliance of the second code. In addition, the integration compatibility of the second code is enhanced through a compatibility audit of a server end, thereby ensuring the stability of the project. Through the multi-end and multi-dimensional code audit of the above design, the code generated by the large model is more in line with the project requirement, thereby ensuring the code generation capability, and in combination with the multi-type audit, the generated code is effectively audited, thereby ensuring the quality of the generated code, which is helpful to improve the software development efficiency in a complex scenario.
[0011] In an optional implementation, performing a basic code logic audit on the first code, and updating the first code based on a basic code logic audit result to obtain a second code, comprises:
[0012] constructing a first prompt word library, the first prompt word library containing at least one of model prompt words determined by programming knowledge, code specifications and typical codes;
[0013] inputting each model prompt word in the first prompt word library and the first code into the multi-modal large model respectively to obtain a first model output result;
[0014] if the first model output result is that the first code has no problem, calculating a preset evaluation index of the first code, and determining the first code as the second code when the preset evaluation index meets a preset threshold.
[0015] The present application converts programming knowledge, code specifications and typical codes into corresponding model prompt words, and performs a basic programming logic audit on the generated code by using various model prompt words and a multi-modal large model, so as to realize comprehensive and multi-dimensional code basic audit, thereby significantly improving the software development efficiency while ensuring the code quality.
[0016] In an optional embodiment, the code review method based on a large model further comprises:
[0017] If the first model output result is that the first code has a problem, a repair scheme is generated by using the multi-modal large model, the repair scheme is determined by the problem of the first code; the first code is repaired according to the repair scheme, and the step of inputting each model prompt word in the first prompt word library and the first code into the multi-modal large model respectively to obtain the first model output result is returned until the first model output result is that the first code has no problem and the preset evaluation index meets the preset threshold, and the first code is determined as the second code;
[0018] Or, when the preset evaluation index does not meet the preset threshold, an optimization scheme is generated by using the multi-modal large model, the optimization scheme is determined by the preset evaluation index; the first code is optimized according to the optimization scheme, and the step of inputting each model prompt word in the first prompt word library and the first code into the multi-modal large model respectively to obtain the first model output result is returned until the preset evaluation index meets the preset threshold, and the first code is determined as the second code.
[0019] When the multi-modal large model finds a code problem or a performance index problem during the basic code logic review of the code by using the multi-modal large model, the corresponding repair or optimization scheme is directly generated and the corresponding code repair or optimization is performed, and the review mechanism is repeated until the code passes the review completely. Through the above-mentioned automatic repair cycle and the optimization mechanism driven by the quantitative index, the intelligentization, standardization and high efficiency of the code quality guarantee can be realized.
[0020] In an optional embodiment, the second code is audited based on project code requirements in multiple dimensions, and the second code is submitted to a server based on the multi-dimensional standard audit result, comprising:
[0021] The corresponding dimension prompt words are determined based on the project code requirements and the preset audit dimensions, and the preset audit dimensions at least include syntax correctness audit, semantic consistency audit, security compliance audit and design pattern matching audit;
[0022] The second prompt word library is constructed based on each dimension prompt word;
[0023] Each dimension prompt word in the second prompt word library and the second code are input into the multi-modal large model to obtain a second model output result;
[0024] When the second model output result is that the second code has no problem, the second code is submitted to the server.
[0025] The present application can comprehensively cover the key dimensions of code quality by designing the dimension prompt words including syntax correctness auditing, semantic consistency auditing, security compliance auditing and design pattern matching auditing, and combining each dimension prompt word with a multi-modal large model to perform fine-grained auditing on the second code that passes the initial audit, so as to realize the fine-grained, standardized and intelligent code auditing, and further guarantee the quality of the code corresponding to the server to be submitted.
[0026] In an optional implementation, the code auditing method based on a large model further includes:
[0027] When the second model output result is that the second code has problems, a modification scheme is generated by using the multi-modal large model, the modification scheme is determined by the problems existing in the second code;
[0028] According to the modification scheme, the second code is modified, and the steps of inputting each dimension prompt word in the second prompt word library and the second code into the multi-modal large model to obtain the second model output result are returned until the second model output result is that the second code has no problems, and the second code is submitted to the server.
[0029] When the multi-modal large model finds the code problems, the corresponding modification scheme is directly generated and the corresponding code is modified, and the auditing mechanism is repeated until the code has no problems, through the above-mentioned automatic repair closed loop and the optimization mechanism of multiple iterations of auditing, the intelligent, standardized and efficient code quality guarantee is realized.
[0030] In an optional implementation, the first code is obtained, including:
[0031] The project code requirement includes at least one of the user prompt word and the model input data;
[0032] The target function vector matched with the user prompt word is retrieved from the code index library, and the code index library is constructed by processing the function vectors of a plurality of codes;
[0033] After the model input data is preprocessed, the processed data is obtained, and the processed data, the user prompt word and the target function vector are input into the multi-modal large model, and the first code is output correspondingly.
[0034] The present application retrieves the target function vector with the most matched semantics from the code index library by the user prompt word, inputs the multi-modal large model based on the user prompt word and combines the model input data and the target function vector, so that the model output can more comprehensively understand the complete code of the requirement and the context, and the generated code is more suitable for the actual business scenario requirement.
[0035] In an optional embodiment, the construction process of the code index library comprises:
[0036] Obtaining a plurality of project codes;
[0037] Respectively analyzing each project code to determine the corresponding code function;
[0038] Respectively performing vectorization processing on each code function to obtain a corresponding function vector;
[0039] Respectively storing each function vector locally, and constructing a code index library based on each function vector and its corresponding storage location.
[0040] The present application can realize the storage and retrieval of code semantics by analyzing the corresponding code functions of each project code, performing function vectorization processing, and respectively storing each function vector to construct a code index library, thereby accelerating the software development efficiency in complex scenarios to a certain extent.
[0041] In an optional embodiment, the code review method based on a large model further comprises:
[0042] Receiving a problem report fed back by the server side, the problem report being fed back by the server side based on the compatibility review result of the second code;
[0043] Feeding back the problem report to the corresponding user, so that the user optimizes the project code requirements according to the problem report.
[0044] The present application can make the user immediately adjust the project code requirements by designing the instant feedback of the server-side compatibility review to find problems, which helps to ensure the quality of the generated code and improves the software development efficiency in complex scenarios.
[0045] In a second aspect, the present application provides a code review method based on a large model, applied to a server side, the method comprising:
[0046] Receiving the second code submitted by the local side, the second code being obtained by the local side from the first code, the first code being generated by a multi-modal large model based on project code requirements; performing basic code logic review on the first code, and updating the first code based on the basic code logic review result to obtain the second code; performing multi-dimensional standard review on the second code based on the project code requirements, and sending the multi-dimensional standard review result;
[0047] Performing compatibility review on the second code, and merging the second code with the associated code based on the compatibility review result, the associated code being a code associated with the second code in terms of project code requirements.
[0048] The code auditing method based on the large model of the application is applied to a server side, specifically by receiving second code submitted by a local side after basic code logic auditing and multi-dimensional standard auditing, simultaneously performing compatibility auditing on the second code, and merging the second code with associated code based on the compatibility auditing result, the integration compatibility of the second code can be enhanced, and the stability of the project is ensured, through the multi-end and multi-dimensional code auditing of the above design, the code generated by the large model is more in line with the project requirements, and the code generation capability is ensured, and the generated code is effectively audited by combining multiple types of auditing, and the quality of the generated code is further ensured, which is helpful to improve the software development efficiency in complex scenarios.
[0049] In an optional implementation, the compatibility auditing on the second code and the merging of the second code with the associated code based on the compatibility auditing result include:
[0050] Obtaining a current running environment of the server;
[0051] Retrieving the code associated with the second code in terms of project code requirements by using a multi-modal large model to obtain associated code;
[0052] Constructing a third prompt word library based on the current running environment and the associated code, the third prompt word library containing at least one of model prompt words determined by dependency conflicts, interface changes, interface mismatches, resource leaks, and server performance;
[0053] Inputting each model prompt word in the third prompt word library and the second code into the multi-modal large model to obtain a third model output result;
[0054] When the third model output result is that the second code has no problem, merging the second code with the associated code.
[0055] By obtaining the current running environment of the server and the code associated with the second code in terms of project code requirements, and constructing a third prompt word library, the compatibility of the second code is audited by using each model prompt word and a multi-modal large model, which can comprehensively audit multi-dimensional compatibility risks, and the accuracy, reliability and stability of the code generated by the large model are ensured.
[0056] In an optional implementation, the code auditing method based on the large model further includes:
[0057] When the third model output result is that the second code has a problem, generating a problem report and feeding back the problem report to the local side; wherein the problem report is determined by the problem of the second code.
[0058] The application can automatically generate a problem report containing specific problem types and feed back to the local end when the third model output result is problematic, can realize timely feedback of problems, and can further help to obtain the generated code expected by the user according to the feedback problems.
[0059] In a third aspect, the application provides a code review system based on a large model, which comprises:
[0060] a local end and a server end;
[0061] The local end is configured to execute the code review method based on the large model of the first aspect or any of the corresponding embodiments thereof.
[0062] The server end is configured to execute the code review method based on the large model of the second aspect or any of the corresponding embodiments thereof.
[0063] The code review system based on the large model of the application can realize multi-end and multi-dimensional code review through the corresponding design of the local end and the server end, so that the code generated by the large model is more in line with the project requirements, further guarantees the code generation capability, and effectively reviews the generated code in combination with multiple types of review mechanisms, so as to effectively ensure the quality of the generated code and further help to improve the software development efficiency in complex scenarios.
[0064] In a fourth aspect, the application provides a computer device, which comprises a memory and a processor, the memory and the processor are in communication connection with each other, the memory stores computer instructions, and the processor executes the code review method based on the large model of the first aspect or any of the corresponding embodiments thereof, or the code review method based on the large model of the second aspect or any of the corresponding embodiments thereof by executing the computer instructions.
[0065] In a fifth aspect, the application provides a computer readable storage medium, which stores computer instructions, and the computer instructions are used to make the computer execute the code review method based on the large model of the first aspect or any of the corresponding embodiments thereof, or the code review method based on the large model of the second aspect or any of the corresponding embodiments thereof.
[0066] The large model-based code auditing method and system of the present application generate a first code corresponding to the project code requirements through a multi-modal large model, and perform a local end-based basic code logic audit on the first code to improve the basic quality of the first code; at the same time, a multi-dimensional standard audit is combined to further adapt to the project specifications, which can greatly ensure the standardization and compliance of the second code; in addition, a server end-based compatibility audit is designed to enhance the integration compatibility of the second code, thereby ensuring the stability of the project; the above multi-end and multi-dimensional code auditing designed by the present application not only makes the large model generated code more in line with the project requirements, thereby ensuring the code generation capability, but also combines multiple types of audits to effectively audit the generated code, thereby ensuring the quality of the generated code, which helps to improve the software development efficiency in complex scenarios. BRIEF DESCRIPTION OF DRAWINGS
[0067] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the specific embodiments or prior art description will be briefly introduced as follows. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can also obtain other drawings according to these drawings without creative labor.
[0068] Figure 1 is a flowchart of a large model-based code auditing method according to an embodiment of the present application;
[0069] Figure 2 is a flowchart of another large model-based code auditing method according to an embodiment of the present application;
[0070] Figure 3 is a flowchart of still another large model-based code auditing method according to an embodiment of the present application;
[0071] Figure 4 is a flowchart of yet another large model-based code auditing method according to an embodiment of the present application;
[0072] Figure 5 is a structural block diagram of a large model-based code auditing system according to an embodiment of the present application;
[0073] Figure 6 is a working schematic diagram of an intelligent programming assistance system based on a multi-modal code large model;
[0074] Figure 7 is a flowchart of a project index;
[0075] Figure 8 is a flowchart of self-evolution auditing;
[0076] Figure 9is a process schematic diagram of multi-dimensional code review;
[0077] Figure 10 is a structural schematic diagram of a computer device of an embodiment of the present application. DETAILED DESCRIPTION
[0078] To make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0079] Currently, traditional programming assistance tools mainly rely on static syntax rule libraries and limited pattern matching techniques, and the core problems are reflected in the following three aspects:
[0080] 1. Weak ability of context understanding: Rule-based code completion tools, such as Eclipse, IDE (Integrated Development Environment) plug-ins, etc., can only recognize local syntax structures, and lack global modeling capabilities for code semantics, development intentions, and cross-file contexts. For example, when dealing with complex requirements involving multi-module interaction, the tool cannot associate interface definitions and function logic scattered in the project, resulting in significant deviation of completion suggestions from the developer's real intentions.
[0081] 2. Lack of multi-modal data processing: Existing tools usually only process pure text code, ignoring the naturally existing multi-modal information in the software development process, such as development requirement documents, UML (UML-Unified Modeling Language) diagrams, log files, API (Application Programming Interface) documents, etc. Research shows that more than 60% of programming errors are caused by requirement understanding deviation or cross-modal information inconsistency, and traditional tools cannot effectively avoid such problems through single-modal code analysis.
[0082] 3. Static auditing mechanism is rigid: Code quality auditing generally relies on pre-defined rules (such as code smell detection of SonarQube), which is difficult to adapt to rapidly evolving programming paradigms (such as cloud-native architecture, low-code development) and emerging security threats (such as supply chain attacks). For example, for logic defects specific to dependency injection vulnerabilities or AI-generated code, traditional rule libraries often miss detection or false positives due to update lag.
[0083] Based on the above problems, the prior art improves the understanding ability of the large model to the code structure by introducing a large model containing a multi-modal encoder to combine different modal information of the code. Although this kind of technology uses a multi-modal large model to process some text, pictures and other content, it only optimizes the prompt words of the large model in the code generation link, and there is no related research on further review after code generation, and the quality of the generated results cannot be guaranteed. Based on the above analysis, the technical evolution of the intelligent programming auxiliary system needs to break through the following core problems:
[0084] 1. How to build a unified multi-modal encoding space to realize efficient alignment and joint reasoning of heterogeneous data such as code, documents, charts, etc.
[0085] 2. How to design a code generation architecture with long-range dependency modeling capability to support cross-file and cross-module semantic consistency guarantee.
[0086] 3. How to establish a closed-loop self-evolution mechanism to realize continuous improvement of system capability through fine-grained feedback learning and dynamic rule base updating.
[0087] 4. How to develop an interpretable review algorithm to ensure the correctness of the code function while meeting safety, ethics and other non-functional constraints.
[0088] In summary, the embodiment of the present application provides an innovative solution to the above challenges, which deeply integrates a multi-modal large model with a self-evolution review mechanism to build an end-to-end intelligent programming assistance framework, thereby significantly improving the development efficiency and code quality in complex scenarios.
[0089] The embodiment of the present application provides a code review method based on a large model. It should be noted that the steps shown in the flowchart can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order from here.
[0090] In this embodiment, a code review method based on a large model is provided, which is applied to a local terminal, Figure 1 is a flowchart of the code review method based on a large model according to the embodiment of the present application, as Figure 1 shown, the flowchart includes the following steps:
[0091] Step S101, obtaining a first code, the first code is generated by a multi-modal large model based on project code requirements.
[0092] It should be noted that the multi-modal large model in this embodiment has the potential to generate code and audit the generated code, i.e., the multi-modal large model in this embodiment can generate code based on project code requirements, and can also audit the generated code. The specific content of the multi-modal large model can be adaptively adjusted according to actual needs, such as designing the multi-modal large model as a multi-modal encoder to mine data features of different modalities, or using GPT-4, Gemini and other models to construct a corresponding large model technical architecture combined with actual project code requirements. This is only an exemplary illustration.
[0093] In step S102, the first code is audited for basic code logic, and the first code is updated based on the basic code logic audit result to obtain second code.
[0094] In this embodiment, the basic code logic audit is the initial audit of the code on the local end. The initial audit content of the code mainly includes basic syntax, such as programming language specifications, semantic logic, etc. The specific audit content can be adaptively set according to actual needs. For example, referring to common programming knowledge, code specifications such as function naming specifications to design corresponding model prompts to enable the multi-modal large model to perform self-evolution audit on the first code generated by the model, which is only an exemplary illustration.
[0095] In step S103, the second code is audited based on project code requirements, and the second code is submitted to the server based on the multi-dimensional standard audit result, so that the server performs compatibility audit on the second code, and based on the compatibility audit result, the second code is merged with the associated code. The associated code is code associated with the second code in terms of project code requirements.
[0096] It should be noted that the multi-dimensional standard audit in this embodiment is intended to adapt to project requirements and further comprehensively audit the quality of large model generated code from more dimensions. The specific audit dimensions can be adaptively adjusted according to actual project requirements, such as including semantic audit and project design requirement audit. It should be noted that the multi-dimensional standard audit in this embodiment is performed on the local end, and after no code quality problems are found in various audits, it can be submitted to the server end for subsequent audit.
[0097] In addition, the code compatibility audit in this embodiment is to review the code on the server side to ensure its compatibility with the existing system or environment, and the specific audit content can be adaptively set according to the actual project requirements. For example, the code compatibility audit focuses on functional compatibility audit (i.e., checking whether the code can normally run on different operating systems, browsers or other platforms, ensuring the integrity and correctness of the function), interface compatibility (i.e., verifying whether the code is compatible with existing interfaces, including APIs, database interfaces, etc., ensuring smooth data exchange and processing), performance compatibility (i.e., evaluating the performance of the code in different environments, ensuring that it can achieve the expected execution speed and efficiency under various conditions), etc., which are only exemplary. In this embodiment, the associated code is essentially at least one code associated with the project code requirement of the second code. It should be explained that an actual project in practical application often contains multiple functions, and the code design requirement corresponding to a certain function may be one or more, so the corresponding code generated according to different code design requirements is associated with the project code requirement.
[0098] The code auditing method based on a large model provided in the embodiment of the application is applied to a local end, specifically by obtaining a first code generated by a multi-modal large model based on a project code requirement, auditing the first code through a basic code logic to improve the basic quality of the first code, and further adapting to project specifications in combination with multi-dimensional standard auditing to ensure the standardization and compliance of the second code. In addition, the integration compatibility of the second code is enhanced through compatibility auditing on the server side, thereby ensuring the stability of the project. Through the multi-end and multi-dimensional code auditing designed above, not only the code generated by the large model is more in line with the project requirements, thereby ensuring the code generation capability, but also the generated code is effectively audited in combination with multiple types of auditing, thereby ensuring the quality of the generated code, which helps to improve the software development efficiency in complex scenarios.
[0099] In this embodiment, a code auditing method based on a large model is provided, which is applied to a local end, Figure 2 is a flowchart of another code auditing method based on a large model according to an embodiment of the application, as Figure 2 shown, the flowchart includes the following steps:
[0100] Step S201, obtaining a first code, the first code being generated by a multi-modal large model based on a project code requirement.
[0101] Specifically, the step S201 of obtaining the first code includes:
[0102] Step S2011, obtaining a project code requirement, the project code requirement containing at least one of a user prompt word and model input data.
[0103] It should be noted that the user prompt in the embodiment refers to the instruction, question, description or other forms of text information input by the user to the artificial intelligence model (such as a large language model, a multi-modal model, etc.), and its core function is to guide the model to generate the corresponding output result according to the user's demand. Its form can be a sentence, a paragraph of text, or even a combination of keywords, such as "generate the corresponding code snippet according to the input picture"; the model input data in the embodiment refers to the information carrier provided to the artificial intelligence model (such as a large language model) for training or reasoning, which is the basis for the model to calculate, learn and generate output. Its form and content vary according to the model type and task target, and its core function is to let the model extract features, learn rules or complete specific functions from it. Its specific types include text data (such as "today's weather is good"), numerical data, image data, audio data, etc. One or more of the above types of data can be obtained according to actual needs as input data for the multi-modal large model in the embodiment.
[0104] Step S2012, retrieving a target function vector matching the user prompt from a code index library, which is constructed by processing a plurality of codes into function vectors.
[0105] Specifically, the construction process of the code index library in the above step S2012 includes:
[0106] Step A1, obtaining a plurality of project codes.
[0107] In the embodiment, the project code is generated according to the actual project requirements.
[0108] Step A2, respectively parsing each project code to determine the corresponding code function.
[0109] In the embodiment, the specific meaning of the code function is adaptively determined according to the actual project requirements. For example, when the project requirement is "to realize user order management", it can be decomposed into multiple function modules, such as order creation / payment / logistics tracking / after-sales sub-functions; then each sub-function is converted into a code function, that is, the corresponding function is written, such as OrderService (order creation logic), PaymentController (payment interface) function, etc., and a plurality of project codes associated with each other are obtained.
[0110] Step A3, performing vectorization processing on each code function to obtain the corresponding function vector.
[0111] It should be noted that step A3 is mainly the vectorization processing of code functions, that is, the process of converting code segments (such as functions, classes) into numerical vectors, and the core goal is to enable the computer to understand the semantics of the code (that is, "what is this code doing"). In this embodiment, the vectorization processing can be implemented by referring to the conventional vector representation in the art, such as directly mapping the code functions to vectors using the CodeBERT model.
[0112] Step A4, each function vector is locally stored, and a code index library is constructed based on each function vector and its corresponding storage location.
[0113] In the embodiment of the application, by analyzing the corresponding code functions of each project code, the function vectorization processing is performed, and each function vector is locally stored to construct a code index library, which can realize the storage and retrieval of code semantics, and to a certain extent, the software development efficiency in complex scenarios is accelerated.
[0114] Step S2013, after the preset processing of the model input data, the processed data is obtained, and the processed data, the user prompt word and the target function vector are input into the multi-modal large model, and the first code is output.
[0115] In this embodiment, the content of the preset processing can be adaptively adjusted according to the specific type of the actual model input data, aiming to make the processed model input data have a unified specification. For example, when the model input data is text data, special characters (such as HTML tags, Markdown format symbols, etc.) are removed using regular expressions, and then lexical analysis and part-of-speech tagging are performed to convert the text into a word sequence, which can ensure that the preset processed data uploaded is effectively received and processed by the multi-modal large model, which is only an exemplary description.
[0116] In the embodiment of the application, the user prompt word is retrieved from the code index library to obtain the target function vector with the most matched semantics, and the multi-modal large model is input based on the user prompt word and in combination with the model input data and the target function vector, so that the model output can more comprehensively understand the complete code of the requirement and the context, and the generated code is more suitable for the actual business scenario requirement.
[0117] Step S202, performing basic code logic auditing on the first code, and updating the first code based on the basic code logic auditing result to obtain the second code.
[0118] Specifically, the above step S202 includes:
[0119] Step S2021, constructing a first prompt word library, the first prompt word library containing at least one of the model prompt words determined by the programming knowledge, the code specification and the typical code.
[0120] It should be noted that programming knowledge refers to the sum of theories, techniques, skills and experiences related to computer programming, which is the basis for developers to build software systems and solve practical problems, and covers multiple levels from basic concepts to advanced practices; in the embodiment, the model prompt words can be determined according to the syntax rules of the programming language (i.e., the basic syntax structure of each programming language, such as Python, Java, JavaScript, etc., such as variable declaration, control flow, function definition, etc.), semantic characteristics (i.e., the execution logic of the language, such as static / dynamic type, memory management mechanism, etc.).
[0121] In addition, it should be noted that code specifications refer to a series of rules and guidelines developed during the software development process to ensure code readability, maintainability and reliability, that is, code specifications are standard guidelines for guiding programming practices. Specifically, following code specifications can not only improve code readability, but also ensure code style consistency; common code specifications include naming conventions, indentation specifications, comment specifications, etc., for example, variable names should be descriptive, function names should use verbs to describe actions, class names usually use camel case naming conventions, etc., which are only exemplary.
[0122] It should be noted that the typical code in the embodiment refers to the excellent code case of the project, which is determined according to the historical project generated code. For example, the best practice (i.e., typical code) is determined according to the set best practice rules for each project generated code. It should be noted that the best practice is a set of established guidelines aimed at improving code quality, readability and reliability, which ensures compliance with industry standards, encourages consistency, and promotes cooperation among developers. By following the best practices, the generated code becomes easier to understand, modify and debug, thereby improving the overall software quality. In the embodiment, the specific content of the model prompt words extracted based on the code specifications and the best practices is adaptively adjusted according to the actual project requirements.
[0123] In step S2022, each model prompt word in the first prompt word library and the first code are input into the multi-modal large model to obtain a first model output result.
[0124] In step S2023, if the first model output result is that the first code has no problem, a preset evaluation index of the first code is calculated, and when the preset evaluation index meets a preset threshold, the first code is determined as the second code.
[0125] In the embodiment, the specific content of the preset evaluation index and the corresponding preset threshold is adaptively set according to the actual requirements, such as the preset evaluation index being code complexity, and the corresponding preset threshold being 10, which is only exemplary.
[0126] The embodiment of the present application can realize comprehensive and multi-dimensional basic code auditing by converting programming knowledge, code specifications and typical codes into corresponding model prompt words and utilizing various model prompt words and multi-modal large models to perform basic programming logic auditing on generated codes, thereby ensuring code quality and significantly improving software development efficiency.
[0127] It should be noted that, in the present embodiment, if the first model output result is that the first code has problems and the preset evaluation index does not meet the preset threshold, the multi-modal large model is needed to modify the generated code. Therefore, the code auditing method based on the large model of the present embodiment further comprises:
[0128] Step B1, if the first model output result is that the first code has problems, a multi-modal large model is used to generate a repair scheme, the repair scheme is determined by the problems of the first code; the first code is repaired according to the repair scheme, and the step of inputting each model prompt word in the first prompt word library and the first code into the multi-modal large model to obtain the first model output result is returned, until the first model output result is that the first code has no problems and the preset evaluation index meets the preset threshold, the first code is determined as the second code.
[0129] In the present embodiment, the specific content of the repair scheme is adaptively determined according to the actual problems of the first code. For example, the model finds that the code has syntax errors, such as missing colons in the program, and the corresponding repair scheme is to locate the error and perform symbol repair; or the model finds that the code has semantic errors, such as unused variables defined in the program, and the corresponding repair scheme is to locate the variable and perform code repair, which is only illustrative.
[0130] Step B2, when the preset evaluation index does not meet the preset threshold, an optimization scheme is generated by using a multi-modal large model, the optimization scheme is determined by the preset evaluation index; the first code is optimized according to the optimization scheme, and the step of inputting each model prompt word in the first prompt word library and the first code into the multi-modal large model to obtain the first model output result is returned, until the preset evaluation index meets the preset threshold, the first code is determined as the second code.
[0131] In the present embodiment, the specific content of the optimization scheme is adaptively determined according to the actual problems of the preset evaluation index. For example, the preset evaluation index is code complexity, the model finds that the current code complexity calculated is high, and the corresponding optimization scheme is to optimize the code structure to reduce the code complexity, which is only illustrative.
[0132] In the embodiment of the application, when the multimodal large model discovers a code problem or a performance index problem during the basic code logic auditing of the code by using the multimodal large model, a corresponding repair or optimization scheme is directly generated and corresponding code repair or optimization is performed, and the auditing mechanism is repeated until the code completely passes the auditing. Through the above-mentioned automatic repair cycle and the optimization mechanism driven by the quantitative index, the intelligentization, standardization and high efficiency of the code quality guarantee can be realized.
[0133] In step S203, the second code is audited based on the project code requirements in multiple dimensions, and the second code is submitted to the server based on the multi-dimensional standard auditing result, so that the server performs compatibility auditing on the second code, and the second code is merged with the associated code based on the compatibility auditing result. The associated code is the code associated with the second code in terms of project code requirements.
[0134] Specifically, the multi-dimensional standard auditing of the second code based on the project code requirements in step S203 and the submission of the second code to the server based on the multi-dimensional standard auditing result include:
[0135] In step S2031, the corresponding dimension prompt word is determined based on the project code requirements and the preset auditing dimension. The preset auditing dimension at least includes syntax correctness auditing, semantic consistency auditing, security compliance auditing and design pattern matching auditing.
[0136] It should be noted that the syntax correctness auditing in the embodiment focuses on whether the code conforms to the syntax rules of the programming language (such as bracket matching, semicolon use, variable declaration, etc.); the semantic consistency auditing mainly focuses on whether the code logic correctly implements the expected function, and whether the use of variables and functions conforms to the semantics; the security compliance auditing focuses on whether the code has security vulnerabilities, such as SQL injection (i.e., the application does not judge or filter the legality of user input data, and the attacker can add additional SQL statements at the end of the predefined query statement in the application, and perform illegal operations without the administrator's knowledge, in order to achieve the purpose of cheating the database server to execute unauthorized arbitrary queries, and further obtain the corresponding data information), wherein SQL is Structured Query Language (Structured Query Language), and whether it conforms to industry standards, such as General Data Protection Regulation (General Data Protection Regulation, GDPR).
[0137] It needs to be explained that the design pattern matching audit refers to checking whether the data structure meets a specific condition through a specific syntax or mechanism in programming, and executing corresponding operations according to the matching result, which can simplify the code, improve the safety of the code, and enhance the readability and maintainability of the code. In this embodiment, the design pattern matching audit focuses on whether the code format conforms to the industry-recognized design pattern.
[0138] Step S2032, constructing a second prompt word library based on each dimension prompt word.
[0139] Step S2033, inputting each dimension prompt word in the second prompt word library and the second code into the multi-modal large model respectively to obtain a second model output result.
[0140] Step S2034, when the second model output result is that the second code has no problem, submitting the second code to the server.
[0141] Step S2035, when the second model output result is that the second code has a problem, generating a modification scheme using the multi-modal large model, the modification scheme being determined according to the problem existing in the second code; modifying the second code according to the modification scheme, and returning to the step of inputting each dimension prompt word in the second prompt word library and the second code into the multi-modal large model respectively to obtain the second model output result until the second model output result is that the second code has no problem, and then submitting the second code to the server.
[0142] In this embodiment, the specific content of the modification scheme is adaptively determined according to the actual problem existing in the second code. For example, the second code has a security risk, that is, there is a security vulnerability of SQL injection risk due to the non-parameterized SQL query in the code, so the corresponding modification scheme is to use parameterized query, which is only illustrative.
[0143] In the embodiment of the application, by designing the dimension prompt words including syntax correctness audit, semantic consistency audit, security compliance audit and design pattern matching audit, and combining each dimension prompt word with the multi-modal large model to perform fine auditing on the second code that passes the initial audit, the key dimensions of code quality can be covered in all directions, the fine, standardized and intelligent code auditing is realized, and the quality of the code to be submitted to the server is further ensured.
[0144] It should be noted that the auditing of the large model to generate the code in the embodiment is a multi-terminal and multi-dimensional auditing mechanism, wherein not only is the local terminal designed to be responsible for the process of generating the code and submitting the code for auditing, but also the server terminal is designed to perform compatibility auditing on the second code submitted by the local terminal, and the code requirements are optimized based on the feedback of the compatibility auditing and the corresponding problem report obtained from the compatibility auditing. Therefore, the code auditing method based on the large model in the embodiment further comprises:
[0145] Step C1, receiving the problem report fed back by the server terminal, wherein the problem report is fed back by the server terminal based on the compatibility auditing result.
[0146] In the embodiment, the compatibility auditing includes code dependency conflicts, interface mismatches and the like, and is used to evaluate the influence of the code on the server performance, such as whether there is resource leakage, performance bottleneck under high concurrency and the like.
[0147] Step C2, feeding back the problem report to the corresponding user, so that the user optimizes the project code requirements according to the problem report.
[0148] In the embodiment, the specific content of the optimization can be adaptively determined according to the compatibility auditing problems of the actual code, such as quickly positioning to the corresponding problem code for timely optimization processing when there is a resource leakage problem, which is only an exemplary description.
[0149] In the embodiment of the application, the instant feedback of the problem found by the server terminal compatibility auditing can enable the user to immediately adjust the project code requirements, which helps to ensure the quality of the generated code and can improve the software development efficiency in complex scenarios.
[0150] In the embodiment, a code auditing method based on a large model is provided, which is applied to a server terminal, Figure 3 is a flowchart of another code auditing method based on a large model according to an embodiment of the application, as Figure 3 shown, the flowchart comprises the following steps:
[0151] Step S301, receiving the second code submitted by the local terminal, wherein the second code is obtained by the local terminal from the first code, and the first code is generated based on the project code requirements by a multi-modal large model; performing basic code logic auditing on the first code, and updating the first code based on the basic code logic auditing result to obtain the second code; performing multi-dimensional standard auditing on the second code based on the project code requirements, and sending
[0152] It should be noted that the related content of the basic code logic auditing and the multi-dimensional standard auditing in the embodiment is described above, and will not be repeated here.
[0153] Step S302, compatibility auditing is performed on the second code, and the second code is merged with associated code based on the compatibility auditing result, the associated code being code associated with the second code in terms of project code requirements.
[0154] In this embodiment, the relevant content of the compatibility auditing is described above and will not be repeated here. Specifically, the code auditing method based on a large model applied to the server side can enhance the integration compatibility of the second code by receiving the second code submitted by the local side after the basic code logic auditing and multi-dimensional standard auditing, simultaneously performing compatibility auditing on the second code, and merging the second code with associated code based on the compatibility auditing result. This can further ensure the stability of the project. Through the multi-end and multi-dimensional code auditing described above, the code generated by the large model is more in line with the project requirements, thereby ensuring the code generation capability. At the same time, the generated code is effectively audited in combination with multiple types of auditing, further ensuring the quality of the generated code, and helping to improve the software development efficiency in complex scenarios.
[0155] In this embodiment, a code auditing method based on a large model is provided, which is applied to the server side, Figure 4 is a flowchart of still another code auditing method based on a large model according to an embodiment of the present application, as shown in the figure, the flowchart includes the following steps: Figure 4
[0156] Step S401, receiving the second code submitted by the local side, the second code being obtained by the local side from the first code, the first code being generated by a multi-modal large model based on project code requirements; performing basic code logic auditing on the first code, and updating the first code based on the basic code logic auditing result to obtain the second code; performing multi-dimensional standard auditing on the second code based on project code requirements, and sending the second code based on the multi-dimensional standard auditing result. For details, please refer to step S301 of the embodiment shown in Figure 3
[0157] Step S402, performing compatibility auditing on the second code, and merging the second code with associated code based on the compatibility auditing result, the associated code being code associated with the second code in terms of project code requirements.
[0158] Specifically, step S402 described above includes:
[0159] Step S4021, obtaining the current running environment of the server.
[0160] In the present embodiment, the specific content of the current running environment and its specific acquisition method can be adaptively adjusted according to actual needs. For example, the current running environment includes hardware configuration of the server, operating system information, software dependency, and network status, and other dimensional data. Each data can be determined according to conventional data acquisition methods in the art, and is only illustrative.
[0161] Step S4022, retrieving code associated with the second code using a multi-modal large model to obtain associated code.
[0162] In the present embodiment, the specific way of retrieving using a multi-modal large model is not limited here, such as matching retrieval according to the function of the second code or setting project keywords.
[0163] Step S4023, constructing a third prompt word library based on the current running environment and the associated code, the third prompt word library containing at least one of the model prompt words determined by dependency conflict, interface change, interface mismatch, resource leakage, and server performance.
[0164] Step S4024, inputting each model prompt word in the third prompt word library and the second code into the multi-modal large model to obtain a third model output result.
[0165] Step S4025, when the third model output result is that the second code has no problem, merging the second code with the associated code.
[0166] In the present embodiment, by obtaining the current running environment of the server and the code associated with the project code requirement of the second code, and constructing a third prompt word library, the compatibility of the second code is audited using each model prompt word and a multi-modal large model, which can comprehensively audit multi-dimensional compatibility risks, thereby ensuring the accuracy, reliability, and stability of the large model generated code.
[0167] Step S4026, when the third model output result is that the second code has a problem, generating a problem report and feeding back the problem report to the local end; wherein the problem report is determined by the problem of the second code.
[0168] In the present embodiment, the specific content of the problem report is adaptively determined according to the actual problem of the second code. In addition, the specific manifestation of the content in the problem report can be adaptively set according to the actual project needs, such as the problem report including problem type, code location, and impact range, etc. information, to fully represent the problem of the second code.
[0169] When the third model output result is a second code with a problem, a problem report containing a specific problem type is automatically generated and fed back to the local end in the embodiment of the application, which can realize timely feedback of the problem, and the corresponding optimization is performed according to the feedback problem, thereby helping to obtain the generated code expected by the user.
[0170] In the embodiment, a large model-based code auditing system is also provided, Figure 5 is a structural block diagram of the large model-based code auditing system according to the embodiment of the application. As shown in Figure 5 the system includes a local end 501 and a server end 502. It should be noted that the components of the system are used to realize the corresponding embodiments and preferred embodiments described above, and those that have been described will not be repeated. Specifically, the large model-based code auditing system of the embodiment realizes multi-end and multi-dimensional code auditing through the corresponding design of the local end and the server end, which not only makes the large model generated code more in line with the project requirements, further guarantees the code generation capability, but also combines multiple auditing mechanisms to effectively audit the generated code, which can effectively ensure the quality of the generated code, and further helps to improve the software development efficiency in complex scenarios.
[0171] In a specific embodiment, an intelligent programming assistance system and a self-evolution auditing scheme based on a multi-modal code large model are provided. Specifically, by combining the code generation capability of the multi-modal large model with the self-developed auxiliary coding tool, the self-evolution code auditing mechanism is added while ensuring the quality of code generation, which can make the model continuously optimize its output results to achieve the user's expected expectations, which not only guarantees the code generation capability, but also ensures that the quality of the generated code meets the requirements and meets the current user's auxiliary coding tool scene. Figure 6 is a working schematic diagram of the intelligent programming assistance system based on the multi-modal code large model. As shown in Figure 6 the specific technical solution is as follows:
[0172] Step 1: Project engineering index.
[0173] 1. Functional vectorization processing.
[0174] In the embodiment, the code analysis tool is used to deeply analyze the code for the code project. For example, the ast library of Python is used to parse Python code to obtain detailed information such as function definition, class structure, and variable usage. For Java projects, the JavaParser library is used to extract key elements such as classes, methods, and fields.
[0175] Further, according to the code function characteristics, a feature extraction rule is designed. For example, Figure 7The flowchart of the project index shows that for an e-commerce project, the functions of commodity search, ordering, payment, etc. are analyzed respectively, and the key information such as code logic, interface calling, data flow related to each function is converted into corresponding vector representation, that is, the complex code function can be presented in a numerical form that is easy for computers to process and understand.
[0176] In this embodiment, a suitable vector representation method is adopted, such as a BGE-M3 pre-trained language model (which maps any text to a low-dimensional dense vector) to generate embedding vectors and convert key features into vectors. For code logic, the function vector representation can be obtained by tokenizing and vectorizing the code statements, and then using average pooling.
[0177] 2. Establish a local index library.
[0178] In this embodiment, Milvus vector database is selected to build a local index environment. First, install and configure Milvus to ensure its stable operation, and then set appropriate storage path, memory allocation and other parameters. Specifically, the results of function vectorization are stored locally to build a code index library (which is similar to a large "data dictionary" that provides fast lookup and matching support for subsequent operations).
[0179] It should be noted that Milvus vector database is used for storage because it has the characteristics of high availability, high performance, and easy expansion, and is used for real-time recall of massive vector data. For example, using embedding technology to convert various unstructured data such as text, images, and audio into corresponding function vectors, and then using Milvus to store these vectors.
[0180] It should be explained that in this embodiment, the code index library is established, which is similar to the establishment of a knowledge base, that is, the entire code in the project is indexed, and the indexing process is: scanning each code file one by one, vectorizing each code segment in each file as an index block, and establishing an index library for the entire project. After the index is established, the user can use the index library as the basis for question and answer the next time he asks a question. First, find the most similar index code segment in the index library based on the question, and ask the code model together with this code segment to generate code content that is more consistent with the current project.
[0181] 3. Submit the index library to assist the model understanding.
[0182] In this embodiment, the index library calling logic is embedded at the interface between the user and the model. Specifically, when the user asks a programming question, the system automatically triggers the index library retrieval program to find similar vectors in Milvus based on the keywords or key concepts in the question.
[0183] It should be noted that when the user asks the model a question, the system will automatically submit the indexed code base to the multi-modal large model. After receiving the question and the indexed library, the model can use the information in the indexed library to better understand the overall logic and context of the project. For example, if the user asks about the code implementation of the commodity inventory update, the model can use the vector information related to the inventory management function in the indexed library to quickly locate the code logic related to inventory, related interfaces and data flow in the project, so as to better understand the user's demand and generate code suggestions that are more in line with the actual situation of the project.
[0184] Step two: multi-modal large model access.
[0185] 1. Data upload processing.
[0186] In this embodiment, the self-developed auxiliary coding tool can provide diversified data upload entrances, such as supporting file dragging, folder selection, network link import, etc. Specifically, the user can conveniently upload code files (supporting multiple programming language formats such as.py,.java,.cpp, etc.), requirement documents (.docx,.pdf, etc.), UML diagrams (.png,.svg, etc.), log files (.log), API documents (.md,.html, etc.).
[0187] It should be noted that for different types of data, a special preprocessing process is developed in this embodiment. Specifically, for text data, regular expressions are used to remove special characters (such as HTML tags, Markdown format symbols, etc.), perform lexical analysis and part-of-speech tagging, and convert the text into a word sequence; for image data (such as UML diagrams), optical character recognition (Optical Character Recognition, OCR) is used, which is a technology that converts the text in paper documents into editable and searchable text data to recognize the text information in the image, and combines image segmentation algorithm to extract graphic elements (such as class boxes, relationship lines, etc.), and converts them into structured data such as XML format, which is convenient for subsequent feature extraction and digital conversion. Through the above data processing method in this embodiment, it is ensured that the uploaded data can be effectively received and processed by the multi-modal large model.
[0188] 2. Multi-modal data input model.
[0189] In this embodiment, a multi-modal encoder is designed in the multi-modal large model. Specifically, an extended model using the Transformer architecture is used to encode code text and requirement document text, using a multi-head attention mechanism to capture the association of information at different positions; for image structured data, a convolutional neural network is used to extract image features, and then map them to the same dimension space as the text features, realizing the fusion of multi-modal data.
[0190] Further, to enhance the model's understanding of multi-modal data, during training, a large number of samples containing code, requirement documents, UML diagrams, etc. are used. In this embodiment, the model is fine-tuned through self-supervised learning tasks such as contrastive learning and masked language modeling, allowing the model to learn the potential connections between different modal data, establish a unified semantic representation, and improve the accuracy and context relevance of code generation.
[0191] 3. Generate code output.
[0192] In this embodiment, the multi-modal large model receives pre-processed data and user instructions, and generates code based on the model's training knowledge and understanding of multi-modal data. During the generation process, the model will refer to code style specifications (such as Python's PEP8 specification, Java code style guidelines, etc.) and input different language code specifications and styles according to the defined specification content and different languages, to ensure the readability of the generated code. For example, when developing a mobile application, the model can generate code that conforms to the application interface interaction logic and correctly calls APIs to implement functions, by combining design documents, API documents, and existing code.
[0193] Further, a code generation result display interface is provided to present the code in the form of syntax highlighting, code folding, etc. to facilitate user viewing and editing. At the same time, a code explanation function is provided, and for key code segments generated by the model, natural language explanations can be generated to help users understand the code logic and implementation ideas. The multi-modal large model uses its powerful language generation capabilities and understanding of multi-modal data to generate corresponding code suggestions or complete code segments based on the input data and received user questions or programming task instructions. In this embodiment, since the model fully considers multi-modal information, the generated code can better meet the programming needs in complex scenarios.
[0194] Step three: self-evolution review mechanism.
[0195] 1. Initial code generation and submission review.
[0196] In this embodiment, after the multi-modal large model generates code, the code is input into the review module inside the model. The review module preloads common programming knowledge, code specifications (such as code complexity restrictions, function naming specifications, etc.), and best practices (such as correct use of design patterns). The model will preliminarily evaluate the generated code based on the programming knowledge, code specifications, and best practices it has learned. Specifically, it can check whether the code conforms to basic syntax rules, whether there are obvious logical errors, whether function calls are correct, etc. Figure 8 is a flowchart of the self-evolution review process.
[0197] Further, use a syntax checking tool (such as Python's pylint, Java's Checkstyle, etc.) to perform syntax analysis on the code, marking the location and type of syntax errors. At the same time, through the construction of symbol table, control flow analysis and other technologies, check whether the code has obvious logical errors, such as the use of undefined variables, infinite loops, etc.
[0198] 2. Loop optimization and review.
[0199] In this embodiment, if the model finds that the code has problems, it will develop optimization strategies according to the type and severity of the problem. Specifically, for syntax errors, directly repair according to syntax rules; for logical errors, generate modification suggestions through similar code logic cases learned by the model. If the model finds that there is a problem with the parameter passing of a function, it will adjust the parameter passing method according to the definition and usage scenario of the function, and then check whether the modified code has other problems. For example, when using the model to judge the problems of code generation, the problem classification in the prompt word is divided into two categories, namely syntax error and logical error, and each category is divided into two categories, namely serious and prompt, where serious problems need to be optimized immediately by the model. The model will check after each code generation until there is no serious problem in the check result.
[0200] Then, the optimized code is submitted to the model for review again, and the cycle is repeated. In this process, the model continuously adjusts the code to gradually approach the expected state. The optimized code is continuously submitted to the review module, and the syntax and logic checking process is repeated, and the code is continuously optimized until the code quality reaches a certain standard or meets the user's requirements.
[0201] 3. Termination condition judgment.
[0202] In this embodiment, the above-mentioned loop is continuously performed until one of the following two termination conditions is met:
[0203] One is that the model considers that the generated code has met the expectations, that is, the code has no obvious syntax errors, logical errors, and meets the code specifications and programming best practices. Specifically, the model judges whether the code meets the expectations through the internal set quality evaluation indicators; among them, the indicators include code complexity, code specification compliance, function correctness verification (that is, through simple unit testing or simulation running), etc. When the code reaches the set threshold in each indicator, it is considered that the code meets the expectations.
[0204] The second is manual termination of the optimization process by the user. Specifically, when the termination conditions are met, the final code result is output, which has significantly improved quality and accuracy compared to the initially generated code. For example, users can manually terminate the optimization process through integrated function keys, such as the Cancel button. That is, when the user feels that multiple rounds of interaction are frequent, they can manually click the Cancel button to stop further interaction.
[0205] Step 4: Multi-dimensional code review.
[0206] 1. Local editor review.
[0207] In this embodiment, a code assist tool plug-in is integrated into the local editor. Taking Visual Studio Code as an example, a dedicated plug-in is developed. When the user is ready to submit the code, the plug-in automatically triggers the code scanning task.
[0208] Furthermore, it checks according to the audit rules. In terms of grammatical correctness checking, the code is dynamically verified based on the abstract syntax tree. For example, for Python code, the ast library is used to build AST, traverse the syntax tree nodes, check whether the node type and attributes conform to the grammatical rules, and accurately locate the grammatical error nodes; in semantic consistency checking, by building a cross-file semantic graph, the definition and usage relationship of variables and functions in the code is analyzed, and cross-module logical conflicts are detected; and according to the code macro model and the pre-set audit rules, the code is comprehensively checked. Figure 9 It is a flowchart of multi-dimensional code review.
[0209] It's important to note that the above rules cover multiple aspects, including syntax error checking, potential logical error detection, and code style compliance. Specifically, assuming review issues are categorized into four levels: fatal, serious, general, and prompt. If the model detects a fatal or serious issue in the code—for example, an unfixable syntax error that could render the entire program inoperable, or a serious security vulnerability like SQL injection—the tool will immediately reject the user's code submission, provide a prompt with the specific issue, and guide the user through corrections. The review content and standards are shown in the multi-dimensional review system in Table 1.
[0210] Table 1
[0211]
[0212] It should be noted that this embodiment uses dynamic threat signature learning technology for security compliance checking. It obtains the latest security threat signatures from the security intelligence platform in real time and updates the local audit rule base, ensuring that the rule update delay is less than 1 minute.
[0213] It should be noted that in the design mode matching aspect of the embodiment, an architecture mode recognition algorithm based on a graph neural network (GNN) is used to analyze the structure and relationship of the code and identify deep architecture design defects.
[0214] 2. Server-side review.
[0215] In this embodiment, a code review service is deployed on the server side. Specifically, when the code is submitted to the server, the server automatically starts the code scanning process and conducts a comprehensive check on the code.
[0216] It should be noted that in addition to the part of the check content repeated on the local editor side in the server-side review of the embodiment, in-depth checks are also conducted in combination with the server running environment and the overall architecture requirements of the project. Specifically, the compatibility of the code with other code modules on the server is checked, such as whether there are dependency conflicts, interface mismatches, etc.; the impact of the code on the server performance is evaluated, such as whether there are resource leaks, performance bottlenecks under high concurrency, etc. Specifically, in this embodiment, the local review and server-side code review are organically unified for the first time. First, the user needs to perform code review before submitting the code locally, and if the code is not reviewed, it cannot be submitted to the server side. After the user submits the code to the server, the server will perform code review again, and the server will perform code review based on the code submitted in the past and the defect library of this project to ensure that there are no problems mentioned above when the code is merged into the server code library.
[0217] Further, according to the check results, if the code has fatal or serious problems, the server rejects the code merging and feeds back a detailed problem report to the user, including problem type, code location, impact range, etc. information, helping the user quickly locate and solve the problem, ensuring the quality and stability of the project code.
[0218] In summary, the self-evolution review method of the intelligent programming assistance system based on the multi-modal code large model in the embodiment of the application has the following advantages:
[0219] 1. Multi-modal heterogeneous data alignment and joint reasoning: In this embodiment, a multi-modal semantic fusion programming assistance system is constructed, which improves the accuracy and context relevance of code generation in complex scenarios; and through the self-developed auxiliary coding tool (i.e. the tool supports uploading and recognizing text, files, tables, pictures, voice, etc. Content, using a multi-modal model to process the above content, and then interacting with the code large model), data in various data structures can be uploaded and processed, and the processed data can be input into the large model to ensure the accuracy of model reasoning.
[0220] 2. Multi-module joint indexing and cross-module semantic consistency: This embodiment will vectorize the entire code project function and establish a local code index library. When the user asks a question, the indexed code library will be submitted to the model together, so that the model can better understand the user's question, and the generated code will be more consistent with the logic and artistic conception of the current project. In addition, multiple questions can be submitted to the model during the conversation to solve the problem of multi-module joint indexing.
[0221] 3. Closed-loop self-evolution capability construction: In this embodiment, a self-evolution feedback loop is established. After code generation, the generated code is further submitted to the model for evaluation, and the model reviews the code. If the model considers that the code has problems, it will optimize the generated content again and then continue to submit it to the model for evaluation. This process is repeated until the model considers that the generated code meets the expectations, or the user manually terminates the optimization process to obtain the final result.
[0222] 4. Multi-dimensional code review mechanism combination: In this embodiment, a code review mechanism is added in multiple dimensions on multiple terminals when developing a self-developed code auxiliary tool. When the user submits the code to the online server, the tool will actively scan the code. If there are fatal and serious problems, the user will be denied code submission. After the code is submitted to the server and before code merging, the code will be scanned again. If there are fatal and serious problems, the user will be denied code merging. In this way, the quality of the code is controlled on both ends to ensure that the generated and submitted code meets the quality standards.
[0223] In the embodiment of the application, a computer device is also provided. Please refer to Figure 10 , Figure 10 is a structural schematic diagram of the above computer device provided in the optional embodiment of the application, as Figure 10 shown, the computer device includes one or more processors 10, a memory 20, and an interface for connecting various components, including a high-speed interface and a low-speed interface. Various components are communicatively connected to each other using different buses, and can be installed on a common motherboard or in other ways as needed. The processor can process instructions executed in the computer device, including instructions stored in the memory or memory to display GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, each providing part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 10 In the embodiment, the processor 10 is taken as an example.
[0224] The processor 10 can be a central processor, a network processor, or a combination thereof. The processor 10 can further include a hardware chip. The hardware chip can be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device can be a complex programmable logic device, a field programmable logic device, a general array logic, or any combination thereof.
[0225] The memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform the methods illustrated in the above embodiments.
[0226] The memory 20 can include a program storage area and a data storage area. The program storage area can store an operating system, application programs required by at least one function, and the like. The data storage area can store data created according to the use of the computer device, and the like. In addition, the memory 20 can include a high-speed random access memory, and can further include a non-transitory memory such as at least one disk storage device, a flash memory device, or other non-transitory solid state memory device. In some alternative embodiments, the memory 20 can optionally include a memory disposed remotely from the processor 10, which can be connected to the computer device through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0227] The memory 20 can include a volatile memory such as a random access memory, and can also include a non-volatile memory such as a flash memory, a hard disk, or a solid state disk. The memory 20 can further include a combination of the above-mentioned types of memories.
[0228] The computer device further includes a communication interface 30 for the master chip to communicate with other devices or communication networks.
[0229] The embodiments of the present application also provide a computer readable storage medium. The above-mentioned method according to the embodiments of the present application can be implemented in hardware, firmware, or recorded in a storage medium, or stored in a remote storage medium or a non-transitory machine readable storage medium and stored in a local storage medium through network downloading of computer code, so that the method described herein can be processed by such software on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, or a solid state disk, etc. Further, the storage medium can further include a combination of the above-mentioned types of memories. It can be understood that the computer, the processor, the microprocessor master chip, or the programmable hardware includes a storage component that can store or receive software or computer code, when the software or computer code is accessed and executed by the computer, the processor, or the hardware, the method illustrated in the above embodiments is implemented.
[0230] While embodiments of the present application have been described in conjunction with the appended drawings, various modifications and changes are possible within the spirit and scope of the present application, and such modifications and changes are intended to fall within the scope of the appended claims.
Claims
1. A code review method based on a large model, applied to the local end, characterized in that: The method comprises: Obtaining a first code, where the first code is generated by a multimodal large model based on a project code requirement; Performing a basic code logic review on the first code, and updating the first code based on a result of the basic code logic review to obtain a second code; The second code is subjected to a multi-dimensional standard review based on the project code requirement, and the second code is submitted to a server based on the multi-dimensional standard review result, so that the server performs a compatibility review on the second code, and merges the second code with an associated code based on the compatibility review result, where the associated code is a code that is associated with the second code in accordance with the project code requirement.
2. The code review method based on a large model according to claim 1 is characterized in that: The performing a basic code logic review on the first code and updating the first code based on the basic code logic review result to obtain the second code includes: Building a first prompt word library, wherein the first prompt word library includes at least one of model prompt words determined by programming knowledge, code specifications, and typical codes; Inputting each model prompt word in the first prompt word library and the first code into the multimodal large model to obtain a first model output result; If the output result of the first model is that there is no problem with the first code, a preset evaluation index of the first code is calculated, and when the preset evaluation index meets a preset threshold, the first code is determined to be the second code.
3. The code review method based on a large model according to claim 2 is characterized in that: The method further comprises: If the first model outputs a result indicating that there is a problem with the first code, generating a repair plan using the multimodal large model, the repair plan being determined by the problem with the first code; repairing the first code according to the repair plan, and returning to the step of inputting each model prompt word in the first prompt word library and the first code into the multimodal large model to obtain the first model output result, until the first model outputs a result indicating that there is no problem with the first code and the preset evaluation indicator meets a preset threshold, determining the first code as the second code; Alternatively, when the preset evaluation indicator does not meet the preset threshold, an optimization plan is generated using the multimodal large model, and the optimization plan is determined by the preset evaluation indicator; the first code is optimized according to the optimization plan, and the process returns to the step of inputting each model prompt word in the first prompt word library and the first code into the multimodal large model to obtain the output result of the first model, until the preset evaluation indicator meets the preset threshold, and the first code is determined as the second code.
4. The code review method based on a large model according to claim 1 is characterized in that: The performing a multi-dimensional standard review on the second code based on the project code requirement, and submitting the second code to the server based on the multi-dimensional standard review result, includes: Determine corresponding dimension prompt words based on the project code requirements and preset audit dimensions, where the preset audit dimensions include at least grammatical correctness audit, semantic consistency audit, security compliance audit, and design pattern matching audit; Construct a second prompt word library based on prompt words of each dimension; Inputting each dimension prompt word and the second code in the second prompt word library into the multimodal large model respectively to obtain a second model output result; When the second model outputs a result that there is no problem with the second code, the second code is submitted to the server.
5. The code review method based on a large model according to claim 4 is characterized in that: The method further comprises: When the second model outputs a result indicating that there is a problem with the second code, generating a modification plan using the multimodal large model, the modification plan being determined by the problem with the second code; The second code is modified according to the modification plan, and the step of inputting the prompt words of each dimension in the second prompt word library and the second code into the multimodal large model respectively to obtain the output result of the second model is returned. When the output result of the second model is that there is no problem with the second code, the second code is submitted to the server.
6. The code review method based on a large model according to claim 1 is characterized in that: The obtaining of the first code includes: Obtaining a project code requirement, wherein the project code requirement includes at least one of a user prompt word and model input data; Retrieving a target function vector that matches the user prompt word from a code index library, wherein the code index library is constructed by processing multiple codes into function vectors; After the model input data is processed in a preset manner, processed data is obtained, and the processed data, the user prompt word, and the target function vector are input into the multimodal large model, and a first code is output accordingly.
7. The code review method based on a large model according to claim 6 is characterized in that: The construction process of the code index library includes: Get multiple project codes; Analyze each of the project codes separately to determine the function of the corresponding code; Performing vectorization processing on each of the code functions to obtain a corresponding function vector; Each of the function vectors is stored locally, and a code index library is constructed based on each of the function vectors and its corresponding storage location.
8. The code review method based on a large model according to claim 1 is characterized in that: The method further comprises: receiving a problem report fed back by the server, wherein the problem report is fed back based on a compatibility review result of the server on the second code; Feedback the problem report to the corresponding user, so that the user can optimize the project code requirements according to the problem report.
9. A code review method based on a large model, applied to the server side, characterized in that: The method comprises: Receiving a second code submitted by a local end, where the second code is a first code obtained by the local end, where the first code is generated by a multimodal large model based on project code requirements; performing a basic code logic review on the first code, and updating the first code based on the basic code logic review result to obtain a second code; performing a multi-dimensional standard review on the second code based on the project code requirements, and sending the second code based on the multi-dimensional standard review result; A compatibility review is performed on the second code, and based on the compatibility review result, the second code is merged with an associated code, where the associated code is a code that is associated with the second code in a project code requirement.
10. The code review method based on a large model according to claim 9, characterized in that: The performing a compatibility review on the second code and merging the second code with the associated code based on the compatibility review result includes: Obtaining the current operating environment of the server; using the multimodal large model to retrieve the code associated with the second code and the project code requirement, and obtaining the associated code; Building a third prompt word library based on the current operating environment and the associated code, wherein the third prompt word library includes at least one of model prompt words determined by dependency conflict, interface change, interface mismatch, resource leakage, and server performance; Inputting each model prompt word in the third prompt word library and the second code into the multimodal large model respectively to obtain a third model output result; When the output result of the third model is that there is no problem with the second code, the second code is merged with the associated code.
11. The code review method based on a large model according to claim 10, characterized in that: The method further comprises: When the output result of the third model is that there is a problem with the second code, a problem report is generated and the problem report is fed back to the local end; wherein, the problem report is determined by the existence of the problem with the second code.
12. A code review system based on a large model, characterized in that: The system comprises: Local side and server side; Wherein, the local end is used to execute the code review method based on the large model according to any one of claims 1 to 8; The server side is used to execute the code review method based on the large model as described in any one of claims 9 to 11.
13. A computer device, characterized in that: The computer device includes: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the large model-based code review method according to any one of claims 1 to 8 or claims 9 to 11 by executing the computer instructions.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, which are used to enable a computer to execute the large model-based code review method according to any one of claims 1 to 8 or claims 9 to 11.
Citation Information
Cited By
Content auditing method and device, server and medium
CN121390039A