Method for generating training data and electronic device

CN122903891APending Publication Date: 2026-10-13ZHEJIANG GEELY HLDG GRP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611029351.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-10
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0004]但是,当输入信息不足时,模型只能基于已有内容进行猜测式推理,从而导致输出结果存在不完整或不准确的问题

Benefits of technology

[0008]本公开实施例提供的技术方案与现有技术相比具有如下优点:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122903891A_ABST
    Figure CN122903891A_ABST
Patent Text Reader

Abstract

The present disclosure relates to the technical field of model training, and particularly relates to a training data generation method and an electronic device. The present disclosure determines whether the existing context information of the target component is complete by performing semantic analysis on the existing context information of the target component, and if the existing context information is incomplete, obtains related supplementary information from a code repository or other knowledge base, and uses the existing context information and the related supplementary information together to generate training data, reduces the influence of guess-type reasoning of a large language model on the quality of the training data, and improves the completeness and accuracy of the training data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of model training technology, and in particular to a method for generating training data and an electronic device. Background Technology

[0002] As the application of large language models in code understanding and generation continues to deepen, how to automatically construct high-quality training data based on complex code repositories has become a key issue in current research and engineering practice.

[0003] In existing technologies, for code understanding and training data generation tasks, inference methods based on large language models are typically used to generate the corresponding training data. These methods primarily construct prompts containing code snippets as input, allowing the large language model to directly output training data after inference.

[0004] However, when the input information is insufficient, the model can only make guessing inferences based on the existing content, which leads to incomplete or inaccurate output results. Summary of the Invention

[0005] To address the aforementioned technical problems, this disclosure provides a method for generating training data and an electronic device.

[0006] A first aspect of this disclosure provides a method for generating training data, including: Retrieve the first context information of the target component in the code repository; Semantic analysis is performed on the target component to obtain a first analysis result, which is used to characterize whether the first context information is complete. If the first analysis result does not fully represent the first context information, supplementary information corresponding to the target component is obtained from the code repository and / or the preset knowledge base; Based on the first context information and supplementary information, training data corresponding to the target component is generated.

[0007] A second aspect of this disclosure provides an electronic device, including: processor; Memory, used to store executable instructions; The processor is used to read executable instructions from memory and execute the executable instructions to implement the training data generation method provided in the first aspect above.

[0008] The technical solution provided in this disclosure has the following advantages compared with the prior art: The training data generation method and electronic device provided in this disclosure first perform semantic analysis on the existing context information of the target component to determine whether the context information is complete. If it is incomplete, relevant supplementary information is obtained from the code repository or other knowledge base and used together with the existing context information to generate training data. This reduces the impact of guesswork reasoning by large language models on the quality of training data and improves the completeness and accuracy of training data. Attached Figure Description

[0009] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0010] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 This is a flowchart of a method for generating training data provided in an embodiment of this disclosure; Figure 2 This is a schematic diagram of an application scenario provided by an embodiment of this disclosure; Figure 3 A flowchart illustrating a method for generating training data according to another embodiment of this disclosure; Figure 4 This is a schematic diagram of the structure of a training data generation device provided in an embodiment of this disclosure; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0012] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0013] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.

[0014] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0015] It should be noted that, in this document, 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. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0016] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0017] As the application of large language models in code understanding and generation deepens, automatically constructing high-quality training data from complex code repositories has become a key issue in current research and engineering practice. Existing technologies typically employ a single model combined with fixed input prompts for code analysis and generation. This method relies solely on contextual information from a single input and lacks dynamic scalability. In complex code repository scenarios, due to multi-layered function call relationships and cross-file / cross-module dependencies between code components, such methods struggle to obtain complete contextual information, leading to insufficient understanding of the code logic.

[0018] Currently, tasks involving code comprehension and training data generation typically employ one-off inference methods based on a single large language model. These methods primarily construct input prompts containing code snippets, allowing the model to directly output analysis results or generate training data during a single round of inference. However, because this method relies on fixed contextual input, the model cannot dynamically acquire additional information during inference. When input information is insufficient, the model can only perform guesswork based on existing content, leading to incomplete or inaccurate analysis results.

[0019] Furthermore, in scenarios involving complex code repositories, it is difficult to effectively handle function call chains and cross-module dependencies. Because code components typically involve multiple levels of nested calls and implementation logic scattered across different files, a single input mechanism cannot cover all relevant information. This makes it difficult for the model to establish complete semantic relationships, resulting in significant deficiencies in the generated results regarding logical consistency and business completeness.

