Text expansion methods, devices, storage media, and computer program products

By text expansion of the initial test question data of the LLM model, language models and regular expressions are used to filter and discard low-quality data, which solves the problem of lack of high-quality samples in model training, achieves efficient and safe data expansion, and improves the model Performance and adaptability.

CN118503715BActive Publication Date: 2024-10-15LANGCHAO ELECTRONIC INFORMATION IND CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410962576.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-10-15
Estimated Expiration
2044-07-18

AI Technical Summary

Technical Problem

Existing LLM models lack high-quality and sufficient number of training samples during the training process, resulting in performance bottlenecks and security risks. Especially when the cost of data collection is high or the number of samples is small, data expansion becomes particularly important, but existing The method is time-consuming and laborious, and it is difficult to ensure data quality.

Method used

By selecting test question data from the preset initial test question data set, input the test question data to be expanded and similar question prompt words into the language model, extract and filter the expansion results, and discard inconsistent or low-quality data until all test question data are expanded, using Regular expressions determine the normativeness of replies and control the discarding threshold to achieve high-quality text expansion.

Benefits of technology

It effectively increases the number of test question data required for model training, reduces the difficulty of post-data screening, improves data quality, reduces security risks, and improves the robustness and adaptability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118503715B_ABST
    Figure CN118503715B_ABST
Patent Text Reader

Abstract

The present application discloses a text expansion method, device, storage medium and computer program product, which are applied to the field of data expansion technology, including: selecting a test data from an initial test data set as the test data to be expanded; inputting the test data to be expanded and a first prompt word into a language model, obtaining a first reply and extracting N test data; for any one of the N test data, after inputting the test data into the language model, obtaining a standard answer and an analytical answer given by the language model, and discarding the test data when the standard answer and the analytical answer are inconsistent; when all the test data in the initial test data set have been selected as the test data to be expanded, the expansion of the initial test data set is completed. The solution of the present application increases the number of test data, realizes expansion, and by discarding low-quality expansion content, it is conducive to reducing the difficulty of processing data screening and filtering in the later stage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data expansion, and in particular to a text expansion method, device, storage medium and computer program product. Background Art

[0002] For many machine learning and deep learning tasks, the size and diversity of the data set are important factors in determining the quality of the model. For example, LLM (Large Language Model) is an artificial intelligence model designed to understand and generate human language. It requires a large amount of text data for training and can perform a variety of tasks including text summarization, translation, and sentiment analysis.

[0003] Data augmentation can generate new data from existing data. Its purpose is to increase the diversity and scale of the data set. By expanding the data set, the model can be exposed to more diverse training samples, helping the model to better learn to deal with different scenarios and features. It can also reduce the risk of overfitting because the model is exposed to more possibilities and forms of variation. In addition, it also helps to improve the robustness and adaptability of the model. Data augmentation is particularly important when the number of samples collected is small or the collection cost is high. For example, when performing tasks such as image classification, object detection, speech recognition, and natural language processing, data augmentation is particularly important because the collected data is often affected by multiple factors such as environment, angle, light, and background.

[0004] The current LLM model usually collects data from sources such as the Internet and books, which may contain a large amount of unprocessed text. This data may become the performance bottleneck of the LLM model. The collected data needs to be further processed in order to effectively improve the performance, but this process is time-consuming and laborious. In addition, the training data of some models mainly comes from open source information libraries on the Internet, which may be mixed with user personal information, which can easily bring security risks. In addition, the quality of some content is not high.

[0005] In summary, how to provide high-quality training samples with a sufficient number of samples for subsequent use in model training and testing is a technical problem that technicians in this field urgently need to solve. Summary of the invention

[0006] The purpose of the present invention is to provide a text expansion method, device, storage medium and computer program product to provide high-quality training samples and a sufficient number of samples for subsequent use in model training and testing.

[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0008] In a first aspect, the present invention provides a text expansion method, comprising:

[0009] Selecting a test question data from a preset initial test question data set as the test question data to be expanded; wherein the test question data to be expanded includes a question text and option texts;

[0010] Inputting the test question data to be expanded and a first prompt word for guiding the language model to expand the number of similar questions in the test question data to be expanded into a language model, and obtaining a first response from the language model to the first prompt word;

[0011] Extracting N test question data included in the first reply; wherein N is a positive integer;

[0012] For any one of the N test data, after the test data is input into the language model, a standard answer for the option text of the test data and a parsed answer for the option text of the test data given by the language model are obtained, and when the standard answer and the parsed answer are inconsistent, the test data is discarded;

[0013] Each test question data that has not been discarded is used as the expansion result of this round, and the test question data to be expanded are selected again until all the test question data in the initial test question data set have been selected as the test question data to be expanded, and the expansion of the initial test question data set is completed.

[0014] On the other hand, after obtaining the first response of the language model to the first prompt word, the method further includes:

[0015] Determining whether the first response meets a preset specification;

[0016] If not, the first reply is discarded, and the next test question data to be expanded is selected;

