Trusted ai programming collaborative control method and system
Patent Information
- Application Number
- CN202610863577.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-15
- Publication Date
- 2026-09-18
AI Technical Summary
[0004]有鉴于此,本公开实施例提供了一种可信AI编程协同控制方法及系统,能够解决现有技术中在大规模软件项目的持续、多步骤自动编程任务中,仅靠提示信息约束 AI 模型,既难以持续保证代码符合项目架构规范与工程约定,还缺乏有效状态约束与纠偏机制,易出现代码问题、错误累积甚至任务失效等问题
[0010]The trusted AI programming collaborative control method provided in this disclosure determines the asset type of the project to be programmed based on the received user requirements before the task begins; it then calls the parsing strategy corresponding to the asset type to perform multi-dimensional analysis of the project to be programmed, constructing a project gene map; it extracts valid contract rules from the project gene map and determines the global contract centroid vector of the project to be programmed based on all valid contract rules; during the generation process, it intervenes in the probability distribution of candidate lexical units in real time based on the semantic deviation between the code content generated by the large language model at each time step and the global contract centroid vector, as well as the default cost function corresponding to the code content, to obtain optimized target code content. This method can transform the project's architectural specifications and engineering conventions into quantifiable semantic constraint benchmarks and implement real-time intervention during the code generation process, achieving engineering-level constraints on the AI code generation process and effectively ensuring the compliance of the generated code and the stability of long-term tasks.
Smart Images