[0020] To address the aforementioned problems, this disclosure provides a method for generating training data, which will be described below with reference to specific embodiments.

[0021] Figure 1 This is a flowchart illustrating a method for generating training data according to an embodiment of this disclosure. This method can be executed by a training data generation device, which can be implemented in software and / or hardware. The training data generation device can be configured in an electronic device, such as a server or terminal, where the terminal specifically includes a mobile phone, computer, or tablet computer. Furthermore, this method can be applied to… Figure 2 The application scenario shown includes a training data generation system deployed in electronic devices. For example... Figure 2 As shown, the training data generation system includes multiple agents, namely, orchestration master agent 21, semantic analysis agent 22, information extraction agent 23, and data generation agent 24.

[0022] It is understood that the training data generation method provided in this disclosure can also be applied in other scenarios.

[0023] The following is combined with Figure 2 The application scenarios shown are for Figure 1 The method for generating the training data shown will be introduced. For example... Figure 1 As shown, the method for generating training data provided in this embodiment includes the following steps.

[0024] S110. Obtain the first context information of the target component in the code repository.

[0025] A code repository refers to a computer system or collection of structured files used to store and manage software source code. A target component refers to an independent business unit within the code repository that has been selected as the object for current semantic analysis and training data generation; it can be a function, class, or method.

[0026] The first context information refers to basic information directly related to the target component. For example, the original context information could be the source code text of the target component itself. Alternatively, the first context information could also be the context information after the last update.

[0027] The orchestration master agent in the system is generated using training data. After acquiring the code repository to be processed, the code repository is structured and parsed to identify multiple components with independent business functions. The target component can be any one of the multiple components, and the first context information of the target component is determined.

[0028] S120. Perform semantic analysis on the target component to obtain the first analysis result.

[0029] The first analysis result is used to characterize whether the first contextual information is complete.

[0030] Semantic analysis refers to the process of parsing a target component by combining it with primary contextual information, transforming the syntactic structure of the code into an understandable business semantic expression.

[0031] The standard for whether the first context information is complete is whether the training data generation system can fully and accurately understand the business logic of the target component based on the first context information.

[0032] The orchestration main agent calls the semantic analysis agent to parse the target component and its first context information, evaluate whether the business logic of the target component can be fully understood based on the first context information, and finally output the first analysis result containing the information completeness judgment.

[0033] S130. If the first analysis result indicates that the first context information is incomplete, obtain supplementary information corresponding to the target component from the code repository and / or the preset knowledge base.

[0034] If the first analysis result does not represent the first context information completely, it means that there is a lack of information in the first context information. The training data generation system is currently unable to fully understand the business logic of the target component, such as being unable to explain the execution purpose of the code or to establish a complete logical relationship.

[0035] A pre-built knowledge base refers to a pre-constructed set of structured knowledge, such as external semantic information related to the domain of the code repository, including business rules, industry standards, and general technical specifications.

[0036] When the semantic analysis agent provides a first analysis result that is incomplete in representing the first context information, the training data generation system enters the information supplementation process. During this process, the information extraction agent obtains the corresponding supplementary information based on the structured request generated by the semantic analysis agent, thereby expanding the first context information.

[0037] S140. Based on the first context information and supplementary information, generate training data corresponding to the target component.

[0038] Training data refers to structured data used to train a model, which helps the model learn the semantic understanding and logical reasoning capabilities of code.

[0039] After obtaining the supplementary information, the orchestration master agent fuses the first context information with the supplementary information and calls the data generation agent to generate training data based on the fused information.

[0040] Alternatively, if the first analysis result fully represents the first context information, then training data corresponding to the target component is generated based on the first context information.

[0041] For example, training data can be generated by a prompting-driven data generation agent. An example of a prompting-driven project is as follows: "You are a training data generation expert. Please generate the corresponding training data based on the following context information:" Formatting requirements: [Please enter the desired format here according to your specific needs, such as: question-answer pairs, instruction responses, or structured data containing inference chains.] Context information: {context}.

[0042] This embodiment of the disclosure first performs semantic analysis on the existing context information of the target component to determine whether the context information is complete. If it is incomplete, relevant supplementary information is obtained from the code repository or other knowledge base and used together with the existing context information to generate training data. This reduces the impact of guesswork reasoning by large language models on the quality of training data and improves the completeness and accuracy of training data.