[0017] If yes, the operation of extracting the N test question data included in the first reply is performed.

[0018] On the other hand, determining whether the first response meets the preset specification includes:

[0019] The preset parameter items in the first reply are filtered based on regular expressions to obtain filtering results, and whether the first reply meets preset specifications is determined based on the filtering results.

[0020] On the other hand, based on the regular expression, the preset parameter items in the first reply are screened to obtain the screening results, and based on the screening results, whether the first reply meets the preset specification is judged, including:

[0021] Determine the number of line breaks in the first reply based on a regular expression;

[0022] Determining whether the number of line breaks is within a preset number range;

[0023] If yes, determining that the first response meets the preset specification;

[0024] If not, it is determined that the first reply does not meet the preset specification.

[0025] On the other hand, it also includes:

[0026] Whenever the first reply is discarded and the next selection of the test question data to be expanded is performed, the discard quantity value is increased by 1; wherein the initial value of the discard quantity value is 0;

[0027] When the discarded quantity value reaches a preset first threshold, the text expansion process is paused, and a prompt message indicating that the first prompt word is inappropriate is output.

[0028] On the other hand, extracting N test question data included in the first reply includes:

[0029] Based on regular expressions, the test data are separated by line breaks in the first reply to extract the N test data included in the first reply, and the digital labels and irregular symbols before each line break are removed.

[0030] On the other hand, it also includes:

[0031] Establishing a binding relationship between the initial test question data set and the first prompt word;

[0032] When a prompt word modification instruction is received, the content of the first prompt word is modified based on the prompt word modification instruction.

[0033] On the other hand, it also includes:

[0034] For any one of the N test question data, after the test question data is discarded, the test question data is placed into a preset wrong test question database.

[0035] On the other hand, it also includes:

[0036] Upon receiving the first instruction, taking the test question data specified by the first instruction from the error test question database;

[0037] Based on the options carried in the first instruction, the standard answers of the option texts of the test question data specified by the first instruction are determined, and the test question data specified by the first instruction is added to the expansion result.

[0038] On the other hand, for any one of the N test data, after the test data is input into the language model, a standard answer for the option text of the test data and a parsed answer for the option text of the test data given by the language model are obtained, including:

[0039] For any one of the N test question data, the test question data is input into the language model to obtain a standard answer for the option text of the test question data given by the language model;

[0040] Inputting a second prompt word for guiding the language model to perform option analysis on the test question data into the language model, and obtaining a second response to the second prompt word given by the language model;

[0041] The number of options of the test data is obtained, and based on the logical value of the last layer in the language model, the logarithmic probability of each option of the test data is obtained, and the option with the largest logarithmic probability is used as the parsed answer to the option text of the test data given by the language model.

[0042] On the other hand, for any one of the N test data, after the test data is input into the language model, a standard answer for the option text of the test data and a parsed answer for the option text of the test data given by the language model are obtained, including:

[0043] For any one of the N test question data, the test question data is input into the language model to obtain a standard answer for the option text of the test question data given by the language model;

[0044] Inputting a second prompt word for guiding the language model to perform option analysis on the test question data into the language model, and obtaining a second response to the second prompt word given by the language model;

[0045] The second reply is parsed to obtain a parsed answer to the option text of the test question data given by the language model.

[0046] On the other hand, parsing the second reply to obtain the parsed answer of the option text for the test question data given by the language model includes:

[0047] Determining whether there is identification information in a preset format in the second reply based on a regular expression;

[0048] If it exists, then based on the options carried in the identification information, the parsed answers of the option text for the test question data given by the language model are obtained.

[0049] In a second aspect, the present invention further provides a computer program product, comprising a computer program, which implements the steps of the above-mentioned text expansion method when executed by a processor.

[0050] In a third aspect, the present invention further provides a text expansion device, comprising:

[0051] Memory for storing computer programs;

[0052] A processor is used to execute the computer program to implement the steps of the text expansion method as described above.

[0053] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the text expansion method as described above are implemented.

[0054] By applying the technical solution provided by the embodiment of the present invention, the amount of test data that can be used to achieve the purpose of model training can be conveniently and effectively increased by expanding the data of the initial test data set. Specifically, a test data can be selected from the preset initial test data set as the test data to be expanded, and the test data to be expanded includes the question text and the option text, and then expansion is achieved based on this to obtain the expansion result of this round, and then the test data to be expanded can be selected again until all the test data in the initial test data set have been selected as the test data to be expanded, indicating that the expansion of the initial test data set is completed.

[0055] After obtaining a certain test data to be expanded, the present application considers that the test data to be expanded and the first prompt word used to guide the language model to expand the number of similar questions for the test data to be expanded can be input into the language model, so that the first reply of the language model for the first prompt word can be automatically obtained, which is very convenient in operation. Afterwards, the N test data included in the first reply can be extracted. And the present application further considers that since these N test data are expanded by the language model based on the test data to be expanded and the first prompt word, in order to ensure its quality, it is also necessary to clean the data. Specifically, for any one of the N test data, the present application scheme will input the test data into the language model, and then obtain the standard answer and analytical answer given by the language model. If the standard answer and the analytical answer are inconsistent, the test data can be discarded, that is, the expansion content that may be of low quality is discarded, which is conducive to reducing the difficulty of processing data screening and filtering in the later stage.

