Business code generation method and device fusing code specification detection

By combining a deep learning model based on the Transformer architecture with enterprise coding specification documents, the problem of disconnection between general large models and enterprise-specific specifications was solved, achieving high-quality and stable business code generation and continuous optimization, reducing manual verification costs, and improving development efficiency.

CN120803465AInactive Publication Date: 2025-10-17CLOUDCHAIN GRP CO LTD

Patent Information

Application Number
CN202511300387.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-12
Publication Date
2025-10-17
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In existing technologies, there is a serious disconnect between the code generated by general large models and enterprise-specific specifications, resulting in uncontrollable code quality, high manual verification costs, and difficulty in understanding enterprise-specific architectural constraints and multi-dimensional specifications. This leads to large fluctuations in code quality, lack of developer trust, and high verification costs.

Method used

Using a deep learning model based on the Transformer architecture, combined with enterprise coding standard documents and code audit models, we generate business code that complies with enterprise standards through causal language modeling, abstract syntax tree parsing, and reinforcement learning. We also optimize the model through multiple rounds of iteration and incremental fine-tuning to achieve a closed-loop process of code generation and auditing.

Benefits of technology

This ensures that code generation complies with enterprise-specific specifications from beginning to end, reduces manual verification costs, improves code quality stability and development efficiency, and enhances developers' trust in AI-generated code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803465A_ABST
    Figure CN120803465A_ABST
Patent Text Reader

Abstract

The invention provides a business code generation method and a business code generation device fusing code specification detection, which adopt a'generation-review-optimization 'closed-loop process to convert traditional post auditing into beforehand quality construction. Based on a pre-training code large model, an initial code is generated under a three-level cue word composed of a user demand, a context abstract and a system instruction, the system instruction is dynamically injected into an enterprise specification, and it is ensured that the generated code is initially compliant. And the auditing module performs semantic and architecture verification through abstract syntax tree analysis and a pre-training auditing model, automatically checks problems, sorts and repairs priorities, and generates an auditing report. And if defects are found, the system drives the model to be iteratively generated according to the priority until codes meeting the standard are output. The whole-process defect data is used for incremental fine adjustment to promote continuous evolution of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer science and technology, and in particular to a method and device for generating business code integrating code specification detection. Background Art

[0002] Against the backdrop of accelerating FinTech iteration, enterprise-level software development places higher demands on code quality, security compliance, and delivery speed. Traditional code generation and auditing approaches primarily rely on general-purpose large-scale models or static rule engines. The former, exemplified by tools like GitHub Copilot and Tongyi Lingma, significantly improves coding efficiency by pre-training on massive amounts of open source code to enable automatic completion and snippet generation. The latter uses predefined rules or pattern matching to perform syntax, style, and security scans on code. However, both approaches exhibit significant shortcomings in enterprise scenarios. Because general-purpose large-scale models are trained on public repositories, their output style inherently deviates from internal enterprise coding standards. These models struggle to identify contextual features such as microservice communication protocols and financial business constraints, resulting in low compliance with generated code and poor reliability of key algorithms. This requires developers to invest significant effort in secondary verification. Static rule-based auditing, on the other hand, is limited to surface-level defect detection and lacks a deep understanding of code semantics and architectural relationships. Furthermore, rule maintenance is costly and responsive, making it difficult to adapt to rapidly evolving business needs. These deficiencies collectively result in significant code quality fluctuations, long manual review cycles, and limited AI tool adoption, severely hindering enterprises' agile delivery capabilities in highly compliant environments. Therefore, a new business code generation solution tailored to enterprise needs is urgently needed. Summary of the Invention

[0003] In view of this, an embodiment of the present invention provides a business code generation method and device that integrates code specification detection to eliminate or improve one or more defects existing in the existing technology, and solve the core technical problems that the code generated by the general large model is seriously disconnected from the enterprise-specific specifications, the quality is uncontrollable, and the cost of subsequent manual verification is high.

[0004] One aspect of the present invention provides a method for generating service code integrating code specification detection, the method comprising the following steps: Generate business code based on user requirement-related prompts based on a pre-trained code model. The code model is a deep learning model based on the Transformer architecture, trained using a sample code dataset to perform causal language modeling tasks. The prompts include a three-level structure: structured user requirements, a summary of the current code context, and system instructions. The system instructions are used to define project types, task boundaries, output formats, and specifications. The output format and the specification are checked by performing abstract syntax tree parsing on the business code and matching with preset patterns in the enterprise coding specification document, the business code is subjected to semantic understanding and architecture verification by using a pre-trained code audit model to output problem checking results, the problem checking results are classified based on preset standards and labeled with repair priorities to generate an audit report; In the case that the audit report indicates that there is a code problem, the code large model is instructed to regenerate the business code and the corresponding audit report in order based on the repair priority, and multiple rounds of iteration are performed until the output meets the preset standard of the target business code, and the target business code is provided to the user end; the business code with code problems and the corresponding audit report are recorded for incremental fine-tuning of the code large model.

[0005] In some embodiments, the pre-training step of the code large model comprises: The codes in the preset open source code library, the enterprise internal code library for the specified business type, the enterprise coding specification document and the code review record are sliced, and the business requirement description is configured based on the annotations, function names, submission information or manual annotation to build the sample code dataset; The initial code large model based on DeepSeek-Coder, Qwen2.5-Coder, CodeLlama or StarCoder is trained to perform causal language modeling tasks to update the parameters to obtain the code large model.

[0006] In some embodiments, the method further comprises automatically generating the prompt words by using a prompt word generation module, comprising the steps of: Obtaining business code requirement description information from the user end, performing intent recognition and entity extraction based on a preset large language model, filling the recognized intent and entity into a predefined template to form a structured user demand; the entity includes operation object, key action, technical constraint and business constraint; Obtaining the code file currently being edited, the project configuration file set and the reference code library specified by the user end, performing abstract syntax tree parsing on the code file currently being edited, extracting the configuration dependent on the code file in the project configuration file set, retrieving the reference code library to obtain reference code snippets using the abstract syntax tree parsing result as a query condition, and combining to obtain the current code context summary; In the enterprise coding specification document, the project type, the task boundary, the output format and the specification are constructed based on the user demand to build the system instruction; The user demand, the current code context summary and the system instruction are combined to build a prompt word.

[0007] In some embodiments, the pre-training step of the code audit model comprises: Finding code cases containing problem records and repair records in open source code libraries and de-identified enterprise internal code libraries, slicing the code cases to obtain a plurality of samples and constructing an audit sample training set; Using the audit sample training set to perform problem detection and classification task training on the initial code audit model based on Qwen2.5-Coder, CodeLlama or StarCoder to update the parameters to obtain the code audit model.