[0043] In some embodiments, semantic analysis is performed on the target component to obtain a first analysis result, including: parsing the function call relationship, input and output parameters and business rule description information corresponding to the target component based on the first context information; if there is an unparsed function call relationship, and / or there are input and output parameters from unknown sources, and / or the business rule description information is incomplete, then the first analysis result is determined to be that the first context information is incomplete.

[0044] Function call relationships refer to the call associations between code units within the target component and between the target component and external components. Examples include other functions called by the target component, instances where the target component is called by other functions, and nested call levels between functions. Unresolved function call relationships refer to situations where a function call statement exists in the first context information, but the implementation code of the called function is not within the scope of the first context information, making it impossible to obtain the specific execution logic of the function.

[0045] Input and output parameters refer to the input data and returned output results in the target component. They may also include the number, type, and method of passing parameters, as well as their usage within the function. Input and output parameters from unknown sources refer to parameters that exist in the first context information, but whose definition, assignment logic, or data source is outside the scope of the first context information, making it impossible to determine their meaning, value range, and function.

[0046] Business rule description information refers to the business logic descriptions embodied in the code through comments, docstrings, naming conventions, etc., as well as the business rules corresponding to the execution logic of the code itself. Incomplete business rule description information means that insufficient information cannot be extracted from the primary context information to infer the specific business functions and business rules implemented by the code.

[0047] The semantic analysis agent first parses the function signatures, input / output parameters, and control flow structure of the target component and identifies key logic branches in the code. Then, by analyzing the call statements in the function body, it extracts potential dependencies, including the called function, its class, and external modules. The semantic analysis agent further determines whether the current context information is sufficient to support a complete understanding, such as whether there are unresolved function calls, missing explanations of the sources of key variables, and missing necessary business rule descriptions.

[0048] Specifically, a structured prompting engineering-driven semantic analysis agent performs semantic parsing on the target components.

[0049] The following is a sample project example: "You are a code comprehension expert. Please analyze the following code and context:" 1. What is the purpose (business meaning) of this code? 2. Which dependencies are missing? 3. Do you need more information to complete the analysis? Please return the results in XML format: <analysis> <BUSINESS_MEANING> Specific business meaning description< / BUSINESS_MEANING> <MISSING_DEPENDENCIES> List of missing dependencies< / MISSING_DEPENDENCIES> <INFO_NEED> true / false< / INFO_NEED>< / analysis> Code content: {component_code} Context information: {context}.

[0050] The code content represents the target component, and the context information represents the first context information of the target component.

[0051] After the semantic analysis agent performs the semantic analysis task, it outputs the first analysis result.

[0052] Optionally, the first analysis result includes the judgment result on whether the first context information is complete, and the supplementary information required for missing information.

[0053] This disclosure embodiment objectively and comprehensively evaluates the first context information through multiple dimensions of judgment criteria, ensuring the accuracy and rationality of the judgment on the integrity of the first context information, providing a reliable data or information foundation for the generation of training data, and further improving the accuracy and integrity of the training data generation.

[0054] In some embodiments, the completeness of the supplemented context information still needs to be determined.

[0055] After obtaining supplementary information, second context information is generated based on the first context information and the supplementary information; based on the second context information, semantic analysis is performed on the target component to obtain the second analysis result.

[0056] Similar to the first analysis result, the second analysis result is used to characterize whether the second contextual information is complete.

[0057] One possible scenario is that if the second analysis result fully represents the second context information, then training data corresponding to the target component is generated based on the second context information.

[0058] After obtaining the supplementary information, the orchestration master agent merges and splices the supplementary information with the first context information to obtain the second context information.

[0059] Optionally, semantic compression methods can be used to control the length of the second context information, preventing it from becoming too long and causing the input content of the semantic analysis agent to be too large. Semantic compression methods refer to using a large language model to compress the second context information, retaining the content semantically relevant to the target component and removing relatively redundant content.

[0060] After obtaining the second context information, the orchestration master agent calls the semantic analysis agent again to perform a new round of semantic parsing and obtain the second analysis result.

[0061] When the second analysis result fully represents the second context information, the main agent is orchestrated to call the data generation agent to execute the training data generation process.