[0056] To sum up, in the present application scheme, the expansion of test questions can be easily achieved, that is, the amount of test question data that can be used for model training and other purposes is effectively increased, and by discarding the expanded content that may be of low quality, it is helpful to reduce the difficulty of later data screening and filtering. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 paying creative work.

[0058] Figure 1 A flowchart of a text expansion method provided in a specific embodiment of the present invention;

[0059] Figure 2 A structural schematic diagram of a text expansion device provided by a specific implementation mode of the present invention;

[0060] Figure 3 The present invention is a schematic diagram of the structure of a computer-readable storage medium. DETAILED DESCRIPTION

[0061] The core of the present invention is to provide a text expansion method, device, storage medium and computer program product, which can easily realize the expansion of test questions, that is, effectively increase the amount of test question data that can be used for model training and other purposes, and by discarding the expanded content that may be of low quality, it is helpful to reduce the difficulty of later data screening and filtering.

[0062] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention 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 invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0063] Please refer to Figure 1 , Figure 1 The present invention provides a flowchart of a text expansion method according to a specific embodiment of the present invention. The text expansion method may include the following steps:

[0064] Step S101: selecting a test question data from a preset initial test question data set as the test question data to be expanded; wherein the test question data to be expanded includes a question text and option texts.

[0065] The present application solution can realize text expansion, specifically, the expansion of test question data, and the expanded test question data is specifically multiple-choice question data. Therefore, any test question data described in this application will include question text and option text.

[0066] The initial test question data set is a set including multiple test question data. For example, a test question data in the initial test question data set is specifically:

[0067] What is the main reason why sunlight heats up black asphalt roads in the sun? A. Asphalt effectively reflects sunlight. B. Asphalt absorbs sunlight. C. Asphalt cools sunlight. D. Asphalt scatters sunlight.

[0068] The question text in this example is "What is the main reason why the sun heats the black asphalt road in the sun?", and the rest of the content is the option text, which specifically includes 4 options.

[0069] These test question data in the initial test question data set are usually similar or have a related test question data, so they are placed in the same set. Of course, in other specific occasions, the specific rules for placing different test question data in the same set can be set according to actual needs and will not affect the implementation of the present invention.

[0070] Each test question data in the initial test question data set can be expanded according to the scheme of the present application. That is to say, each test question data in the initial test question data set will be used as the test question data to be expanded in turn, so as to achieve expansion based on the principle of the scheme of the present application. Therefore, in the following text, the expansion process of a single test question data to be expanded is used as an example to illustrate, and for other test question data to be expanded, the expansion principle is the same.

[0071] When selecting a test data from a preset initial test data set, for example, a more convenient implementation method is to number each test data in the initial test data set, and then select them in sequence from 1 to K. Whenever a test data is selected, the selected test data is used as the test data to be expanded in this round. It can be understood that K here refers to the total number of test data in the preset initial test data set.

[0072] Step S102: inputting the test question data to be expanded and a first prompt word for guiding the language model to expand the number of similar questions for the test question data to be expanded into the language model, and obtaining a first response of the language model to the first prompt word.

[0073] After selecting the test data to be expanded that is needed for this round of expansion, this round of expansion can be started. This application takes into account that the language model has the ability to understand and generate human language, so a trained language model can be used to achieve this round of expansion of the test data to be expanded. And this application also takes into account that since the test data to be expanded is to be expanded, the expanded test data should be similar to the test data to be expanded, which is conducive to reducing the difficulty of expanding the language model and improving the quality of the expanded test data. At the same time, since the expanded test data is similar to the test data to be expanded, it can be directly placed in the same set later without manual classification.

[0074] Therefore, based on the design purpose of expanding similar questions, in the present application, not only the data of test questions to be expanded is input into the language model, but also the first prompt word is input to guide the language model to expand the number of similar questions for the test question data to be expanded. That is to say, after the language model receives the test question data to be expanded and the first prompt word, it can know that the content that should be replied is specifically the similar questions of the test question data to be expanded.

[0075] The specific content of the first prompt word can be pre-set as long as it can achieve the functional requirements of the present application for the first prompt word. For example, it can be specifically set to "Please generate multiple similar test question data based on the above scenarios and options." For example, it can be specifically set to "Please generate at least N test question data similar to the original question based on similar scenarios."