Figure CN122777097A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence-assisted and software-automated control technology, and in particular to a reliable AI programming collaborative control method and system. Background Technology
[0002] As the application of artificial intelligence (AI) technology in software engineering deepens, generative model-based automated programming tools have achieved breakthrough development. Tools such as Cursor and Copilot can quickly generate functions, complete modules, and even complete complex code refactoring tasks based on natural language requirements. Industry data shows that more than 60% of new code created globally is currently generated by AI. These tools significantly shorten development cycles, provide a new path to improve software development efficiency, and have become a mainstream auxiliary means in modern software development.
[0003] However, large-scale software projects that incorporate AI programming often have complex architectural designs and strict engineering conventions. Currently, AI programming primarily relies on prompts for constraint, making it difficult to consistently ensure code compliance throughout the long-term generation process. AI-generated code frequently exhibits inconsistent styles, redundant dependencies, and even fictitious library calls, increasing later maintenance costs, introducing security vulnerabilities, and deviating from the project's established architectural specifications and engineering standards. Furthermore, in continuous, multi-step automated programming tasks, the lack of effective state constraints and correction mechanisms often leads to error accumulation or even task failure. Summary of the Invention
[0004] In view of this, the present disclosure provides a trusted AI programming collaborative control method and system, which can solve the problems in the prior art where, in the continuous, multi-step automatic programming tasks of large-scale software projects, relying solely on prompt information to constrain the AI model is not only difficult to continuously ensure that the code conforms to the project architecture specifications and engineering conventions, but also lacks an effective state constraint and correction mechanism, which easily leads to problems such as code problems, error accumulation, and even task failure.
[0005] In a first aspect, embodiments of this disclosure provide a trusted AI programming collaborative control method, including: Based on the received user requirements, determine the asset type of the project to be programmed; The parsing strategy corresponding to the asset type is invoked to perform multi-dimensional analysis of the project to be programmed and construct the project gene map. Valid contract rules are extracted from the project gene map, and the global contract centroid vector of the project to be programmed is determined based on all the valid contract rules. Based on the semantic deviation between the code content generated at each time step of the large language model and the global contract centroid vector, real-time intervention is performed on the probability distribution of candidate lexical units to obtain the optimized target code content.
[0006] Secondly, this disclosure also provides a trusted AI programming collaborative control system, including: The asset type determination unit is used to determine the asset type of the project to be programmed based on the received user requirements. The project gene map construction unit is used to call the parsing strategy corresponding to the asset type to perform multi-dimensional analysis of the project to be programmed and construct the project gene map. A global contract centroid vector determination unit is used to extract valid contract rules from the project gene map and determine the global contract centroid vector of the project to be programmed based on all the valid contract rules. The optimization unit is used to intervene in the probability distribution of candidate lexical units in real time based on the semantic deviation between the code content generated by the large language model at each time step and the global contract centroid vector, as well as the default cost function corresponding to the code content, to obtain the optimized target code content.
[0007] Thirdly, this disclosure also provides a computer device, which adopts the following technical solution: The computer device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor; the instructions are executed by the at least one processor to enable the at least one processor to execute any of the trusted AI programming collaborative control methods described above.
[0008] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium storing computer instructions; the computer instructions are used to cause a computer to execute any of the trusted AI programming collaborative control methods described above.
[0009] Fifthly, embodiments of this disclosure also provide a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of any of the methods described above.
[0010] The trusted AI programming collaborative control method provided in this disclosure determines the asset type of the project to be programmed based on the received user requirements before the task begins; it then calls the parsing strategy corresponding to the asset type to perform multi-dimensional analysis of the project to be programmed, constructing a project gene map; it extracts valid contract rules from the project gene map and determines the global contract centroid vector of the project to be programmed based on all valid contract rules; during the generation process, it intervenes in the probability distribution of candidate lexical units in real time based on the semantic deviation between the code content generated by the large language model at each time step and the global contract centroid vector, as well as the default cost function corresponding to the code content, to obtain optimized target code content. This method can transform the project's architectural specifications and engineering conventions into quantifiable semantic constraint benchmarks and implement real-time intervention during the code generation process, achieving engineering-level constraints on the AI code generation process and effectively ensuring the compliance of the generated code and the stability of long-term tasks.
[0011] The above description is merely an overview of the technical solution disclosed herein. In order to better understand the technical means of this disclosure and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0012] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a flowchart illustrating the trusted AI programming collaborative control method provided in an embodiment of this disclosure.
[0014] Figure 2 This is a flowchart illustrating the method for constructing a project gene map provided in an embodiment of this disclosure.
[0015] Figure 3 A flowchart illustrating a method for determining the global contract centroid vector of a project to be programmed, as provided in an embodiment of this disclosure.
[0016] Figure 4 This is a flowchart illustrating a first embodiment of the optimized method for obtaining target code content provided in this disclosure.
[0017] Figure 5 A flowchart illustrating a second embodiment of the optimized method for obtaining target code content provided in this disclosure.
[0018] Figure 6This is a schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. Detailed Implementation
[0019] The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.
[0020] It should be understood that the following specific examples illustrate the implementation of this disclosure, and those skilled in the art can easily understand other advantages and effects of this disclosure from the content disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. This disclosure can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this disclosure. It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments can be combined with each other. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0021] It should be noted that various aspects of embodiments within the scope of the appended claims are described below. It will be apparent that the aspects described herein can be embodied in a wide variety of forms, and any particular structure and / or function described herein is merely illustrative. Based on this disclosure, those skilled in the art will understand that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects set forth herein can be used to implement the device and / or practice the method. Additionally, this device and / or method can be implemented using structures and / or functionalities other than one or more of the aspects set forth herein.
[0022] It should also be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this disclosure. The drawings only show the components related to this disclosure and are not drawn according to the number, shape and size of the components in actual implementation. In actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0023] Furthermore, specific details are provided in the following description to facilitate a thorough understanding of the examples. However, those skilled in the art will understand that the described aspects can be practiced without these specific details.
[0024] Reference Figure 1 This application discloses a trusted AI programming cooperative control method, including: S100, determine the asset type of the project to be programmed based on the received user requirements; S200 calls the parsing strategy corresponding to the asset type to perform multi-dimensional analysis of the programming project and build the project gene map; S300 extracts valid contract rules from the project gene map and determines the global contract centroid vector of the project to be programmed based on all valid contract rules.
[0025] S400 performs real-time intervention on the probability distribution of candidate lexical units based on the semantic deviation between the code content generated at each time step of LLM and the global contract centroid vector, as well as the default cost function corresponding to the code content, to obtain the optimized target code content.
[0026] S100-S300 are performed before the task begins, used for feedforward control. By loading the project gene map and extracting valid contract rules, the current contract centroid is calculated as the generation constraint benchmark to prevent obvious architectural errors and ensure the stability of long-term tasks. S400 is an actual intervention during the code generation process, which can impose engineering-level constraints on the AI code generation process to achieve the stability and reliability of automated programming tasks.
[0027] The trusted AI programming collaborative control method disclosed in this application constructs a project gene map to comprehensively represent project characteristics, then extracts contract rules from the map and calculates the global contract centroid, and finally performs real-time probabilistic intervention based on the contract centroid during code generation. Unlike traditional static rule checks, this method uniformly maps heterogeneous knowledge such as project architecture specifications and engineering conventions to a high-dimensional vector space, forming a quantified semantic constraint benchmark, and applies probabilistic intervention in real time during the decoding stage of the generative model. This effectively solves the architecture drift problem that occurs in large language models (LLMs) in long-term coding tasks, i.e., the phenomenon that the generative model gradually deviates from the established architecture specifications of the project during continuous output. The solution disclosed in this application enables the large-scale application of AI programming in large-scale projects, effectively solves the problems of constraint, traceability, data retention, and stability, and promotes the deep integration of AI programming and engineering practice.
[0028] The method for determining the asset types of S100 projects to be programmed specifically includes: traversing the target project's file system, analyzing the project assets based on file type and content characteristics, and determining their corresponding asset types. Asset types can be divided into three categories: 1) Source code files, which include all programming language source files in the project, such as .java, .py, .ts, etc. 2) Configuration files, which include build configurations, code quality rules, dependency declaration files, etc.; build configurations include Maven POM, Gradle scripts, etc.; code quality rules include Linter / Formatter configurations, etc.; dependency declaration files include package.json, requirements.txt, etc. 3) Documentation files, which include architecture design documents, README, API specification documents, constraint declarations in inline code comments, etc. Through this step, a categorized and labeled list of project files can be obtained.
[0029] Reference Figure 2 The specific methods for constructing the S200 project gene map include: S210, Obtain the target parsing strategy corresponding to the asset type.
[0030] S220 invokes the target parsing strategy to perform multi-dimensional parsing of the project to be programmed and extracts several heterogeneous nodes corresponding to the project to be programmed.
[0031] Among these, several heterogeneous nodes include code-level nodes and document-level nodes. Specifically, for asset types that are source code files, the corresponding programming language's syntax parser is invoked to transform the source code into an abstract syntax tree, from which code-level nodes are extracted. These are code elements with structured semantics, including classes, interfaces, functions, decorators, modules, etc. Each code-level node carries its source file path, start and end line numbers, and other location information.
[0032] For assets that are configuration files, a structured parser is used to extract the constraint declarations, transforming each valid constraint into a document-level node. The structured parser can be a JSON, YAML, or XML parser; the constraint declarations include dependency blacklists, encoding rule configurations, and build target declarations.
[0033] For asset types such as document files, natural language processing techniques are used to identify information such as architectural constraints and design principles from unstructured text and transform them into document-level nodes. For example, layered architecture principles in design documents, prohibited dependencies in Linter configuration files, and technology stack conventions in README are all extracted as independent document-level nodes.
[0034] In this embodiment, heterogeneous nodes are mainly divided into code-level nodes and document-level nodes. Code-level nodes originate from the AST parsing of source code files, while document-level nodes originate from the structured parsing of configuration files and the NLP parsing of document files.
[0035] S230: Establish relationship edges between different heterogeneous nodes to generate the project gene map.
[0036] After node extraction, the relationships between nodes are established to complete the graph assembly. In this application, the Project Gene Graph (PGG) is the project architecture graph. Specifically, it is automatically established based on reference relationships in the AST, including structured dependencies such as class inheritance, interface implementation, function calls, and module imports. It is also established based on explicit declarations in the configuration file, such as the mapping relationship between constraint targets specified in Linter rule configurations and corresponding code modules. Furthermore, it establishes associations between document-level nodes and code-level nodes based on semantic matching. Text semantic similarity algorithms, such as vector cosine similarity based on a pre-trained language model, are used to calculate the semantic relevance between document-level nodes and code-level nodes. When the similarity exceeds a preset threshold, an association edge is established. For example, a constraint association is established between a document-level node in the design document stating that the Service layer must not directly access the database and a specific Service class code-level node in the project. The PGG is completed when all files in the target project have been parsed into nodes according to the above process, and all identifiable relationships between nodes have been established as edges.
[0037] Reference Figure 3 The method for determining the global contract centroid vector of the project to be programmed using S300 specifically includes: S310: Extract valid contract rules from the project's gene map according to preset contract rules.
[0038] Specifically, for document-level class nodes, the explicitly declared rule types are extracted from the document-level nodes, which include architectural constraints, naming conventions, dependency restrictions, etc.
[0039] For code-level class nodes, the content is determined from the pattern of the code-level nodes, which includes a natural language description or code pattern representing the rules.
[0040] For relation edges, dependency constraints are extracted from the relation edges in order to determine the source nodes of the corresponding rules in the project gene map.
[0041] Each valid contract rule is a triple consisting of rule type, content, and dependency constraints; that is, each contract rule is represented as a triple.
[0042] S320 utilizes a code embedding model fine-tuned for the code domain to encode the content of each valid contract rule into a vector of the same dimension, thereby obtaining several embedding vectors.
[0043] Specifically, using a code embedding model fine-tuned for the code domain, the content of each contract rule is encoded as a d-dimensional vector, where d is preferably 1536. This embedding model can uniformly encode code snippets and natural language descriptions into the same vector space, ensuring the comparability of heterogeneous information. Finally, all valid contract rule sets are transformed into a set of semantic vectors, used for the global contract centroid calculation below, and reused as a unified semantic metric basis in the causal traceability subsystem and the project self-evolution subsystem.
[0044] S330, based on all embedded vectors, determine the global contract centroid vector of the project to be programmed.
[0045] The global contract centroid vector is : .
[0046] in, The total number of all embedding vectors; For the first The embedding vector corresponding to each valid contract rule is the i-th contract rule. Vector representation after code embedding model encoding; For the first The weights of valid contract rules are used to distinguish the rigidity of rules. They can be automatically assigned values based on the rule type, typically ranging from [0.5, 2.0]. For example, for core architecture rules (such as security red lines and hierarchical constraints), let... For version 2.0, regarding general style suggestions (such as naming preferences), set... The value is 0.5. The dimension of the global contract centroid vector is also d, representing the current architectural specification center of the project, preferably 1536.
[0047] Reference Figure 4 The S400 (Generation Process Control Mechanism) method, which "obtains the optimized target code content based on the semantic deviation between the code content generated at each time step of the LLM and the global contract centroid vector, as well as the default cost function corresponding to the code content," specifically includes the following methods for obtaining the optimized target code content: A100 retrieves the code content generated at each time step of the LLM and the target vector belonging to the same dimension as the centroid of the global contract.
[0048] Specifically, during the autoregressive decoding process, the Large Language Model (LLM) obtains the sequence of all tokens generated up to the current time step; in the autoregressive decoding, the LLM generates code token by token. This represents the sequence of all tokens generated up to time step t, using the embedding vector of the current generation context. express.
[0049] There are two ways to obtain it. The first way is: to... Encoding using the above code embedding model (the same model used for contract rule vectorization) yields an aggregated vector that compresses a variable-length sequence into a fixed-length representation. The second approach is to directly extract the LLM during processing. The hidden state is the internal representation vector output by the last layer of the network, which naturally contains semantic information of the current generation context.
[0050] A200 represents the semantic deviation between the target vector and the global contract centroid vector.
[0051] The semantic deviation is D(t): Where D(t) is the semantic deviation at time step t, ranging from [0, 2]. The larger the value, the more the current generation logic deviates from the project architecture specification. It is the global contract centroid vector. The target vector (i.e., the embedding vector of the current generation context).
[0052] A300, if the semantic deviation is greater than the preset drift threshold, the probability distribution of candidate lexical units is nonlinearly corrected in the output probability layer of the large language model to obtain the optimized target code content.
[0053] In the real-time analysis of the generation process, if the default cost function is not less than the preset threshold and the candidate tokens do not cause the code to violate the explicit architecture rules, the corresponding code is output; if the candidate tokens cause the code to violate the explicit architecture rules, such as triggering the dependency blacklist or violating the hierarchical constraints, the generation of the token is physically blocked at any deviation level. Through real-time intervention in the generation process, the optimized target code content is obtained.
[0054] In this application, when semantic deviation At that time, no soft intervention is carried out, meaning the model is freely generated within compliance limits. When this value is exceeded, it is considered that the AI has begun architectural drift, triggering the execution of non-linear correction. The preset drift threshold is used to determine whether the generated content has deviated from the project specifications, and the value range is [0.15, 0.25].
[0055] The triggering of nonlinear correction specifically includes: based on the calculated semantic deviation, performing nonlinear correction on the probability distribution of candidate lexical units in the output probability layer (Logits layer) of LLM, that is, calculating the semantic deviation between the current generated content and the contract centroid, and then intervening in the probability distribution of candidate lexical units based on the deviation.
[0056] Specifically, obtaining the probability distribution actually used for sampling. : , After contract anchoring intervention, Token The probability of being ultimately selected; this is the probability distribution actually used for sampling. For large language models in the autoregressive decoding process, given the generated sequence Predict the next token under the given conditions. The original probability distribution, which is the output of the model without intervention. This is a soft drift penalty term used to apply adjustable probabilistic suppression to candidate lexical units that deviate from the item canonical direction. Its value depends on the candidate lexical unit. The semantic relevance calculation with respect to the current contract centroid takes the value of a finite non-negative real number. The dynamic penalty coefficient controls the soft drift penalty. The intensity. For hard default cost function, independent of It always applies, and is computed based on hard contract rules in PGG. For example, if a candidate lexical would cause the code to violate explicit schema rules, then... If the value is considered to be infinity, then the generation of the token will be physically blocked at any deviation level; otherwise, it will be 0.
[0057] In this application, when semantic deviation season =0. When hour, As the deviation increases exponentially, ,in The growth rate parameter is preferably set to 10.
[0058] The methods disclosed in the above embodiments enable physical-level intervention in the generation process. Even if the model produces illusions, its token sampling probability will be forcibly pulled back to a compliant semantic space, effectively ensuring that the generated code strictly adheres to project-specific layering principles, security red lines, and dependency specifications in its deep logic, and significantly reducing the risk of architectural entropy increase in large-scale software engineering.
[0059] Furthermore, the semantic deviation-based generative intervention mechanism aims to protect the core idea of forced correction during the generation process. It is not limited to a specific Softmax formula; any mechanism that includes a dynamic penalty function and multi-level intervention strategies falls within the scope of this application. The dynamic penalty function aims to define a mapping relationship where the penalty intensity coefficient and the semantic deviation exhibit a monotonically non-decreasing relationship, particularly for cases exceeding a preset drift threshold.
[0060] The multi-level intervention strategy specifically includes: for the white-box model, in the Logits calculation stage, introducing two independent penalty terms: a soft drift penalty term controlled by the penalty intensity coefficient and a hard default cost function that is always in effect, directly reshaping the predicted probability distribution of the token.
[0061] For black-box / API models, a candidate sampling-discrimination mechanism is adopted to generate multiple candidate fragments. The fragments are scored and re-ranked using a scoring mechanism that combines semantic deviation and hard rule violation indicator functions to select the optimal fragment. Alternatively, an iterative rejection sampling strategy is adopted to generate and discriminate the compliance of candidate fragments one by one until the generated code fragments meet the semantic deviation threshold requirements and do not violate hard contract rules.
[0062] In this application, the aforementioned decoding layer intervention mechanism is applicable to white-box models with open Logits interfaces. Considering that some large language model services only provide text output interfaces and do not expose the underlying Logits probability distribution, this application also provides a set of candidate sampling, evaluation, and filtering mechanisms for black-box models, as detailed in [reference needed]. Figure 5 In the second embodiment, the method for obtaining the optimized target code content in S400 includes: B100 controls the large language model to generate several candidate code snippets in parallel for the same prompt word.
[0063] Among them, the number of candidate code segments is not less than 3; during the generation process, a high sampling temperature parameter is set, which controls the randomness of the LLM output. The higher the value, the more diverse the generated results, so as to ensure the diversity of the candidate set.
[0064] B200, outside the model, performs posterior analysis on each candidate code segment based on the global contract centroid vector to obtain the score result corresponding to each candidate code segment.
[0065] The score result corresponding to the i-th candidate code snippet is : ,in, The semantic deviation between the candidate fragment and the contract centroid is consistent with the D(t) calculation method in the white-box model mentioned above (i.e. Specifically, first, the candidate fragments The model is encoded into a vector by embedding code, and then its expression is calculated. The cosine distance. This is a hard rule violation indicator function, which operates at the granularity of the entire code segment rather than the granularity of a single term. If a candidate segment violates a hard contract rule, such as containing blacklisted dependency libraries, then... If it is infinity, then it is 0. , , These are the corresponding adjustment coefficients, which can be flexibly set according to actual needs.
[0066] B300 selects candidate code segments whose scoring results meet preset conditions as the optimized target code content.
[0067] Specifically, the segments with scores below the safety threshold are discarded directly, and the segment with the highest score is output as the final result. This process is transparent to the user and implements logical constraints without Logits permissions.
[0068] Furthermore, iterative rejection sampling can be used as an alternative strategy to the aforementioned batch candidate scoring method; specifically, the iterative rejection sampling method includes generating only one candidate fragment per round. Calculate its semantic deviation and violations of hard rules ;like Below the preset safety threshold and If the value is 0, the fragment is accepted as the final output; otherwise, the fragment is rejected and resampled until a qualified output is obtained or the maximum number of retries is reached. This strategy is suitable for scenarios with limited computational resources where multiple candidate fragments are generated in parallel.
[0069] Furthermore, the trusted AI programming collaborative control method disclosed in this application also includes: the construction of the project gene map and the calculation of the global contract centroid vector are performed during the project initialization phase or when the project state changes. The obtained global contract centroid vector will be persisted and reused in all subsequent code generation requests. When a user initiates a code generation request, real-time analysis is performed based on the global contract centroid vector to implement real-time constraints on each decoding time step, i.e., real-time intervention is performed.
[0070] The trusted AI programming collaborative control method disclosed in this application further includes: during the generation process, obtaining the causal reasoning graph corresponding to the code content generated at each time step of the LLM, obtaining the path causal confidence degree corresponding to any code node based on the causal reasoning graph, and constructing a reverse tracing interaction engine corresponding to the target code content based on the path causal confidence degree.
[0071] Furthermore, the trusted AI programming collaborative control method disclosed in this application also includes: in response to an interaction request (click, annotation) to a code node, executing a reverse graph traversal algorithm through a reverse tracing interaction engine, extracting the smallest causal subgraph strongly correlated with the corresponding code node from the causal reasoning graph, and displaying it based on a preset visualization strategy.
[0072] The causal reasoning graph (CRG) is a directed acyclic graph. Regarding node types in the causal reasoning graph, the CRG includes four types of nodes: 1) Demand nodes. 1) This represents the user's original input request; 2) Context nodes This refers to external knowledge slices obtained through retrieval-enhanced generation techniques; 3) Decision nodes This represents the intermediate inference steps of the model. By performing syntactic dependency analysis on the output of the thought chain, each inference statement is broken down into independent graph nodes; 4) Code nodes This represents the final generated code snippet, and each code node is also associated with the semantic deviation output by the contract anchoring subsystem as a node attribute.
[0073] For edge types in a causal reasoning graph, directed edges in a CRG represent causal dependencies between nodes, including deductive edges from requirement to decision, referential edges from context to decision, generative edges from decision to code, and direct evidence edges from context to code. Then, a user requirement-based approach is established. -Retrieval Context - Decision Node -Final code node It is a directed acyclic graph (DAG) of the main link, and can be constructed when there is direct evidence to support it. → Supplementary evidence.
[0074] After constructing the CRG, to identify logical illusions—that is, generated code lacking effective reasoning support—a discriminative model is introduced to score the confidence of reference edges in the CRG. For any generated code node... Calculate its path causality confidence (PCC). This indicator reflects the strength of logical support between code generation and its direct reasoning basis.
[0075] ,in, For the i-th code node The PCC score, ranging from [0, 1], is used to measure whether the code snippet has sufficient logical basis. The set of all direct predecessor nodes pointing to this code node in the CRG, including decision nodes. and context nodes . As a weighting factor, satisfying The total weight of the decision-type parent node is preferably set to 0.6, and the total weight of the context-type parent node is preferably set to 0.4. If there are multiple parent nodes of the same type, they are further evenly distributed within that category.
[0076] parent node The baseline confidence level. When When it is a demand node, context node, or decision node, Initializing to 1 indicates that the node itself has already been included in the current valid inference chain; based on this, then... It describes the strength of its actual logical support for the target code node.
[0077] Logical implication score, used to quantify predecessor nodes. Does it provide substantive logical support? The generation, rather than formally irrelevant references, is achieved through a lightweight cross-encoder model, with the input being... That is, the text content of the predecessor node and the code content of the code node; the output range is [0, 1]. If A value less than 0.5 indicates that the code generation does not match the reason for its reference, i.e., a logical illusion has occurred.
[0078] This embodiment enables each line of generated code to have a traceable chain of evidence. Developers can intuitively see the AI's decision-making basis through visual interaction, and it can automatically mark logical nodes with low path causality confidence (PCC), greatly reducing the cognitive load and trust cost of manual code review.
[0079] Furthermore, based on path causal confidence, a reverse tracing interactive engine corresponding to the target code content is constructed, with the aim of allowing developers to review the basis for code generation in a white-box manner.
[0080] The reverse tracing interaction engine includes: dynamic extraction of the tracing subgraph, visualization rendering based on path causality confidence (PCC), and score tracing.
[0081] Specifically, the dynamic extraction of the source subgraph includes: when a user provides feedback on a specific line or block of code in an IDE or code review interface... When a focus signal, such as a click or annotation, is received, the source engine immediately executes a reverse graph traversal algorithm to extract the minimum causal subgraph strongly correlated with the code node from the CRG. .
[0082] ;in, This refers to the set of all upstream ancestor nodes of the code node in the CRG, including the decision node. Context nodes and demand nodes . This refers to the logical implication score corresponding to edge e. For an edge e=(u,v) pointing from node u to node v, its value is the logical support strength recorded in the CRG for that edge; The purpose of displaying the threshold is to ensure that noisy edges with extremely low logical implicature scores (such as <0.1) are automatically filtered out, and only the core inference chain is displayed to avoid information overload.
[0083] PCC-based visualization rendering includes: extracting sub-graphs The mapping is done as a visual mind map or sidebar flow card, and a PCC-based visual coding strategy is applied. Specifically, the background color saturation of a code node is positively correlated with its PCC, and the depth of the associated edge is positively correlated with the logical implication score of the corresponding edge. If a node's PCC > 0.8 and the edge's implication score is high, it indicates a high-confidence link and is displayed as a solid / dark line, representing strong logical support. If 0.5 < node PCC < 0.8, or the edge's implication score is low, it indicates a low-confidence link and is displayed as a dashed / light line, prompting the developer to manually review it.
[0084] If the path causality confidence of a code node's PCC is less than a preset logical illusion threshold, a logical illusion warning icon will be displayed next to that line of code in the UI. Clicking this icon will display a system message indicating that the code lacks valid contextual basis or logical reasoning support, and is suspected of logical illusion. The logical illusion threshold is used to distinguish between acceptable weak support and a lack of valid basis.
[0085] For code modification scenarios, this application supports two-way traceability. When a user modifies... Afterwards, it not only updates the CRG of the current node, but also automatically highlights the corresponding nodes. Upstream decision nodes and context nodes with direct causal relationships will provide real-time notifications to users: the original inference chain corresponding to your modification has changed and the relevant contextual basis needs to be reviewed again, thereby realizing influence domain analysis at the human-machine collaboration level. These human correction behaviors will be captured by the project's self-evolutionary subsystem and used for subsequent contract centroid updates.
[0086] In this application, causal traceability and contract anchoring work in parallel during the generation process. While the latter implements real-time probabilistic intervention, the linear code generation process can be transformed into a queryable and verifiable directed acyclic graph, i.e., a causal reasoning graph, enabling precise backtracking from code to decision-making basis. At the data flow level, this application can receive the semantic deviation output by the contract anchoring subsystem as an attribute of code nodes in the CRG. Simultaneously, the constructed CRG provides a structured basis for human review. Human code corrections based on the CRG review results will be further captured by the project self-evolution subsystem described below, thus connecting a complete data link from compliant generation to traceable review to adaptive evolution.
[0087] In this embodiment, the aim is to protect the anti-illusion algorithm logic that transforms unstructured reasoning processes into verifiable causal graphs and quantifies the strength of logical support. It is not limited to specific graph structure implementations or confidence calculation models. As long as it includes structured mapping, logical support calculation, and interactive tracing visualization, it is within the scope of protection of this application.
[0088] Specifically, structured mapping refers to parsing the intermediate reasoning steps (thought chains) generated by the large language model into independent graph nodes, and establishing their dependency edges with the retrieved knowledge slices and final code fragments in the graph database to construct a causal reasoning graph.
[0089] Logical support calculation refers to using natural language reasoning models or cross-encoders to quantify the logical implication score of the parent node to the child node, and combining it with the node weights on the path to calculate the path causal confidence of the terminal code node.
[0090] Interactive source tracing visualization refers to using path causal confidence to differentiate lines of code in the user interface, such as highlighting warnings and differentiating transparency, and responding to user focus events to dynamically extract and display key causal subgraphs filtered by confidence.
[0091] Furthermore, when the target code enters the codebase, a knowledge-closed-loop strategy based on feedback entropy reduction is automatically triggered. This involves three sequentially linked steps: identifying whether human corrections exist, updating the contract centroid, calculating the project's composite entropy, and triggering adaptive feedback. If the submission does not involve human corrections, the interaction is treated as a zero-correction sample where the AI result is directly accepted.
[0092] First, it identifies whether human corrections exist. That is, when a code submission containing AI-generated code occurs, a difference analyzer is triggered. By comparing the code changes between the original AI-generated code and the final code stored in the codebase, a knowledge correction vector is obtained. .
[0093] Specifically, by comparing the code changes before and after the commit, the corrections are identified. .in, The original code generated by AI. This is the final code to enter the codebase; if the commit has not been modified by humans, then it is defined as... This treats the interaction as a zero-correction sample, and the knowledge correction vector is calculated accordingly. This vector represents the gradient direction from general model cognition to project-specific cognition.
[0094] ,in, This is a knowledge correction vector, oriented towards human-preferred programming styles / logic, used to guide the update direction of the contract centroid; when hour, A value of 0 indicates that no new project preference corrections will be introduced in this round of interaction.
[0095] This indicates that the same code embedding model is used for the vectorization of contract rules in the contract anchoring subsystem, ensuring that the correction vector and the contract centroid are in the same vector space.
[0096] The knowledge correction vector was extracted in the previous step. Subsequently, to avoid system oscillations caused by a single sample correction, an inertial weighted update algorithm is used to dynamically adjust the global contract centroid, thus obtaining the inertially updated global contract centroid. .
[0097] ;in, The contract centroid before the t-th update is the constraint benchmark currently used by the contract anchoring subsystem. The updated contract centroid will serve as the new constraint benchmark for the contract anchoring subsystem during the next round of code generation. This is the inertia retention coefficient, used to maintain the stability of historical knowledge and ensure the smoothness of system evolution. A recommended value range is [0.95, 0.999]. A larger value indicates a more conservative system; a smaller value indicates a faster system adapts to new knowledge. This is the evolutionary learning rate. It controls the impact of a single feedback on the global norm; a value of [0.01, 0.1] is recommended. This parameter will be dynamically adjusted according to changes in the project's composite entropy. This is the knowledge correction vector extracted in the previous step.
[0098] Furthermore, after completing the inertial update of the contract centroid, the effectiveness of the update can be evaluated to prevent blind evolution. Therefore, a closed-loop control model based on dynamic entropy monitoring is established. By quantifying the deviation between the AI-generated code and the final human-generated code, the effectiveness of the evolution is evaluated in real time, and system parameters are dynamically adjusted accordingly. This closed-loop control model based on dynamic entropy monitoring obtains the comprehensive deviation between the original AI-generated code and the final code stored in the codebase. Then, based on the comprehensive deviation and the time decay factor, the project composite entropy is constructed. Finally, based on the project's composite entropy The changing trend automatically triggers adaptive feedback by invoking the corresponding feedback control mode.
[0099] Specifically, the overall deviation value of a single code iteration is first calculated. This value is composed of two weighted differences: one is the text-level bias, which uses Levenshtein edit distance to calculate the difference between the AI-generated text and the manually corrected text, and then normalizes it; the other is the structural bias, which uses Tree Edit Distance (TED) to calculate the operational cost of the abstract syntax tree nodes of both, and then normalizes it. This dimension is used to capture core semantic changes such as logical flow and function call relationships.
[0100] . The overall deviation value for the k-th submission, ranging from [0, 1]; This is the normalized tree edit distance, with a value range of [0, 1].
[0101] , All are dimension weight coefficients. To ensure The value range is [0, 1].
[0102] The above comprehensive deviation value The calculation is not limited to Levenshtein and TED algorithms. Within the scope of protection of this application, any combination of algorithms that can measure sequence similarity such as BLEU and Rouge and structural / semantic similarity such as CodeBLEU and ControlFlow Graph Matching can be used to construct this deviation measurement index, that is, all of them are within the scope of protection of this application.
[0103] To quantitatively measure the aforementioned knowledge entropy reduction process, a comprehensive deviation value is obtained. Then, a time decay factor is introduced, and a weighted average is performed on all samples within the observation window to construct the project's composite entropy. Because each new code commit introduces new code into the observation window. The sample window slides accordingly. It is a time-varying variable that updates with each commit event, denoted as... is the project composite entropy calculated based on the current window after the t-th submission, a metric reflecting the overall evolution level of the project.
[0104] W is the observation window length, with a value range of [20, 100], used to smooth out fluctuations in the programming habits of individual developers. This is a time decay factor with a value range of (0, 1]. This factor is used to ensure that recent code interactions have a greater influence on the system's evolutionary state.
[0105] Entropy-based adaptive feedback control refers to not only continuously monitoring the project's composite entropy... It will also be based on its changing trend The corresponding feedback control mode is automatically triggered. Among them, .
[0106] like and If it is determined that the AI has deeply mastered the implicit specifications of the project, the evolutionary learning rate will be automatically reduced. The value is preferentially reduced to 10% of the original value to prevent model degradation caused by overfitting. The preferred values are [0.1, 0.15].
[0107] like and If the current evolution is determined to be stagnant and the AI is unable to learn complex rules through simple imitation, then the retrieval depth of RAG will be automatically increased or the sampling range of the project's gene map will be expanded.
[0108] like If knowledge contamination or drastic environmental changes are detected, the current centroid update logic will be immediately abrogated, and the system will roll back to the previous stable version of the contract centroid. It generates an anomaly report for manual review. That is, after the task is completed, if the code passes the audit and enters the code repository, the current anchor point is strengthened; if the code is modified by humans, the project's self-evolution subsystem uses the correction data to update, making the next generated anchor loss more accurate.
[0109] Existing AI models are typically static and unable to remember human preferences and corrective logic generated during project development, leading to the recurrence of the same errors. This application introduces a time-weighted project composite entropy calculation model, combining text edit distance and AST tree edit distance to accurately capture the deep logical differences in human corrective behavior. Through an inertial weighted update algorithm, it dynamically adjusts the contract centroid, enabling it to automatically learn implicit knowledge such as project-specific naming habits and error handling styles from human modifications. Furthermore, it adaptively adjusts the evolution rate based on the project's composite entropy trend, such as knowledge solidification or abnormal circuit breaking, ensuring that the model's capabilities remain synchronized with project evolution and effectively avoiding catastrophic forgetting.
[0110] Existing agents often suffer from cascading errors when performing autonomous reconstruction tasks that last for hours due to a lack of corrective mechanisms. The solution disclosed in this application couples pre- and in-process constraints, causal traceability of process records, and post-process feedback into a tightly closed-loop control system. When the system detects excessive oscillations in the project's composite entropy or excessive semantic deviation, it can automatically trigger circuit breaker rollback or strengthen retrieval strategies. This mechanism can effectively suppress error accumulation in long-term tasks, enabling AI to safely and stably execute complex system-level reconstruction tasks without human intervention.
[0111] Secondly, this application discloses a trusted AI programming cooperative control system for executing the trusted AI programming cooperative control method disclosed in the first aspect of this application. The system includes: The asset type determination unit is used to determine the asset type of the project to be programmed based on the received user requirements. The project gene map construction unit is used to call the parsing strategy corresponding to the asset type to perform multi-dimensional analysis of the project to be programmed and construct the project gene map. A global contract centroid vector determination unit is used to extract valid contract rules from the project gene map and determine the global contract centroid vector of the project to be programmed based on all the valid contract rules. The optimization unit is used to intervene in the probability distribution of candidate lexical units in real time based on the semantic deviation between the code content generated by the large language model at each time step and the global contract centroid vector, as well as the default cost function corresponding to the code content, to obtain the optimized target code content.
[0112] A computer device according to embodiments of the present disclosure includes a memory and a processor. The memory is used to store non-transitory computer-readable instructions. Specifically, the memory may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM) and / or cache memory. The non-volatile memory may, for example, include read-only memory (ROM), hard disk, flash memory, etc.
[0113] The processor may be a central processing unit (CPU) or other processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the computer device to perform desired functions. In one embodiment of this disclosure, the processor is used to execute computer-readable instructions stored in the memory, causing the computer device to perform all or part of the steps of the trusted AI programming cooperative control method described in the foregoing embodiments of this disclosure.
[0114] Those skilled in the art will understand that, in order to solve the technical problem of how to achieve a good user experience, this embodiment may also include well-known structures such as communication buses and interfaces, and these well-known structures should also be included within the protection scope of this disclosure.
[0115] like Figure 6 This is a schematic diagram of a computer device provided for an embodiment of the present disclosure. It illustrates a structural schematic diagram suitable for implementing the computer device in the embodiments of the present disclosure. Figure 6 The computer device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0116] like Figure 6 As shown, a computer device may include a processor (such as a central processing unit, graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) or programs loaded from storage devices into random access memory (RAM). The RAM also stores various programs and data required for the operation of the computer device. The processor, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.
[0117] Typically, the following devices can be connected to the I / O interface: input devices, such as sensors or visual information acquisition devices; output devices, such as displays; storage devices, such as magnetic tapes or hard drives; and communication devices. Communication devices allow the computer device to communicate wirelessly or wiredly with other devices (such as edge computing devices) to exchange data. Although Figure 6A computer apparatus with various devices is shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or included alternatively.
[0118] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processor, all or part of the steps of the trusted AI programming cooperative control method of embodiments of this disclosure are performed.
[0119] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.
[0120] A computer-readable storage medium according to embodiments of the present disclosure stores non-transitory computer-readable instructions. When these non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the trusted AI programming cooperative control method described in the foregoing embodiments of the present disclosure are performed.
[0121] The aforementioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or portable hard drive), media with built-in rewritable non-volatile memory (e.g., memory card), and media with built-in ROM (e.g., ROM cartridge).
[0122] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.
[0123] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0124] In this disclosure, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The block diagrams of devices, apparatuses, devices, and systems involved in this disclosure are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as "comprising," "including," "having," etc., are open-ended terms meaning "including but not limited to," and are used interchangeably with them. The terms "or" and "and" as used herein refer to the terms "and / or," and are used interchangeably with them unless the context clearly indicates otherwise. The term "such as" as used herein refers to the phrase "such as but not limited to," and is used interchangeably with it.
[0125] Additionally, as used herein, the "or" used in a list of items beginning with "at least one" indicates a separate list, such that a list of, for example, "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not imply that the described example is preferred or better than other examples.
[0126] It should also be noted that in the systems and methods of this disclosure, the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered as equivalent solutions to this disclosure.
[0127] Various changes, substitutions, and modifications can be made to the technology described herein without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of this disclosure is not limited to the specific aspects of the processes, machines, manufactures, events, means, methods, and actions described above. Currently existing or later-developed processes, machines, manufactures, events, means, methods, or actions that perform substantially the same function or achieve substantially the same result as the corresponding aspects described herein can be utilized. Therefore, the appended claims include such processes, machines, manufactures, events, means, methods, or actions within their scope.
[0128] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.
[0129] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations therein.
Claims
1. A reliable AI programming collaborative control method, characterized in that, include: Based on the received user requirements, determine the asset type of the project to be programmed; The parsing strategy corresponding to the asset type is invoked to perform multi-dimensional analysis of the project to be programmed and construct the project gene map. Valid contract rules are extracted from the project gene map, and the global contract centroid vector of the project to be programmed is determined based on all the valid contract rules. Based on the semantic deviation between the code content generated at each time step of the large language model and the global contract centroid vector, real-time intervention is performed on the probability distribution of candidate lexical units to obtain the optimized target code content.
2. The trusted AI programming collaborative control method according to claim 1, characterized in that, The process of invoking the parsing strategy corresponding to the asset type to perform multi-dimensional analysis of the project to be programmed and construct a project genetic map includes: Obtain the target parsing strategy corresponding to the asset type; The target parsing strategy is invoked to perform multi-dimensional parsing of the project to be programmed, and extract several heterogeneous nodes corresponding to the project to be programmed. The several heterogeneous nodes include code-level nodes and document-level nodes. Establish relationship edges between different heterogeneous nodes to generate the project's gene map.
3. The trusted AI programming collaborative control method according to claim 1, characterized in that, The step of extracting valid contract rules from the project gene map and determining the global contract centroid vector of the project to be programmed based on all the valid contract rules includes: Valid contract rules are extracted from the project's gene map according to preset contract rules; By using a code embedding model fine-tuned for the code domain, the content of each of the aforementioned valid contract rules is encoded into a vector of the same dimension, resulting in several embedding vectors; Based on all the aforementioned embedding vectors, determine the global contract centroid vector of the project to be programmed.
4. The trusted AI programming collaborative control method according to claim 3, characterized in that, The step of extracting valid contract rules from the project's gene map according to preset contract rules includes: Extract explicitly declared rule types from document-level nodes; Determine the content from the pattern of code-level nodes; Extract dependency constraints from relation edges; Each of the aforementioned valid contract rules is a triple consisting of the rule type, the content, and the dependency constraint.
5. The trusted AI programming collaborative control method according to claim 1, characterized in that, The step of obtaining the optimized target code content based on the semantic deviation between the code content generated at each time step of the large language model and the global contract centroid vector includes: Obtain the code content generated at each time step of the large language model and the target vector belonging to the same dimension as the global contract centroid; Generate the semantic deviation between the target vector and the global contract centroid vector; If the semantic deviation is greater than a preset drift threshold, the probability distribution of candidate lexical units is nonlinearly corrected in the output probability layer of the large language model to obtain the optimized target code content.
6. The trusted AI programming collaborative control method according to claim 1, characterized in that, The step of obtaining the optimized target code content based on the semantic deviation between the code content generated at each time step of the large language model and the global contract centroid vector includes: The large language model is controlled to generate several candidate code snippets in parallel for the same prompt word; Outside the model, a posterior analysis is performed on each candidate code segment based on the global contract centroid vector to obtain the score result corresponding to each candidate code segment; The candidate code segments whose scoring results meet the preset conditions are selected as the optimized target code content.
7. The trusted AI programming collaborative control method according to claim 1, characterized in that, The generation process also includes: Obtain the causal reasoning graph corresponding to the code content generated at each time step of the large language model; Based on the causal reasoning graph, obtain the path causal confidence level corresponding to any code node; Based on the path causal confidence, a reverse tracing interaction engine corresponding to the target code content is constructed.
8. The trusted AI programming collaborative control method according to claim 7, characterized in that, Also includes: In response to an interaction request for a code node, the reverse graph traversal algorithm is executed through the reverse tracing interaction engine to extract the smallest causal subgraph that is strongly correlated with the corresponding code node from the causal reasoning graph, and then displayed based on a preset visualization strategy.
9. The trusted AI programming collaborative control method according to claim 8, characterized in that, When the target code content enters the code library, a knowledge closed-loop strategy based on feedback entropy reduction is automatically triggered. The automatically triggered execution of the knowledge closed-loop strategy based on feedback entropy reduction includes: Trigger the difference analyzer to obtain a knowledge correction vector by comparing the code changes between the original code generated by AI and the final code stored in the code repository; Based on the knowledge correction vector, the global contract centroid is dynamically adjusted using an inertial weighted update algorithm to obtain the inertial updated global contract centroid.
10. A trusted AI programming collaborative control system, characterized in that, include: The asset type determination unit is used to determine the asset type of the project to be programmed based on the received user requirements. The project gene map construction unit is used to call the parsing strategy corresponding to the asset type to perform multi-dimensional analysis of the project to be programmed and construct the project gene map. A global contract centroid vector determination unit is used to extract valid contract rules from the project gene map and determine the global contract centroid vector of the project to be programmed based on all the valid contract rules. The optimization unit is used to intervene in the probability distribution of candidate lexical units in real time based on the semantic deviation between the code content generated by the large language model at each time step and the global contract centroid vector, as well as the default cost function corresponding to the code content, to obtain the optimized target code content.