[0062] Optionally, the semantic analysis agent and the data generation agent can be the same agent, which automatically executes the training data generation process when it is determined that the second context information is complete.

[0063] This embodiment of the disclosure further ensures the quality of training data by expanding the context information and then evaluating the completeness of the expanded context information through semantic analysis. Training data is generated only after the completeness of the expanded context information is confirmed.

[0064] In some embodiments, obtaining supplementary information corresponding to the target component from the code repository and / or preset knowledge base includes: if the number of times the supplementary information corresponding to the target component is obtained is less than a preset number threshold, then obtaining the supplementary information corresponding to the target component from the code repository and / or preset knowledge base.

[0065] If the first analysis result does not represent complete first context information, then the first context information needs to be supplemented and expanded. In this case, it is necessary to first determine whether the number of times the information is supplemented for the target component is less than a preset threshold to avoid excessive looping in the information supplementation process.

[0066] If the number of times supplementary information is obtained is less than the preset threshold, more information related to the target component can be obtained, the supplementary information can be obtained, the first context information can be updated, and the updated second context information can be semantically analyzed and followed up.

[0067] If the number of times the supplementary information is added is greater than or equal to the preset number of times threshold is set, it means that the current number of times the supplementary information is added has reached or exceeded the upper limit, and no more context information will be added. Training data will be generated based on the first context information obtained after the last addition.

[0068] Figure 3 A flowchart illustrating a method for generating training data according to another embodiment of this disclosure. (See attached flowchart.) Figure 3 As shown, the method includes the following steps: S310, Determine the target component and context information.

[0069] S320. Determine if the context information is complete.

[0070] If yes, execute S350. If no, execute S330.

[0071] S330. Determine whether the number of times supplementary information is less than the preset number threshold.

[0072] If yes, proceed to S340. If no, proceed to S350.

[0073] S340. Obtain supplementary information and update the context information based on the supplementary information.

[0074] S350. Generate training data corresponding to the target component based on context information.

[0075] This embodiment of the disclosure sets a preset threshold number of times to supplement context information that is still missing after expansion within the range allowed by system resources. At the same time, it avoids resource waste or excessively large context information due to excessive number of loops in the information supplementation process. It ensures the integrity of context information as much as possible within a certain range, and achieves a balance between information processing efficiency and training data quality.

[0076] The following explains the process of structured parsing of code repositories.

[0077] In some embodiments, before obtaining the first context information of the target component in the code repository, the ownership relationship between files in the code repository is determined based on the file directory of the code repository; a syntax parsing tool is invoked to parse the source code of the code repository and generate an abstract syntax tree; a dependency graph is generated based on the ownership relationship and the abstract syntax tree; and at least one component corresponding to the code repository is determined based on the business units in the dependency graph.

[0078] The file directory of a code repository reflects the hierarchical structure of the code repository. The ownership relationship between files refers to the inclusion and contained relationship between each file and directory in the code repository, as well as the parallel relationship between files at the same level.

[0079] The orchestration master agent receives the code repository path as input and constructs a hierarchical structure representation of the code repository by traversing the file directory to clarify the ownership relationship between files.

[0080] Abstract syntax trees (ASTs) are used to represent the syntactic structure and function call relationships of a code repository. Parsing tools can perform syntactic analysis on source code, transforming the source code text into a structured syntactic representation. Each node in the AST represents a syntactic element in the source code, and the parent-child relationships between nodes represent the inclusion relationships between syntactic elements.

[0081] Dependency graphs are used to represent the syntactic and logical relationships between files. Nodes represent code units, or components; directed edges represent dependencies between code units, such as function calls, class inheritance, and variable references. The syntactic and logical relationships between files refer to the logical connections established between code units in different files through syntactic elements, such as a function in one file calling a function in another file.

[0082] A component is a function in a code repository, or a class and method in a code repository, and at least one component includes the target component.

[0083] The orchestration master broker extracts functions, classes, and methods from the code repository and manages them as components. Each component is assigned a unique identifier to facilitate its location in structured data (such as a dependency graph) during subsequent processing. Simultaneously, the orchestration master broker constructs a dependency graph based on the code repository's hierarchical structure and abstract syntax tree to represent the dependencies between components, describing function call chains and inter-module relationships.