[0076] In addition, it should be noted that although the specific content of the first prompt word can be set to different forms, as long as the functional requirements of the first prompt word of this application are achieved, in actual applications, for the same test question data to be expanded, when different forms of first prompt words are selected, the first replies generated by the language model will be different, and for some forms of first prompt words, the language model may output a first reply of lower quality due to reasons such as incomprehensibility or easy misunderstanding, that is, the output first reply is not a similar question of the expected test question data to be expanded. Therefore, in actual applications, a more suitable first prompt word can be set by selection.

[0077] For example, in a specific implementation, the staff can pre-list several candidate prompt words, and then determine the best candidate prompt word through testing as the first prompt word required by the present application. There can also be multiple specific testing methods. For example, in a specific scenario, M test question data can be set and input into the language model one by one. Each time a test question data is input, the candidate prompt word currently being tested is input, so as to obtain a total of M replies output by the language model for the candidate prompt word, and then the probability of low-quality replies in the M replies is counted as the test result of the candidate prompt word. M in this implementation is a positive integer, usually not less than 2. According to the same principle, after obtaining the test results of each candidate prompt word, the candidate prompt word with the lowest probability of low-quality replies can be selected as the first prompt word.

[0078] Step S103: extracting N test question data included in the first reply.

[0079] Since the first reply output by the language model is a question expansion for the test question data to be expanded, the N test question data included in the first reply can be extracted.

[0080] N is a positive integer, and its specific value will be affected by the specific content setting of the first prompt word. It can be understood that in order to ensure that a sufficient number of test question data are expanded, when the specific content of the first prompt word is set, the language model will usually be allowed to expand the expanded test question data into more similar questions, that is, N is usually not less than 2.

[0081] When extracting the N test question data included in the first reply, there can be many specific implementation methods. For example, the test question data in the first reply output by the language model is usually separated by line breaks and numbers, so each line break can be identified to extract the N test question data included in the first reply.

[0082] In a specific implementation of the present invention, after obtaining the first response of the language model to the first prompt word, the following steps may also be included:

[0083] Determine whether the first response meets the preset specifications;

[0084] If not, the first response is discarded and the next test question data to be expanded is selected;

[0085] If yes, an operation of extracting N test question data included in the first reply is performed.

[0086] In this implementation, after step S102, the operation of step S103 will not be executed immediately, but it will be determined first whether the first reply meets the preset specifications. This is because although the extracted test data will be filtered in the subsequent step S104, if the lower-quality first replies can be directly filtered before executing step S103, it will help improve the execution efficiency of the present application scheme. By filtering the lower-quality first replies, it will also help to ensure the quality and reliability of the expansion results ultimately obtained by the present application scheme.

[0087] Specifically, if the first reply meets the preset specifications, it means that the N test question data included in the first reply can be conveniently and effectively extracted later. Therefore, the operation of step S103 can be performed normally. On the contrary, if the first reply does not meet the preset specifications, it means that the quality of the first reply is low, and it is difficult to extract the test question data included therein. In some cases, such a first reply is not a similar question expansion to be treated as the expanded test question data. Therefore, for such a first reply, there is no need to perform subsequent operations, but it can be directly discarded, and the process can be directly returned to step S101 to select the next test question data to be expanded.

[0088] There are many specific implementation methods for determining whether the first reply meets the preset specifications. For example, in one scenario, it can be determined whether it meets the preset specifications based on the word range of the first reply. In another specific implementation of the present invention, the preset parameter items in the first reply can be screened based on regular expressions to obtain screening results, and then it can be determined whether the first reply meets the preset specifications based on the screening results. This is because it is more convenient to implement when judging whether the first reply meets the preset specifications based on regular expressions, and the accuracy is usually higher when the preset parameter items in the first reply are screened to obtain the screening results to achieve the judgment compared to some other judgment methods.

[0089] The parameter items used in this implementation may be one or more, and the specific content may be set and adjusted according to actual needs, but generally speaking, parameter items should be selected that can more accurately and effectively reflect whether the first reply meets the preset specifications.

[0090] In a specific implementation of the present invention, the preset parameter items in the first reply are screened based on a regular expression to obtain a screening result, and based on the screening result, it is determined whether the first reply meets the preset specification, which may specifically include:

[0091] Determine the number of line breaks in the first reply based on a regular expression;

[0092] Determine whether the number of line breaks is within a preset range;

[0093] If yes, then it is determined that the first response meets the preset specification;

[0094] If not, it is determined that the first reply does not meet the preset specification.

[0095] This implementation takes into account that each test question data in the first reply output by the language model is usually separated by line breaks and numbers. Therefore, the number of line breaks in the first reply can usually more accurately determine whether the first reply meets the preset specifications. For example, in one scenario, when determining the number of line breaks in the first reply based on a regular expression, the regular expression text.split(' / n') can be used to determine the number of line breaks in the first reply. For example, in one scenario, according to the requirements of the first prompt word, a total of 10 test question data similar to the test question data to be expanded will be generated, then the preset number range can be set to 9 to 10, that is, if the number of line breaks in the first reply is 9 or 10, it is determined that the first reply meets the preset specifications, otherwise it is determined that the first reply does not meet the preset specifications.