[0008] In some embodiments, the problem checking result is severity graded and repair priority is labeled based on preset standards, comprising: Using the Common Vulnerability Scoring System to score the problem types indicated in the problem checking result, with a score interval of 0-10, and a higher score corresponding to a more serious problem; Setting 4 repair priorities, including a first priority with a score of 9 or more, corresponding to immediate blocking release; a second priority with a score of 7-8.9, corresponding to scheduled repair; a third priority with a score of 4-6.9, corresponding to scheduled repair in subsequent versions; and a fourth priority with a score of 4 or less, corresponding to only recording; Performing multiple rounds of iteration until the output meets the preset standard of the target business code, comprising: when the repair priority of the code problem indicated by the audit report corresponding to the business code is the third priority, the fourth priority or no code problem, outputting the business code of the current round as the target business code.

[0009] In some embodiments, the business code with code problems and its corresponding audit report are recorded for incremental fine-tuning of the code large model, comprising: The prompt words, the business code generated in the current round, the code problem types recorded in the audit report and their corresponding scores and severity grades are constructed as a state space, and the parameter update amount of the code large model is constructed as an action space. The pass rate of the preset test project, the business code output running time and the score are weighted and summed to calculate the reward value, and the calculation formula is: ; Where R represents the reward value, R tests represents the normalized representation of the pass rate of the preset test project, R eff represents the normalized representation of the business code output running time, R risk represents the normalized representation of the score; , and denotes a weight coefficient; The policy network takes a state of the state space as input and outputs an action in the action space, and the evaluation network takes a state of the state space as input and outputs an estimate of the reward value; based on reinforcement learning, maximize the cumulative update of the estimate of the reward value to update the policy network and the evaluation network, and simultaneously implement incremental fine-tuning of the code large model.

[0010] In some embodiments, recording the business code with code problems and the corresponding audit report thereof for incremental fine-tuning of the code large model comprises: Constructing the business code with code problems and the corresponding audit report thereof into an incremental data set according to a set period; Taking the code large model as a generator and the code audit model as a discriminator, alternately updating the generator and the discriminator based on adversarial learning using the incremental data set to implement incremental fine-tuning of the code large model.

[0011] In another aspect, the present application also provides a business code generation device fused with code specification detection, comprising a processor, a memory and computer programs / instructions stored on the memory, wherein the processor is used to execute the computer programs / instructions, and when the computer programs / instructions are executed, the device implements the steps of the above method.

[0012] In another aspect, the present application also provides a computer readable storage medium having computer programs / instructions stored thereon, wherein the computer programs / instructions are executed by a processor to implement the steps of the above method.

[0013] In another aspect, the present application also provides a computer program product comprising computer programs / instructions, wherein the computer programs / instructions are executed by a processor to implement the steps of the above method.

[0014] The business code generation method and device for fusion code specification detection provided by the application convert traditional post-audit into pre-quality construction through a closed-loop process of generation-examination-optimization. A pre-trained code large model is called to output initial business codes under a three-level prompt word framework of user demand, context summary and system instruction; wherein the system instruction dynamically injects project type, task boundary, output format and enterprise exclusive coding specification, so that the generated result has a specification basis from the beginning. Then, a code examination module performs abstract syntax tree analysis on the obtained codes, and matches the codes with preset modes in enterprise specification documents, and simultaneously performs semantic understanding and architecture verification by using an audit model also based on pre-training, to automatically perform problem checking and repair priority sorting, and generate a structured audit report. If the report shows defects, the system drives the large model to iteratively re-code, and re-audit again until the target business code fully meeting the preset standard is output for the user to use. During the whole process, all defective codes and their audit results are recorded and used for incremental fine-tuning of the large model, to realize continuous evolution of the model capability.

[0015] Additional advantages, objects, and features of the application will be set forth in part by the description that follows, and will become apparent to those skilled in the art upon examination of the following detailed description and drawings in which

[0016] Those skilled in the art will appreciate that the objects and advantages of the application can be implemented without regard to the specific details of the following description and that the application can be implemented in various ways, as will be apparent to persons skilled in the art from the following detailed description. BRIEF DESCRIPTION OF DRAWINGS

[0017] The accompanying drawings, which are incorporated herein to provide a further understanding of the application, constitute part of this application and illustrate the application without limiting the same. In the drawings: Figure 1 The flowchart of the business code generation method for fusion code specification detection according to an embodiment of the application.

[0018] Figure 2 The flowchart of the intelligent code generation scheme for deep coupling code specification detection according to an embodiment of the application. DETAILED DESCRIPTION

[0019] To make the objects, technical solutions and advantages of the application clearer, the application will be further described in detail below in combination with embodiments and drawings. Herein, the illustrative embodiments of the application and their descriptions are used to explain the application, but not to limit the application.

[0020] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, the accompanying drawings only show structures and / or processing steps closely related to the solutions according to the present invention, while other details that are not closely related to the present invention are omitted.

[0021] It should be emphasized that the term "include / comprises" when used herein refers to the existence of features, elements, steps or components, but does not exclude the existence or addition of one or more other features, elements, steps or components.

[0022] Existing technologies have the following problems: 1) Insufficient specification adaptability and conflicts between general models and proprietary specifications: pre-trained large models are based on public code bases and deviate from internal corporate coding standards; context-awareness limitations: difficulty understanding enterprise-specific architectural constraints, such as microservice communication protocols; multi-dimensional specification integration barriers: unstable performance when simultaneously meeting multiple requirements such as coding style, security compliance, and performance optimization. 2) Output code quality fluctuates greatly, with the risk of hallucination code: generating code segments that appear reasonable but are actually unrunnable; implicit propagation of technical debt: the potential for copying bad patterns in public code bases; unreliable key business logic, such as the low generation accuracy of core modules such as financial algorithms. 3) Adoption is bottlenecked by a lack of developer trust. Surveys show that only 32% of developers fully trust AI-generated code; verification costs offset benefits: manual review can take longer than direct coding.

[0023] In view of this, the present invention provides a method for generating business code by integrating code specification detection, such as Figure 1 As shown, the method includes the following steps S101 to S103: Step S101: Generate business code based on the pre-trained code model according to the prompt words related to user needs; the code model is a deep learning model based on the Transformer architecture, and is trained by performing causal language modeling tasks using a sample code dataset; the prompt words include a three-level structure of structured user needs, current code context summary and system instructions; system instructions are used to define project types, task boundaries, output formats and specifications.

[0024] Step S102: After performing abstract syntax tree parsing on the business code, it is matched with the preset pattern in the enterprise coding specification document to verify the output format and specifications, and a pre-trained code audit model is used to perform semantic understanding and architecture verification on the business code to output problem verification results. Based on the preset standards, the problem verification results are graded in severity and marked with repair priorities to generate an audit report.

