Inspection code generation method and system, electronic equipment and storage medium
By entering the large language model of the demand document and reminder, generate and repair the inspection code, solve the problem of the complexity of the configuration and inspection tool in the existing technologies, and improve the efficiency of configuration inspection.
Patent Information
- Application Number
- CN202411276267.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-01-28
AI Technical Summary
In the prior art, configuration inspection tools become complex and specialized, exceeding the learning scope of general designers, resulting in excessive use costs and affecting configuration inspection efficiency.
By entering the large language model of the demand document and reminder, based on the large language model, check the request document generation processing of the required document through the prompt collection, and perform self -inspection and repair the initial inspection code generated by the generated. The target check code is obtained.
It has reduced the learning cost of users, avoids complex data analysis, improves the efficiency of configuration inspections, and allows non -professional developers to quickly configure and check.
Smart Images

Figure CN119376705A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, system, electronic device and storage medium for generating a check code. Background Art
[0002] As application development efficiency increases, the detection tasks in the development process are also becoming heavier. In the application development process, a framework that separates the configuration table from the code is usually used. Since the configuration table is maintained manually according to business needs, mismatches may occur, causing program exceptions.
[0003] In the related art, a configuration checking tool is proposed to check whether the configuration form filled in by the designer contains any content inconsistent with the agreement. Although it can improve the accuracy and efficiency of a single configuration check, as the development content becomes more complex, the checking tools are becoming more and more complex and specialized, which is beyond the scope that general designers can learn and use, resulting in excessively high usage costs and affecting the efficiency of configuration checking. Summary of the invention
[0004] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention provides a method, system, electronic device and storage medium for generating a check code, which can improve the efficiency of configuration checking.
[0005] In one aspect, an embodiment of the present invention provides a method for generating a check code, comprising:
[0006] Input the requirement document and the prompt word set into the large language model;
[0007] Based on the large language model, the inspection code generation process is performed on the requirement document through the prompt word set, and the generated initial inspection code is self-checked and repaired to obtain a target inspection code, wherein the initial inspection code is used to match the inspection requirements of the requirement document, and the target inspection code is the initial inspection code that has passed the self-check and repair process.
[0008] According to some embodiments of the present invention, the prompt word set includes prompt words for requirement splitting and prompt words for code generation, and the checking code generation process of the requirement document by using the prompt word set based on the large language model includes:
[0009] Performing requirement splitting processing on the requirement document based on the requirement splitting prompt word to obtain a sub-requirement set, wherein the requirement splitting prompt word is used to indicate an output format of the sub-requirement set;
[0010] Based on the code generation prompt word, code generation processing is performed on each sub-requirement in the sub-requirement set to obtain the initial check code, wherein the code generation prompt word is used to indicate the code format and code content of the initial check code.
[0011] According to some embodiments of the present invention, the step of performing requirement splitting processing on the requirement document based on the requirement splitting prompt word to obtain a sub-requirement set includes:
[0012] Performing semantic recognition processing on the requirement document based on the requirement splitting prompt words to obtain functional requirements;
[0013] The requirement document is split based on the functional requirements to obtain the sub-requirement set.
[0014] According to some embodiments of the present invention, the step of performing code generation processing on each sub-requirement in the sub-requirement set based on the code generation prompt word to obtain an initial check code includes:
[0015] Determine a check rule and a code template based on the code generation prompt, wherein the check rule is used to match the functional requirements of the sub-requirements, and the code template includes an input format, an output format, and code content;
[0016] The code template is subjected to code completion processing based on the inspection rule to obtain the initial inspection code.
[0017] According to some embodiments of the present invention, the prompt word set further includes positive sample prompt words, negative sample prompt words and self-check and repair prompt words, and the self-check and repair processing is performed on the generated initial inspection code to obtain the target inspection code, including:
[0018] Based on the positive sample prompt word, a positive sample generation process is performed on each sub-demand in the sub-demand set to obtain a positive sample set;
[0019] Based on the negative sample prompt word, a negative sample generation process is performed on each sub-requirement in the sub-requirement set to obtain a negative sample set;
[0020] Performing configuration check processing on the positive sample set and the negative sample set based on the initial check code to obtain a pass code and an error code;
[0021] Perform code repair processing on the error code based on the self-check and repair prompt word to obtain a repair code;
[0022] The target inspection code is determined based on the pass code and the repair code.
[0023] According to some embodiments of the present invention, the step of performing positive sample generation processing on each sub-requirement in the sub-requirement set based on the positive sample prompt word to obtain the positive sample set includes:
[0024] Determining data requirements and table formats based on the positive sample prompt words, wherein the data requirements are used to match the functional requirements of the sub-requirements;
[0025] Table data generation processing is performed based on the data requirements and the table format to obtain the positive sample set.
[0026] According to some embodiments of the present invention, the step of performing negative sample generation processing on each sub-requirement in the sub-requirement set based on the negative sample prompt word to obtain a negative sample set includes:
[0027] Determining an erroneous requirement and a table format based on the negative sample prompt word, wherein the erroneous requirement is used to generate an erroneous demonstration of a functional requirement for the sub-requirement;
[0028] Table data generation processing is performed based on the error requirement and the table format to obtain the negative sample set.
[0029] According to some embodiments of the present invention, the performing configuration check processing on the positive sample set and the negative sample set based on the initial check code to obtain a pass code and an error code includes:
[0030] Performing module loading processing on the initial inspection code based on a dynamic module loading function to obtain an executable module;
[0031] The positive sample set and the negative sample set are respectively input into the executable module for inspection and processing to obtain the pass code and the error code.
[0032] According to some embodiments of the present invention, the performing code repair processing on the error code based on the self-check repair prompt word to obtain the repair code includes:
[0033] Determine the function output and result format based on the self-check and repair prompt word, wherein the function output is the error cause of the error code;
[0034] The error code is repaired based on the function output and the result format to obtain the repair code.
[0035] According to some embodiments of the present invention, after performing self-check and repair processing on the generated initial check code to obtain the target check code, the method further includes:
[0036] Get the configuration table to be checked;
[0037] Dynamically loading the target inspection code to obtain a dynamic module;
[0038] The configuration table is checked and processed based on the dynamic module to obtain a configuration check result.
[0039] On the other hand, an embodiment of the present invention provides a check code generation system, including:
[0040] An input module, configured to input the requirement document and the prompt word set into the large language model;
[0041] The inspection code generation module is configured to perform inspection code generation processing on the requirement document through the prompt word set based on the large language model, and perform self-check and repair processing on the generated initial inspection code to obtain a target inspection code, wherein the initial inspection code is used to match the inspection requirements of the requirement document, and the target inspection code is the inspection code that passes the self-check and repair.
[0042] On the other hand, an embodiment of the present invention provides an electronic device, comprising at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions executable by the at least one control processor, and the instructions are executed by the at least one control processor so that the at least one control processor can execute the check code generation method of the above-mentioned other aspect.
[0043] On the other hand, an embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the inspection code generation method of the above-mentioned other aspect.
[0044] One of the above technical solutions has the following advantages or beneficial effects: The present application provides a method, system, electronic device and storage medium for generating a check code, which inputs a requirement document and a prompt word set into a large language model, performs check code generation processing on the requirement document through the prompt word set based on the large language model, and performs self-check and repair processing on the generated check code to obtain the check code. According to the technical solution of this embodiment, the generation and processing of the check code through the large language model can reduce the learning cost of users, avoid complex data analysis and processing, and improve the efficiency of configuration checking. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a flow chart of a method for generating a check code provided by an embodiment of the present invention;
[0046] Figure 2 yes Figure 1 Flow chart of the check code generation in step S102;
[0047] Figure 3 yes Figure 2 Flow chart of step S201;
[0048] Figure 4 yes Figure 2 Flow chart of step S202;
[0049] Figure 5 yes Figure 1 Flow chart of code self-check and repair in step S102;
[0050] Figure 6 is a flowchart of a specific example provided by the present invention;
[0051] Figure 7 is a schematic diagram of the structure of a check code generation system provided by an embodiment of the present invention;
[0052] Figure 8 It is a structural diagram of an electronic device provided by another embodiment of the present invention. DETAILED DESCRIPTION
[0053] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0054] In the description of the present invention, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., and orientations or positional relationships indicated are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.
[0055] In the description of the present invention, "several" means one or more, "more" means more than two, "greater than", "less than", "exceed" etc. are understood as not including the number itself, and "above", "below", "within" etc. are understood as including the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0056] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention based on the specific content of the technical solution.
[0057] It should be noted that in the field of rule checking technology, as the development efficiency of applications becomes higher and higher, the configuration data to be tested for each application is also increasing, and the detection tasks in the development process are becoming heavier. In the development process of applications, a framework that separates the configuration table from the code is usually adopted. The configuration table is maintained by the designer, while the code is implemented by professional developers. Since the configuration table is maintained manually according to business needs, mismatches may occur, causing program exceptions. Especially in some projects that require long-term maintenance, due to the turnover of project personnel, new maintenance personnel do not understand the initial design of the project well enough, and mismatches will occur more frequently. If an additionally designed configuration checking tool is used for configuration checking, although the accuracy can be greatly improved, the configuration table is mainly maintained by the designer, so this checking tool is also mainly used by the designer. The designer will write the table configuration rules that have been determined in the development process into the tool, and use the tool to check the configuration table before submitting each new form. This leads to the design of the configuration table becoming more complicated as the development content becomes more complicated. Accordingly, in order to cover more scenarios, the checking tools will become more complex and specialized in rule configuration, becoming more like a professional tool used by programmers, deviating from the original intention of being used by non-developers. For example, after years of iteration, the checking tools have begun to use input rules such as regular expressions and custom scripts for configuration checking, which is beyond the scope of what general designers can learn and use, resulting in high usage costs and affecting the efficiency of configuration checking.
[0058] Therefore, an embodiment of the present invention provides a check code generation scheme, which inputs a requirement document and a prompt word set into a large language model, wherein the prompt word set includes requirement splitting prompt words, positive sample prompt words, negative sample prompt words, code generation prompt words, and self-check and repair prompt words. Based on the large language model, the requirement document is processed for check code generation through the prompt word set, and the generated check code is processed for self-check and repair to obtain the check code. According to the technical scheme of this embodiment, the check code generation process is performed through the large language model, which can reduce the learning cost of users, avoid complex data analysis and processing, and improve the efficiency of configuration checking.
[0059] In the present invention, a check code generation method, system, electronic device and storage medium are provided, which are described in detail one by one in the following embodiments.
[0060] The processing procedure of a check code generation method provided by an embodiment of the present invention can cover most application scenarios, so that non-professional developers can also quickly perform configuration checks. Specifically, the designer inputs the requirement document and the prompt word set into the large language model in the system. The large language model performs check code generation processing on the requirement document based on the prompt word set, and performs self-check and repair processing on the generated check code to obtain the check code. The designer can generate the check code corresponding to the requirement document through human-computer interaction with the large language model through the prompt word set, and save the check code to the system, which eliminates repeated data analysis, reduces the learning cost of the designer, and improves the efficiency of configuration checking.
[0061] It should be noted that the execution subject of the inspection code generation method of this embodiment can be a computer system, and the computer system can be a human-computer interaction device such as a personal computer, a terminal, or a common server. It can also be implemented through an integrated configuration inspection device, for example, an artificial intelligence (AI) analysis module and a memory are directly integrated into the configuration inspection device, and the intelligent analysis of the large language model is realized through the AI analysis module, and the inspection code is stored in the memory. Unless otherwise specified, this embodiment does not limit the form of the execution subject of the inspection code generation method.
[0062] Reference Figure 1 , Figure 1 This is a flowchart of a method for generating a check code provided by an embodiment of the present invention. The method for generating a check code includes but is not limited to steps S101 to S102:
[0063] Step S101: input the requirement document and the prompt word set into the large language model.
[0064] Specifically, the prompt word set can be obtained through editing input or generated through a prompt word template, wherein the editing input may include manual input, voice input and other input methods; the prompt word template is a pre-established template that can be stored in a database. By pre-establishing a prompt word template, the input workload is reduced and the input efficiency is improved.
[0065] In practical applications, the requirement document is a requirement text about the table content check function, which is used to check the content of the configuration table. The prompt word set includes requirement splitting prompt words, positive sample prompt words, negative sample prompt words, code generation prompt words and self-check repair prompt words, which are used to provide the necessary context information for the large language model to help the model understand the specific needs of the user. For example, in the inspection code generation system, the model can be guided to focus on the key parts of the rules through clear prompt words, so as to generate more accurate inspection codes. Among them, the requirement splitting prompt words are used to instruct the large language model to split the requirement document, the positive sample prompt words are used to instruct the large language model to generate positive samples for the sub-requirements obtained by splitting, the negative sample prompt words are used to instruct the large language model to generate negative samples for the sub-requirements obtained by splitting, the code generation prompt words are used to instruct the large language model to generate corresponding inspection codes for the sub-requirements obtained by splitting, and the self-check repair prompt words are used to instruct the large language model to self-check the generated inspection code and repair the wrong code. Large Language Model (LLM) is an artificial intelligence model trained with a large amount of text data, which can understand, generate and process natural language text. The large language model uses deep learning technology to learn the statistical laws and patterns of language on massive text data, so that it can perform various natural language processing tasks such as text generation, dialogue systems, language translation, question-answering systems, etc. The embodiment of the present application applies the large language model to the inspection code generation system, generates the inspection code for configuration table inspection through human-computer interaction with the large language model through the prompt word set, can cope with the increasingly complex configuration table inspection requirements based on the large language model, and does not require the user to master complex configuration rules, thereby reducing the cost of use.
[0066] For example, Figure 1 As shown, the requirement document and the prompt word set can be input on the terminal, which can be a human-computer interaction device such as a personal computer, a smart phone, or a tablet computer. The input method can be voice input or handwriting input, and the prompt word set can also be generated based on a template, but is not limited to this. The large language model is deployed on the server, and a commercial large language model can be directly used, or it can be fine-tuned and trained based on a basic large language model. The requirement document and the prompt word set input by the terminal are sent to the large language model in the server, and the large language model performs corresponding processing to generate a check code corresponding to the requirement document, which is saved in the database in the form of code.
[0067] It is conceivable that the large language model can also be deployed locally by downloading the model file on the terminal, configuring a suitable computing environment, such as installing necessary libraries and frameworks, and writing or configuring code for loading and running the model. By localizing the large language model, the large language model can be run on the terminal to generate the inspection code.
[0068] Step S102, based on the large language model, the inspection code generation process is performed on the requirement document through the prompt word set, and the generated initial inspection code is self-checked and repaired to obtain a target inspection code, wherein the initial inspection code is used to match the inspection requirements of the requirement document, and the target inspection code is the initial inspection code that has passed the self-check and repair process.
[0069] Specifically, human-computer interaction is performed on the large language model through a set of prompt words, and the large language model is instructed to generate a corresponding initial inspection code according to the requirement document. The initial inspection code is used to match the inspection requirements of the requirement document, and code inspection is performed on the generated initial inspection code based on the large language model. The initial inspection code that does not meet expectations is repaired, and the inspection code that meets expectations is determined as the target inspection code.
[0070] In practical applications, the prompt word set includes prompt words for demand splitting, positive sample prompt words, negative sample prompt words, code generation prompt words, and self-check and repair prompt words, and the large language model is instructed to perform corresponding generation processing based on different prompt words. For example, based on the prompt words for demand splitting, the large language model can be instructed to split the demand document, and based on the prompt words for code generation, the large language model can be instructed to generate inspection code for the sub-requirements obtained by splitting. The embodiment of the present application performs a detailed disassembly of the generation of the inspection code through the prompt words in the prompt word set, and designs the code inspection and repair process, which effectively reduces the number of inference layers of the large language model and improves the accuracy of the large language model's answers. Compared with the results directly given by the large language model, it has higher accuracy and stability.
[0071] For example, Figure 1 As shown, the large language model is deployed on the server. After the requirement document and the prompt word set are input into the large language model through the terminal, the check code is generated for the requirement document through the prompt word set based on the large language model, and the generated initial check code is self-checked and repaired to obtain the target check code. The target check code is the check code text after the self-check and repair process. The code text data can be saved to the database, or returned to the terminal and saved in a storage space such as memory. The configuration table can be configured and checked through the target check code finally generated to obtain the check result.
[0072] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the present application instructs a large language model to perform corresponding code generation and self-check and repair processing through a prompt word set, and generates corresponding inspection codes based on the configuration table inspection requirements in the requirement document. For users, they only need to input the requirement document and the prompt word set. Users do not need to master complex configuration rules, and can generate inspection codes by expressing requirements in colloquial language. Therefore, the present embodiment can directly generate inspection codes for configuration table inspection, reduce usage costs, and improve configuration inspection efficiency.
[0073] Reference Figure 2 In one implementation of the embodiment of the present invention, the code generation process is performed on the requirement document based on the large language model through the prompt word set, which specifically includes but is not limited to the following steps:
[0074] Step S201, performing requirement splitting processing on the requirement document based on the requirement splitting prompt word to obtain a sub-requirement set, wherein the requirement splitting prompt word is used to indicate the output format of the sub-requirement set;
[0075] Step S202, performing code generation processing on each sub-requirement in the sub-requirement set based on the code generation prompt word to obtain an initial check code, wherein the code generation prompt word is used to indicate the code format and code content of the initial check code.
[0076] Specifically, the requirement splitting prompt words are used to instruct the large language model to split the requirement document and specify the output format of the sub-requirement set obtained by the splitting. The embodiment of the present application performs requirement splitting on the requirement document based on the large language model through the requirement splitting prompt words to obtain a sub-requirement set, which includes at least one sub-requirement obtained by splitting the requirement document. The requirement document is a requirement text about the table content checking function, and the requirement text may include one or more contents that need to be checked. The requirement splitting prompt words can instruct the large language model to perform requirement analysis on the requirement text and split it to obtain a sub-requirement set, and specify the output format of the sub-requirement set, thereby effectively controlling the output format of the large language model and facilitating subsequent processing.
[0077] In actual applications, based on the requirement splitting prompt words input by the user, the large language model splits the requirement document, splits each inspection requirement in the requirement document to obtain the corresponding sub-requirements, and saves the sub-requirement set. In this process, the input requirement splitting prompt words can be modified, or after obtaining the sub-requirement set, if it does not meet the requirements, continue to enter the corresponding prompt words to modify the returned result, through multiple rounds of human-computer interaction, until a sub-requirement set that meets the requirements is generated.
[0078] Exemplarily, the code generation prompt is used to instruct the large language model to generate corresponding check codes according to the sub-requirements, and determine the code format and check code of the check code. The check code is used to match each sub-requirement, and can be a whole code text to match each sub-requirement, or multiple code texts can be matched to each sub-requirement respectively. The code format is the specific format of the check code, such as Python code, etc., and the check code is the corresponding sub-requirement, such as the field or data that needs to be checked.
[0079] It can be imagined that the embodiment of the present application generates prompt words based on the code input by the user, and the large language model generates a corresponding initial inspection code for each sub-requirement obtained by splitting. The inspection requirements of the sub-requirements can be completed through the initial inspection code, and the configuration table can be configured and checked. Similarly, the input code generation prompt words can be modified to meet the output requirements, and the large language model can be interacted with by human-computer interaction through multiple rounds of human-computer dialogue until an initial inspection code that meets the requirements is generated.
[0080] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the present application performs requirement splitting processing on the requirement document through requirement splitting prompt words to obtain a sub-requirement set, which can enable the large language model to better understand each inspection requirement in the requirement document, and performs code generation processing on each sub-requirement in the sub-requirement set through code generation prompt words to obtain an initial inspection code, and can directly generate code for checking the configuration table through the large language model, reducing the learning cost of designers.
[0081] See also Figure 3 In one implementation of the embodiment of the present invention, the requirement document is split based on the requirement splitting prompt words to obtain a sub-requirement set, including:
[0082] Step S301, performing semantic recognition processing on the requirement document based on the requirement splitting prompt words to obtain functional requirements;
[0083] Step S302: split the requirement document based on the functional requirements to obtain a sub-requirement set.
[0084] Specifically, the requirement splitting prompt words are used to instruct the large language model to understand and analyze the requirement document and split it into a set of sub-requirements that conform to the output format. Functional requirements define the function of checking the content of configuration tables or other tables. In the configuration check application scenario, this functional requirement is the need to check specific content of the configuration table, such as the value size of a field in the configuration table.
[0085] In actual applications, based on the requirement splitting prompt words, the large language model performs semantic recognition on the requirement document and identifies the specific inspection functional requirements in the requirement document. The large language model performs natural language processing on the requirement document and uses deep learning algorithms to understand the semantic content in the document, including the meaning of vocabulary, sentence structure, and contextual relationships, thereby realizing semantic recognition of the requirement document and obtaining functional requirements. After obtaining the functional requirements, the large language model splits the requirement document to obtain a sub-requirement set, and the output of the sub-requirement set needs to conform to the output format of the requirement splitting prompt words. When the large language model splits the document according to the functional requirements, it first analyzes the overall structure and description of each functional module in the requirement document, and then uses natural language understanding and processing capabilities to identify the logical relationships and boundaries between each functional requirement, and then splits the document into multiple independent sub-requirement sets that focus on specific functional requirements.
[0086] Exemplarily, a requirement document may include multiple specific inspection requirements, which may be obtained based on user input or based on pre-established text. For example, a requirement document contains the following content: "The id field in the weapon table should be unique, and the id field exists in the id field in the item table, the id in the item table is unique and continuously incremented, and the value of the count field in the table does not exceed 999". The requirement document contains multiple inspection requirements, and the fields in the weapon table and the item table need to be checked. By inputting the requirement prompt word into the large language model, the requirement prompt word can be input through the human-computer interaction interface, and the content of the requirement prompt word is: "The following is a requirement text about the table content inspection function. Split this requirement into one or more sub-requirements. The function of each sub-requirement is as simple as possible. Your expression should be in line with the programmer's habits, clear and intuitive." The requirement prompt word is used to instruct the large language model to split the requirement document and output a result that meets the requirements. Then the requirement document is input into the large language model, and the requirement document is semantically recognized based on the instruction of the requirement prompt word to obtain the functional requirements, and the requirement document is split based on the functional requirements to obtain a sub-requirement set that meets the requirements. Based on the requirement splitting prompt words, the final sub-requirement set is generated through the large language model. The content of the sub-requirement set is:
[0087] "The id field in the weapon table should be unique.
[0088] The id field in the weapon table exists in the id field in the item table.
[0089] The id field in the item table should be unique.
[0090] The id field in the item table should be incremented continuously.
[0091] The value of the count field in the item table does not exceed 999. "
[0092] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the present application performs demand splitting processing on the demand document based on the demand splitting prompt words to obtain a sub-requirement set, which enables the large language model to better understand the demand document, split the demand document, and generate a sub-requirement set that is easy to process for subsequent processing. The user's spoken demand can be split into multiple sub-requirements, so that each sub-requirement can be processed separately, which is conducive to reducing the number of reasoning layers of the large language model and improving the generation efficiency of the inspection code.
[0093] Reference Figure 4 In one implementation of the embodiment of the present invention, code generation processing is performed on each sub-requirement in the sub-requirement set based on the code generation prompt word to obtain an initial check code, including:
[0094] Step S401, determining a check rule and a code template based on the code generation prompt word, wherein the check rule is used to match the functional requirements of the sub-requirements, and the code template includes an input format, an output format, and code content;
[0095] Step S402: Perform code completion processing on the code template based on the inspection rule to obtain an initial inspection code.
[0096] Specifically, the code generation prompt is used to instruct the large language model to output the initial inspection code that meets the sub-requirements. The inspection rules can be determined. The inspection rules are used to match the functional requirements of the sub-requirements, that is, the corresponding inspection code is defined according to the specific functional requirements of the sub-requirements. The code template includes input format, output format and code content. The input format is the input format of the inspection code, the output format is the output format of the inspection code, and the code content is the pre-established or edited code content. The initial inspection code is the code used to check the configuration table, which can be Python code, etc. The specific format is determined based on the code generation prompt.
[0097] In actual applications, the large language model can determine the inspection rules and code templates based on the code generation prompts, and then complete the code templates based on the inspection rules to obtain the inspection code that meets the inspection test. By inputting the code generation prompts into the large language model and obtaining the split sub-requirement set, the inspection rules are matched based on the functional requirements of each sub-requirement in the sub-requirement set, and the code templates are completed based on the inspection rules to obtain the initial inspection code.
[0098] Exemplarily, the embodiment of the present application generates code for each sub-requirement in the sub-requirement set to obtain the initial inspection code of the corresponding sub-requirement. Taking a specific sub-requirement as an example, the content of the sub-requirement is: "The id field in the weapon table exists in the id field in the item table". The sub-requirement is input into the large language model, and the corresponding code generation prompt is input to generate the initial inspection code. The code generation prompt is: "Complete the python3 code according to the requirements. This code checks the input table according to the given rules. The input of the code is a dictionary containing the mapping of the table name and the table data. The table data format is pandas DataFrame. The code output is a list of line numbers and reasons for violating the rules. Your answer only contains the complete python code. The unfinished code is as follows: (the code content is not shown)". The code generation prompt stipulates that the initial inspection code is used to check the input table, and the inspection rule is the content of the sub-requirement. The code generation prompt also defines a code template, which limits the code input to a dictionary containing table names and table data mappings, and limits the table data format to pandas DataFrame, where pandas DataFrame is a two-dimensional, variable-size, potentially heterogeneous table data structure, similar to a SQL table or Excel data table, with row labels and column labels. In addition, the code generation prompt limits the code output to a list of line numbers and reasons for rule violations, and limits the large language model output to only output complete Python code. The code template can include unfinished code content, which is not shown here. The code content can specify an import statement. For example, the code content is: "import pandas as pd" is used to introduce the pandas library into the current environment and set an alias pd for it. Among them, pandas is a powerful Python data analysis library that provides high-speed, flexible and expressive data structures. The code content may also include the return result format and the function name and function parameters that define the inspection table. The code content may standardize the format of the output initial inspection code to facilitate docking with the system or database.
[0099] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the present application performs code generation processing on each sub-requirement in the sub-requirement set based on the code generation prompt word to obtain an initial check code, and can quickly generate the check code through a large language model, so that designers can generate check codes to perform configuration checks on the configuration table without having to master professional knowledge, thereby reducing the learning cost of designers and improving data processing efficiency.
[0100] Reference Figure 5In one implementation of the embodiment of the present invention, the generated initial inspection code is subjected to self-inspection and repair processing to obtain a target inspection code, including:
[0101] Step S501, performing positive sample generation processing on each sub-demand in the sub-demand set based on the positive sample prompt word to obtain a positive sample set;
[0102] Step S502, performing negative sample generation processing on each sub-demand in the sub-demand set based on the negative sample prompt word to obtain a negative sample set;
[0103] Step S503, performing configuration check processing on the positive sample set and the negative sample set based on the initial check code to obtain a pass code and an error code;
[0104] Step S504, performing code repair processing on the error code based on the self-check repair prompt word to obtain a repair code;
[0105] Step S505, determining a target inspection code based on the passed code and the repair code.
[0106] Specifically, the positive sample prompt word is used to instruct the large language model to generate a corresponding positive sample according to each sub-requirement in the sub-requirement set, and the positive sample is a table sample that meets the sub-requirement. The negative sample prompt word is used to instruct the large language model to generate a corresponding negative sample according to each sub-requirement in the sub-requirement set, and the negative sample is a table sample that does not meet the sub-requirement. The initial check code is the code generated by the large language model based on the code generation prompt word, and is used to perform a configuration check on the configuration table. The pass code is the code whose output result meets the expected result after the initial check code output by the large language model is executed as a function, and the error code is the code whose output result fails to meet the expected result after the initial check code output by the large language model is executed as a function. The repair code is the code whose output result meets the expected result after the error code is repaired by the large language model based on the self-check repair prompt word and the function is executed. The target check code includes two types of code data, the pass code and the repair code, which can be saved in a database or in memory.
[0107] In actual applications, the large language model generates positive samples for each sub-requirement in the sub-requirement set based on the positive sample prompt words to obtain a positive sample set, and generates negative samples for each sub-requirement in the sub-requirement set based on the negative sample prompt words to obtain a negative sample set. The positive sample set and the negative sample set are used to verify the results of the initial check code generated by the large language model. The large language model performs configuration check processing on the positive sample set and the negative sample set based on the initial check code, determines the code in the initial check code that meets the expected output as the pass code, and determines the code that does not meet the expected output as the error code. Then the large language model performs code repair processing on the error code based on the self-check repair prompt words to obtain the repair code, which can output the expected result through function execution. Finally, the pass code and the repair code are determined as the target check code, and the check code is saved in the database.
[0108] One of the above technical solutions has the following advantages or beneficial effects: In the embodiment of the present application, the large language model generates a positive sample set and a negative sample set through positive sample prompt words and negative sample prompt words, which can provide a data basis for code inspection and is directly generated by the large language model, reducing the difficulty of data acquisition and improving processing efficiency. In addition, the large language model performs code repair processing on the error code based on the self-check repair prompt words to obtain the repair code, and can use the positive and negative samples generated by the large language model to check the generated code, thereby improving the accuracy and reliability of the code output by the large language model.
[0109] In an implementation of the embodiment of the present invention, a positive sample generation process is performed on each sub-demand in the sub-demand set based on the positive sample prompt word to obtain a positive sample set, including:
[0110] Determine data requirements and table formats based on positive sample prompt words, where data requirements are used to match functional requirements of sub-requirements;
[0111] Based on data requirements and table formats, tabular data generation and processing are performed to obtain a positive sample set.
[0112] Specifically, the positive sample prompt word is used to instruct the large language model to generate a positive sample set, which can be obtained through user input or edited based on a pre-established prompt word template. The data requirements are used to match the functional requirements of the sub-requirements, and the table format is used to limit the table format of the positive samples output by the large language model. Among them, positive samples (Pos it iveSample) in machine learning refer to sample data that meets specific conditions or standards and is marked as "positive" or "yes".
[0113] In actual applications, the positive sample prompt words are input into the large language model through the human-computer interaction interface. The large language model can determine the data requirements and table formats based on the positive sample prompt words, thereby generating a table that meets the requirements according to the data requirements, and limiting the table format of the table, outputting each sample data that meets the functional requirements of the sub-requirements, and obtaining a positive sample set.
[0114] Exemplarily, the embodiment of the present application can obtain data requirements and table formats based on positive sample prompt words. The data requirements match each sub-requirement in the sub-requirement set. The large language model generates corresponding positive samples based on the specified data requirements and table formats. In the configuration check, the positive sample is the configuration data that meets the sub-requirement. Taking a specific sub-requirement as an example, the content of the sub-requirement is: "The id field in the weapon table exists in the id field in the item table". The large language model generates table data corresponding to the sub-requirement based on the input positive sample prompt words, and finally generates the weapon table and the item table, and the id field in the weapon table is the same as the id field in the item table. In a feasible embodiment, the content of the positive sample prompt words is: "The following is a requirement for table content. Please generate one or more table samples. The data in the sample meets the given requirements. In the result you return, the table content is expressed in CSV format, the table data volume is 5 lines, and the return format is json format." The positive sample prompt words instruct the large language model to generate one or more table samples. The data of the table sample needs to meet the given requirements. The given requirement, that is, the data requirement, is the content of the sub-requirement. The table format of the table sample is also specified in the positive sample prompt word, and the table format includes the content format, and the content format is limited to the CSV format, wherein the CSV (Comma-Separated Values) format is a simple file format for storing table data, including numbers, text, etc. The CSV file consists of a series of rows, each row contains the same number of fields, and these fields are separated by delimiters (usually commas, but can also be other characters, such as tabs, semicolons, etc.). The data volume of the table is limited to 5 rows, and the data format output by the large language model is specified as json format, wherein json (JavaScript Object Notation) is a lightweight data exchange format that is easy to read and write, and is also easy to machine parse and generate. It should be noted that the embodiment of the present application can also limit the table format according to actual conditions, such as limiting the content format to XML format, Excel format and other file formats, and setting the table data volume to 8 rows.
[0115] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the present application performs positive sample generation processing on each sub-requirement in the sub-requirement set based on the positive sample prompt word to obtain a positive sample set, and can quickly and efficiently generate positive sample data through a large language model for result verification of the initial check code generated by the large language model, thereby enhancing the generalization ability and accuracy of the large language model and reducing data acquisition costs and manual labeling costs.
[0116] In an implementation of the embodiment of the present invention, a negative sample generation process is performed on each sub-requirement in the sub-requirement set based on the negative sample prompt word to obtain a negative sample set, including:
[0117] Determine the wrong requirements and table format based on negative sample prompt words, wherein the wrong requirements are used to generate wrong demonstrations of functional requirements for sub-requirements;
[0118] Based on the error requirements and table format, the table data generation process is performed to obtain a set of negative samples.
[0119] Specifically, the negative sample prompt word is used to instruct the large language model to generate a negative sample set, which can be obtained through user input or edited based on a pre-established prompt word template. The table format is used to define the table format of negative samples output by the large language model. Among them, negative samples (Negat ive Samp le) in machine learning refer to sample data that does not match the expected target or category.
[0120] In actual applications, negative sample prompt words are input into the large language model through the human-computer interaction interface. The large language model can determine the wrong requirements and table formats based on the negative sample prompt words, and thus generate a table with opposite requirements to the sub-requirements based on the wrong requirements, limit the table format of the table, and output each sample data that does not meet the functional requirements of the sub-requirements to obtain a negative sample set.
[0121] Exemplarily, the embodiment of the present application can obtain an error requirement and a table format based on a negative sample prompt word. The error requirement is used to generate an error demonstration of the functional requirement for the sub-requirement. The large language model generates a corresponding negative sample based on the specified error requirement and table format. In the configuration check, the negative sample is the configuration data that does not meet the sub-requirement. Taking a specific sub-requirement as an example, the content of the sub-requirement is: "The id field in the weapon table exists in the id field in the item table". The large language model generates table data that does not meet the sub-requirement based on the input negative sample prompt word, and finally generates a weapon table and an item table, but the id field in the weapon table is different from the id field in the item table. In a feasible embodiment, the content of the negative sample prompt word is: "The following is a requirement for table content. Please generate one or more table samples. The data in the sample does not meet the given requirements. In the result you return, the table content is expressed in CSV format, the table data volume is 5 lines, and the return format is json format." The negative sample prompt word instructs the large language model to generate one or more table samples. The data of the table sample is an error requirement and needs to meet the given requirements, that is, to generate content that does not meet the sub-requirement. The table format of the table sample is also specified in the negative and positive sample prompt words. The table format includes the content format, which is limited to CSV format, and the data volume of the table is limited to 5 rows, and the data format output by the large language model is specified as json format. Similarly, the embodiment of the present application can also limit the table format of the negative sample according to the actual situation, for example, limiting the content format to XML format, Excel format and other file formats, and setting the table data volume to 10 rows.
[0122] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the present application performs negative sample generation processing on each sub-requirement in the sub-requirement set based on the negative sample prompt word to obtain a positive sample set, and can quickly and efficiently generate negative sample data through a large language model for result verification of the initial check code generated by the large language model, thereby enhancing the generalization ability and accuracy of the large language model and reducing data acquisition costs and manual labeling costs.
[0123] In an implementation of the embodiment of the present invention, configuration check processing is performed on the positive sample set and the negative sample set based on the initial check code to obtain a pass code and an error code, including:
[0124] Perform module loading processing on the initial check code based on the dynamic module loading function to obtain an executable module;
[0125] The positive sample set and the negative sample set are respectively input into the executable module for inspection and processing to obtain the pass code and error code.
[0126] Specifically, the dynamic module loading function is used to load the code text of the initial check code into an executable module, and the executable module refers to a modular and reusable code structure. The initial check code can be executed by a python interpreter to obtain an executable module, or it can be constructed by an interpreter of another coding language to obtain an executable module.
[0127] In practical applications, the dynamic module loading function can enable the definitions of functions, classes, variables, etc. in the initial inspection code to be imported and used by other parts of the program, thereby building a modular and reusable code structure and obtaining an executable module. Then the positive sample set and the negative sample set are respectively input into the executable module for inspection and processing, and the code whose output of the executable module meets the expected results is determined as a pass code, and the code whose output of the executable module meets the expected results is determined as an error code.
[0128] Exemplarily, the dynamic module loading function can adopt Python's importlib.util.spec_from_loader function and importlib.util.module_from_spec function, wherein the importlib.util.spec_from_loader function is used to create a module specification object according to a given loader and module name, and this specification object contains the information required for loading the module. The importlib.util.module_from_spec function creates a new module object according to this module specification object, and this module object can then be filled with content (such as loading code through a loader) and used as part of a Python program. These two functions work together to make it possible to dynamically load and execute Python modules.
[0129] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the present application performs module loading processing on the initial inspection code based on the dynamic module loading function to obtain an executable module, and the executable module can improve the reusability, organization and encapsulation of the inspection code, and can be shared and reused by different projects. In addition, the embodiment of the present application also inputs the positive sample set and the negative sample set into the executable module for inspection processing to obtain the pass code and the error code, and can check the code content of the initial inspection code generated by the large language model based on the positive sample set and the negative sample set generated by the large language model, thereby reducing the cost of obtaining external data, effectively reducing the number of inference layers of the large language model, and improving the accuracy of the output of the large language model.
[0130] In an implementation of the embodiment of the present invention, code repair processing is performed on the error code based on the self-check repair prompt word to obtain the repair code, including:
[0131] Determine the function output and result format based on the self-check and repair prompt words, where the function output is the error cause of the error code;
[0132] The error code is repaired based on the function output and result format to obtain a repair code.
[0133] Specifically, the self-check repair prompt word is used to instruct the large language model to perform code repair on the error code, the function output is the error cause of the error code output, and the result format is the code format and content format of the repair code.
[0134] In actual applications, positive sample prompt words are input into the large language model through the human-computer interaction interface. The large language model can obtain the function output and result format based on the self-check and repair prompt words, and perform code repair on the error code through the function output and result format.
[0135] Specifically, the large language model can determine the data requirements and table formats based on the positive sample prompt words, thereby generating a table that meets the requirements according to the data requirements, and limiting the table format of the table, outputting each sample data that meets the functional requirements of the sub-requirements, and obtaining a positive sample set.
[0136] Exemplarily, the embodiment of the present application can obtain the function output and result format based on the self-check and repair prompt word, and the function output is the error cause of the error code. The large language model repairs the error code based on the specified function output and result format to obtain the expected repair code. In a feasible embodiment, the content of the self-check and repair prompt word is: "The execution result of the following code does not meet expectations, repair the code and explain the reason, the input parameters of the function have been correctly converted, and your return result format is: error cause, repaired code". The self-check and repair prompt word instructs the large language model to repair the error code and explain the reason for the code error, and return the correct code. It should be noted that during the self-check and repair process, the repaired code can be checked again until the expected running result is obtained or the maximum number of retries is exceeded. When the correct code text is obtained, the repair code is obtained by saving the code text data. If the maximum number of retries is exceeded, an exception is thrown for manual intervention.
[0137] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the present application performs code repair processing on the error code based on the self-check repair prompt word to obtain the repair code, which can be repaired through self-checking and also provides an opportunity for manual correction, effectively reducing the number of inference layers of the large language model and improving the accuracy of the output of the large language model.
[0138] In an implementation of the embodiment of the present invention, after performing self-check and repair processing on the generated initial check code to obtain the target check code, the method further includes:
[0139] Get the configuration table to be checked;
[0140] Dynamically load the target inspection code to obtain a dynamic module;
[0141] The configuration table is checked and processed based on the dynamic module to obtain the configuration check result.
[0142] Specifically, the configuration table to be checked can be a configuration table of a game application or a configuration table of other applications. The target check code is a code generated by a large language model for checking the configuration table. The dynamic module is a modular and reusable code structure.
[0143] In actual applications, the configuration table to be checked can be obtained through the terminal, or it can be obtained from the server or code library through the configuration management tool. The target inspection code generated by the large language model is dynamically loaded into the terminal or application, and the configuration table is checked to obtain the configuration inspection result.
[0144] Exemplarily, after the large language model generates target check codes for all sub-requirements in the requirement document, the code generated by the target check code can be saved in the database. When it is necessary to check the configuration table to be checked, the code data text of the target check code is retrieved and loaded into the python dynamic module. The configuration table is checked in sequence through the dynamic module, and the final result is output.
[0145] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the present application obtains a dynamic module by dynamically loading the target inspection code, and then obtains a configuration inspection result by inspecting the configuration table based on the dynamic module. The configuration inspection result can be generated quickly without the user having to master complex configuration rules, thereby improving the efficiency of the configuration inspection.
[0146] In order to better illustrate the technical solution of this embodiment, a specific example is proposed below. Figure 6This example is applied to the check code generation scenario of the configuration table of the application. The user input is received through the large language model. The user input includes a requirement document and a prompt word set. The user input requirement document is split into multiple sub-requirements based on the prompt word set through the large language model, and positive and negative samples are generated for each sub-requirement. The positive and negative samples can be saved in the database to provide a data basis for subsequent code inspection. The python code is generated for each sub-requirement through the large language model, and the positive and negative samples are input to determine whether the generated code is correct. The code that fails the inspection is re-generated, and the code that passes the inspection is saved to obtain the sub-requirement and the corresponding code. Finally, the inspection code, that is, the corresponding code script, is saved in the database.
[0147] Corresponding to the above method embodiment, the present invention also provides an embodiment of a check code generation system, Figure 7 FIG. 2 is a schematic diagram showing the structure of a check code generation system according to an embodiment of the present invention. Figure 7 As shown, the inspection code generation system includes:
[0148] An input module 701 is configured to input a requirement document and a prompt word set into a large language model;
[0149] The inspection code generation module 702 is configured to perform inspection code generation processing on the requirement document through the prompt word set based on the large language model, and perform self-check and repair processing on the generated initial inspection code to obtain a target inspection code, wherein the initial inspection code is used to match the inspection requirements of the requirement document, and the target inspection code is the inspection code that has passed the self-check and repair.
[0150] The above is a schematic scheme of a check code generation system of this embodiment. It should be noted that the technical scheme of the check code generation system and the technical scheme of the check code generation method applied to the check code generation system belong to the same concept, and the details not described in detail in the technical scheme of the check code generation system can be referred to the description of the technical scheme of the check code generation method.
[0151] like Figure 8 As shown, Figure 8 The structure block diagram of an electronic device 800 provided according to an embodiment of the present invention is shown. The components of the electronic device 800 include but are not limited to a memory 810 and a processor 820. The processor 820 is connected to the memory 810 via a bus 830, and the database 850 is used to store data.
[0152] The electronic device 800 also includes an access device 840 that enables the electronic device 800 to communicate via one or more networks 860. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 840 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0153] In one embodiment of the present invention, the above components of the electronic device 800 and Figure 8 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 8 The electronic device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present invention. Those skilled in the art can add or replace other components as needed.
[0154] The electronic device 800 may be any type of stationary or mobile electronic device, including a mobile computer or mobile electronic device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable electronic device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary electronic device such as a desktop computer or a PC. The electronic device 800 may also be a mobile or stationary server.
[0155] The processor 820 is used to execute computer executable instructions of the inspection code generation method.
[0156] The above is a schematic scheme of an electronic device of this embodiment. It should be noted that the technical scheme of the electronic device and the technical scheme of the above-mentioned inspection code generation method belong to the same concept, and the details not described in detail in the technical scheme of the electronic device can be referred to the description of the technical scheme of the above-mentioned inspection code generation method.
[0157] An embodiment of the present invention further provides a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the above-mentioned inspection code generation method is implemented.
[0158] As a non-transient computer-readable storage medium, the memory can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage devices. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. The device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and are implemented to be located in one place, or may also be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0159] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media generally include computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0160] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions under the shared conditions without violating the spirit of the present invention. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present invention.
Claims
1. A method for generating a check code, characterized in that: include: Input the requirement document and the prompt word set into the large language model; Based on the large language model, the inspection code generation process is performed on the requirement document through the prompt word set, and the generated initial inspection code is self-checked and repaired to obtain a target inspection code, wherein the initial inspection code is used to match the inspection requirements of the requirement document, and the target inspection code is the initial inspection code that has passed the self-check and repair process.
2. The method according to claim 1, characterized in that The prompt word set includes prompt words for requirement splitting and prompt words for code generation, and the checking code generation process of the requirement document by using the prompt word set based on the large language model includes: Performing requirement splitting processing on the requirement document based on the requirement splitting prompt word to obtain a sub-requirement set, wherein the requirement splitting prompt word is used to indicate an output format of the sub-requirement set; Based on the code generation prompt word, code generation processing is performed on each sub-requirement in the sub-requirement set to obtain the initial check code, wherein the code generation prompt word is used to indicate the code format and code content of the initial check code.
3. The method according to claim 2, characterized in that The step of performing requirement splitting processing on the requirement document based on the requirement splitting prompt word to obtain a sub-requirement set includes: Performing semantic recognition processing on the requirement document based on the requirement splitting prompt words to obtain functional requirements; The requirement document is split based on the functional requirements to obtain the sub-requirement set.
4. The method according to claim 2, characterized in that: The step of performing code generation processing on each sub-requirement in the sub-requirement set based on the code generation prompt word to obtain an initial check code includes: Determine a check rule and a code template based on the code generation prompt, wherein the check rule is used to match the functional requirements of the sub-requirements, and the code template includes an input format, an output format, and code content; The code template is subjected to code completion processing based on the inspection rule to obtain the initial inspection code.
5. The method according to claim 2, characterized in that: The prompt word set also includes positive sample prompt words, negative sample prompt words and self-check and repair prompt words. The self-check and repair process is performed on the generated initial inspection code to obtain the target inspection code, including: Based on the positive sample prompt word, a positive sample generation process is performed on each sub-demand in the sub-demand set to obtain a positive sample set; Based on the negative sample prompt word, a negative sample generation process is performed on each sub-requirement in the sub-requirement set to obtain a negative sample set; Performing configuration check processing on the positive sample set and the negative sample set based on the initial check code to obtain a pass code and an error code; Perform code repair processing on the error code based on the self-check and repair prompt word to obtain a repair code; The target inspection code is determined based on the pass code and the repair code.
6. The method according to claim 5, characterized in that The step of performing positive sample generation processing on each sub-demand in the sub-demand set based on the positive sample prompt word to obtain a positive sample set includes: Determining data requirements and table formats based on the positive sample prompt words, wherein the data requirements are used to match the functional requirements of the sub-requirements; Table data generation processing is performed based on the data requirements and the table format to obtain the positive sample set.
7. The method according to claim 5, characterized in that The step of performing negative sample generation processing on each sub-requirement in the sub-requirement set based on the negative sample prompt word to obtain a negative sample set includes: Determining an erroneous requirement and a table format based on the negative sample prompt word, wherein the erroneous requirement is used to generate an erroneous demonstration of a functional requirement for the sub-requirement; Table data generation processing is performed based on the error requirement and the table format to obtain the negative sample set.
8. The method according to claim 5, characterized in that The performing configuration check processing on the positive sample set and the negative sample set based on the initial check code to obtain a pass code and an error code includes: Performing module loading processing on the initial inspection code based on a dynamic module loading function to obtain an executable module; The positive sample set and the negative sample set are respectively input into the executable module for inspection and processing to obtain the pass code and the error code.
9. The method according to claim 5, characterized in that The performing code repair processing on the error code based on the self-check repair prompt word to obtain a repair code includes: Determine the function output and result format based on the self-check and repair prompt word, wherein the function output is the error cause of the error code; The error code is repaired based on the function output and the result format to obtain the repair code.
10. The method according to any one of claims 1 to 9, characterized in that: After the generated initial inspection code is subjected to self-inspection and repair processing to obtain the target inspection code, the method further includes: Get the configuration table to be checked; Dynamically loading the target inspection code to obtain a dynamic module; The configuration table is checked and processed based on the dynamic module to obtain a configuration check result.
11. A check code generation system, characterized in that: include: An input module, configured to input the requirement document and the prompt word set into the large language model; The inspection code generation module is configured to perform inspection code generation processing on the requirement document through the prompt word set based on the large language model, and perform self-check and repair processing on the generated initial inspection code to obtain a target inspection code, wherein the initial inspection code is used to match the inspection requirements of the requirement document, and the target inspection code is the inspection code that passes the self-check and repair.
12. An electronic device, characterized in that: It includes at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor so that the at least one control processor can execute the inspection code generation method as described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the inspection code generation method according to any one of claims 1 to 10.
Citation Information
Cited By
Image processing method and device, equipment and storage medium
CN120079104A
Code scanning analysis method and system based on large model
CN120893046A