[0084] For example, the orchestration master proxy includes a structure parsing layer, a semantic modeling layer, and a component atomization layer. The structure parsing layer transforms file paths in the code repository into a hierarchical topology tree, establishing the ownership relationships between files. The semantic modeling layer traverses the abstract syntax tree generated by the syntax parsing tool, transforming the tree structure into a multi-dimensional dependency graph, and identifying cross-file references, inheritance, and invocation logic. The component atomization layer deconstructs independent business units from the dependency graph to obtain components and extracts the component's context information. Optionally, this context information is the first context information.

[0085] This disclosure transforms the original code repository into a structured semantic analysis object, providing an accurate and orderly data foundation for semantic analysis, information supplementation, and training data generation, thereby improving the automation level of the entire process and thus increasing the efficiency of training data generation.

[0086] The process of obtaining supplementary information is described below. This process is divided into an internal code retrieval stage and an external knowledge retrieval stage.

[0087] During the internal code retrieval phase, the dependency chain corresponding to the target component is determined in the dependency graph; supplementary information is obtained based on the dependency chain.

[0088] A dependency chain refers to the set of paths that can be reached from the target component node along directed edges in a dependency graph. It is used to represent other components that the target component directly or indirectly depends on during execution.

[0089] The information extraction agent locates the node corresponding to the target component in the dependency graph based on the identifier of the target component, and extends upward or downward along the dependency chain corresponding to the target component to obtain more complete execution path information of the target component and obtain supplementary information.

[0090] If the first analysis result does not fully represent the first context information, supplementary requirement information is generated to represent the missing information in the first context information.

[0091] Supplemental requirement information refers to natural language text generated by the semantic analysis agent to describe the specific missing content in the first context information.

[0092] In the external knowledge retrieval stage, a search is performed in the preset knowledge base based on the vector representation of the supplementary requirement information to obtain supplementary information whose vector similarity is greater than the preset similarity threshold.

[0093] The information extraction agent converts the supplementary requirement information into a vector representation, searches the preset knowledge base based on the vector representation, calculates the vector similarity between the vector representation of each knowledge item in the preset knowledge base and the vector representation of the supplementary requirement information, and obtains the knowledge items with a vector similarity greater than a preset similarity threshold as supplementary information.

[0094] Optionally, duplicate entries can be removed from the retrieved knowledge items. Alternatively, a large language model can be used to retain the key content with the highest similarity to the target component, thus filtering out redundant information.

[0095] Optionally, the supplementary information obtained during the internal code retrieval phase and the supplementary information obtained during the external knowledge retrieval phase can be integrated to finally obtain the supplementary information corresponding to the target component.

[0096] This embodiment of the disclosure integrates internal information obtained from the code repository and external information obtained from the preset knowledge base to form comprehensive multi-source supplementary information, thereby improving the comprehensiveness of the obtained supplementary information and helping to improve the quality of training data.

[0097] In some implementations, the generated training data needs to be quality checked, and the training data that passes the check can be used to train the model.

[0098] The model to be trained is primarily used to complete two types of tasks. One type is code understanding and question answering, where the model needs to generate answers based on user-input questions, providing code evidence from the code repository and the reasoning process. The other type is code architecture design, where the model needs to generate design solutions based on user-input requirements and the code repository, providing code evidence from the code repository and the reasoning process.

[0099] Optionally, training data may include code snippets, reasoning chains, and question-answer pairs.

[0100] The first pre-defined model is primarily used for code comprehension and question-answering tasks. For training data for such tasks, if the code snippets exist in the code repository and their execution logic conforms to the reasoning chain, the training data is deemed to have passed validation. If the training data passes validation, the first pre-defined model is trained using the training data.

[0101] The second pre-set model is mainly used to perform code architecture design tasks. For training data for such tasks, test code needs to be built during verification. The test code is used to verify the code snippets. The test code is run in a sandbox to obtain the running results. If the code snippets exist in the code repository, the execution logic of the code snippets conforms to the reasoning chain, and the running results indicate that the test code runs successfully, the training data is determined to have passed the verification. If the training data has passed the verification, the second pre-set model is trained using the training data.

[0102] Code snippets are the foundation of reasoning thought chains. It is necessary to ensure that code snippets exist in the code repository to prevent data generation agents from generating fictitious content during the data generation process and to ensure the authenticity of training data.

[0103] The reasoning thought chain is a structured text formed by an intelligent agent in the process of understanding code logic. It is a step-by-step natural language description of the actual execution path of the code from a given input to the final output, including key logical branches, condition judgments, variable passing and state changes in the code.