[0096] In a specific embodiment of the present invention, it may also include:

[0097] Whenever the first response is discarded and the next selection of the test data to be expanded is performed, the discard quantity value is increased by 1; wherein the initial value of the discard quantity value is 0;

[0098] When the discarded quantity value reaches a preset first threshold, the text expansion process is paused, and a prompt message indicating that the first prompt word is inappropriate is output.

[0099] In this implementation, every time a first reply is discarded, the discarded number value will increase by 1, that is, the discarded number value represents the total number of first replies that have been discarded in this text expansion process. And it can be understood that the more discarded number values, the more low-quality first replies there are. When the discarded number value reaches the preset first threshold, it means that too many first replies have been discarded. This is not a normal situation. It is usually caused by the inappropriate first prompt word. Therefore, the text expansion process can be paused, and a prompt message indicating that the first prompt word is inappropriate is output, so that the staff can intervene in time.

[0100] In addition, it should be noted that, in actual applications, the test data in the initial test data set are usually similar or related test data, and there can be multiple initial test data sets, different sets represent different types of test data, and for different initial test data sets, when executing the present application scheme, the same first prompt word can be used, or different first prompt words can be used respectively, but for each test data to be expanded in the same initial test data set, the same first prompt word is used.

[0101] In a specific embodiment of the present invention, it may also include:

[0102] Establishing a binding relationship between the initial test question data set and the first prompt word;

[0103] When the prompt word modification instruction is received, the content of the first prompt word is modified based on the prompt word modification instruction.

[0104] This implementation method takes into account that, when there are multiple initial test question data sets, configuring each initial test question data set with its own first prompt word is more conducive to ensuring the quality of the first reply than using the same first prompt word for each initial test question data set. Therefore, a binding relationship between the initial test question data set and the first prompt word is established to indicate that for a certain initial test question data set, the initial test question data set uses the first prompt word bound to itself.

[0105] Of course, in order to ensure flexibility, modifications are also allowed, that is, the staff can send prompt word modification instructions. When the prompt word modification instruction is received, it means that the content of the first prompt word bound to a certain initial test question data set needs to be modified. Therefore, the content of the corresponding first prompt word can be modified based on the prompt word modification instruction.

[0106] In a specific implementation of the present invention, step S103 may specifically include:

[0107] Based on the regular expression, the test data is separated by the line break in the first reply to extract the N test data included in the first reply, and the digital labels and irregular symbols before each line break are removed.

[0108] This implementation takes into account that each test question data in the first reply output by the language model is usually separated by line breaks and numbers. Therefore, when extracting the N test question data included in the first reply, the test question data can be separated by line breaks in the first reply based on regular expressions, thereby extracting the N test question data included in the first reply.

[0109] This implementation also takes into account that the digital labels and irregular symbols before each line break are invalid interference data. Therefore, in order to improve data quality, it is possible to clear the digital labels and irregular symbols before each line break based on regular expressions, such as the re.sub() method based on regular expressions.

[0110] Step S104: For any one of the N test question data, after the test question data is input into the language model, a standard answer for the option text of the test question data and an analytical answer for the option text of the test question data given by the language model are obtained, and when the standard answer and the analytical answer are inconsistent, the test question data is discarded.

[0111] For any one of the N test data, after the test data is input into the language model, the language model will give a standard answer, that is, give the standard answer for the option text of the test data. For example, a test data has 4 options. After the test data is input into the language model, the language model will give a response of "the standard answer is B", which means that option B is the standard answer given by the language model.

[0112] At the same time, you can also use the language model to get the parsed answer. The parsed answer refers to the correct option obtained after the language model analyzes the options.

[0113] Under normal circumstances, the standard answer and the analyzed answer should be consistent. If the standard answer and the analyzed answer are inconsistent, it indicates an abnormal situation. For example, it is because the test data is easy to understand incorrectly, or there is more than one correct answer among the options. In this regard, in order to ensure the quality of the expanded test data, this application scheme will discard the test data at this time.

[0114] In a specific implementation of the present invention, step S104 may specifically include:

[0115] For any one of the N test question data, the test question data is input into the language model to obtain a standard answer for the option text of the test question data given by the language model;

[0116] Inputting into the language model a second prompt word for guiding the language model to perform option analysis on the test question data, and obtaining a second response to the second prompt word given by the language model;

[0117] The number of options of the test data is obtained, and the logarithmic probability of each option of the test data is obtained based on the logical value of the last layer in the language model, and the option with the largest logarithmic probability is used as the parsed answer given by the language model for the option text of the test data.

[0118] This implementation method takes into account that, for any one of the N test data, after the test data is input into the language model, the standard answer given by the language model can be directly obtained. After that, by inputting a more detailed prompt word, i.e., the second prompt word, into the language model, the language model can be guided to analyze the options of the test data. For example, in one case, the second prompt word is specifically "Please analyze each option of the test data and indicate why the option is correct or incorrect." After the second prompt word used to guide the language model to analyze the options of the test data is input into the language model, the second reply given by the language model can be obtained.