[0025] Step S103: In the case where the audit report indicates that there is a code problem, the code large model is instructed to regenerate the business code and the corresponding audit report in order based on the repair priority, multiple iterations are performed until the output meets the preset standard of the target business code, and the target business code is provided to the user end; the business code with code problems and the corresponding audit report are recorded for incremental fine-tuning of the code large model.

[0026] The purpose of step S101 is to generate business code under the condition of specification constraints, and the core is to use three-level prompt words to guide the large model to generate high-quality and high-compliance initial business code. The code large model can be based on DeepSeek-Coder, Qwen2.5-Coder, CodeLlama or StarCoder, and is obtained through two-stage training of pre-training and field fine-tuning. In the pre-training stage, TB-level open source code is used as a sample to perform a causal language modeling (CLM) task, so that the model learns general syntax and API usage. In the field fine-tuning stage, the model is further supervised and fine-tuned on enterprise internal compliance code, financial security coding specifications and other data sets, so that the model implicitly understands enterprise-specific constraints.

[0027] In some embodiments, the pre-training step of the code large model includes steps S1011-S1012: Step S1011: Slice the codes in the preset open source code library, enterprise internal code library for a specified business type, enterprise coding specification document and code review record, and configure business requirement descriptions based on annotations, function names, submission information or manual annotations to build the sample code data set.

[0028] Step S1012: Perform a causal language modeling task training on the initial code large model based on DeepSeek-Coder, Qwen2.5-Coder, CodeLlama or StarCoder using the sample code data set to update the parameters to obtain the code large model.

[0029] Step S1011 slices and re-labels four types of original corpus including public open source code, enterprise-owned code, enterprise coding specification document and historical code review records to form a high-quality and trainable sample code data set. The slicing is performed at the minimum granularity of function or logic block, necessary context prefixes are retained, and the length is controlled within the maximum input token number of the model; then a "business requirement description" is automatically or manually supplemented for each slice, the sources include existing annotations, function names, submission information and manual review labels, so that each sample presents a ternary structure of "requirement-code-specification", facilitating the subsequent causal language modeling to directly learn the mapping relationship of how to write correct code under the requirement and specification constraints.

[0030] In step S1012, the selected 7B-15B scale open source code large model is further trained for causal language modeling using the above data set. DeepSeek-Coder, Qwen2.5-Coder, CodeLlama, StarCoder, qwen3-code, etc. can be used as the base. The training process keeps the original autoregressive objective unchanged, and only adjusts the learning rate, batch size and training step number, so that the model can fully absorb enterprise standards and review experience while maintaining general programming capabilities; At the same time, a small amount of special markers are introduced to distinguish requirements, specifications, code and repair fragments to accelerate convergence and improve downstream specification compliance rate. After training, a code large model with enterprise-specific coding constraint understanding ability is obtained, which can be directly used for the generation task in step S101.

[0031] In order to guide the code large model to better generate business code, the present application introduces a three-level structure prompt based on prompt engineering, which converts human intent into executable constraints for the model. Among them, the user demand is the NLU (Natural Language Understanding) processing of the natural language input by the user, including intent recognition and entity extraction, which is structured into a clear and unambiguous task description. The context summary is obtained by AST parsing the current code file to obtain the imported dependencies, defined function / variable names; retrieve similar code fragments and design patterns in the project through the vector database; read the project configuration file to determine the technology stack. The system instruction is automatically extracted from the enterprise coding specification document and dynamically assembled according to the project type and task boundary of this task.

[0032] In some embodiments, the method further comprises automatically generating prompts using a prompt generation module, comprising steps S1013-S1016: Step S1013: Obtain business code requirement description information from the user end, perform intent recognition and entity extraction based on a pre-set large language model, and fill the recognized intent and entity into a pre-defined template to form a structured user demand; The entities include operation objects, key actions, technical constraints and business constraints.

[0033] Step S1014: Obtain the user-specified code file being edited, project configuration file set and reference code library, perform abstract syntax tree parsing on the code file being edited, extract the configuration of the code file dependency in the project configuration file set, and retrieve the reference code library to obtain the reference code fragment using the abstract syntax tree parsing result as the query condition, and combine to obtain the current code context summary.

[0034] Step S1015: In the enterprise coding specification document, find the project type, task boundary, output format and specification based on the user demand to build the system instruction.

[0035] Step S1016: combine the user demand, the current code context summary, and the system instruction set to build a prompt word.

[0036] In step S1013, the preset large language model used is usually a model that has been fine-tuned and focused on code task intent recognition and entity extraction, such as a model using BERT or a similar architecture for fine-tuning.

[0037] First, a high-quality instruction fine-tuning dataset needs to be constructed. This dataset contains a large number of sample pairs composed of instructions, input natural language description text, and expected output. The instructions come from common tasks in code development scenarios, such as identifying the intent of this code requirement and extracting entities in the description. The input is the user's original natural language requirement description, and the expected output is the annotated structured result, such as annotated intent categories and entity information. Then, using a supervised fine-tuning method, the prepared dataset is used to train the pre-trained base large language model. In this process, the model parameters are iteratively updated based on the difference between the generated output and the expected output, so as to learn how to accurately map ambiguous user input to structured user requirements.

[0038] To further improve the quality of the model output and make it more in line with the preferences of human experts, such as paying more attention to safety-related constraints in entity extraction, a reinforcement learning based on human feedback is usually introduced. First, a reward model needs to be trained, which learns the quality ranking of different model outputs by human, such as output A is better than output B, so as to obtain the ability to evaluate the quality of the output. Then, using reinforcement learning algorithms, the reward model's score is used as a signal to optimize the language model that has been fine-tuned, encouraging it to generate structured output that can obtain higher rewards, i.e. higher quality and more compliant output. Finally, through multiple iterations and verifications, a fine-tuned large language model that specializes in understanding code requirements and accurately outputting structured information is obtained.

[0039] In step S1014, the goal is to automatically generate a current code context summary, which essentially provides a precise background report for the large model on where the code is currently being written. This step achieves this goal through multiple technical means: first, the code file being edited by the user is parsed using Abstract Syntax Tree (AST) to accurately extract declared dependencies, functions, and variables, thereby avoiding generating duplicate or conflicting code. Next, the project configuration file is analyzed to determine the project technology stack, framework version, and declared dependencies, ensuring that the generated code is fully compatible with the project environment. Finally, the key information obtained from the previous parsing is used as a query condition to search for similar code snippets and general patterns in the entire reference code library using vector retrieval technology, guiding the model to generate code that conforms to the project conventions and existing architecture. Ultimately, these information is combined into a structured context summary, enabling the large model to generate code as if it were a senior developer familiar with the entire background of the project.

