Data generation method, device and equipment and readable storage medium
By combining and diversifying the description instructions of the API and generating multiple result instructions based on mapping relationships, the problem of insufficient diversity of API data sets in the prior art is solved. The generated multi-object data set can better meet the training needs of the instruction generation model.
Patent Information
- Application Number
- CN202411724367.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-07
AI Technical Summary
The prior art is difficult to generate the diversity required to meet the instruction generation model training, especially when processing the instructions corresponding to the results of the API are generated on the data set.
By obtaining the mapping relationship between the description instruction set, the result instruction set, and the single object description instruction and the single result instruction, a single object description instruction is combined to generate the multi-object description instruction and expand it diversity. Then, the multi-result instruction is determined based on the mapping relationship, and finally the multi-object data set is constructed.
The generated multi-object dataset has higher diversity, which can better meet the training needs of instruction generation models and improve the model's understanding of specific fields and task scenarios.
Smart Images

Figure CN119577455A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information processing technology, and in particular to a data generation method, device, equipment and readable storage medium. Background Art
[0002] For users who are not familiar with API (application programming interface) instructions, they can use the instruction generation model to obtain API instructions. That is, the user enters the description instruction, and the model feedbacks the result instruction (that is, the specific API command) corresponding to the description instruction. Multiple instructions can trigger multiple APIs (application programming interfaces) to work together. This requires the model to be able to cope with multiple description instructions and feedback the corresponding multiple API result instructions. At this time, further pre-training or supervised fine-tuning (SFT) is required through a large amount of task data to enhance the model's understanding of specific fields and task scenarios. For example, the user inputs the instruction: change to a bar chart, set the title color to red, and the column color to green. The API results that the model should return are two categories and three types, namely: {chart:{type:bar,color:green},title:{color:red}}.
[0003] In order for the generative model to master the API in a specific field, it must be trained with a large number of data pairs, including the correspondence between continuous input description instructions and multi-API results (real instructions, such as {chart:{type:bar,color:green},title:{color:red}}). At present, the main methods for synthesizing API-oriented data, especially multi-API combination data, are: manual data construction, program automatic generation, and the use of models combined with API document generation. However, the data pairs generated by these data synthesis methods still cannot meet the diversity required for model training and learning.
[0004] In summary, how to effectively solve the problem of generating data sets based on instructions corresponding to API descriptions and results is a technical problem that technicians in this field urgently need to solve. Summary of the invention
[0005] The purpose of this application is to provide a data generation method, device, equipment and readable storage medium, which can generate a multi-object data set for an API that meets the diversity required for instruction generation model training.
[0006] In order to solve the above technical problems, this application provides the following technical solutions:
[0007] A data generation method, comprising:
[0008] Acquire a description instruction set, a result instruction set, and a mapping relationship between a single object description instruction in the description instruction set and a single result instruction in the result instruction set;
[0009] Combining the single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, and performing diversity expansion on the multi-object description instructions;
[0010] After the expansion is completed, the multiple result instructions corresponding to each of the multiple object description instructions are determined from the result instruction set according to the mapping relationship;
[0011] A multi-object data set is constructed by utilizing the multi-object description instructions and the multi-result instructions corresponding thereto.
[0012] Preferably, the multi-object description instruction is diversified and extended, including:
[0013] randomly inserting punctuation marks into the sentences of the multi-object description instructions to expand the diversity of punctuation marks;
[0014] and / or,
[0015] The description style of the multi-object description instruction is modified to expand the style diversity.
[0016] Preferably, the multi-object description instruction is modified to expand the style diversity, including:
[0017] Using a language processing module to complicate the multi-object description instruction to obtain a complex multi-object description instruction;
[0018] Using a language processing module to simplify the multi-object description instruction to obtain a concise multi-object description instruction;
[0019] The language processing module is used to remove the subject from the multi-object description instruction to obtain a multi-object description instruction without a subject.
[0020] Preferably, according to the mapping relationship, determining the multiple result instructions corresponding to each of the multiple object description instructions from the result instruction set includes:
[0021] According to the mapping relationship, searching from the result instruction set for a single result instruction corresponding to each single object description instruction in the multiple object description instructions;
[0022] performing dependency detection on multiple single result instructions to supplement the single result instruction being found;
[0023] After the supplementation is completed, the multiple single-result instructions found are concatenated to obtain a multiple-result instruction.
[0024] Preferably, it also includes:
[0025] The arrangement order of the multiple single result instructions found is randomly combined to obtain multiple result instructions with different orders.
[0026] Preferably, the single object description instructions in the description instruction set are combined to obtain a plurality of multi-object description instructions, including:
[0027] Get the sampling ratios corresponding to different types of application programming interfaces;
[0028] Collecting a single object description instruction that meets the sampling ratio from the description instruction set;
[0029] The collected single object description instructions are combined to obtain a plurality of multi-object description instructions that meet the sampling ratio.
[0030] Preferably, after combining the single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, the method further includes:
[0031] Construct the prompt words;
[0032] The trained language processing model is used in combination with the prompt word to select a multi-object description instruction that is similar to the actual user description expression from a plurality of multi-object description instructions.
[0033] A data generating device, comprising:
[0034] A data acquisition module, used for describing an instruction set, a result instruction set, and a mapping relationship between a single object description instruction in the description instruction set and a single result instruction in the result instruction set;
[0035] A combination expansion module, used for combining single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, and performing diversity expansion on the multi-object description instructions;
[0036] A result mapping module, used for determining, after the expansion is completed, from the result instruction set according to the mapping relationship, the multiple result instructions corresponding to each of the multiple object description instructions;
[0037] The data construction module is used to construct a multi-object data set by using the multi-object description instructions and the multi-result instructions corresponding thereto.
[0038] An electronic device, comprising:
[0039] Memory for storing computer programs;
[0040] A processor is used to implement the steps of the above-mentioned data generation method when executing the computer program.
[0041] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned data generation method are implemented.
[0042] Apply the method provided in the embodiments of the present application to describe the mapping relationship between the instruction set, the result instruction set, and the single object description instruction in the description instruction set and the single result instruction in the result instruction set; combine the single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, and perform diversity expansion on the multi-object description instructions; after the expansion is completed, determine the multiple result instructions corresponding to each multi-object description instruction from the result instruction set according to the mapping relationship; and construct a multi-object data set using the multi-object description instructions and their corresponding multi-result instructions.
[0043] In the present application, firstly, a description instruction set, a result instruction set, and a mapping relationship between a single object description instruction in the description instruction set and a single result instruction in the result instruction set are obtained. Then, the single object description instructions in the description instruction set are combined to obtain a plurality of multi-object description instructions, and the multi-object description instructions are diversified. After the expansion is completed, the multi-result instructions corresponding to each multi-object description instruction are determined from the result instruction set according to the mapping relationship between the single object description instruction in the description instruction set and the single result instruction in the result instruction set. Finally, a multi-object data set can be constructed using the multi-object description instructions and the multi-result instructions corresponding to the multi-object description instructions and their corresponding multi-result instructions. That is, the multi-object data set records the multi-object description instructions, the multi-result instructions, and the mapping relationship between the multi-object description instructions and the multi-result instructions. Since the multi-object description instructions are diversified when constructing the multi-object data set, a diversified multi-object data set can be obtained, and the model trained based on the multi-object data set can also meet the diversity requirements.
[0044] Correspondingly, the embodiments of the present application also provide a data generation device, equipment and readable storage medium corresponding to the above-mentioned data generation method, which have the above-mentioned technical effects and are not repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0046] Figure 1 This is a flowchart of an implementation method of a data generation method in an embodiment of the present application;
[0047] Figure 2A schematic diagram of constructing a single instruction API in an embodiment of the present application;
[0048] Figure 3 A schematic diagram of constructing a multi-instruction API in an embodiment of the present application;
[0049] Figure 4 This is a schematic diagram of the structure of a data generating device in an embodiment of the present application;
[0050] Figure 5 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application;
[0051] Figure 6 This is a schematic diagram of the specific structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0053] Please refer to Figure 1 , Figure 1 This is a flow chart of a data generation method in an embodiment of the present application, the method comprising the following steps:
[0054] S101, obtaining a description instruction set, a result instruction set, and a mapping relationship between a single object description instruction in the description instruction set and a single result instruction in the result instruction set.
[0055] In this embodiment, the description instruction set, the result instruction set, and the mapping relationship between a single object description instruction in the description instruction set and a single result instruction in the result instruction set can be obtained by directly reading from a storage medium, sending through other devices, or analyzing an API document.
[0056] The description instruction set includes multiple single object description instructions; the result instruction set includes multiple single result instructions; and the mapping relationship is the matching relationship between the single object description instruction and the single result instruction.
[0057] That is to say, in this embodiment, a large number of single instruction APIs are first obtained, that is, data pairs of single object description instructions and single result instructions, and the single object description instructions therein are all summarized as elements in a description instruction set, and the single result instructions therein are all summarized as elements in a result instruction set, and the matching relationship of the data pairs, that is, the mapping relationship between the single object description instruction and the single result instruction in the result instruction set.
[0058] Please refer to Figure 2 , for single-instruction API construction: for a given number of API documents, use a language processing model, such as a GPT model, to generate description instructions (such as single questions) and their corresponding API results for each API multiple times, namely, a description instruction set (since they are all descriptions in the form of a single question, they can also be called a single question set) and a result instruction set (since they contain single API instructions, they can also be called an API result set).
[0059] The following is an example of constructing a prompt when building a single API:
[0060] Task: Users use natural language to control the fields, properties, events, and parameters of components.
[0061] Limitations: 1. The query is an imperative statement of the user's actual needs, which must be rich and diverse and close to the user's usage habits; 2. Generate corresponding APIs for the current options and expansion words.
[0062] Note: Output in JSON format, no apology or explanation is needed, no comments are generated. Repeat, no apology or explanation is needed, no comments are generated.
[0063] Result: Use JSON to include the List format. Each element contains two fields: query and api. The event parameters are generated according to the contents of the corresponding fields. The query is the user's natural language description, and the API is in the corresponding JSON format.
[0064] Example: The input is {example_input}, and the output is {example_output}.
[0065] Current: Input is {d}, please output {k} results.
[0066] According to the above prompts, the language processing model can output the corresponding single API data pair.
[0067] S102: Combine the single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, and perform diversity expansion on the multi-object description instructions.
[0068] In this embodiment, multiple object description instructions may be obtained by combining single object description instructions in the description instruction set.
[0069] Specifically, in practical applications, the number of elements of the combination can be set, and then all the multi-object description instructions that meet the number of elements of the combination can be found from the description instruction set. For example, if there are N single-object description instructions in the description instruction set, and if the number of elements of the combination is set to 2 and 3, then every 2 and every 3 single-object description instructions can be combined into a multi-object description instruction by traversing.
[0070] Of course, when actually combining, the single object description instructions may be screened, and then the screened multiple single object description instructions may be combined. The screening rules may be based on description relevance, dependency, etc., which will not be described in detail here.
[0071] The combination method can directly connect two or more single object descriptions. For example, there is a single object description instruction A: the title is set to data generation, and a single object description instruction B: the title transparency is changed to 0. The multiple single object description instructions obtained by combining instructions A and B: the title is set to data generation, and the title transparency is changed to 0. The connection position can be marked with a symbol, or it does not need to be marked.
[0072] In a specific implementation of the present application, a single object description instruction in the description instruction set is combined to obtain a plurality of multi-object description instructions, including:
[0073] Step 1: Obtain sampling ratios corresponding to different types of application programming interfaces;
[0074] Step 2: Collecting a single object description instruction that meets the sampling ratio from the description instruction set;
[0075] Step 3: Combine the collected single object description instructions to obtain multiple object description instructions that meet the sampling ratio.
[0076] For ease of description, the above steps are combined for explanation below.
[0077] In this embodiment, APIs may be classified, and sampling ratios corresponding to different types of application programming interfaces may be set by command input or editable interface input.
[0078] Then, a single object description instruction that meets the sampling ratio is collected from the description instruction set. Subsequently, multiple object description instructions are obtained by combining the collected single object description instructions. These multiple object description instructions are adapted to the sampling ratio.
[0079] That is to say, this embodiment can customize the ratio: allowing users to customize the sampling ratio of different types of APIs.
[0080] In a specific implementation of the present application, after combining the single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, the following further includes:
[0081] Step 1: Construct prompt words;
[0082] Step 2: Using the trained language processing model and combining the prompt words, select a multi-object description instruction that is similar to the actual user description expression from a number of multi-object description instructions.
[0083] For ease of description, the above two steps are combined for explanation below.
[0084] In this embodiment, common questions can be selected. Specifically, since the randomly generated multiple questions are far from the real user questions, for example: closing the title, setting the title to data generation, and changing the title transparency to 0, the description does not meet the real needs.
[0085] In order to select multi-object description instructions that are close to the actual user description expression, prompt words can be constructed, and common question combinations can be selected from them using the knowledge of the GPT large model itself.
[0086] Example: The prompt example is as follows:
[0087] Given the current list of questions, please randomly select {m} questions for me and combine them. The combined questions need to conform to the user's real scenario. The current list of questions is {query_list}. Your answer needs to be output in JSON format. No apology or explanation is required, no comments need to be generated, and no JSON should be included. Your answer is only in JSON format.
[0088] The JSON format is as follows: [[query1,query2,query3],...], please output {k} results.
[0089] In this way, a multi-object description instruction that is close to the real user question can be selected from the multi-object description instructions generated by random combination.
[0090] After the multi-object description instructions are obtained by combination, the multi-object description instructions can be diversified and expanded to enrich the multi-object description instructions.
[0091] Specifically, the multi-object description instruction can be modified to obtain more multi-object description instructions. For example, for a multi-object description instruction C, it is obtained by combining a single object description instruction A and a single object description object B. When the instruction C is expanded, at least one description of the instruction A and the instruction B therein can be modified, and the order of the combination can also be adjusted.
[0092] In a specific implementation of the present application, the multi-object description instruction is diversified and extended, including:
[0093] Punctuation marks are randomly inserted into the sentences of multi-object description instructions to expand the diversity of punctuation marks;
[0094] and / or,
[0095] The description style of multi-object description instructions is modified to expand the style diversity.
[0096] That is to say, in actual application, the punctuation of the sentence segmentation of the multi-object description instruction can be modified to expand the punctuation diversity. The description style of the multi-object description instruction can also be modified to expand the style diversity. It is also possible to do both, that is, modify both the punctuation of the sentence segmentation and the description style. Among them, the description style can be complex, simple, subjectless, etc.
[0097] Regarding punctuation diversity: define the set of punctuation used, such as spaces, Chinese and English commas, semicolons, etc. In real user scenarios, users often use different punctuation. Different punctuation is randomly inserted into the sentence segments of multiple questions to expand the combination of different punctuation and increase generalization.
[0098] In a specific implementation of the present application, the multi-object description instruction is modified to expand the style diversity, including:
[0099] The multi-object description instruction is complicated by using a language processing module to obtain a complex multi-object description instruction;
[0100] The multi-object description instruction is simplified by using a language processing module to obtain a concise multi-object description instruction;
[0101] The language processing module is used to remove the subject from the multi-object description instruction to obtain the multi-object description instruction without a subject.
[0102] That is to say, regarding style diversity: in order to better meet the user's usage scenarios, different types of prompt words are constructed, and the current question is rewritten using a large model. For example: for the multi-object description instruction "Please open the title, the title size is 13, and the title font is Songti", the subject is omitted: title open, size is 13, font is Songti, complicated: please open the title of the current chart, where the title size please help me set to 13, the title size is set to Songti, etc., simplified: title open, size 13, font is Songti.
[0103] The prompt example is as follows:
[0104] Given the current question and the corresponding API, assuming that you are a user, rewrite the current question. The rewriting requirement is: {strategy}, the current question is {query}, and the current API is: {instruction}.
[0105] Your answer needs to be output in JSON format. No apologies or explanations are required. No comments need to be generated. Do not include JSON. Your answer should only be in JSON format.
[0106] The JSON format is as follows: [{"query": the changed question},...], please output {k} results.
[0107] S103: After the expansion is completed, the multiple result instructions corresponding to each multi-object description instruction are determined from the result instruction set according to the mapping relationship.
[0108] Since the multi-object description instruction is obtained by combining the single object description instructions in the description instruction set, the mapping relationship between the single result instruction corresponding to each single object description instruction remains unchanged before and after the combination. Therefore, the multiple result instructions corresponding to each multi-object description instruction can be directly found from the result instruction set.
[0109] For example, if a multi-object description instruction C is a combination of a single object description instruction A and a single object description instruction B, then the multi-result instructions of the multi-object description instruction C are the superposition of the single result instruction A of the single object description instruction A and the single result instruction B of the single object description instruction B.
[0110] In a specific implementation of the present application, according to the mapping relationship, determining the multiple result instructions corresponding to each multiple object description instruction from the result instruction set includes:
[0111] Step 1: According to the mapping relationship, search from the result instruction set for a single result instruction corresponding to a single object description instruction in each multi-object description instruction;
[0112] Step 2: performing dependency detection on multiple single result instructions to supplement the searched single result instruction;
[0113] Step 3: After completing the supplementation, the multiple single result instructions found are spliced to obtain a multiple result instruction.
[0114] For ease of description, the above steps are combined for explanation below.
[0115] In this embodiment, according to the mapping relationship between the single object description instruction in the description instruction set and the single result instruction in the result instruction set, the single result instruction corresponding to the single object Muon number instruction in each multi-object instruction can be found from the result instruction set. In order to avoid the lack of corresponding API instructions for API instructions with dependencies, the dependencies of the found single result instruction can also be detected, and the confirmed dependencies corresponding to the single result instruction can be supplemented based on the detection results. For example, when setting the title font, it is necessary to generate an additional title start, that is, to rely on a certain API, and the definition of the dependency can be provided through the API document.
[0116] After the supplementation is completed, the multiple single result instructions found (including the single result instructions supplemented after the dependency detection) can be spliced to obtain multiple result instructions.
[0117] In a specific implementation of the present application, it further includes: randomly combining the arrangement order of the multiple single result instructions found to obtain multiple result instructions with different orders. Order change: After the API is merged, the order is randomly combined to achieve the purpose of robustness.
[0118] S104. Construct a multi-object data set using the multi-object description instructions and their corresponding multi-result instructions.
[0119] The multi-object data set records the multi-object description instructions, the multi-result instructions, and the mapping relationship between the multi-object description instructions and the multi-result instructions. In other words, the API sets corresponding to the multiple questions are merged to finally obtain the multi-question API results. The multi-object data set can be used to train the instruction generation model, or after the training is completed, the model that includes the instruction generation function in multiple functions. In this embodiment, there is no specific limitation on the architecture of the model itself, the training method, etc.
[0120] Apply the method provided in the embodiments of the present application to describe the mapping relationship between the instruction set, the result instruction set, and the single object description instruction in the description instruction set and the single result instruction in the result instruction set; combine the single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, and perform diversity expansion on the multi-object description instructions; after the expansion is completed, determine the multiple result instructions corresponding to each multi-object description instruction from the result instruction set according to the mapping relationship; and construct a multi-object data set using the multi-object description instructions and their corresponding multi-result instructions.
[0121] In the present application, firstly, a description instruction set, a result instruction set, and a mapping relationship between a single object description instruction in the description instruction set and a single result instruction in the result instruction set are obtained. Then, the single object description instructions in the description instruction set are combined to obtain a plurality of multi-object description instructions, and the multi-object description instructions are diversified. After the expansion is completed, the multi-result instructions corresponding to each multi-object description instruction are determined from the result instruction set according to the mapping relationship between the single object description instruction in the description instruction set and the single result instruction in the result instruction set. Finally, a multi-object data set can be constructed using the multi-object description instructions and the multi-result instructions corresponding to the multi-object description instructions and their corresponding multi-result instructions. That is, the multi-object data set records the multi-object description instructions, the multi-result instructions, and the mapping relationship between the multi-object description instructions and the multi-result instructions. Since the multi-object description instructions are diversified when constructing the multi-object data set, a diversified multi-object data set can be obtained, and the model trained based on the multi-object data set can also meet the diversity requirements.
[0122] In order to facilitate those skilled in the art to better understand and implement the data generation method provided in the embodiment of the present application, the data generation method is described in detail below in combination with relevant technologies.
[0123] API documentation and usage guides are usually targeted at expert fields, with the goal of accurately describing the API's functionality and avoiding ambiguity. To this end, APIs are usually described and defined using standardized language and a unified format. However, when ordinary or non-professional users use APIs, especially when using multiple API combinations, there may be dependencies between APIs, which often makes them face huge barriers to understanding, and they must consult documentation to understand the API's functionality and usage. This gap in understanding significantly increases the difficulty for them to call APIs correctly, especially when multiple APIs are used together.
[0124] By controlling API calls and parameter settings through natural language, the difficulty of using APIs can be reduced. This approach is particularly important in the era of large models, because the development of natural language processing (NLP) technology has made the semantic understanding of the model more accurately aligned with the code. However, although the model has excellent generalization capabilities in a wide range of fields, it is often difficult to cover the data of the basic model for customized API functions for enterprises, businesses or individuals, especially when multiple instructions trigger multiple APIs to work together. At this time, it is necessary to further pre-train or supervised fine-tuning (SFT) through a large amount of task data to enhance the model's understanding of specific fields and task scenarios. For example, the user inputs a description instruction: change to a bar chart, set the title color to red, and the column color to green. The model should return two categories and three types of API results, namely: {chart:{type:bar,color:green},title:{color:red}}. In order for generative models (such as GPT) to master APIs in specific fields, they must be trained through a large number of data pairs, including the correspondence between continuous input description instructions and multiple API results. Since the model has strong natural language understanding capabilities through huge pre-training data, it can handle these customized tasks well.
[0125] The main methods for synthesizing API-oriented data, especially multi-API combination data, are: manual data construction: creating data manually or obtaining data manually generated by users by crawling historical data; program automation generation: setting strategies for each API and setting strategies for multiple API combinations through program automation, automatically generating possible API results, and then reverse-annotating the corresponding input instructions; API document-based generation: building API documents and entering each API description, using existing open source large models to generate possible input and output cases, and randomly combining them to construct multi-API data, thereby constructing training data.
[0126] Among them, the disadvantages of manually constructing data or generating it by grabbing historical data are: high verification cost: each piece of data needs to be manually verified to ensure its correctness, which is time-consuming and labor-intensive; low data generation efficiency: relying on a large amount of manual operations, the efficiency of generating data is low, and it is difficult to meet large-scale data needs; difficulty in controlling data distribution and quantity: in terms of data scale and diversity, it is difficult to perform fine-grained control through manual means, which is prone to data deviation or deficiency, and inconsistent with the distribution of actual usage scenarios.
[0127] The program automatically generates data. By writing a program, setting strategies for each API, automatically enumerating and generating API output results, and then constructing the results of distributed and controllable API combinations, and finally reversely annotating input instructions based on the output results. Disadvantages: High development cost: Depends on the detailed generation strategy of each API, such as color, font, preset value, etc., which requires a lot of development time and resources; Poor scalability: When adding new APIs, data types or return values, it is necessary to redesign and implement the combination generation strategy of multiple APIs, resulting in high maintenance costs; Limited flexibility: Automatically generated data is often subject to rule constraints and is difficult to cover APIs, especially scenarios where multiple APIs are used at the same time.
[0128] Based on the automatic generation of API documents and big models, by providing API documents, the open source big model is used to generate API input and output sample data. There are disadvantages: low instruction coverage: the input and output cases generated by the big model often cannot fully cover all the usage scenarios of the API, and it is easy to miss some important use cases, especially in the API usage scenarios with multiple instructions, which are more difficult to enumerate and construct; data distribution is uneven: the generated data may have deviations in distribution, and it is impossible to achieve comprehensive coverage of the data; insufficient processing of extreme values: less consideration is given to boundary values and abnormal situations, and it is difficult to ensure the comprehensiveness of the data; weak generalization: the generated data instructions lack flexibility and are difficult to adapt to API generation, especially the wide application in the multi-instruction API generation scenario, and the multi-question construction is far from the real scenario users.
[0129] In order to solve this problem, the technical solution provided by the embodiment of the present application is: according to the API document, for each API, a single API instruction can be generated, and an instruction combination strategy can be designed to automatically combine the scenarios of multiple instructions and the corresponding API results, and the knowledge of the GPT large model itself can be used to select commonly used combination questions that meet real scenarios, and the generalization and generation capabilities of the large model can be used to expand and optimize multiple instructions to generate special business data for large model training. This method not only helps to control the distribution ratio of data, but also significantly increases the diversity and robustness of generating multiple instructions, which meets the usage scenarios of real users. This allows a set of general solutions to automatically and controllably generate API training data for multiple instructions for multiple business parties.
[0130] It can be seen that the technical solution provided by the embodiment of the present application has technical effects including but not limited to: achieving automation and reducing labor; controllable data distribution; improved robustness due to instruction diversity; improved generalization; and conforming to the user's real scenario. Specifically, based on the data generation method, the following can be constructed: Figure 3 The multi-instruction API automatic generation framework shown in the figure can achieve:
[0131] (1) Improved coverage: By generating single questions and their API results multiple times, we build question sets and API result sets with higher coverage, covering different types of API call scenarios and ensuring that the generated questions are closer to the usage scenarios of real users.
[0132] (2) Uniform distribution: Users can customize the sampling ratio of different types of APIs, thereby adjusting the distribution of APIs to make the generated questions and API results more uniform and avoid over-sampling or under-sampling of certain types of APIs.
[0133] (3) Alignment with real user needs: Using the language knowledge of the big model, we construct combined questions that meet real user needs and filter out randomly generated questions that are far from the real scenario.
[0134] Question construction strategies:
[0135] (1) Compound question construction: Compound questions are constructed based on single questions and API result sets, while ensuring that the compound questions and the corresponding API sets maintain contextual relevance.
[0136] (2) Customized Ratio: It provides the function of customizing the sampling ratio of different API types. Users can adjust the ratio of different types of APIs according to different scenarios to optimize the coverage of generated questions.
[0137] (3) Common question selection mechanism: Through the language understanding ability of the GPT large model, questions that are closer to real user habits are screened out to avoid generating random question combinations that do not meet the needs.
[0138] Question diversity strategy:
[0139] (1) Punctuation diversity: By inserting different punctuation marks (such as spaces, Chinese and English commas, semicolons, etc.), we can simulate the sentence segmentation methods in real scenarios, improve the generalization ability of questions, and increase their applicability in different input scenarios.
[0140] (2) Style diversity: By constructing different prompt words, we can generate diverse question styles and expand the ways of expressing questions, such as simplifying or omitting the subject, or constructing complex questions. This style expansion ensures that the diversity of questions better covers the language styles of real users.
[0141] API merging strategy:
[0142] (1) Context dependency processing: Consider the context dependencies between API calls. When generating a composite API call, check the dependencies and ensure that the relevant API instructions are generated correctly.
[0143] (2) Order-independence optimization: The generated combined API can be called in different orders. This random combination of orders improves the robustness of API calls and ensures that the calling order of multi-instruction API sets in different scenarios can be flexibly responded to.
[0144] In actual applications, users need to use natural language to specify the corresponding components (i.e., API names) and set various parameters of the components (API parameters) to achieve quick and convenient use and increase creation efficiency.
[0145] 1. In the front-end business scenario construction, product managers can quickly build pages and try to compare different solutions. For example, I need the tab bar component to be displayed as text type, and I want to make the third tab of the tab bar unavailable.
[0146] 2. In the scenario of component adjustment, users can quickly specify the effect without having to search for the required adjustment items in a large number of APIs: users need to use natural language to set various parameters of the component, for example, adjust the font size to size 4, turn on footers, and use seasonal charts.
[0147] 3. In the financial market chart configuration, product managers and designers can quickly compare the differences between different solutions and quickly build styles and functions for different markets. For example: the color of the candlestick chart frame is dark red, and the cross cursor becomes blue.
[0148] Corresponding to the above method embodiment, the embodiment of the present application further provides a data generating device, and the data generating device described below and the data generating method described above can refer to each other.
[0149] See also Figure 4 As shown, the device includes the following modules:
[0150] The data acquisition module 101 is used for describing the instruction set, the result instruction set, and the mapping relationship between a single object description instruction in the description instruction set and a single result instruction in the result instruction set;
[0151] A combination expansion module 102, used for combining single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, and performing diversity expansion on the multi-object description instructions;
[0152] A result mapping module 103 is used to determine, after the expansion is completed, the multiple result instructions corresponding to each multiple object description instruction from the result instruction set according to the mapping relationship;
[0153] The data construction module 104 is used to construct a multi-object data set by using the multi-object description instructions and the corresponding multi-result instructions.
[0154] Apply the device provided in the embodiment of the present application to describe the mapping relationship between the description instruction set, the result instruction set, and the single object description instruction in the description instruction set and the single result instruction in the result instruction set; combine the single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, and perform diversity expansion on the multi-object description instructions; after the expansion is completed, determine the multiple result instructions corresponding to each multi-object description instruction from the result instruction set according to the mapping relationship; and construct a multi-object data set using the multi-object description instructions and their corresponding multi-result instructions.
[0155] In the present application, firstly, a description instruction set, a result instruction set, and a mapping relationship between a single object description instruction in the description instruction set and a single result instruction in the result instruction set are obtained. Then, the single object description instructions in the description instruction set are combined to obtain a plurality of multi-object description instructions, and the multi-object description instructions are diversified. After the expansion is completed, the multi-result instructions corresponding to each multi-object description instruction are determined from the result instruction set according to the mapping relationship between the single object description instruction in the description instruction set and the single result instruction in the result instruction set. Finally, a multi-object data set can be constructed using the multi-object description instructions and the multi-result instructions corresponding to the multi-object description instructions and their corresponding multi-result instructions. That is, the multi-object data set records the multi-object description instructions, the multi-result instructions, and the mapping relationship between the multi-object description instructions and the multi-result instructions. Since the multi-object description instructions are diversified when constructing the multi-object data set, a diversified multi-object data set can be obtained, and the model trained based on the multi-object data set can also meet the diversity requirements.
[0156] In a specific implementation of the present application, the combined extension module is specifically used to randomly insert punctuation marks into the sentence segments of the multi-object description instructions to expand the diversity of punctuation marks;
[0157] and / or,
[0158] The description style of multi-object description instructions is modified to expand the style diversity.
[0159] In a specific implementation of the present application, the combined expansion module is specifically used to complicate the multi-object description instruction using the language processing module to obtain a complex multi-object description instruction;
[0160] The multi-object description instruction is simplified by using a language processing module to obtain a concise multi-object description instruction;
[0161] The language processing module is used to remove the subject from the multi-object description instruction to obtain the multi-object description instruction without a subject.
[0162] In a specific implementation of the present application, the result mapping module is specifically used to search the result instruction set for a single result instruction corresponding to a single object description instruction in each multi-object description instruction according to the mapping relationship;
[0163] performing dependency detection on multiple single result instructions to supplement the single result instruction being found;
[0164] After the supplementation is completed, the multiple single-result instructions found are concatenated to obtain a multiple-result instruction.
[0165] In a specific implementation of the present application, the result mapping module is further used to randomly combine the arrangement order of the multiple single result instructions found to obtain multiple result instructions with different orders.
[0166] In a specific implementation of the present application, the combined extension module is specifically used to obtain sampling ratios corresponding to different types of application programming interfaces;
[0167] Collecting a single object description instruction that meets the sampling ratio from the description instruction set;
[0168] The collected single object description instructions are combined to obtain a plurality of multi-object description instructions that meet the sampling ratio.
[0169] In a specific implementation of the present application, it also includes:
[0170] A screening module is used to combine single object description instructions in the description instruction set to obtain a number of multi-object description instructions and then construct prompt words;
[0171] By using the trained language processing model and combining the prompt words, a multi-object description instruction that is similar to the actual user description expression is selected from several multi-object description instructions.
[0172] Corresponding to the above method embodiment, an embodiment of the present application further provides an electronic device. The electronic device described below and the data generation method described above can refer to each other.
[0173] See also Figure 5 As shown, the electronic device includes:
[0174] A memory 332, for storing computer programs;
[0175] The processor 322 is used to implement the steps of the data generating method of the above method embodiment when executing a computer program.
[0176] For details, please refer to Figure 6 , Figure 6A schematic diagram of the specific structure of an electronic device provided for this embodiment, which may have relatively large differences due to different configurations or performances, may include one or more processors (central processing units, CPU) (for example, one or more processors) and a memory 332, and the memory 332 stores one or more computer programs 342 or data 344. Among them, the memory 332 can be a temporary storage or a permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the processor 322 can be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the electronic device 301.
[0177] The electronic device 301 may further include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .
[0178] The steps in the data generating method described above can be implemented by the structure of an electronic device.
[0179] Corresponding to the above method embodiment, the embodiment of the present application further provides a readable storage medium. The readable storage medium described below and the data generation method described above can refer to each other.
[0180] A readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the data generating method of the above method embodiment.
[0181] The readable storage medium may specifically be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other readable storage medium that can store program codes.
[0182] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0183] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0184] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0185] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms include, include or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0186] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data generation method, characterized in that: include: Acquire a description instruction set, a result instruction set, and a mapping relationship between a single object description instruction in the description instruction set and a single result instruction in the result instruction set; Combining the single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, and performing diversity expansion on the multi-object description instructions; After the expansion is completed, the multiple result instructions corresponding to each of the multiple object description instructions are determined from the result instruction set according to the mapping relationship; A multi-object data set is constructed by utilizing the multi-object description instructions and the multi-result instructions corresponding thereto.
2. The method according to claim 1, characterized in that The multi-object description instruction is diversified and extended, including: randomly inserting punctuation marks into the sentences of the multi-object description instructions to expand the diversity of punctuation marks; and / or, The description style of the multi-object description instruction is modified to expand the style diversity.
3. The method according to claim 2, characterized in that The multi-object description instructions are modified to expand style diversity, including: Using a language processing module to complicate the multi-object description instruction to obtain a complex multi-object description instruction; Using a language processing module to simplify the multi-object description instruction to obtain a concise multi-object description instruction; The language processing module is used to remove the subject from the multi-object description instruction to obtain a multi-object description instruction without a subject.
4. The method according to claim 1, characterized in that According to the mapping relationship, determining the multiple result instructions corresponding to each of the multiple object description instructions from the result instruction set includes: According to the mapping relationship, searching from the result instruction set for a single result instruction corresponding to each single object description instruction in the multiple object description instructions; performing dependency detection on multiple single result instructions to supplement the single result instruction being found; After the supplementation is completed, the multiple single-result instructions found are concatenated to obtain a multiple-result instruction.
5. The method according to claim 4, characterized in that Also includes: The arrangement order of the multiple single result instructions found is randomly combined to obtain multiple result instructions with different orders.
6. The method according to claim 1, characterized in that The single object description instructions in the description instruction set are combined to obtain a plurality of multi-object description instructions, including: Get the sampling ratios corresponding to different types of application programming interfaces; Collecting a single object description instruction that meets the sampling ratio from the description instruction set; The collected single object description instructions are combined to obtain a plurality of multi-object description instructions that meet the sampling ratio.
7. The method according to any one of claims 1 to 6, characterized in that: After combining the single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, the method further includes: Construct the prompt words; The trained language processing model is used in combination with the prompt word to select a multi-object description instruction that is similar to the actual user description expression from a plurality of multi-object description instructions.
8. A data generating device, characterized in that: include: A data acquisition module, used for describing an instruction set, a result instruction set, and a mapping relationship between a single object description instruction in the description instruction set and a single result instruction in the result instruction set; A combination expansion module, used for combining single object description instructions in the description instruction set to obtain a plurality of multi-object description instructions, and performing diversity expansion on the multi-object description instructions; A result mapping module, used for determining, after the expansion is completed, from the result instruction set according to the mapping relationship, the multiple result instructions corresponding to each of the multiple object description instructions; The data construction module is used to construct a multi-object data set by using the multi-object description instructions and the multi-result instructions corresponding thereto.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the data generation method according to any one of claims 1 to 7 when executing the computer program.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data generation method according to any one of claims 1 to 7 are implemented.