[0119] MMLU (Massive Multitask Language Understanding) is dedicated to evaluating and improving the capabilities of language models on various language understanding tasks. The project spans multiple fields and topics, including history, mathematics, etc., and aims to challenge the model's understanding ability and knowledge scope through these diverse topics.

[0120] The present application takes into account that the options of MMLU are only ABCD, and the test data expanded by the present application solution may contain more or fewer options. Therefore, in this implementation, it is necessary to obtain the number of options of the test data. For example, when there are 5 options, the obtained options can be expressed as dict_choice = {0: "A", 1: "B", 2: "C", 3: "D", 4: "E", 5: "F"}. Afterwards, based on the logical value logits of the last layer in the language model, the logarithmic probability of each answer can be obtained and recorded in the list probs, that is, the logarithmic probability of each option of the test data is obtained. Finally, the operation of pred = dict_choice [np.argmax(probs)] can be executed, and the option with the largest logarithmic probability is used as the parsed answer given by the obtained language model.

[0121] It can be seen that in this implementation, the parsing answer given by the language model is obtained based on the logical value of the last layer in the language model. Such an implementation does not require particularly high accuracy for the second prompt word, and the parsing answer given by the language model is obtained through the logical value of the last layer, which is relatively simple and convenient to implement.

[0122] In a specific implementation of the present invention, step S104 may specifically include:

[0123] For any one of the N test question data, the test question data is input into the language model to obtain a standard answer for the option text of the test question data given by the language model;

[0124] Inputting into the language model a second prompt word for guiding the language model to perform option analysis on the test question data, and obtaining a second response to the second prompt word given by the language model;

[0125] The second reply is parsed to obtain the parsed answer of the option text for the test question data given by the language model.

[0126] In this implementation, for any one of the N test data, after the test data is input into the language model, the standard answer given by the language model can be directly obtained. After that, by inputting a more detailed prompt word, i.e., the second prompt word, which is preset in advance, into the language model, the language model can be guided to perform option analysis on the test data, thereby obtaining the second reply given by the language model. After that, in this implementation, the second reply is directly parsed to obtain the parsed answer given by the language model, and a relatively accurate parsed answer can be obtained.

[0127] There may be multiple specific implementations of parsing the second reply to obtain the parsed answer given by the language model. For example, in a specific implementation of the present invention, parsing the second reply to obtain the parsed answer given by the language model for the option text of the test question data may specifically include:

[0128] Determine whether there is identification information in a preset format in the second reply based on a regular expression;

[0129] If it exists, based on the options carried in the identification information, the parsed answer of the option text for the test question data given by the language model is obtained.

[0130] In this implementation, it is specifically based on a regular expression to determine whether there is identification information in a preset format in the second reply. For example, if the standard answer to a certain test question is A, the generated second reply may have a symbolic prompt such as "Option A is the correct answer, the correct answer is A". Therefore, according to the characteristics of these symbolic prompts, a regular expression can be used to determine whether there is identification information in a preset format in the second reply, so as to obtain the parsed answer given by the language model based on the clear option letters carried in the identification information. For example, in one case, the regular expression used is specifically re.search(r"the correct answer is.*?\b([AF])\b", answer). That is, the identification information in the preset format in this example is "the correct answer is.*", that is, as long as the identification information "the correct answer is" exists, a clear option letter will be obtained from this identification information, and then the letter will be used as the obtained parsed answer.

[0131] Step S105: taking each test question data that has not been discarded as the expansion result of this round, and reselecting the test question data to be expanded, until all the test question data in the initial test question data set have been selected as the test question data to be expanded, the expansion of the initial test question data set is completed.

[0132] For any one of the test data to be expanded, after similar questions are expanded and discarded, one or more expanded test data similar to the test data to be expanded will be retained, and these test data can be used as the expansion results of this round. The processing process of each test data to be expanded is the same. Therefore, until all the test data in the initial test data set have been selected as the test data to be expanded, the expansion of the initial test data set is completed.

[0133] In a specific embodiment of the present invention, it may also include:

[0134] For any one of the N test question data, after the test question data is discarded, the test question data is placed into a preset wrong test question database.

[0135] This implementation method takes into account that for any one of the N test data, if the test data is discarded, it means that the test data is not conventional. For example, the test data is test data with errors. For example, the question text of the test data may be wrong. For example, there may be multiple correct options in the option text of the test data, which leads to the test data being test data with errors, and then the standard answer and the analytical answer obtained in the previous operation are inconsistent. For another example, the test data is test data without errors, but it is discarded in the above process because it is easy to understand and make mistakes.

[0136] In this regard, in this implementation mode, these test question data will be specially collected, that is, placed in a preset erroneous test question database for use in some occasions. For example, in some occasions, some test question data that are easy to understand and erroneous are needed to conduct intensive training of designated models. The staff can then sort out the required test question data from the erroneous test question database of this implementation mode, which helps to improve the work efficiency of the staff.