[0104] The reasoning steps described in the reasoning chain should be consistent with the actual execution path of the code snippet. That is, each reasoning step described in the reasoning chain should be able to form a one-to-one mapping relationship with the sequence of instructions actually executed by the code snippet at runtime.

[0105] For example, the causal logical relationships described in the inference chain must be consistent with the actual execution order and dependencies determined by the control flow in the code, such as if-else, for loops, function calls, etc.; the changes in variable states and parameter passing in the inference chain must be consistent with the changes in memory states during the actual execution of the code; and the final conclusion or output deduced by the inference chain must be the same as the result produced after the code segment is actually executed.

[0106] Test code is used to verify the functionality and executability of code snippets in the training data. Examples include input test cases, code snippet call statements, and result assertion statements, to verify whether the code snippets can produce the expected output under given input.

[0107] For example, the training data generation system also includes a result verification agent. The orchestration master agent calls the result verification agent, which is driven by a prompting project to verify the training data. An example of a prompting project is shown below: "You are a code data quality auditing expert, skilled at ensuring the absolute reliability of training data through static logic analysis and dynamic sandbox execution."

[0108] Please perform multi-dimensional validation on the following generated training data and output the validation results.

[0109] Verification dimensions: 1. Source Grounding: Check whether the generated code snippets can be found in the original code context; illusion generation is strictly prohibited.

[0110] 2. Logical Consistency: Verify whether the steps described in the inference chain match the actual execution path of the code.

[0111] 3. Dynamic Reliability (Sandbox Execution): Build a piece of test code, ready to run in a sandbox environment.