[0040] In step S1015, the generation system instructs the large model to act as a technical director, setting unbreakable hard rules and standards. This process begins with an analysis of user requirements to determine the project type (such as web backend, frontend component library) and task boundaries (such as whether to generate unit tests). Subsequently, the system automatically retrieves all relevant provisions from the enterprise coding specification document library based on the determined project type and keywords in the requirements (such as "login" and "password"). These specification libraries typically include code style, security red lines, performance requirements, and architectural constraints, such as "passwords must be encrypted using bcrypt" and "API responses must be uniformly wrapped." Finally, the system converts these scattered provisions into clear and executable machine instructions, dynamically assembling them into complete system instructions, ensuring that all outputs of the large model begin with a high degree of compliance with enterprise standards, fundamentally guaranteeing the compliance and consistency of the code.

[0041] Step S1016 is the final step of the prompt generation process, which aims to intelligently assemble and format the three independent components produced by the previous steps into the final prompt. This step is not simply a string concatenation, but a structured process that emphasizes structure. It typically uses XML tags or other explicit separators to clearly and unambiguously combine the three parts. This structured format is crucial because it explicitly guides the large model to understand the sequence: first, follow the hard rules in the system instructions, then provide the background environment from the context summary, and finally accurately complete the specific task defined by the user requirements. Through the integration of step S1016, a vague user input is transformed into a high-quality prompt rich in prior knowledge, constraints, and explicit intentions, laying a solid foundation for generating high-quality and high-acceptance code.

[0042] The function of step S102 is far beyond traditional static code checking. It deeply analyzes the generated business code through a double-audit mechanism. First, the code is converted into a structured tree using abstract syntax tree parsing, and is accurately matched with the preset patterns in the enterprise coding specification document, which efficiently captures surface problems such as code style, naming conventions, basic security anti-patterns, etc. However, its real advantage lies in the use of a pre-trained code audit large model for deep semantic understanding and architecture verification. This model, trained on a large amount of vulnerability code and compliant code, can understand program intent, data flow and control flow, thereby discovering deep defects that AST cannot identify, such as logic errors, potential security vulnerabilities (such as SQL injection, cross-site scripting), bad design patterns (such as circular dependency, tight coupling), and violations of enterprise architecture specifications. Finally, the system combines the two types of problems and ranks them based on the preset CVSS standard for severity and repair priority, and finally generates a structured and actionable audit report that not only points out the problems, but also guides the urgency of repair.

[0043] In some embodiments, the pre-training step of the code audit model includes steps S1021-S1022: Step S1021: Find code cases containing problem records and repair records in open source code repositories and de-identified enterprise internal code repositories, slice the code cases to obtain multiple samples and build an audit sample training set; Step S1022: Use the audit sample training set to train the initial code audit model based on Qwen2.5-Coder, CodeLlama or StarCoder to perform problem detection and classification tasks to update the parameters to obtain the code audit model.

[0044] Step S1021 is the basis for building a high-quality audit model, and its core is to build a training dataset that can teach the model to identify the differences between good and bad code. The process first mines historical data from open source code repositories (such as GitHub) and de-identified enterprise internal code repositories, with the key goal being to find code cases that contain explicit problem records and repair records. These cases provide natural and practice-verified "problem code-repaired code" paired samples, with high data value.

[0045] Subsequently, these code cases are finely sliced, i.e. the code is cut into appropriate granularity units such as function level and module level, to ensure the relevance of the samples and the efficiency of the model processing. Finally, through systematic collection, organization and annotation of these sliced samples, an audit sample training set is built that covers multiple defect types such as security vulnerabilities, performance bottlenecks and specification violations. The quality of this dataset directly determines the ceiling of the subsequent audit model's capabilities.

[0046] Step S1022 is the core training stage of giving the model auditing ability, and its essence is to specialize a general code generation model into a professional code auditing model. This step first selects a powerful model that has been well pre-trained on general code as a base, such as Qwen2.5-Coder, CodeLlama or StarCoder. These base models already have strong code syntax and semantic understanding capabilities, providing a high starting point for subsequent specialization training.

[0047] Next, the base model is supervised fine-tuned for problem detection and classification tasks using the audit sample training set constructed in step S1021. During training, the model no longer learns how to generate the next Token, but learns to judge whether a given code snippet has a problem and what type of problem it is. Through this process, the model's parameters are iteratively updated, and its internal knowledge is focused and strengthened from broad code generation capabilities to sharp insights and classification capabilities for code defect patterns. The final code auditing model becomes an intelligent auditing expert that can understand the deep semantics of code and accurately identify and classify hundreds of code quality and security problems.

[0048] In some embodiments, the problem checking results are severity graded and repair priority labeled based on preset standards, including steps S1023-S1025: Step S1023: The problem types indicated in the problem checking results are scored using a general vulnerability scoring system, with a score range of 0-10, and a higher score corresponding to a more serious problem.

[0049] Step S1024: Four repair priorities are set, including a first priority for a score of 9 or higher, corresponding to immediate blocking of release; a second priority for a score of 7-8.9, corresponding to scheduled repair; a third priority for a score of 4-6.9, corresponding to scheduling for subsequent version repair; and a fourth priority for a score of 4 or less, corresponding to only recording.

[0050] Step S1025: Perform multiple iterations until the output meets the preset standards of the target business code, including: when the audit report of the business code indicates that the repair priority of the code problem is the third priority, the fourth priority, or there is no code problem, output the business code of the current round as the target business code.

[0051] Steps S1023 to S1025 collectively constitute an intelligent management system that converts technical problem discovery into executable development decisions, with the core being the introduction of objective standards to achieve automation and standardization of audit result processing.

[0052] Step S1023 first adopts the Common Vulnerability Scoring System (CVSS) as an objective and quantitative evaluation scale. CVSS provides a detailed scoring framework that assesses the severity of security vulnerabilities, even general code defects, discovered by the audit model by evaluating multiple dimensions such as attack vectors, attack complexity, required privileges, and impact on confidentiality, integrity, and availability, giving a severity score of 0 to 10. This approach transforms the subjective severity judgment that relies on expert experience into a repeatable, comparable standardized data, laying a solid foundation for subsequent priority ranking. In other embodiments, other vulnerability scoring mechanisms can also be used.