[0137] Furthermore, in a specific embodiment of the present invention, it may also include:

[0138] Upon receiving the first instruction, taking the test question data specified by the first instruction from the error test question database;

[0139] Based on the options carried in the first instruction, the standard answers of the option texts of the test question data specified by the first instruction are determined, and the test question data specified by the first instruction is added to the expansion result.

[0140] In this implementation mode, when the first instruction is received, it indicates that the staff member requires the test data specified by the first instruction to be taken out from the error test database, and after taking out, the standard answer of the option text of the test data specified by the first instruction will be determined based on the options carried in the first instruction. That is to say, in this implementation mode, the standard answer of a certain test data is directly specified by the first instruction, and the test data specified by the first instruction can be added to the expansion result to increase the number of test data expanded by the present application scheme. This implementation mode is usually applied in the case where the number of expanded test data is insufficient, and the staff member can take out some test data without errors from the error test database and directly specify the standard answer to increase the number of expanded test data.

[0141] By applying the technical solution provided by the embodiment of the present invention, the amount of test data that can be used to achieve the purpose of model training can be conveniently and effectively increased by expanding the data of the initial test data set. Specifically, a test data can be selected from the preset initial test data set as the test data to be expanded, and the test data to be expanded includes the question text and the option text, and then expansion is achieved based on this to obtain the expansion result of this round, and then the test data to be expanded can be selected again until all the test data in the initial test data set have been selected as the test data to be expanded, indicating that the expansion of the initial test data set is completed.

[0142] After obtaining a certain test data to be expanded, the present application considers that the test data to be expanded and the first prompt word used to guide the language model to expand the number of similar questions for the test data to be expanded can be input into the language model, so that the first reply of the language model for the first prompt word can be automatically obtained, which is very convenient in operation. Afterwards, the N test data included in the first reply can be extracted. And the present application further considers that since these N test data are expanded by the language model based on the test data to be expanded and the first prompt word, in order to ensure its quality, it is also necessary to clean the data. Specifically, for any one of the N test data, the present application scheme will input the test data into the language model, and then obtain the standard answer and analytical answer given by the language model. If the standard answer and the analytical answer are inconsistent, the test data can be discarded, that is, the expansion content that may be of low quality is discarded, which is conducive to reducing the difficulty of processing data screening and filtering in the later stage.

[0143] To sum up, in the present application scheme, the expansion of test questions can be easily achieved, that is, the amount of test question data that can be used for model training and other purposes is effectively increased, and by discarding the expanded content that may be of low quality, it is helpful to reduce the difficulty of later data screening and filtering.

[0144] Corresponding to the above method embodiment, the embodiment of the present invention further provides a text expansion system, which can be referred to in correspondence with the above text. The text expansion system may include:

[0145] The module for determining the test question data to be expanded is used to select a test question data from a preset initial test question data set as the test question data to be expanded; wherein the test question data to be expanded includes a question text and an option text;

[0146] An expansion module, used for inputting the test question data to be expanded and a first prompt word for guiding the language model to expand the number of similar questions for the test question data to be expanded, and obtaining a first response of the language model to the first prompt word;

[0147] A test question data extraction module, used to extract N test question data included in the first reply; wherein N is a positive integer;

[0148] A filtering module is used for obtaining, for any one of the N test data, a standard answer for the option text of the test data and a parsed answer for the option text of the test data given by the language model after inputting the test data into the language model, and discarding the test data when the standard answer and the parsed answer are inconsistent;

[0149] The module for selecting the test question data to be expanded is used to take the test question data that have not been discarded as the expansion result of this round, and re-select the test question data to be expanded until all the test question data in the initial test question data set have been selected as the test question data to be expanded, thereby completing the expansion of the initial test question data set.

[0150] Corresponding to the above method and system embodiments, the embodiments of the present invention further provide a text expansion device, a computer-readable storage medium, and a computer program product, which can be referred to in correspondence with the above.

[0151] See also Figure 2 As shown, the device may include:

[0152] Memory 201, used for storing computer programs;

[0153] The processor 202 is configured to execute a computer program to implement the steps of the text expansion method in any of the above embodiments.

[0154] The computer program product includes a computer program, and when the computer program is executed by a processor, the steps of the text expansion method in any of the above embodiments are implemented.

[0155] See also Figure 3 The computer readable storage medium 30 stores a computer program 31, and when the computer program 31 is executed by the processor, the steps of the text expansion method in any of the above embodiments are implemented. The computer readable storage medium 30 mentioned here includes RAM (Random Access Memory), memory, ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable Read Only Memory), register, hard disk, removable disk, or any other form of storage medium known in the technical field.

[0156] It should also be noted that, in this article, relational terms such as first and second, etc. are only used 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", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including 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. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0157] Professionals may further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in 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 the above description according to the function. 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. Specific examples are used herein to illustrate the principles and implementation methods of the present invention, and the description of the above embodiments is only used to help understand the technical solution and its core idea of ​​the present invention. It should be pointed out that for ordinary technicians in the technical field, without departing from the principle of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.

