A method for batch data generation based on token training for limited large language models
Constructing contextual prompt words and batch random startup parameters through user-defined data item information, combined with secondary format verification rules, solves the problems of low data generation efficiency and large language model token length limitations in software testing, and achieves high-quality, The ability to batch generate large amounts of test data.
Patent Information
- Application Number
- CN202410767410.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-06-14
AI Technical Summary
The existing technology is inefficient when generating test data in software testing, and it is difficult to generate realistic simulation data. Moreover, large language model dialogues have duplication and token length limitations, making it impossible to generate large amounts of data in batches.
By constructing contextual prompt words based on user-defined data item information, configuring batch random startup parameters, calculating the maximum returnable token length, verifying data generation results using secondary format verification rules, and cyclically acquiring and saving batch test data.
It improves the efficiency of test data generation, ensures the quality and consistency of generated data, solves the problem of large language model token length limitations, and enables batch generation of millions of pieces of data.
Smart Images

Figure CN118331890B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field, and in particular to a method, device and data generation equipment for batch generating data based on token training to limit a large language model. Background Art
[0002] During software testing, it is often necessary to simulate and generate test data. If performance or stress testing is required, tens of thousands of data points need to be generated.
[0003] Regarding the method of generating test data, the traditional approach is for software engineers to develop specific test data generation code based on data item requirements and then run the code to generate test data.
[0004] However, developing data generation code specifically based on data item requirements is a custom development model that requires separate development each time, which is very inefficient. If you want to develop very realistic simulation data, it will take longer and delay testing time.
[0005] Although the large language model can generate test data through manual or API dialogue, there are several problems with the dialogue of the large language model:
[0006] The large language model (or "AI large language model") needs to know the exact content of the requirements. If the quality of ordinary text descriptions is poor, a more effective interaction format for large language models needs to be designed.
[0007] The data generated by large language model conversations may contain content that does not meet the requirements and is prone to generating duplicate data. Automated secondary data verification capabilities are required to ensure that the generated data meets the requirements.
[0008] Large language model conversations have token length limits and can only generate dozens of data at a time. It is necessary to solve multiple rounds of concurrent conversations and breakpoint resuming capabilities to ensure that the data generated by each interaction is orderly and meets the requirements. Summary of the invention
[0009] In order to solve the technical problems existing in the prior art, the embodiment of the present invention provides a method and apparatus for batch generating data based on token training and limited large language model, and a data generating device. The technical solution is as follows:
[0010] On the one hand, a method for batch generating data based on token training and limiting a large language model is provided, which is used to batch generate test data, characterized in that the method comprises:
[0011] S1. Based on the user-defined data item information, construct the context prompt words required for interaction for the AI large language model, and configure batch random start parameters for the context prompt words;
[0012] S2, calculating the maximum returnable token length of the context prompt word in the AI large language model, and importing it into the AI large language model together with the context prompt word, performing data generation and returning the data generation result;
[0013] S3. Based on the data item requirement check rule of the secondary format verification, the data generation result returned by the AI large language model is verified, and the verified qualified data generation result is output;
[0014] S4, cyclically obtain and verify and output all qualified data generation results, obtain batch test data and save them to the database.
[0015] As a preferred embodiment of the present invention, in step S1, the context prompt words required for interaction are constructed for the AI large language model based on the user-defined data item information, including:
[0016] Predefine a number of data item information, each of which includes the following data item requirements: data item name, type, length, value range, whether to allow duplication, and data item description;
[0017] Writing each piece of data item information into a structured database for storage;
[0018] The structured database is read by using a programming language, traversing to obtain JSON intermediate format data of each piece of the data item information, and performing SQL language metadata structure conversion on the JSON intermediate format data of each piece of the data item information, and generating an SQL language text corresponding to each piece of the data item information, wherein: a UNIQUE KEY mark is added to a non-repeating element in the SQL language text, and when the data item information with the UNIQUE KEY mark added is read, it indicates that the current data item is not allowed to be repeated;
[0019] After the traversal is completed, the context prompt words required for the AI large language model interaction are generated.
[0020] As a preferred embodiment of the present invention, in step S1, configuring batch random start parameters for the context prompt words includes:
[0021] The preset batch random start parameters are written into the SQL language text of each data item information, and the batch random start parameters include:
[0022] The batch and current interaction time randomly generated by the system for the SQL language text of each piece of data item information;
[0023] When the AI large language model completes interactive execution of the SQL language text of the data item information of the current batch, it interactively executes the SQL language text of the data item information of the next batch according to the random startup parameters of the next batch randomly generated by the system.
[0024] As a preferred embodiment of the present invention, in step S2, the maximum returnable token length of the context prompt word in the AI large language model is calculated, and the context prompt word is imported into the AI large language model together with the context prompt word, data is generated and the data generation result is returned, including:
[0025] make:
[0026] The maximum token length that can be returned by the AI large language model is A.
[0027] make:
[0028] The maximum token length of the current context prompt word is B, then: ,
[0029] Where: n is the number of text characters, is the word length of each text;
[0030] Calculate the maximum returnable token length of the current context prompt word in the AI large language model: l(B)=AB, where:
[0031] l(B) is the maximum returnable token length of the current context prompt word;
[0032] Send the context prompt word and the corresponding maximum returnable token length to the AI large language model;
[0033] The AI large language model performs intelligent interaction according to the imported context prompt words and the corresponding maximum returnable token length, automatically generates simulated test data and returns data generation results.
[0034] As a preferred embodiment of the present invention, in step S3, the data item requirement checking rule based on secondary format verification includes the following two format verification rules:
[0035] The data item requirement checking rule of the first format verification is used to detect whether the data generation result returned by the AI large language model meets the data item requirement pre-defined by the user;
[0036] The data item requirement checking rules for the second format verification are used to use the Bloom filter algorithm to detect whether the data generation result returned by the AI large language model is repeatedly generated.
[0037] As a preferred implementation scheme of the present invention, in step S3, verifying the data generation result returned by the AI large language model and outputting the verified data generation result includes:
[0038] Based on the data item requirement check rules of the secondary format verification, the current data generation result returned by the AI large language model is verified:
[0039] If the current data generation result satisfies two format verification rules in the data item requirement checking rule based on the secondary format verification at the same time, the current data generation result is deemed qualified and output, and the data generation position of the current data generation result is recorded at the same time;
[0040] If the current data generation result does not meet the two format verification rules in the data item requirement check rules based on secondary format verification: as long as one of them is not met, it will be unqualified, then the current data generation result is deemed unqualified, and the next data generation result returned by the AI large language model is re-obtained and verified.
[0041] As a preferred embodiment of the present invention, in step S3, when verifying the data generation result returned by the AI large language model, it also includes:
[0042] Calculate the token length of the current data generation result returned by the AI large language model, and determine whether the token length of the current data generation result exceeds the preset limit:
[0043] If not, obtaining the next data generation result returned by the AI large language model;
[0044] If it exceeds, the process goes to step S1 to regenerate the next batch of context prompt words, and at the same time, the data generation position of the data generation result recorded last time is added to the context prompt words.
[0045] On the other hand, a device for batch generating data based on token training to limit a large language model is provided, and the device for batch generating data based on token training to limit a large language model is used to implement the above-mentioned method for batch generating data based on token training to limit a large language model, and the device includes:
[0046] A corpus custom construction module is used to construct contextual prompt words required for interaction for the AI large language model based on user-defined data item information, and configure batch random start parameters for the contextual prompt words;
[0047] A data generation module, used to calculate the maximum returnable token length of the context prompt word in the AI large language model, and import it into the AI large language model together with the context prompt word, perform data generation and return the data generation result;
[0048] A data verification module, used to verify the data generation result returned by the AI large language model based on the data item requirement inspection rules of the secondary format verification, and output the verified qualified data generation result;
[0049] The data storage module is used to cyclically acquire and verify and output all qualified data generation results, obtain batch test data and save them in a database.
[0050] On the other hand, a data generation device is provided, the data generation device comprising: a processor; a memory, the memory storing computer-readable instructions, the computer-readable instructions being executed by the processor to implement any of the above-mentioned methods for batch generating data based on token training to limit a large language model. The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0051] The present invention constructs contextual prompt words required for interaction for the AI large language model based on user-defined data item information, and configures batch random startup parameters for the contextual prompt words; calculates the maximum returnable token length of the contextual prompt words in the AI large language model, and imports the contextual prompt words into the AI large language model together with the contextual prompt words, generates data and returns the data generation result; verifies the data generation result returned by the AI large language model based on the data item requirement inspection rules of the secondary format verification, and outputs the verified qualified data generation result; cyclically obtains and verifies and outputs all qualified data generation results, obtains batch test data and saves it to the database. It allows users to flexibly configure the data item requirements to be generated, including the type, length, range, whether to allow duplication and remarks of each data item. The present invention can automatically construct text interaction content that can be understood by the AI large language model according to the requirements described by the user, and automatically generates simulation test data in batches.
[0052] This paper designs a data generation interactive format for AI large language models, adds secondary data inspection capabilities during data generation, and can effectively improve the quality of AI large language model data generation. It solves the problem of AI large language model token length limitation and can generate more than millions of data at one time.
[0053] The present invention can improve the generation efficiency of test data and avoid time delays, and can also solve the dialogue and breakpoint-resume problems in data generation, thereby ensuring that the data generated in each interaction is orderly and meets the requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0055] Figure 1 It is a flow chart of a method for batch generating data based on token training and limiting a large language model provided by an embodiment of the present invention;
[0056] Figure 2 It is a schematic diagram of using a data item requirement table to record user-defined data item information provided by an embodiment of the present invention;
[0057] Figure 3 This is a schematic diagram of JSON intermediate format data read using a programming language provided by an embodiment of the present invention;
[0058] Figure 4 This is a schematic diagram of a generated SQL language format provided by an embodiment of the present invention;
[0059] Figure 5 This is a data checking flow chart provided by an embodiment of the present invention;
[0060] Figure 6 This is a schematic diagram of a final generated result of all qualified data generation provided by an embodiment of the present invention;
[0061] Figure 7 It is a block diagram of a device for batch generating data based on token training and limiting a large language model provided by an embodiment of the present invention;
[0062] Figure 8 It is a structural schematic diagram of a data generating device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0063] The technical solution of the present invention is described below in conjunction with the accompanying drawings.
[0064] In the embodiments of the present invention, words such as "exemplarily" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "example" in the present invention should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "example" is intended to present the concept in a specific way. In addition, in the embodiments of the present invention, the meaning expressed by "and / or" can be both, or it can be either of the two.
[0065] In the embodiments of the present invention, "image" and "picture" can sometimes be used interchangeably. It should be noted that when the difference between them is not emphasized, the meanings they want to express are the same. "of", "corresponding" and "corresponding" can sometimes be used interchangeably. It should be noted that when the difference between them is not emphasized, the meanings they want to express are the same. In the embodiments of the present invention, sometimes a subscript such as W 1 It may be mistakenly written as a non-subscript form such as W1. When the difference is not emphasized, the meanings they express are the same.
[0066] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0067] Large language model, or AI large language model,
[0068] Large Language Model (LLM) is a deep learning model trained on massive text data. It not only has the ability to generate natural language text, but also has the ability to deeply understand the meaning of the text and handle various natural language tasks such as text summarization, question answering, translation, etc.
[0069] The large language model uses deep learning technology and multi-layer neural networks to model the statistical laws and potential semantic information of language. During the training process, the large language model will learn and abstract a large amount of text data, so that it can generate logical and coherent language output. At the same time, in order to ensure that the model has good generalization ability, it is also necessary to collect and organize large-scale data sets for training.
[0070] The big language model has demonstrated strong capabilities and potential in natural language processing, machine translation, dialogue systems, text generation, and other fields. It can understand human natural language input and generate semantically relevant output based on the input content. By learning a large amount of text data, the big language model can gain a deep understanding of language structure, grammar, semantics, and other aspects.
[0071] In this embodiment, the AI large language model can be selected by the user, such as Chat GPT\Llama\Wenxin Yiyan\Tongyi Qianwen.
[0072] Regarding the semantic interaction of the AI big language model, please understand it in conjunction with the logical architecture of the AI big language model. This embodiment will not go into details. Example 1
[0073] The embodiment of the present invention provides a method for batch generating data based on token training and limiting a large language model. The method can be implemented by a data generating device, which can be a terminal or a server. Figure 1 The flowchart of the method for batch generation of data based on token training limited large language model is shown. The processing flow of the method may include the following steps:
[0074] On the one hand, a method for batch generating data based on token training and limiting a large language model is provided, which is used to batch generate test data, characterized in that the method comprises:
[0075] S1. Based on the user-defined data item information, construct the context prompt words required for interaction for the AI large language model, and configure batch random start parameters for the context prompt words;
[0076] S2, calculating the maximum returnable token length of the context prompt word in the AI large language model, and importing it into the AI large language model together with the context prompt word, performing data generation and returning the data generation result;
[0077] S3. Based on the data item requirement check rule of the secondary format verification, the data generation result returned by the AI large language model is verified, and the verified qualified data generation result is output;
[0078] S4, cyclically obtain and verify and output all qualified data generation results, obtain batch test data and save them to the database.
[0079] The main technical point of the present invention is: converting the custom data input by the user into an SQL interactive data format that is easier for the AI large language model to understand, ensuring that the AI large language model can generate high-quality data more accurately, and at the same time performing secondary format verification on the data generated by the AI large language model, including data type, range and high-speed deduplication check based on the Bloom filter algorithm, to ensure that the generated data meets user requirements.
[0080] The AI large language model has a token length limit and cannot generate large amounts of data in batches. The present invention saves data in batches in the middle, brings the data position into the context prompt word, and repeatedly interacts with the AI large language model, so as to achieve the effect of batch generation of non-repetitive data. At the same time, in the process of interacting with the large language, the batch and current interaction time information are added each time, so that the AI large language model can be automatically called in a loop to generate, improve the randomness of the data generated each time, and improve the robustness of the model to the data.
[0081] Each step is described in detail below.
[0082] As a preferred embodiment of the present invention, in step S1, the context prompt words required for interaction are constructed for the AI large language model based on the user-defined data item information, including:
[0083] Predefine a number of data item information, each of which includes the following data item requirements: data item name, type, length, value range, whether to allow duplication, and data item description;
[0084] Writing each piece of data item information into a structured database for storage;
[0085] The structured database is read by using a programming language, traversing to obtain JSON intermediate format data of each piece of the data item information, and performing SQL language metadata structure conversion on the JSON intermediate format data of each piece of the data item information, and generating an SQL language text corresponding to each piece of the data item information, wherein: a UNIQUE KEY mark is added to a non-repeating element in the SQL language text, and when the data item information with the UNIQUE KEY mark added is read, it indicates that the current data item is not allowed to be repeated;
[0086] After the traversal is completed, the context prompt words required for the AI large language model interaction are generated. The test data requirements, data format and data item requirements are configured by the user.
[0087] When preparing the context prompts required for interaction for the AI large language model, you need to configure the AI large language model role context prompts to indicate that the task taken on by the AI large language model is to complete the data generation task. In order to improve the accuracy of the data returned by the AI large language model, a context dialogue example is given, and the user will enter the data item requirements and format requirements.
[0088] like Figure 2As shown, it is a schematic diagram of using a data item requirement form to record user-defined data item information. The user prepares the requirements for data generation (data item requirements), and the user can enter the requirements into Excel or a professional database. The general requirements include the name, type, length, value range, whether to allow duplication, and detailed description of the data item to be generated. Multiple data item information can be entered at one time. Among them, the data item description specifically sets the data generation restrictions set by the user for each data item, such as whether to limit random generation, whether to allow data to be randomly generated, whether to randomly generate the specific data content of an object (such as randomly generating a member's email address), and other random items. By defining the randomness of data generation for each data item in the data item description, the AI large language model can recognize the randomness of data generation for each data item and randomly define the generated data, thereby improving the model's robustness and discreteness to the data and allowing data to be more widely recognized and generated.
[0089] Model random data generation has the following advantages:
[0090] 1. Diversity and richness: Randomly generating data can produce a large number of different, unique, and varied data samples. This diversity helps the model train and learn in a wider range of contexts and improves its generalization ability.
[0091] 2. Simulate the complexity of the real world: In the real world, data is often complex and changeable. Randomly generating data can simulate this complexity and provide the model with a data set that is closer to the real world, which helps the model better adapt to and process actual data.
[0092] 3. Flexibility: By adjusting the parameters and settings of randomly generated data, it is easy to create datasets with different characteristics and distributions. This flexibility enables the model to adapt to a variety of different tasks and needs, improving its applicability.
[0093] 4. Scalability: Randomly generated data can easily expand the size of the data set to meet the needs of larger-scale training. This is especially important for deep learning models that need to process large amounts of data, helping the model to better learn and extract data features.
[0094] 5. Data privacy and security: In some cases, using real data may involve privacy issues or security risks. Randomly generated data can provide the data required for model training and verification without leaking sensitive information, which helps protect data privacy and security.
[0095] In order to facilitate the system to quickly read data, improve the speed of data writing, and shorten the time for AI large language models to generate test data, SQL structured processing of table data is used here to generate corresponding SQL language text.
[0096] Specifically: Use programming language to read the data item requirement description entered by the user in Excel and convert it into the database-specific SQL language metadata structure (generate SQL structured description). The process is as follows:
[0097] 1. The programming language reads the demand description of Excel data items, traverses each data item and converts it into JSON intermediate format data; Figure 3 As shown, it is a schematic diagram of JSON intermediate format data read by programming language;
[0098] 2. According to the conversion of JSON intermediate format data into SQL language format text, each JSON data item needs to be converted into SQL language syntax, such as Figure 4 As shown, it is a schematic diagram of a generated SQL language format;
[0099] SQL transformations typically include the following:
[0100] 2.1 The field names in SQL language are usually in English, so the data item names need to be converted to English;
[0101] 2.2 The data type is converted to the common type name of the SQL language. For the string type, the data length information needs to be added;
[0102] 2.3 Data items that cannot be repeated are marked with a UNIQUE KEY (i.e., a unique key mark or key label);
[0103] 2.4 Convert the data range and comments of the data item into comment information in SQL language;
[0104] 2.5 Other special syntax conversions.
[0105] The data table contains several data item information. In order to perform subsequent duplication detection on each data item information, a UNIQUE KEY flag is added to the data item that cannot be repeated, that is, a unique key identifier, so that the system can identify whether the current data item is repeatable through the UNIQUE KEY flag of the data item when reading. If the model recognizes that the current data item has this flag, it is determined that the data item cannot be repeated. Adding the UNIQUE KEY flag is also for the purpose of quickly identifying and detecting whether the data items can be repeated during subsequent format detection, thereby improving the detection efficiency of special items. For example, if the email address, member nickname and member number id are not allowed to be repeated, the UNIQUE KEY flag is added to the email address, member nickname and member number id. The data item requirement content is also the basis for building format verification rules. It can be written into the system and saved. Similarly, the model can intelligently generate the corresponding format verification rules on the system based on the data item requirement content (the first one below can be intelligently generated by the AI model. The data item requirement content is input into the model, and the AI model can intelligently generate several rules, and after fusion, the first rule is obtained). In this way, the rules can be quickly customized and matched.
[0106] As a preferred embodiment of the present invention, in step S1, configuring batch random start parameters for the context prompt words includes:
[0107] The preset batch random start parameters are written into the SQL language text of each data item information, and the batch random start parameters include:
[0108] The batch and current interaction time randomly generated by the system for the SQL language text of each piece of data item information;
[0109] When the AI large language model completes interactive execution of the SQL language text of the data item information of the current batch, it interactively executes the SQL language text of the data item information of the next batch according to the random startup parameters of the next batch randomly generated by the system.
[0110] In order to provide randomness and robustness for the data generated by the model, a batch random start parameter is used here to randomly write data items into the model for interaction.
[0111] Because in the process of interacting with the big language, the model needs to interact with multiple batches of written data, and may input multiple data items at a time or input each data item in sequence. If the data items are written in order, the model's fusion recognition of the context content is reduced, and the model's overall understanding of the context is reduced. Therefore, in order to improve the model's understanding of the text context and random interactions, the method of adding batches and current interaction time information each time is adopted, so that the AI big language model generation can be automatically called in a loop, the randomness of each generated data is improved, the model's ability to recognize text is improved, and more extensive and understandable test data is output, thereby improving data diversity.
[0112] Through the above construction, context prompt words for the AI large language model are generated. The context prompt words need to include the following:
[0113] Generated SQL language text;
[0114] The starting number of the automatically increasing data items in the current batch;
[0115] Current system time.
[0116] The model can interactively and randomly generate several test data of the corresponding data items according to the description of each item in the data item table (the description information is configured with the generation keywords for the test data set of the data item, such as generating a test data set of member nicknames according to the description of "random character string" (it will also combine other keywords or generate specific words to comprehensively generate the test data set), and the subsequent model interacts according to the generated keywords and outputs the corresponding test data set), and uses the configured format verification rules to perform deduplication detection to obtain the test data of each data item, thereby obtaining each test data with higher randomness.
[0117] Next, we will enter the model's calculation and interaction with the context token length.
[0118] As a preferred embodiment of the present invention, in step S2, the maximum returnable token length of the context prompt word in the AI large language model is calculated, and the context prompt word is imported into the AI large language model together with the context prompt word, data is generated and the data generation result is returned, including:
[0119] make:
[0120] The maximum token length that can be returned by the AI large language model is A.
[0121] make:
[0122] The maximum token length of the current context prompt word is B, then: ,
[0123] Where: n is the number of text characters, is the word length of each text;
[0124] Calculate the maximum returnable token length of the current context prompt word in the AI large language model: l(B)=AB, where:
[0125] l(B) is the maximum returnable token length of the current context prompt word;
[0126] Send the context prompt word and the corresponding maximum returnable token length to the AI large language model;
[0127] The AI large language model performs intelligent interaction according to the imported context prompt words and the corresponding maximum returnable token length, automatically generates simulated test data and returns data generation results.
[0128] The maximum token length that the AI large language model can return is A, which is usually a parameter given by the AI large language model or defined by the administrator.
[0129] Token is the smallest unit of character encoding in the AI large language model. A token usually represents a word, a number or a punctuation mark. The token length of the current context prompt word is calculated according to the formula = B, and the maximum returnable token length of the current context prompt word in the AI large language model is calculated.
[0130] In the formula, n = the number of text characters, Lsi = the length of each word in the text, and the general algorithm is as follows:
[0131] 1 English letter = 0.25;
[0132] 1 Chinese character = 1.5;
[0133] 1 punctuation mark = 1;
[0134] 1 number = 1.
[0135] The above calculations are completed by the system program itself.
[0136] After the calculation is completed, the context prompt word and the maximum return token length of the current context prompt word are sent to the AI large language model. The AI large language model will interact with itself based on the context prompt word, and generate an interaction format according to the data of the maximum return token length to generate data that meets the requirements.
[0137] Each time the AI large language model returns, it calculates whether the token length exceeds the upper limit. If it detects that the token limit is exceeded, it reorganizes the context prompt words, appends the location of the last data generation to the context prompt words, and repeats step 4. In this way, data can be generated in batches in a loop.
[0138] Loop through the text content returned by the AI large language model, parse the text content, and organize it into a complete set of result data.
[0139] As a preferred embodiment of the present invention, in step S3, the data item requirement checking rule based on secondary format verification includes the following two format verification rules:
[0140] The data item requirement checking rule of the first format verification is used to detect whether the data generation result returned by the AI large language model meets the data item requirement pre-defined by the user;
[0141] The data item requirement checking rules for the second format verification are used to use the Bloom filter algorithm to detect whether the data generation result returned by the AI large language model is repeatedly generated.
[0142] like Figure 5 The data checking flow chart is shown in FIG.
[0143] For the data item requirements pre-customized by the user, please refer to the data item table content described above.
[0144] The data item requirement checking rule for the first format verification is to detect whether the data returned by the current model meets the data item requirements pre-defined by the user (check whether the data type, length, and range meet the requirement definition). If any one item is not met, it is considered unqualified.
[0145] At the same time, in order to prevent data duplication, the Bloom filter algorithm is used to detect whether data items are duplicated. The data item requirements for the second format verification can be checked using the Bloom filter algorithm. Users can configure the corresponding data item information in the Bloom filter to facilitate the import of model output data into the Bloom filter for algorithm detection.
[0146] Bloom Filter is a highly space-efficient probabilistic data structure that uses bit arrays to represent sets and allows a certain false positive rate. Bloom filters are often used to quickly check whether an element exists in a set. Its characteristics are that insertion and query operations are very fast, but elements cannot be deleted and there is a possibility of false positives.
[0147] Bloom filters use a very long binary vector (bit array) and a series of random mapping functions. When an element is added to the set, it is processed by all the mapping functions and the corresponding position in the bit array is set to 1. When you need to check whether an element exists in the set, you only need to check whether the corresponding bits of the element after being processed by all the mapping functions are 1:
[0148] If so, the element may exist in the set; if there is a position of 0, the element definitely does not exist.
[0149] The implementation of Bloom filter is relatively simple, but it should be noted that due to the possibility of conflict in hash function, Bloom filter will produce a certain false positive rate, that is, it is possible to misjudge non-existent elements as existing. The size of the false positive rate is related to the length of the bit array, the number of hash functions and the number of elements in the set.
[0150] The Bloom filter algorithm plays an important role in big data processing with its efficient space utilization and fast query speed. Although there is a certain misjudgment rate, in many scenarios, this probabilistic judgment is sufficient to meet actual needs.
[0151] As a preferred implementation scheme of the present invention, in step S3, verifying the data generation result returned by the AI large language model and outputting the verified qualified data generation result includes:
[0152] Based on the data item requirement check rules of the secondary format verification, the current data generation result returned by the AI large language model is verified:
[0153] If the current data generation result satisfies two format verification rules in the data item requirement checking rule based on secondary format verification at the same time, the current data generation result is deemed qualified and output, and the data generation position of the current data generation result is recorded at the same time;
[0154] If the current data generation result does not meet the two format verification rules in the data item requirement check rules based on secondary format verification: as long as one of them is not met, it will be unqualified, then the current data generation result is deemed unqualified, and the next data generation result returned by the AI large language model is re-obtained and verified.
[0155] The above test first needs to use the data item requirement check rules of the first format check to perform data detection. If the detection is qualified, the second one can be used for detection. The detection order is not allowed to be interchanged to avoid computing pressure and cost on the detection algorithm.
[0156] Qualified data will be recorded and saved, and the data generation location will also be recorded, so that the system can track the initial location of the generated data in a table based on the location, which will be used for the positioning generation of the next batch of data.
[0157] As a preferred embodiment of the present invention, in step S3, when verifying the data generation result returned by the AI large language model, it also includes:
[0158] Calculate the token length of the current data generation result returned by the AI large language model, and determine whether the token length of the current data generation result exceeds the preset limit:
[0159] If not, obtaining the next data generation result returned by the AI large language model;
[0160] If it exceeds, the process goes to step S1 to regenerate the next batch of context prompt words, and at the same time, the data generation position of the data generation result recorded last time is added to the context prompt words.
[0161] If the tests meet the requirements, they are stored in the result file<result.csv> , and record the location of the data that has been generated this time, and update the Bloom filter of each data item that needs to be deduplicated; if data that does not meet the requirements is found during the detection process, it will be discarded directly.
[0162] Each time the AI large language model returns, it calculates whether the token length exceeds the upper limit. If it detects that the token limit is exceeded, it reorganizes the context prompt words, appends the location of the last data generation to the context prompt words, and repeats the steps of interactively generating data by the above model. In this way, data can be generated in batches in a loop.
[0163] S4, cyclically obtain and verify and output all qualified data generation results, obtain batch test data and save them to the database.
[0164] The model will output several items of data according to random interaction. According to the above steps S1-3, output and verification are performed. After all qualified data are obtained, batch test data is obtained and saved in the database.
[0165] The database preferably uses a Mysql structured database to facilitate matching and storing data.
[0166] When all the data is received, the program ends and the file<result.csv> This is the final data generated. Figure 6 As shown, it is a schematic diagram of the final generated results of all qualified data.
[0167] By adopting the above scheme, the present invention adds a secondary data inspection capability in the data generation process by designing a data generation interactive format for AI large language models, which can effectively improve the quality of AI large language model data generation. The problem of AI large language model token length limitation is solved, and more than millions of data can be generated at one time.
[0168] After the data is generated, a test data set of several data items is obtained. The Bloom filter can be used again to traverse each data set for duplicate checking. At this time, the administrator can set the duplicate checking rules for the data item information and check for duplicates, so as to perform the final screening before storage.
[0169] The data input by the user is converted into an SQL interactive data format that is easier for the AI big language model to understand, ensuring that the AI big language model can generate high-quality data more accurately. At the same time, the data generated by the AI big language model is subjected to secondary format verification, including data type, range, and high-speed deduplication check based on the Bloom filter algorithm, to ensure that the generated data meets user requirements.
[0170] The present invention saves data in batches, brings the data location into the context prompt word, and repeatedly interacts with the AI large language model, so as to achieve the effect of batch generation of non-repetitive data.
[0171] Example 2
[0172] Figure 7 1 is a block diagram of a device for batch generating data based on token training to define a large language model according to an exemplary embodiment, wherein the device is used for a method for batch generating data based on token training to define a large language model. Figure 7 , the device comprises:
[0173] A corpus customization construction module 310 is used to construct context prompt words required for interaction for the AI large language model based on user-defined data item information, and configure batch random start parameters for the context prompt words;
[0174] A data generation module 320 is used to calculate the maximum returnable token length of the context prompt word in the AI large language model, and import it into the AI large language model together with the context prompt word, perform data generation and return the data generation result;
[0175] A data verification module 330 is used to verify the data generation result returned by the AI large language model based on the data item requirement inspection rule of the secondary format verification, and output the verified qualified data generation result;
[0176] The data storage module 340 is used to cyclically acquire and verify and output all qualified data generation results, obtain batch test data and save them to the database.
[0177] Please understand the functions and interactions of the various modules of the above device in conjunction with Example 1.
[0178] Example 3
[0179] On the other hand, a data generating device is provided, comprising: a processor; a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, any one of the above-mentioned methods for batch generating data based on token training to limit a large language model is implemented.
[0180] Figure 8 is a structural diagram of a data generating device provided by an embodiment of the present invention, such as Figure 8 As shown, the data generating device may include the above Figure 7 The data batch generation device shown is based on token training to define a large language model. Optionally, the data generation device 410 may include a first processor 2001.
[0181] Optionally, the data generating device 410 may further include a memory 2002 and a transceiver 2003 .
[0182] The first processor 2001, the memory 2002 and the transceiver 2003 may be connected via a communication bus.
[0183] The following is a detailed introduction to the components of the data generation device 410 in combination with 8 pairs:
[0184] The first processor 2001 is the control center of the data generating device 410, and may be a processor or a general term for multiple processing elements. For example, the first processor 2001 is one or more central processing units (CPUs), or may be application specific integrated circuits (ASICs), or may be one or more integrated circuits configured to implement the embodiments of the present invention, such as one or more microprocessors (digital signal processors, DSPs), or one or more field programmable gate arrays (FPGAs).
[0185] Optionally, the first processor 2001 may execute various functions of the data generating device 410 by running or executing a software program stored in the memory 2002 , and calling data stored in the memory 2002 .
[0186] In a specific implementation, as an embodiment, the first processor 2001 may include one or more CPUs, such as Figure 8 CPU0 and CPU1 are shown in FIG.
[0187] In a specific implementation, as an embodiment, the data generating device 410 may also include multiple processors, such as Figure 8 The first processor 2001 and the second processor 2004 are shown in FIG. Each of these processors may be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). The processor here may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0188] The memory 2002 is used to store the software program for executing the solution of the present invention, and is controlled to be executed by the first processor 2001. The specific implementation method can refer to the above method embodiment, which will not be repeated here.
[0189] Optionally, the memory 2002 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 2002 may be integrated with the first processor 2001, or may exist independently and access the first processor 2001 through the interface circuit ( Figure 8 (not shown) is coupled to the first processor 2001, which is not specifically limited in this embodiment of the present invention.
[0190] The transceiver 2003 is used to communicate with a network device or a terminal device.
[0191] Optionally, the transceiver 2003 may include a receiver and a transmitter ( Figure 8 The receiver is used to implement a receiving function, and the transmitter is used to implement a sending function.
[0192] Optionally, the transceiver 2003 may be integrated with the first processor 2001, or may exist independently and communicate with the first processor 2001 through the interface circuit ( Figure 8 (not shown) is coupled to the first processor 2001, which is not specifically limited in this embodiment of the present invention.
[0193] It should be noted that Figure 8 The structure of the data generating device 410 shown in the figure does not constitute a limitation on the router, and the actual knowledge structure recognition device may include more or fewer components than those shown in the figure, or combine certain components, or arrange the components differently.
[0194] In addition, the technical effects of the data generation device 410 can refer to the technical effects of the data batch generation method based on token training to limit the large language model described in the above method embodiment, which will not be repeated here.
[0195] It should be understood that the first processor 2001 in the embodiment of the present invention may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0196] It should also be understood that the memory in the embodiments of the present invention may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0197] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0198] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.
[0199] In the present invention, "at least one" means one or more, and "plurality" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0200] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0201] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can 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 the present invention.
[0202] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0203] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0204] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0205] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0206] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.
[0207] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for batch generating data based on token training limited large language model, used for batch generating test data, It is characterized in that The method comprises: S1. Based on the user-defined data item information, the context prompt words required for interaction are constructed for the AI large language model, and batch random start parameters are configured for the context prompt words; the context prompt words required for interaction are constructed for the AI large language model based on the user-defined data item information, including: Predefine a number of data item information, each of which includes the following data item requirements: data item name, type, length, value range, whether to allow duplication, and data item description; Writing each piece of data item information into a structured database for storage; The structured database is read by using a programming language, traversing to obtain JSON intermediate format data of each piece of the data item information, and performing SQL language metadata structure conversion on the JSON intermediate format data of each piece of the data item information, and generating an SQL language text corresponding to each piece of the data item information, wherein: a UNIQUE KEY mark is added to a non-repeating element in the SQL language text, and when the data item information with the UNIQUE KEY mark added is read, it indicates that the current data item is not allowed to be repeated; After the traversal is completed, the context prompt words required for the AI large language model interaction are generated; S2, calculating the maximum returnable token length of the context prompt word in the AI large language model, and importing it into the AI large language model together with the context prompt word, performing data generation and returning the data generation result; S3. Based on the data item requirement check rule of the secondary format verification, the data generation result returned by the AI large language model is verified, and the verified qualified data generation result is output; S4, cyclically obtain and verify and output all qualified data generation results, obtain batch test data and save them to the database.
2. The method for generating batch data based on token training and limiting large language models according to claim 1, It is characterized in that In step S1, configuring batch random start parameters for the context prompt words includes: The preset batch random start parameters are written into the SQL language text of each data item information, and the batch random start parameters include: The batch and current interaction time randomly generated by the system for the SQL language text of each piece of data item information; When the AI large language model completes interactive execution of the SQL language text of the data item information of the current batch, it interactively executes the SQL language text of the data item information of the next batch according to the random startup parameters of the next batch randomly generated by the system.
3. The method for generating batch data based on token training and limiting large language models according to claim 1, It is characterized in that In step S2, the maximum returnable token length of the context prompt word in the AI large language model is calculated, and the context prompt word is imported into the AI large language model together with the context prompt word, data is generated and the data generation result is returned, including: make: The maximum token length that can be returned by the AI large language model is A. make: The maximum token length of the current context prompt word is B, then: Where: n is the number of text characters, l si is the word length of each text; Calculate the maximum returnable token length of the current context prompt word in the AI large language model: l(B)=AB, in: l(B) is the maximum returnable token length of the current context prompt word; Send the context prompt word and the corresponding maximum returnable token length and import them into the AI large language model; The AI large language model performs intelligent interaction according to the imported context prompt words and the corresponding maximum returnable token length, automatically generates simulated test data and returns data generation results.
4. The method for generating batch data based on token training and limiting large language models according to claim 1, It is characterized in that In step S3, the data item requirement checking rules based on secondary format verification include the following two format verification rules: The data item requirement checking rule of the first format verification is used to detect whether the data generation result returned by the AI large language model meets the data item requirement pre-defined by the user; The data item requirement checking rules for the second format verification are used to use the Bloom filter algorithm to detect whether the data generation result returned by the AI large language model is repeatedly generated.
5. The method for generating batch data based on token training and limiting large language models according to claim 1, It is characterized in that In step S3, the data generation result returned by the AI large language model is verified, and the verified data generation result is output, including: Based on the data item requirement check rules of the secondary format verification, the current data generation result returned by the AI large language model is verified: If the current data generation result satisfies two format verification rules in the data item requirement checking rule based on secondary format verification at the same time, the current data generation result is deemed qualified and output, and the data generation position of the current data generation result is recorded at the same time; If the current data generation result does not meet the two format verification rules in the data item requirement check rules based on secondary format verification: as long as one of them is not met, it will be unqualified, then the current data generation result is deemed unqualified, and the next data generation result returned by the AI large language model is re-obtained and verified.
6. The method for generating batch data based on token training and limiting large language models according to claim 5, It is characterized in that In step S3, when verifying the data generation result returned by the AI large language model, it also includes: Calculate the token length of the current data generation result returned by the AI large language model, and determine whether the token length of the current data generation result exceeds the preset limit: If not, obtaining the next data generation result returned by the AI large language model; If it exceeds, the process goes to step S1 to regenerate the next batch of context prompt words, and at the same time, the data generation position of the data generation result recorded last time is added to the context prompt words.
7. A data batch generation device based on token training to limit a large language model, the data batch generation device based on token training to limit a large language model is used to implement the data batch generation method based on token training to limit a large language model as described in any one of claims 1-6, It is characterized in that The device comprises: The corpus customization construction module is used to construct the context prompt words required for interaction for the AI large language model based on the user-defined data item information, and configure batch random start parameters for the context prompt words; the context prompt words required for interaction for the AI large language model based on the user-defined data item information include: Predefine a number of data item information, each of which includes the following data item requirements: data item name, type, length, value range, whether to allow duplication, and data item description; Writing each piece of data item information into a structured database for storage; The structured database is read by using a programming language, traversing to obtain JSON intermediate format data of each piece of the data item information, and performing SQL language metadata structure conversion on the JSON intermediate format data of each piece of the data item information, and generating an SQL language text corresponding to each piece of the data item information, wherein: a UNIQUE KEY mark is added to a non-repeating element in the SQL language text, and when the data item information with the UNIQUE KEY mark added is read, it indicates that the current data item is not allowed to be repeated; After the traversal is completed, the context prompt words required for the AI large language model interaction are generated; A data generation module, used to calculate the maximum returnable token length of the context prompt word in the AI large language model, and import it into the AI large language model together with the context prompt word, perform data generation and return the data generation result; A data verification module, used to verify the data generation result returned by the AI large language model based on the data item requirement inspection rules of the secondary format verification, and output the verified qualified data generation result; The data storage module is used to cyclically acquire and verify and output all qualified data generation results, obtain batch test data and save them in a database.
8. A data generating device, It is characterized in that The data generating device comprises: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 6 is implemented.