[0053] Step S1024 maps these scores to specific and actionable repair priorities, forming a clear decision pipeline. This mapping relationship (e.g., ≥9 points immediately blocked, 7-8.9 points repaired when period) directly links technical risks with business management processes: the first priority corresponds to fatal problems that must be repaired immediately, which is the red line for release; the second priority corresponds to high-priority problems that need to be solved within the current development cycle; the third priority allows planning for repair in subsequent versions, balancing development progress and quality; the fourth priority is only recorded, avoiding excessive consumption of development resources on minor problems. This classification ensures that limited engineering resources can be invested in repairing the most critical problems, maximizing the efficiency of risk management and control.

[0054] Step S1025 defines the termination condition of the entire iterative generation process. It defines a preset standard that meets the actual quality requirements of the enterprise: that is, it allows the existence of low-priority problems or no problems when outputting the final code. This design acknowledges the need to balance development efficiency and release rhythm while pursuing high quality, and does not pursue absolute zero defects. It allows non-blocking problems to be repaired online, thereby avoiding excessive pursuit of perfection that leads to a surge in iteration costs and release blockage, ensuring the usability and practicality of the intelligent code assistant in actual development processes. The entire process forms a closed-loop, exit-specific automated quality control system.

[0055] Step S103 is the key to realize self-optimization and closed-loop intelligence, which turns one-off code generation into a continuous iterative quality improvement process. This step first determines whether there are problems in the audit report. If there are problems, instead of simply informing the user, an automated feedback loop is started: the system converts the problems in the audit report, especially high-priority problems, into new and more accurate constraint instructions, and feeds them back to the code generation module of step S101, instructing the large model to regenerate the code according to the repair priority order. For example, the new prompt will explicitly require solving the high-priority SQL injection vulnerability, which must use parameterized queries. This process is repeated until the generated code passes all audits and outputs the target business code that meets the preset standards.

[0056] More advanced is that this step has the ability of continuous learning. All the audited problematic code and its corresponding report will be automatically recorded to form a high-quality <error code, correction scheme, audit rule> dataset. The system regularly (e.g., every week) uses this dataset to incrementally fine-tune the code generation large model. This enables the model to learn from mistakes and internalize the enterprise's coding standards and best practices, thereby directly avoiding similar problems in subsequent generations and achieving a spiral increase in the quality of generated code, ultimately significantly reducing the cost of manual review and improving development efficiency.

[0057] In some embodiments, recording the business code with code problems and its corresponding audit report for incremental fine-tuning of the code large model includes steps S1031 and S1032: Step S1031: Construct the prompt, the business code generated in the current round, the code problem types recorded in the audit report, and their corresponding scores and severity ratings into a state space, and the parameter update amount of the code large model into an action space; calculate the reward value by weighted sum of the passing rate of the preset test project, the output running time of the business code, and the score, the calculation formula is: ; Where R represents the reward value, R tests represents the normalized representation of the passing rate of the preset test project, R eff represents the normalized representation of the output running time of the business code, R risk represents the normalized representation of the score; 、 and represent the weight coefficients.

[0058] Step S1032: Based on the policy network, the state of the state space is input and the action in the action space is output. Based on the evaluation network, the state of the state space is input and the estimate of the reward value is output. Based on reinforcement learning, the cumulative update of the estimate of the reward value is maximized to update the policy network and the evaluation network, and the incremental fine-tuning of the code large model is realized synchronously.

[0059] Steps S1031 and S1032 collectively describe an extremely advanced and automated reinforcement learning (RL) framework for realizing the continuous self-evolution of the code large model. The core idea is to formalize the optimization process of the model as a learning problem of an agent interacting with an environment, thereby realizing more accurate and efficient optimization than traditional incremental fine-tuning.

[0060] In step S1031, the system first constructs the basic elements required for reinforcement learning. It defines the prompt words for each code generation and audit, the generated business code, the problem types audited and their severity scores as the state space, which provides the agent with all the information needed for decision-making. At the same time, the update amount of the code large model parameters is defined as the action space. A comprehensive reward function is designed to calculate the reward value (Reward) by weighted sum of the passing rate of preset test items, code running time and audit score, while encouraging the model to generate correct (high passing rate), high-performance (fast running) and safe and compliant (high audit score) codes, thereby accurately aligning with the comprehensive quality requirements of enterprises.

[0061] Step S1032 specifically implements the Actor-Critic reinforcement learning algorithm architecture. The policy network (Actor) is responsible for learning the strategy, which takes the state as input and outputs a specific action, i.e., how to update the parameters. The evaluation network (Critic) is responsible for evaluating the value of the state, which predicts the estimated value of the cumulative reward that can be obtained in the future under the current state. During the learning process, the algorithm updates the policy network and the evaluation network simultaneously by maximizing the cumulative reward estimate. The policy network learns to propose actions that can obtain higher rewards (i.e., more effective parameter update schemes), while the evaluation of the evaluation network becomes more and more accurate. The final result of this cycle is that the action output by the policy network is continuously applied to the code large model, realizing the incremental fine-tuning of its parameters.

[0062] In some embodiments, the business code with code problems and its corresponding audit report are recorded for incremental fine-tuning of the code large model, including steps S1033 and S1034: Step S1033: Construct the incremental dataset of business code with code problems and its corresponding audit report according to the set period.

[0063] Step S1034: taking the code large model as a generator and the code audit model as a discriminator, incrementally updating the generator and the discriminator based on the adversarial learning to realize the incremental fine-tuning of the code large model.

[0064] Step S1033 is a data preparation stage, which embodies the systematicness of continuous learning. Unlike single-use data, all audited problematic codes and their reports in a time period are collected according to a set period (such as every week or every half month) and constructed into an incremental data set. This process not only guarantees the timeliness of the training data, but more importantly, it captures the latest and most representative defect patterns in the development process, providing a high-quality error set for the iterative optimization of the model.

[0065] Step S1034 is the essence of the whole process, which innovatively uses the adversarial training concept of GAN. In this framework, the code large model is regarded as a generator, and its goal is to generate as compliant and high-quality business code as possible to try to deceive the discriminator. The code audit model is regarded as a discriminator, which can accurately determine whether the code has problems. Both parties are updated alternately through the incremental data set: that is, the generator is fixed, the discriminator is optimized with new data to make it more discriminative; then the discriminator is fixed, and the generator is optimized with its feedback to force the generator to generate higher quality code to pass more stringent audits. This adversarial game creates a benign competitive environment, driving the continuous improvement of the code large model, while the code audit model also evolves because it is exposed to more high-level code generated by the generator, thereby achieving the synchronous enhancement of the two models, and finally building a more and more powerful intelligent code development system.

[0066] On the other hand, the application also provides a business code generation device integrating code specification detection, comprising a processor, a memory and a computer program / instruction stored on the memory, wherein the processor is used to execute the computer program / instruction, and when the computer program / instruction is executed, the device realizes the steps of the above method.