Claims

1. A text expansion method, characterized in that: include: Selecting a test question data from a preset initial test question data set as the test question data to be expanded; wherein the test question data to be expanded includes a question text and option texts; Inputting the test question data to be expanded and a first prompt word for guiding the language model to expand the number of similar questions in the test question data to be expanded into a language model, and obtaining a first response from the language model to the first prompt word; Extracting N test question data included in the first reply; wherein N is a positive integer; For any one of the N test data, after the test data is input into the language model, a standard answer for the option text of the test data and a parsed answer for the option text of the test data given by the language model are obtained, and when the standard answer and the parsed answer are inconsistent, the test data is discarded; Taking each test question data that has not been discarded as the expansion result of this round, and reselecting the test question data to be expanded, until all the test question data in the initial test question data set have been selected as the test question data to be expanded, the expansion of the initial test question data set is completed; For any one of the N test data, after the test data is input into the language model, a standard answer for the option text of the test data and a parsed answer for the option text of the test data given by the language model are obtained, including: For any one of the N test question data, the test question data is input into the language model to obtain a standard answer for the option text of the test question data given by the language model; Inputting a second prompt word for guiding the language model to perform option analysis on the test question data into the language model, and obtaining a second response to the second prompt word given by the language model; Obtaining the number of options of the test data, obtaining the logarithmic probability of each option of the test data based on the logical value of the last layer in the language model, and taking the option with the largest logarithmic probability as the parsed answer of the option text of the test data given by the language model; Alternatively, for any one of the N test data, after the test data is input into the language model, a standard answer for the option text of the test data and a parsed answer for the option text of the test data given by the language model are obtained, including: For any one of the N test question data, the test question data is input into the language model to obtain a standard answer for the option text of the test question data given by the language model; Inputting a second prompt word for guiding the language model to perform option analysis on the test question data into the language model, and obtaining a second response to the second prompt word given by the language model; The second reply is parsed to obtain a parsed answer to the option text of the test question data given by the language model.

2. The text expansion method according to claim 1, characterized in that: After obtaining a first response from the language model to the first prompt word, the method further includes: Determining whether the first response meets a preset specification; If not, the first reply is discarded, and the next test question data to be expanded is selected; If yes, the operation of extracting the N test question data included in the first reply is performed.

3. The text expansion method according to claim 2, characterized in that: Determining whether the first response meets the preset specification includes: The preset parameter items in the first reply are filtered based on regular expressions to obtain filtering results, and whether the first reply meets preset specifications is determined based on the filtering results.

4. The text expansion method according to claim 3, characterized in that: Filtering the preset parameter items in the first reply based on a regular expression to obtain a filtering result, and judging whether the first reply meets the preset specification based on the filtering result, including: Determine the number of line breaks in the first reply based on a regular expression; Determining whether the number of line breaks is within a preset number range; If yes, determining that the first response meets the preset specification; If not, it is determined that the first reply does not meet the preset specification.

5. The text expansion method according to claim 2, characterized in that: Also includes: Whenever the first reply is discarded and the next selection of the test question data to be expanded is performed, the discard quantity value is increased by 1; wherein the initial value of the discard quantity value is 0; When the discarded quantity value reaches a preset first threshold, the text expansion process is paused, and a prompt message indicating that the first prompt word is inappropriate is output.

6. The text expansion method according to claim 1, characterized in that: Extracting N test question data included in the first reply, including: Based on regular expressions, the test data are separated by line breaks in the first reply to extract N test data included in the first reply, and the digital labels and irregular symbols before each line break are removed.

7. The text expansion method according to claim 1, characterized in that: Also includes: Establishing a binding relationship between the initial test question data set and the first prompt word; When a prompt word modification instruction is received, the content of the first prompt word is modified based on the prompt word modification instruction.

8. The text expansion method according to claim 1, characterized in that: Also includes: For any one of the N test question data, after the test question data is discarded, the test question data is placed into a preset wrong test question database.

9. The text expansion method according to claim 8, characterized in that: Also includes: Upon receiving the first instruction, taking the test question data specified by the first instruction from the error test question database; Based on the options carried in the first instruction, the standard answers of the option texts of the test question data specified by the first instruction are determined, and the test question data specified by the first instruction is added to the expansion result.

10. The text expansion method according to claim 1, characterized in that: Parsing the second reply to obtain the parsed answer of the option text for the test question data given by the language model includes: Determining whether there is identification information in a preset format in the second reply based on a regular expression; If it exists, then based on the options carried in the identification information, the parsed answers of the option text for the test question data given by the language model are obtained.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the text expansion method according to any one of claims 1 to 10 are implemented.

12. A text expansion device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the text expansion method according to any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the text expansion method according to any one of claims 1 to 10 are implemented.