[0112] Output requirements (XML format): <CHECK_REPORT> <STATIC_AUDIT> <CODE_MATCH> Passed / Failed (Reason)< / CODE_MATCH> <REASONING_VAL> Is the logic of the reasoning chain self-consistent?< / REASONING_VAL> < / STATIC_AUDIT> <SANDBOX_SCRIPT> <![CDATA[ # Write the executable code here to verify the code snippet. # Assertions are required to verify the expected logic. ]]> < / SANDBOX_SCRIPT><FINAL_CONFIDENCE> 0-100%< / FINAL_CONFIDENCE>< / CHECK_REPORT> Data to be verified: {generated_data} Original code context: {context}.

[0113] The data to be verified is the generated training data, and the original code context is the target component and context information used to generate the training data.

[0114] The data validation agent compares {generated_data} and {context} to determine the validity of the data.<STATIC_AUDIT> The system provides feedback on the presence of fictitious code. After receiving the output from the data verification agent, the orchestration master agent extracts...<SANDBOX_SCRIPT> The test code within the tag will be pushed into a sandbox for execution, such as an isolated Docker container or Python subprocess. If the returned execution result indicates successful execution, the assertions pass, and other validation conditions are met, then the training data is considered validated. Otherwise, the training data is considered not validated.

[0115] This embodiment of the disclosure enhances the logical depth of the training data by using training data containing reasoning thought chains to train the model, enabling more effective training of the model's ability to handle complex business logic. Furthermore, by validating the training data, it effectively identifies instances of fictitious content generated during the training data generation process, ensuring the authenticity and accuracy of the training data and further improving its quality.

[0116] Figure 4 This is a schematic diagram of the structure of a training data generation device provided in an embodiment of this disclosure.

[0117] In this embodiment of the disclosure, the training data generation device may be located within an electronic device and can be understood as a part of the functional modules in the aforementioned electronic device.

[0118] like Figure 4As shown, the training data generation device 40 may include a determining module 41, an analysis module 42, an acquisition module 43, and a generation module 44; wherein, the determining module 41 is used to acquire the first context information of the target component in the code repository; the analysis module 42 is used to perform semantic analysis on the target component to obtain a first analysis result, which is used to characterize whether the first context information is complete; the acquisition module 43 is used to acquire supplementary information corresponding to the target component from the code repository and / or a preset knowledge base when the first analysis result indicates that the first context information is incomplete; the generation module 44 is used to generate training data corresponding to the target component based on the first context information and the supplementary information.

[0119] In some embodiments, the analysis module 42 includes a first analysis unit and a first determination unit. The first analysis unit is used to parse the function call relationship, input and output parameters, and business rule description information corresponding to the target component based on the first context information; the first determination unit is used to determine that the first analysis result is incomplete first context information if there is an unparsed function call relationship, and / or input and output parameters from unknown sources, and / or incomplete business rule description information.

[0120] In some embodiments, the generation module 44 includes a first generation unit, a second analysis unit, and a second generation unit. The first generation unit is used to generate second context information based on first context information and supplementary information; the second analysis unit is used to perform semantic analysis on the target component based on the second context information to obtain a second analysis result, which is used to characterize whether the second context information is complete; the second generation unit is used to generate training data corresponding to the target component based on the second context information if the second analysis result characterizes the second context information as complete.

[0121] In some embodiments, the acquisition module 43 is used to acquire supplementary information corresponding to the target component from the code repository and / or the preset knowledge base if the number of times the supplementary information corresponding to the target component is acquired is less than a preset threshold.

[0122] In some embodiments, the training data generation apparatus 40 includes a structured processing module, used to determine the ownership relationship between files in the code repository based on the file directory of the code repository; call a syntax parsing tool to parse the source code of the code repository to generate an abstract syntax tree, the abstract syntax tree being used to represent the syntax structure and function call relationship of the code repository; generate a dependency graph based on the ownership relationship and the abstract syntax tree, the dependency graph being used to represent the syntactic logical relationship between files; and determine at least one component corresponding to the code repository based on the nodes in the dependency graph, the component being a function in the code repository, or the component being a class and method in the code repository, the at least one component including a target component.

[0123] In some embodiments, the acquisition module 43 is used to determine the dependency chain corresponding to the target component in the dependency graph; and to acquire supplementary information based on the dependency chain.

[0124] In some embodiments, the acquisition module 43 includes a third generation unit and a search unit. The third generation unit generates supplementary requirement information, which is used to represent the information missing in the first context information; the search unit is used to search in a preset knowledge base based on the vector representation of the supplementary requirement information to obtain supplementary information whose vector similarity is greater than a preset similarity threshold.

[0125] In some embodiments, the training data generation apparatus 40 includes a verification module and a training module. The verification module is used to determine that the training data passes verification if the code snippet exists in the code repository and the execution logic of the code snippet conforms to the reasoning chain, whereby the reasoning chain is used to characterize the reasoning process of generating the code snippet. The training module is used to train a first preset model using the training data if the training data passes verification.

[0126] In some embodiments, the verification module includes a testing unit for constructing test code to verify the code snippet; running the test code in a sandbox to obtain the execution result; and determining that the training data passes verification if the code snippet exists in the code repository, the execution logic of the code snippet conforms to the reasoning chain, and the execution result indicates that the test code runs successfully. The training module is used to train a second preset model using the training data if the training data passes verification.

[0127] It should be noted that, Figure 4 The training data generation device 40 shown can execute the various steps in the above method embodiments and realize the various processes and effects in the above method embodiments, which will not be elaborated here.

[0128] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure.

[0129] In this embodiment of the disclosure, Figure 5 The electronic device shown can be a server or terminal, in which a training data generation system is deployed.

[0130] like Figure 5 As shown, the electronic device may include a processor 510 and a memory 520 storing computer program instructions.

[0131] Specifically, the processor 510 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this disclosure.

[0132] Memory 520 may include a large-capacity storage device for information or instructions. For example, and not limitingly, memory 520 may include a hard disk drive (HDD), a floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 520 may include removable or non-removable (or fixed) media. Where appropriate, memory 520 may be internal or external to the integrated gateway device. In a particular embodiment, memory 520 is a non-volatile solid-state memory. In a particular embodiment, memory 520 includes read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (Electrically Programmable ROM, EPROM), an electrically erasable programmable PROM (EEPROM), an electrically alterable ROM (EAROM), or flash memory, or a combination of two or more of these.

[0133] The processor 510 reads and executes computer program instructions stored in the memory 520 to perform the steps of the training data generation method provided in this embodiment of the disclosure.

[0134] In one example, the electronic device may also include a transceiver 530 and a bus 540. Wherein, as... Figure 5 As shown, the processor 510, memory 520 and transceiver 530 are connected via bus 540 and communicate with each other.

[0135] Bus 540 may include hardware, software, or both. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, bus 540 may include one or more buses.

[0136] This disclosure also provides a computer-readable storage medium that can store a computer program that, when executed by a processor, enables the processor to implement the training data generation method provided in this disclosure.

[0137] The aforementioned storage medium may, for example, include a memory 520 containing computer program instructions, which can be executed by a processor 510 of an electronic device to complete the training data generation method provided in this embodiment. Optionally, the storage medium may be a non-transitory computer-readable storage medium, such as a ROM, random access memory (RAM), compact disc ROM (CD-ROM), magnetic tape, floppy disk, and optical data storage device.

[0138] This disclosure also provides a vehicle that includes electronic devices that can implement the various processes and effects described in the above embodiments of this disclosure, which will not be elaborated here.

[0139] This disclosure also provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a processor, they implement the training data generation method provided in this disclosure and can achieve the various processes and effects in the above embodiments of this disclosure, which will not be elaborated here.

[0140] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for generating training data, characterized in that, include: Retrieve the first context information of the target component in the code repository; Semantic analysis is performed on the target component to obtain a first analysis result, which is used to characterize whether the first context information is complete. If the first analysis result indicates that the first context information is incomplete, supplementary information corresponding to the target component is obtained from the code repository and / or the preset knowledge base; Based on the first context information and the supplementary information, training data corresponding to the target component is generated.

2. The method according to claim 1, characterized in that, The semantic analysis of the target component to obtain a first analysis result includes: Based on the first context information, the function call relationship, input and output parameters, and business rule description information corresponding to the target component are parsed. If there are unresolved function call relationships, and / or input / output parameters from unknown sources, and / or the business rule description information is incomplete, then the first analysis result is determined to be that the first context information is incomplete.

3. The method according to claim 1, characterized in that, The step of generating training data corresponding to the target component based on the first context information and the supplementary information includes: Based on the first context information and the supplementary information, second context information is generated; Based on the second context information, semantic analysis is performed on the target component to obtain a second analysis result, which is used to characterize whether the second context information is complete. If the second analysis result fully represents the second context information, then training data corresponding to the target component is generated based on the second context information.

4. The method according to claim 1, characterized in that, The step of obtaining supplementary information corresponding to the target component from the code repository and / or preset knowledge base includes: If the number of times the supplementary information corresponding to the target component is obtained is less than a preset threshold, then the supplementary information corresponding to the target component is obtained from the code repository and / or the preset knowledge base.

5. The method according to claim 1, characterized in that, Before obtaining the first context information of the target component in the code repository, the method further includes: Based on the file directory of the code repository, determine the ownership relationship between the files in the code repository; A syntax parsing tool is invoked to parse the source code of the code repository and generate an abstract syntax tree, which is used to represent the syntax structure and function call relationships of the code repository; Based on the attribution relationship and the abstract syntax tree, a dependency graph is generated, which is used to represent the syntactic logical relationships between the files; Based on the nodes in the dependency graph, at least one component corresponding to the code repository is determined. The component is a function in the code repository, or the component is a class and method in the code repository. The at least one component includes the target component.

6. The method according to claim 5, characterized in that, Obtain supplementary information corresponding to the target component from the code repository, including: Determine the dependency chain corresponding to the target component in the dependency graph; The supplementary information is obtained based on the dependency chain.

7. The method according to any one of claims 1-6, characterized in that, Retrieve supplementary information corresponding to the target component from a preset knowledge base, including: Generate supplementary requirement information, which is used to characterize the missing information in the context information; In the preset knowledge base, a search is performed based on the vector representation of the supplementary requirement information to obtain supplementary information whose vector similarity is greater than or equal to a preset similarity threshold.

8. The method according to any one of claims 1-6, characterized in that, The training data includes code snippets and reasoning chains, and the method further includes: If the code snippet exists in the code repository and the execution logic of the code snippet conforms to the reasoning chain, the training data is determined to pass the verification. The reasoning chain is used to characterize the reasoning process that generates the code snippet. If the training data passes the verification, the first preset model is trained using the training data.

9. The method according to any one of claims 1-6, characterized in that, The training data includes code snippets and reasoning chains, and the method further includes: Construct test code to verify the code snippet; Run the test code in the sandbox and obtain the results; If the code snippet exists in the code repository, the execution logic of the code snippet conforms to the reasoning chain, and the running result indicates that the test code runs successfully, then the training data is determined to pass the verification. If the training data passes the verification, the second preset model is trained using the training data.

10. An electronic device, characterized in that, include: processor; Memory, used to store executable instructions; The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the method of any one of claims 1-9.