[0067] On the other hand, the application also provides a computer readable storage medium having a computer program / instruction stored thereon, and the computer program / instruction is executed by a processor to realize the steps of the above method.

[0068] On the other hand, the application also provides a computer program product comprising a computer program / instruction, and the computer program / instruction is executed by a processor to realize the steps of the above method.

[0069] The application will be described below in conjunction with a specific embodiment: This embodiment aims to break through the specification adaptation and quality assurance bottleneck of existing code generation technology, and innovatively proposes an intelligent code generation scheme deeply coupled with code specification detection, and constructs a closed-loop technical architecture of specification perception-dynamic review-continuous evolution. In the generation stage, the prompt word engineering framework based on enterprise specification knowledge graph is adopted to convert internal coding standards (such as "Financial Industry Safe Coding Specification") into executable generation constraints, ensuring that the initial code has a specification foundation. In the review stage, more than 200 indicators from basic syntax, security vulnerabilities to industry compliance are audited in real time using a code review large model. In the optimization stage, reinforcement learning mechanism is used to convert code review data into quality feedback signals to drive continuous iteration and optimization of the model. This scheme solves the adaptation problem of general large models and enterprise-specific specifications, and realizes the technical leap from generating usable code to generating compliant high-quality code.

[0070] Large model code generation is mainly based on deep learning models of Transformer architecture, and its core working principle can be summarized as a cycle of learning-predicting-generating. The model is trained through massive code data to learn the statistical rules and structural characteristics of programming languages, and processes code as special sequence data. Unlike natural language, code has a strict syntax structure and clear semantic logic, so modern code large models are optimized for the characteristics of code, such as GitHub Copilot using Codex, Meta's CodeLlama, etc.

[0071] Based on the pre-training and fine-tuning mechanism, the code large model is formed. In the large-scale pre-training process of code, the model is first pre-trained on a TB-level open source code library (such as GitHub) to learn the basic syntax, common patterns and API usage of programming languages. This stage usually uses the causal language modeling (CLM) task, that is, to predict the next token according to the previous code sequence.

[0072] Advanced code models not only learn text sequences, but also implicitly understand the structured features of code. Some models combine abstract syntax tree (AST) information to enable the model to better grasp the hierarchical structure and semantic relationship of code. In the domain fine-tuning stage, the model will be fine-tuned for specific programming languages or enterprise environments. For example, the financial industry may add PCI DSS compliance code fine-tuning to the base model to make the generated code automatically comply with financial security standards.

[0073] As shown in Figure 2 During the code generation process, when the user inputs a prompt, the code large model performs the following steps S1-S4: S1. Context encoding: Convert the code snippet, comments or natural language description provided by the user into a vector representation to capture semantic information.

[0074] S2. Probability distribution prediction: Based on the current context, the model calculates the probability distribution of the next possible token. This is not just simple syntax matching, but also contains the understanding of the code intent.

[0075] S3. Sampling and generation: The next token is selected from the probability distribution through a sampling strategy controlled by the temperature parameter (such as top-p or top-k sampling), gradually building a complete code.

[0076] S4. Multi-round iteration: The generation process is iterative, and each step updates the context based on the previously generated content until the completion of the code snippet.

[0077] Traditional code auditing mainly relies on pre-defined rules and pattern matching, while the embodiment based on large models performs code auditing, realizing the paradigm shift from rule-driven to semantic understanding. Large models not only identify surface syntax problems, but also understand the deep semantics and context association of code, improving the audit work to the cognitive level. By learning code specifications, it automatically detects code vulnerabilities and non-compliant code blocks, and provides audit results and suggestions.

[0078] When the code generation large model outputs the initial code, the code audit model will perform multi-dimensional analysis on the code and generate structured audit reports. These reports are then converted into optimization instructions that the generation model can understand, driving the iterative improvement of code quality.

[0079] Further, the embodiment provides an intelligent code assistant system that integrates two core functions: code generation and code auditing. In the code generation task, the system automatically generates code snippets that meet functional requirements and semantic specifications based on the code large model and user-provided natural language instructions (Prompt). In the code auditing task, the code audit module scans the user's project code comprehensively, identifies code segments that do not meet the specifications, and generates a structured audit report that includes the specific location of the defective code, problem type, severity level, and modification suggestions. In addition, the system has an audit feedback mechanism: this mechanism receives the original report output by the audit module, extracts key features and automatically generates optimization instructions. These instructions further guide the code generation model to avoid similar defects in the subsequent generation process, achieving continuous optimization of the quality of the generated code. The system uses a vLLM inference acceleration engine for deployment and provides an OpenAI interface.

[0080] Specifically, the system provides a code generation module that realizes intelligent generation of high-quality code through large model technology. This module consists of three core parts: 1. Code large model, the large model generation engine adopts a code special large model qwen3-code, the parameter scale is 7B, has the deep understanding ability of code syntax and semantics;Adopting autoregressive generation mode, each token prediction output supports multi-round dialogue context memory, keeps generation consistency;Through quantization technology (such as GPTQ), efficient inference is realized.

[0081] 2. Code specification management system, comprising: structured storage enterprise specification library, covering coding style, security clauses, performance standards and other dimensions;Dynamic rule loading mechanism, automatically matching corresponding specification set according to project type;Specification version control, supporting traceability application of standards in different periods;Violate mode library, record common non-standard code and its correction scheme.

[0082] 3. Hint word engineering system, responsible for converting original requirements into model understandable optimization instructions: among them, hierarchical hint templates are constructed, including three-level structure of system instructions, user requirements and context summary. Inject dynamic variables, automatically fill in project-specific parameters, such as framework version, specification clauses. Perform context retrieval, get relevant code references through vector database. Provide constraint guidance, force key constraints, such as must use design patterns.

[0083] The workflow of code generation module is as follows: after the user inputs the requirements, the system first parses the intention and retrieves the context, then assembles the hint words containing specification constraints, the large model generates candidate code based on the hint, and finally the results are output after post-processing such as formatting, watermark injection. The whole process adopts multi-round iteration mechanism, combined with audit feedback to continuously optimize the generation quality.

[0084] The system provides a code audit module to ensure that the code meets the enterprise quality standards through deep analysis and intelligent detection. The module consists of the following core parts: 1. Audit large model engine, based on code large model qwen3-code-7B using supervised fine-tuning (Supervised Fine-Tuning, SFT) to build. The training data used for fine-tuning includes real code library data, coding specification clauses and defect mode examples. Real code library data comes from enterprise internal historical project code and public compliance code library;Coding specification clauses can be structured enterprise specification documents, industry standards (such as MISRA, PEP8);Defect mode examples include common security vulnerabilities (such as CWE, OWASP Top 10), performance anti-patterns and style deviation samples.

[0085] Each sample label in the training data includes: defect type, severity, code location, and modification suggestion. Defect types such as "null pointer dereference", "buffer overflow", "code style violation"; severity includes three levels of high, medium, and low; code location includes file name, line number, function / module name; modification suggestion includes compliant code examples or repair strategy description.

[0086] The audit large model engine has cross-file context awareness capability and can identify inconsistencies between modules; it supports detection of at least three hundred defect patterns, including security vulnerabilities, performance anti-patterns, etc.

[0087] 2. Multi-dimensional analysis system, including static analysis layer, semantic understanding layer and architecture verification layer. The static analysis layer checks the basic specifications through AST analysis and pattern matching, the semantic understanding layer analyzes the logic problems such as variable flow and exception handling, and the architecture verification layer detects the application of design patterns and component boundaries.

[0088] The workflow of the code audit module is: the input code is first parsed by syntax and features are extracted, the audit large model combines with the rule knowledge base for multi-round analysis, and finally outputs the audit report containing defect positioning, severity evaluation and repair suggestion. The module uses incremental analysis technology to scan only the changed part to improve efficiency, and continuously optimizes the detection strategy through reinforcement learning. This module combines traditional static analysis with AI deep reasoning, which not only guarantees the comprehensiveness of specification checking, but also can identify complex context-related deep problems, becoming the intelligent center of enterprise code quality control.

[0089] The system also provides a code audit result feedback module, which is the self-evolution center of the intelligent code assistant, responsible for converting audit findings into optimization power for the generation model, forming a continuous improvement closed-loop system. This module realizes quality iteration through the following mechanisms: 1. Structured feedback processing pipeline The defect type, severity and modification suggestion in the audit report are coded as structured reward signals to guide the optimization of the code generation model. The generated code is automatically labeled by the audit result classifier according to defect type (security / performance / specification) and classified according to CVSS standard (0-10 points).

[0090] Repair priority ranking: dynamically adjusted according to project stage and code importance.

[0091] 2. Model optimization engine Optimization based on incremental training and reinforcement learning can be adopted. In actual operation, the user's confirmation and correction behavior (such as accepting modification suggestions or ignoring warnings) on the audit result will be recorded as new labeled data for the incremental training of the audit model, so as to realize the continuous self-evolution of the system after deployment. At the same time, the human feedback reinforcement learning (RLHF) idea is adopted, and the compliance score is used as the reward function to fine-tune the code generation model.

[0092] The generation result optimization based on contrastive learning can also be adopted. In the code generation process, the system adopts a contrastive learning strategy to improve the compliance and quality of the output code. The specific steps include: performing multi-candidate generation and encoding, for the same user instruction (Prompt), the code generation model generates multiple candidate code segments. Performing audit scoring, the audit model performs rapid scanning and scoring on each candidate code to evaluate whether it meets the coding specifications and whether there are potential defects. Performing contrast selection and optimization, the system selects the version with the highest comprehensive score as the final output by comparing the audit scores of different candidate codes. At the same time, the score difference is used to construct a contrast loss function, and the code generation model is fine-tuned to produce high-score and low-defect code, thereby gradually reducing undesirable output patterns.

[0093] The workflow of the code audit result feedback module includes receiving the original report of the audit module, including the location, type and severity of the defective code, and extracting key features to generate optimization instructions. Through short-term feedback, immediate modification suggestions for the current session are provided, and through medium and long-term feedback, quarterly guidance model incremental updates are provided.

[0094] The entire feedback optimization mechanism forms an automatic closed loop. The code model generates candidate code, the audit model scans the code and generates a report (including score and defects), the optimal code is selected through a contrastive learning strategy and used for model fine-tuning. The audit result is converted into a reward signal to train the reward model. The RLHF (PPO) is used to optimize the code generation strategy to maximize the reward. User behavior data is collected for the next round of model iteration. By continuously feeding back the audit knowledge to the generation model, an intelligent development closed loop that becomes more and more accurate is finally formed.

[0095] Corresponding to the above method, the application also provides a device / system, which comprises a computer device including a processor and a memory, the memory storing computer instructions, and the processor is configured to execute the computer instructions stored in the memory, and the device / system implements the steps of the method as described above when the computer instructions are executed by the processor.

[0096] The embodiment of the present application also provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the foregoing edge computing server deployment method. The computer readable storage medium can be a tangible storage medium, such as a random access memory (RAM), a memory, a read only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.

[0097] In summary, the service code generation method and device for fusion code specification detection according to the present application construct a closed-loop workflow of “generation-review-optimization”, fundamentally front-locate the quality assurance activities from the traditional post-audit to the code generation stage, and realize the pre-quality construction. The method firstly calls a large-scale pre-trained code generation model to generate an initial code under the guidance of a structured three-level prompt word framework. The framework deeply integrates the functional requirements of the user, the real-time environment summary obtained by AST analysis and project context analysis, and the system-level instructions dynamically injected with enterprise-specific coding specifications, so as to ensure that the generated code has high specification compliance at the source.

[0098] Subsequently, the system starts a multi-dimensional audit mechanism: on the one hand, it performs pattern matching with the rule base through abstract syntax tree analysis to detect code style and basic specification problems; on the other hand, it uses a specially trained code audit large model to perform deep semantic analysis, security vulnerability scanning and architecture compliance verification on the code, and comprehensively identifies potential defects. All problems found will be automatically sorted according to the severity and repair urgency, and a detailed structured audit report will be generated.

[0099] If the audit finds defects, the system will not immediately hand over to manual processing, but will automatically trigger an iterative optimization process according to the problem priority. The code generation model will regenerate the code based on the audit feedback until the output completely meets the preset quality standard of the target code. All defect cases and their audit results generated in the iterative process will be recorded by the system and used as incremental training data to continuously optimize the performance of the code generation model and the audit model through reinforcement learning or adversarial training mechanism, forming an evolutionary closed loop of self-improvement.

[0100] Those of ordinary skill in the art will appreciate that the various illustrative components, systems and methods described in connection with the embodiments disclosed herein can be implemented as hardware, software, or both. The particular implementation is dependent on the specific application and design constraints imposed on the overall system. Skilled persons can implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application. When implemented in hardware, for example, the hardware can comprise an electronic circuit, an Application Specific Integrated Circuit (ASIC), a suitable firmware, a plug-in, a functional card, etc. When implemented in software, the elements of the application are the program or code segments to perform a specific task. The program or code segments can be stored in a machine-readable medium, or transmitted by a carrier wave as data signals over a transmission medium or communication link.

[0101] It is to be understood that the application is not limited to the particular configurations and processes described herein and shown in the drawings. For simplicity, detailed descriptions of known methods and apparatuses are omitted so as not to obscure the disclosure. In the above-described embodiments, several specific steps are described and illustrated as examples. However, the method processes of the present application are not limited to the specific steps described and illustrated, and the order of the steps can be changed, or other steps can be added, or replaced, or eliminated, depending on the application.

[0102] In the present application, features described and / or illustrated with respect to one embodiment can be used in the same or a similar way in one or more other embodiments, and / or in combination with or instead of features of other embodiments.

[0103] The above description is only preferred embodiments of the present application, and is not intended to limit the present application. The embodiments of the present application can be variously changed and modified by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the present application.

Claims

1. A method for generating business code integrating code specification detection, characterized in that: The method comprises the following steps: Generate business code based on user requirement-related prompts based on a pre-trained code model. The code model is a deep learning model based on the Transformer architecture, trained using a sample code dataset to perform causal language modeling tasks. The prompts include a three-level structure: structured user requirements, a summary of the current code context, and system instructions. The system instructions are used to define project types, task boundaries, output formats, and specifications. After performing abstract syntax tree parsing on the business code, the code is matched with the preset pattern in the enterprise coding specification document to verify the output format and the specification. A pre-trained code audit model is used to perform semantic understanding and architectural verification on the business code, and problem verification results are output. The problem verification results are graded according to severity based on preset standards, and repair priorities are marked to generate an audit report. When the audit report indicates that there are code problems, the code model is instructed to regenerate the business code and the corresponding audit report in sequence based on the repair priority, and multiple rounds of iterations are performed until the target business code that meets the preset standards is output and provided to the user end; the business code with code problems and its corresponding audit report are recorded for incremental fine-tuning of the code model.

2. The method for generating business code integrating code specification detection according to claim 1, characterized in that: The pre-training steps of the code model include: Slice the code in the preset open source code base, the enterprise internal code base for the specified business type, the enterprise coding standard document and the code review record, and construct the sample code dataset based on the business requirement description configured based on comments, function names, submission information or manual annotations; The sample code dataset is used to perform causal language modeling training on an initial code large model based on DeepSeek-Coder, Qwen2.5-Coder, CodeLlama or StarCoder, so as to update parameters and obtain the code large model.

3. The method for generating business code integrating code specification detection according to claim 1, characterized in that: The method further includes automatically generating the prompt word using a prompt word generation module, the steps including: Obtaining business code requirement description information from the user terminal, performing intent recognition and entity extraction based on a preset large language model, and filling the recognized intent and entities into a predefined template to form a structured user requirement; the entities include operation objects, key actions, technical constraints, and business constraints; Obtaining a code file currently being edited, a project configuration file set, and a reference code library specified by the user, performing abstract syntax tree parsing on the code file currently being edited, extracting configurations that the code file depends on from the project configuration file set, using the result of the abstract syntax tree parsing as a query condition to search the reference code library to obtain reference code snippets, and combining them to obtain the current code context summary; Searching the project type, the task boundary, the output format and the specification in the enterprise coding specification document based on the user requirements to construct the system instructions; The user requirement, the current code context summary and the system instruction are combined to form a prompt word.

4. The method for generating business code integrating code specification detection according to claim 1, characterized in that: The pre-training steps of the code audit model include: Search for code cases containing problem records and repair records in open source code libraries and desensitized internal enterprise code libraries, slice the code cases to obtain multiple samples, and construct an audit sample training set; The audit sample training set is used to perform problem detection and classification tasks on an initial code audit model based on Qwen2.5-Coder, CodeLlama or StarCoder, so as to perform parameter update to obtain the code audit model.

5. The method for generating business code integrating code specification detection according to claim 1, characterized in that: The problem verification results are graded according to severity and marked with repair priorities based on pre-set standards, including: The common vulnerability scoring system is used to score the types of issues identified in the problem verification results, with scores ranging from 0 to 10, with higher scores corresponding to more serious issues; Set four repair priorities, including the first priority with a score greater than or equal to 9, corresponding to immediate release blocking; the second priority with a score of 7-8.9, corresponding to immediate repair; the third priority with a score of 4-6.9, corresponding to scheduling a subsequent version repair; and the fourth priority with a score less than or equal to 4, corresponding to record-keeping only; Perform multiple rounds of iterations until a target business code that meets preset standards is output, including: when the audit report corresponding to the business code indicates that the repair priority of the code problem is the third priority, the fourth priority or no code problem, the business code of the current round is output as the target business code.

6. The method for generating business code integrating code specification detection according to claim 5, characterized in that: The business code with code problems and the corresponding audit report are recorded for incremental fine-tuning of the code model, including: The prompt words, the business code generated in the current round, the code problem types recorded in the audit report, and their corresponding scores and severity levels are constructed as a state space, and the parameter updates of the code model are constructed as an action space; the pass rate of the preset test items, the business code output running time, and the scores are weighted and summed to calculate the reward value, and the calculation formula is: ; Among them, R represents the reward value, R tests represents the normalized expression of the passing rate of the preset test items, R eff represents the normalized representation of the output running time of the business code, R risk represents a normalized representation of said score; 、 and represents the weight coefficient; Based on the policy network, the state of the state space is used as input and the action in the action space is output; based on the evaluation network, the state of the state space is used as input and the estimation of the reward value is output; based on reinforcement learning, the policy network and the evaluation network are updated to maximize the cumulative estimation of the reward value, and the incremental fine-tuning of the large code model is simultaneously achieved.

7. The method for generating business code integrating code specification detection according to claim 1, characterized in that: The business code with code problems and the corresponding audit report are recorded for incremental fine-tuning of the code model, including: Constructing the business code with code problems and the corresponding audit report into an incremental data set according to a set period; The large code model is used as a generator, and the code audit model is used as a discriminator. The generator and the discriminator are alternately updated using the incremental data set based on adversarial learning to achieve incremental fine-tuning of the large code model.

8. A business code generation device integrating code specification detection, comprising a processor, a memory, and a computer program / instruction stored in the memory, characterized in that: The processor is configured to execute the computer program / instructions. When the computer program / instructions are executed, the device implements the steps of the method according to any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Auxiliary code review method and system based on large language model

    CN119473306A

  • Code review and optimization method driven by large language model

    CN119512556A

  • Code generation method and related equipment

    CN120255895A

  • Code generation method, electronic equipment, readable storage medium and program product

    CN120523473A

Cited By

  • Form generation method, form generation system, storage medium and program product

    CN121680850A

  • Multi-platform firmware analysis and vulnerability scanning system

    CN121808796A

  • Fine-grained code vulnerability detection sorting method and system based on comparative learning

    CN122153922A

  • Backend computer program generation method and device

    CN122284967A