A method, system and computer device for extracting fine-tuning data of a large language model
By extracting fine-tuning data from the original text data, using corpus and inverse text frequency index calculations, the problem of high cost and poor quality construction of fine-tuning data sets of large language model is solved, and efficient and good-quality fine-tuning data extraction is achieved.
Patent Information
- Application Number
- CN202411260476.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-09-10
AI Technical Summary
The existing large language model fine-tuning data sets are costly and of poor quality, especially in professional applications. The existing methods rely on manual annotation or general model generation, resulting in low efficiency and data quality problems.
By extracting fine-tuning data from original text data such as books, building a corpus, using non-stop word division and inverse text frequency index calculation, we determine whether the text corpus is fine-tuning data of a large language model, and improve data quality and construction efficiency.
The extraction of fine-tuning data of high-quality large language models is realized, reducing the cost of data set construction and improving the extraction efficiency and quality of fine-tuning data.
Smart Images

Figure CN118798189B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of large language models, and in particular to a method, system and computer device for extracting fine-tuning data of a large language model. Background Art
[0002] The big language model is an advanced artificial intelligence model based on deep learning and natural language processing technology. The advantage of this model is that it can achieve universal learning in a variety of tasks without a lot of customization of specific languages and characters. From text generation to complex problem solving, the big language model is currently widely used. Compared with traditional models in the field of natural language processing, the big language model has the characteristics of deeper network layers and larger parameter scales, and often requires a large amount of corpus data during the training phase. After the pre-training phase of the big language model is completed, instruction fine-tuning is generally used to activate the big language model's conversational capabilities and ability to solve downstream tasks. Instruction fine-tuning aims to further train the big language model using artificially constructed instruction data, thereby enhancing or unlocking the capabilities of the big language model.
[0003] Related research shows that language models of different sizes can benefit from instruction fine-tuning, and a small model that has been fine-tuned can even perform better than a large model that has not been fine-tuned. At the same time, in professional applications, large language models can be fine-tuned for specific fields. Current practice shows that after fine-tuning instructions for specific fields, the ability of large language models to solve problems in this specific field can be greatly enhanced, which further highlights the importance and effectiveness of instruction fine-tuning.
[0004] The instruction fine-tuning process requires first collecting or building an instruction fine-tuning dataset similar to question-answer pairs, and then fine-tuning the parameters of the large language model in a supervised manner. Currently, most of the open-source instruction fine-tuning datasets are for natural language processing tasks, targeting general daily conversations, text processing and other tasks. In the process of developing large language models in professional specific fields, the construction of high-quality fine-tuning datasets is often costly.
[0005] There are two main methods for constructing fine-tuning datasets: one based on manual annotation and the other based on the capabilities of existing general large language models. Manual annotation construction mainly involves personnel in specific professional fields writing specified fine-tuning data based on their knowledge and experience, which can ensure the quality of fine-tuning data, but the labor cost is very high. It is also possible to use some manually constructed fine-tuning data as examples, combined with appropriate prompt words to input into mature general large models for deep and broad evolution, and generate more fine-tuning data. However, large models with good generation effects are usually closed source models, and calling the commercial services of the models also requires a large cost. In addition, existing mature large models are generally general models with limited understanding of specific fields, and the quality of the generated fine-tuning data is problematic. Summary of the invention
[0006] Based on this, it is necessary to provide a method, system and computer device for extracting fine-tuning data for large language models that can extract fine-tuning data from original text data such as books, which helps to improve the construction efficiency and data quality of fine-tuning data and reduce the construction cost of fine-tuning data sets, in response to the above technical problems.
[0007] In a first aspect, the present application provides a method for extracting fine-tuning data for a large language model, the method comprising:
[0008] Acquire original text data and construct a corpus of the original text data; the corpus includes multiple text corpora; the text corpora uses the minimum title of the original text data as corpus input and uses the text data corresponding to the minimum title as corpus output;
[0009] Based on the corpus, the corpus input of each of the text corpora is divided into non-stop words, and the inverse text frequency index of each of the non-stop words in the corpus is calculated;
[0010] Obtaining a minimum inverse text frequency index mean of the corpus;
[0011] Based on the inverse text frequency index, calculating the mean inverse text frequency index of the non-stop words in the corpus input in each text corpus;
[0012] The inverse text frequency index mean is compared with the minimum inverse text frequency index mean to obtain a comparison result, and according to the comparison result, it is determined whether the text corpus is fine-tuning data of a large language model.
[0013] In one embodiment, the step of dividing the corpus input of each of the text corpora into non-stop words based on the corpus, and calculating the inverse text frequency index of each of the non-stop words in the corpus includes:
[0014] Constructing a stop word dataset of the corpus;
[0015] Based on the stop word data set, traverse each corpus input of the text corpus to perform a word segmentation operation to obtain a word segmentation result, and extract non-stop words of each corpus input according to the word segmentation result;
[0016] The inverse text frequency index of each of the non-stop words in the corpus is calculated.
[0017] In one embodiment, obtaining the minimum inverse text frequency index mean of the corpus includes:
[0018] Extracting target text corpus from the corpus according to a set ratio;
[0019] Obtaining the number of the non-stop words in the corpus input of each of the target text corpora and the inverse text frequency index corresponding to the non-stop words, and calculating the mean value of the inverse text frequency index of each of the target text corpora;
[0020] Constructing a fitting function according to the mean of the inverse text frequency index of each of the target text corpora and the number of the non-stop words in the corpus input of the target text corpora;
[0021] The fitting function is used to fit the inverse text frequency index mean of each target text corpus and the number of non-stop words in the corpus input of the target text corpus to determine the minimum inverse text frequency index mean of the corpus.
[0022] In one embodiment, the calculating, based on the inverse text frequency index, the mean inverse text frequency index of the non-stop words in the corpus input in each text corpus comprises:
[0023] Obtaining the number of non-stop words in the corpus input of each text corpus and the inverse text frequency index corresponding to the non-stop words;
[0024] According to the number of non-stop words in the corpus input and the inverse text frequency index corresponding to each of the non-stop words, the mean inverse text frequency index of the corpus input of each of the text corpora is calculated.
[0025] In one embodiment, comparing the inverse text frequency index mean with the minimum inverse text frequency index mean to obtain a comparison result, and determining whether the text corpus is fine-tuning data for a large language model according to the comparison result includes:
[0026] If the inverse text frequency index mean of the text corpus is greater than or equal to the minimum inverse text frequency index mean, then the text corpus is fine-tuning data for the large language model;
[0027] If the inverse text frequency index mean of the text corpus is less than the minimum inverse text frequency index mean, the text corpus is not fine-tuning data for the large language model.
[0028] In one embodiment, the method further comprises:
[0029] Determining the fine-tuning data ratio of the corpus according to the comparison result;
[0030] Obtaining a fine-tuning ratio threshold of the corpus;
[0031] If the fine-tuning data ratio is less than the fine-tuning ratio threshold, the fitting function is adjusted to adjust the minimum inverse text frequency index mean of the corpus, and the comparison result of the inverse text frequency index mean and the minimum inverse text frequency index mean is re-obtained until the fine-tuning data ratio is greater than or equal to the fine-tuning ratio threshold.
[0032] In one embodiment, obtaining original text data and constructing a corpus of the original text data includes:
[0033] Obtaining original text data, and converting the original text data into markdown format data;
[0034] The markdown format data is parsed to obtain a plurality of initial text corpora, and the initial text corpora are cleaned to construct a corpus of the original text data.
[0035] In a second aspect, the present application also provides a system for extracting fine-tuning data of a large language model, the system comprising:
[0036] A text parsing module, used to obtain original text data and construct a corpus of the original text data; the corpus includes multiple text corpora; the text corpora uses the minimum title of the original text data as corpus input and uses the text data corresponding to the minimum title as corpus output;
[0037] A frequency index calculation module, used for dividing the corpus input of each of the text corpora into non-stop words based on the corpus, and calculating the inverse text frequency index of each of the non-stop words in the corpus;
[0038] A numerical fitting module, used for obtaining the minimum inverse text frequency index mean of the corpus;
[0039] An index mean calculation module, used for calculating the mean of the inverse text frequency index of the non-stop words in the corpus input in each text corpus based on the inverse text frequency index;
[0040] The index mean filtering module is used to compare the inverse text frequency index mean with the minimum inverse text frequency index mean to obtain a comparison result, and determine whether the text corpus is fine-tuning data of a large language model based on the comparison result.
[0041] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the content of the above-mentioned first aspect when executing the computer program.
[0042] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the content of the above-mentioned first aspect when executed by a processor.
[0043] The above-mentioned method, system and computer device for extracting fine-tuning data for a large language model, by acquiring original text data, constructing a corpus of the original text data; the corpus includes multiple text corpora; the text corpus uses the minimum title of the original text data as corpus input and uses the text data corresponding to the minimum title as corpus output; based on the corpus, the corpus input of each of the text corpora is divided into non-stop words, and the inverse text frequency index of each non-stop word in the corpus is calculated; the minimum inverse text frequency index mean of the corpus is obtained; based on the inverse text frequency index, the inverse text frequency index mean of the non-stop words of the corpus input in each text corpus is calculated; the inverse text frequency index mean is compared with the minimum inverse text frequency index mean to obtain a comparison result, and according to the comparison result, it is determined whether the text corpus is the fine-tuning data of the large language model, thereby realizing the extraction of high-quality fine-tuning data for the large language model and improving the extraction efficiency of fine-tuning data. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0045] Figure 1 A diagram of an application environment of a method for extracting fine-tuning data for a large language model in one embodiment;
[0046] Figure 2 A schematic diagram of a flow chart of a method for extracting fine-tuning data for a large language model in one embodiment;
[0047] Figure 3 is a flow chart of step 202 in one embodiment;
[0048] Figure 4 is a flow chart of step 203 in one embodiment;
[0049] Figure 5 is a flow chart of step 204 in one embodiment;
[0050] Figure 6 is a schematic diagram of a flow chart after step 205 in one embodiment;
[0051] Figure 7A structural block diagram of a system for extracting large language model fine-tuning data in one embodiment;
[0052] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0054] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantity limitation, and may indicate the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0055] The method for extracting fine-tuning data of a large language model provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system 106 can store data that the server 104 needs to process. The data storage system 106 can be integrated on the server 104, or placed on the cloud or other network servers.
[0056] On terminal 102, original text data is obtained, and a corpus of the original text data is constructed; the corpus includes multiple text corpora; the text corpus uses the minimum title of the original text data as corpus input and uses the text data corresponding to the minimum title as corpus output; based on the corpus, the corpus input of each of the text corpora is divided into non-stop words, and the inverse text frequency index of each of the non-stop words in the corpus is calculated; the minimum inverse text frequency index mean of the corpus is obtained; based on the inverse text frequency index, the inverse text frequency index mean of the non-stop words of the corpus input in each text corpus is calculated; the inverse text frequency index mean is compared with the minimum inverse text frequency index mean to obtain a comparison result, and according to the comparison result, it is determined whether the text corpus is fine-tuning data for a large language model.
[0057] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, etc. The server 104 may be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0058] In an exemplary embodiment, Figure 2 As shown, a method for extracting fine-tuning data for a large language model is provided, and the method is applied to Figure 1 The terminal in is taken as an example to illustrate, including the following steps 201 to 205.
[0059] Step 201, obtain original text data and construct a corpus of the original text data. The corpus includes multiple text corpora, which use the minimum title of the original text data as corpus input and the text data corresponding to the minimum title as corpus output.
[0060] Specifically, the original text data is obtained. Since there is a hierarchical progressive relationship between the titles of the original text data, the original text data is converted into markdown format data. The markdown format data is parsed, the data is segmented according to the lowest level text block, the smallest title of the original text data is used as the corpus input of the text corpus, and the text data corresponding to the smallest title is used as the corpus output of the text corpus, so as to obtain multiple initial text corpora of the original text data. The initial corpus is in json data format. The initial text corpus is subjected to data cleaning operations such as perplexity screening, table and formula filtering, and title sequence number filtering to obtain the cleaned text corpus, so as to prevent some special texts from affecting the subsequent calculation of the inverse text frequency index. The cleaned text corpus is statistically analyzed to obtain the corpus of the original text data.
[0061] Step 202: Based on the corpus, the corpus input of each of the text corpora is divided into non-stop words, and the inverse text frequency index of each of the non-stop words in the corpus is calculated.
[0062] Specifically, the corpus input of each text corpus is divided into non-stop words to obtain the number of non-stop words in the corpus, and each non-stop word is traversed through each text corpus in the corpus to calculate its inverse text frequency index in the corpus.
[0063] Step 203: Obtain the minimum inverse text frequency index mean of the corpus.
[0064] Step 204: Based on the inverse text frequency index, calculate the average inverse text frequency index of the non-stop words in the corpus input in each text corpus.
[0065] Specifically, there is at least one non-stop word in the corpus input of each text corpus, and the mean of the inverse text frequency index of each text corpus is calculated according to the number of non-stop words in the corpus input of each text corpus and the inverse text frequency index corresponding to each non-stop word.
[0066] Step 205: compare the inverse text frequency index mean with the minimum inverse text frequency index mean to obtain a comparison result, and determine whether the text corpus is fine-tuning data for a large language model based on the comparison result.
[0067] In the above method for extracting fine-tuning data for a large language model, a corpus of the original text data is constructed by acquiring original text data; the corpus includes multiple text corpora; the text corpus uses the minimum title of the original text data as corpus input and the text data corresponding to the minimum title as corpus output; based on the corpus, the corpus input of each of the text corpora is divided into non-stop words, and the inverse text frequency index of each of the non-stop words in the corpus is calculated; the minimum inverse text frequency index mean of the corpus is obtained; based on the inverse text frequency index, the inverse text frequency index mean of the non-stop words of the corpus input in each text corpus is calculated; the inverse text frequency index mean is compared with the minimum inverse text frequency index mean to obtain a comparison result, and according to the comparison result, it is determined whether the text corpus is the fine-tuning data of the large language model, thereby realizing the extraction of high-quality fine-tuning data for the large language model and improving the extraction efficiency of fine-tuning data.
[0068] In one embodiment, Figure 3 As shown, step 202 divides the corpus input of each of the text corpora into non-stop words based on the corpus, and calculates the inverse text frequency index of each of the non-stop words in the corpus, specifically including the following steps 301 to 303.
[0069] Step 301, constructing a stop word dataset of the corpus.
[0070] Step 302: based on the stop word data set, traverse each corpus input of the text corpus to perform a word segmentation operation to obtain a word segmentation result, and extract non-stop words of each corpus input according to the word segmentation result.
[0071] Step 303: Calculate the inverse text frequency index of each of the non-stop words in the corpus.
[0072] Specifically, a stop word data set of the corpus is constructed as needed, and the stop word data set includes words that do not carry meanings, such as prepositions. According to the stop word data set, the corpus input of each text corpus is segmented to obtain the segmentation result of the corpus input, and the non-stop words of each text corpus are extracted from the segmentation result. Each non-stop word is traversed through each text corpus of the corpus to calculate its inverse text frequency index in the corpus.
[0073] Among them, the calculation method of the inverse text frequency index is:
[0074] Log a (m / n);
[0075] a can be adjusted according to the size of the corpus, such as 2, e, 10, etc.; m represents the number of all text items in the corpus; n represents the number of text items containing the current non-stop words.
[0076] In this embodiment, by constructing a stop word dataset, efficient extraction of non-stop words is achieved without the need for manual vocabulary segmentation based on target vocabulary. This can be widely applied to various types of original text corpora, thereby improving the breadth of data extraction for fine-tuning of large language models.
[0077] In one embodiment, Figure 4 As shown, step 203 obtains the minimum inverse text frequency index mean of the corpus, which specifically includes the following steps 401 to 404.
[0078] Step 401: extract target text corpus from the corpus according to a set ratio.
[0079] Specifically, according to a set ratio, high-quality text corpora are selected from the corpus as target text corpora. For example, in a corpus with a data size of 50,000, 100 high-quality text corpora are selected as target text corpora.
[0080] Step 402: Obtain the number of the non-stop words in the corpus input of each target text corpus and the inverse text frequency index corresponding to the non-stop words, and calculate the average value of the inverse text frequency index of each target text corpus.
[0081] Specifically, for each target text corpus, determine the number of non-stop words in its corpus input and the inverse text frequency index corresponding to each non-stop word, and calculate the mean inverse text frequency index of each target text corpus. Among them, the quality of the target text corpus is proportional to the mean inverse text frequency index. Exemplarily, the corpus input of the target text corpus includes 3 non-stop words, and the inverse text frequency index corresponding to each non-stop word is 2.1, 6.7, and 3.5, respectively. Then the mean inverse text frequency index of the target text corpus is (2.1+6.7+3.5) / 3=4.1.
[0082] Step 403: construct a fitting function according to the mean value of the inverse text frequency index of each target text corpus and the number of non-stop words in the corpus input of the target text corpus.
[0083] Specifically, the relationship between the mean of the inverse text frequency index and the number of non-stop words in each target text corpus is integrated to construct a fitting function.
[0084] Step 404: Using the fitting function, fit the inverse text frequency index mean of each target text corpus and the number of non-stop words in the corpus input of the target text corpus to determine the minimum inverse text frequency index mean of the corpus.
[0085] In this embodiment, by extracting high-quality target text corpus and constructing a corresponding fitting function, the minimum inverse text frequency index mean of the corpus is determined, thereby improving the screening accuracy of subsequent fine-tuning data.
[0086] In one embodiment, Figure 5 As shown, step 204 calculates the mean value of the inverse text frequency index of the non-stop words in the corpus input in each text corpus based on the inverse text frequency index, specifically including the following steps 501 to 502.
[0087] Step 501: Obtain the number of non-stop words in the corpus input of each text corpus and the inverse text frequency index corresponding to the non-stop words.
[0088] Step 502: Calculate the mean value of the inverse text frequency index of each text corpus input according to the number of non-stop words in the corpus input and the inverse text frequency index corresponding to each non-stop word.
[0089] Specifically, according to the inverse text frequency index of each non-stop word, the inverse text frequency index mean is calculated for each text corpus in the corpus.
[0090] In one embodiment, step 205 compares the inverse text frequency index mean with the minimum inverse text frequency index mean to obtain a comparison result, and determines whether the text corpus is fine-tuning data of a large language model according to the comparison result, specifically including the following contents:
[0091] If the mean inverse text frequency index of the text corpus is greater than or equal to the minimum mean inverse text frequency index, then the text corpus is the fine-tuning data of the large language model; if the mean inverse text frequency index of the text corpus is less than the minimum mean inverse text frequency index, then the text corpus is not the fine-tuning data of the large language model.
[0092] In this embodiment, the fine-tuning data of the large language model is screened and determined based on the comparison result of the inverse text frequency index mean of each text corpus and the minimum inverse text frequency index mean, thereby improving the accuracy of the screening result.
[0093] In one embodiment, Figure 6 As shown, after step 205 determines whether the text corpus is fine-tuning data for a large language model, the method further includes the following steps 601 to 603.
[0094] Step 601: Determine the fine-tuning data ratio of the corpus according to the comparison result.
[0095] Step 602: Obtain a fine-tuning ratio threshold of the corpus.
[0096] The fine-tuning ratio threshold may be set based on the quantity and quality of fine-tuning data required for the large language model.
[0097] Step 603: If the fine-tuning data ratio is less than the fine-tuning ratio threshold, adjust the fitting function to adjust the minimum inverse text frequency index mean of the corpus, and re-obtain the comparison result between the inverse text frequency index mean and the minimum inverse text frequency index mean until the fine-tuning data ratio is greater than or equal to the fine-tuning ratio threshold.
[0098] Specifically, the comparison results of all text corpora in the comprehensive corpus are used to calculate the proportion of fine-tuning data in the corpus. If the proportion of fine-tuning data is less than the set fine-tuning proportion threshold or the quality of the obtained fine-tuning data does not meet expectations, the fitting function is replaced or the parameters of the fitting function are adjusted to reduce the minimum inverse text frequency index mean of the corpus. The comparison result of the inverse text frequency index mean and the minimum inverse text frequency index mean is re-obtained until the proportion of fine-tuning data is greater than or equal to the fine-tuning proportion threshold.
[0099] Optionally, if the fine-tuning data ratio is less than a set fine-tuning ratio threshold, the selection quality of the target text corpus can be adjusted as needed. By reducing the quality of the target text corpus and reducing the minimum inverse text frequency index mean of the corpus, the fine-tuning data ratio of the corpus is made greater than or equal to the fine-tuning ratio threshold.
[0100] It should be noted that when the fine-tuning data ratio is greater than or equal to the fine-tuning ratio threshold, the fine-tuning data ratio of the corpus can be made less than the fine-tuning ratio threshold by replacing the fitting function or adjusting the parameters of the fitting function or improving the quality of the target text corpus according to the needs of the large language model, thereby improving the minimum inverse text frequency index mean.
[0101] In this embodiment, the fine-tuning data proportion of the corpus is determined by comparing the mean inverse text frequency index of the text corpus with the minimum inverse text frequency index mean, and the fine-tuning data proportion is adjusted according to the actual needs of the large language model to improve the construction efficiency of the fine-tuning data and reduce the construction cost.
[0102] In a preferred embodiment, a method for extracting large language model fine-tuning data from book files is provided, which specifically includes the following contents:
[0103] S1, converts original text data such as original books and papers into markdown format data.
[0104] S2, parse the markdown format data, segment the data according to the lowest level text block, use the smallest title of the original text data as the corpus input instruction of the text corpus, and the text data corresponding to the smallest title as the corpus output output of the text corpus, and construct multiple initial json format text corpora of the original text data. Perform data cleaning operations such as perplexity screening, table and formula filtering, and title sequence number filtering on the initial json format text corpus to obtain the cleaned text corpus.
[0105] S3, statistics are performed on the cleaned text corpus to obtain the corpus of the original text data. The word segmentation tool corresponding to the language of the text corpus is selected, and a stop word data set of the corpus is constructed. Based on the stop word data set, the corpus input instruction of each text corpus is traversed to perform word segmentation operations, and non-stop words of each corpus input are extracted. Each non-stop word is traversed through each text corpus in the corpus, and its inverse document frequency index IDF (Inverse Document Frequency) in the corpus is calculated.
[0106] S4, according to the set ratio, select high-quality text corpora from the corpus as target text corpora. According to the number of non-stop words in the corpus input of each target text corpus and the inverse text frequency index IDF corresponding to each non-stop word, calculate the mean inverse text frequency index of each target text corpus. A mathematical model is pre-assumed, such as a linear piecewise function as a fitting function. Using the fitting function, fit the mean inverse text frequency index of each target text corpus and the number of non-stop words in the corpus input instruction of the target text corpus, and calculate the minimum inverse text frequency index mean of the current corpus.
[0107] S5, write a filter, and use the filter to calculate the mean inverse text frequency index of the corpus input of each text corpus according to the number of non-stop words in the corpus input instruction of each text corpus and the inverse text frequency index IDF corresponding to each non-stop word. Compare the mean inverse text frequency index of each text corpus with the minimum mean inverse text frequency index. If the mean inverse text frequency index of the text corpus is greater than the minimum mean inverse text frequency index, the text corpus is retained as the fine-tuning data of the large language model, otherwise it is discarded.
[0108] S6, when all text corpora in the corpus are filtered by the filter, determine the proportion of fine-tuning data in the corpus. According to the proportion of fine-tuning data, check whether the scale and quality of the fine-tuning data meet expectations. If not, adjust the fitting function, modify the minimum inverse text frequency index mean, and repeat step S5 until the filtering result meets expectations.
[0109] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0110] Based on the same inventive concept, the embodiment of the present application also provides a system for extracting large language model fine-tuning data for implementing the method for extracting large language model fine-tuning data involved above. The implementation solution provided by the system to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more system embodiments for extracting large language model fine-tuning data provided below can refer to the limitations of the method for extracting large language model fine-tuning data above, and will not be repeated here.
[0111] In an exemplary embodiment, Figure 7 As shown, a system for extracting fine-tuning data of a large language model is provided, including: a text parsing module 701, a frequency index calculation module 702, a numerical fitting module 703, an index mean calculation module 704 and an index mean filtering module 705, wherein:
[0112] The text parsing module 701 is used to obtain original text data and construct a corpus of the original text data; the corpus includes multiple text corpora; the text corpora uses the minimum title of the original text data as corpus input and the text data corresponding to the minimum title as corpus output.
[0113] The frequency index calculation module 702 is used to divide the corpus input of each of the text corpora into non-stop words based on the corpus, and calculate the inverse text frequency index of each of the non-stop words in the corpus.
[0114] The numerical fitting module 703 is used to obtain the minimum inverse text frequency index mean of the corpus.
[0115] The index mean calculation module 704 is used to calculate the mean of the inverse text frequency index of the non-stop words in the corpus input in each text corpus based on the inverse text frequency index.
[0116] The index mean filtering module 705 is used to compare the inverse text frequency index mean with the minimum inverse text frequency index mean to obtain a comparison result, and determine whether the text corpus is fine-tuning data of a large language model based on the comparison result.
[0117] In one embodiment, the frequency index calculation module 702 is also used to: construct a stop word data set of the corpus; based on the stop word data set, traverse each corpus input of the text corpus to perform a word segmentation operation to obtain a word segmentation result, and extract non-stop words of each corpus input according to the word segmentation result; calculate the inverse text frequency index of each non-stop word in the corpus.
[0118] In one embodiment, the numerical fitting module 703 is also used to: extract target text corpora from the corpus according to a set ratio; obtain the number of non-stop words in the corpus input of each target text corpus and the inverse text frequency index corresponding to the non-stop words, and calculate the mean of the inverse text frequency index of each target text corpus; construct a fitting function based on the mean of the inverse text frequency index of each target text corpus and the number of non-stop words in the corpus input of the target text corpus; use the fitting function to fit the mean of the inverse text frequency index of each target text corpus and the number of non-stop words in the corpus input of the target text corpus, and determine the minimum mean of the inverse text frequency index of the corpus.
[0119] In one embodiment, the index mean calculation module 704 is also used to: obtain the number of non-stop words in the corpus input of each text corpus and the inverse text frequency index corresponding to the non-stop words; calculate the inverse text frequency index mean of the corpus input of each text corpus based on the number of non-stop words in the corpus input and the inverse text frequency index corresponding to each of the non-stop words.
[0120] In one embodiment, the index mean filtering module 705 is also used for: if the inverse text frequency index mean of the text corpus is greater than or equal to the minimum inverse text frequency index mean, then the text corpus is the fine-tuning data of the large language model; if the inverse text frequency index mean of the text corpus is less than the minimum inverse text frequency index mean, then the text corpus is not the fine-tuning data of the large language model.
[0121] In one of the embodiments, the index mean filtering module 705 is also used to: determine the fine-tuning data ratio of the corpus based on the comparison result; obtain the fine-tuning ratio threshold of the corpus; if the fine-tuning data ratio is less than the fine-tuning ratio threshold, adjust the fitting function to adjust the minimum inverse text frequency index mean of the corpus, and re-obtain the comparison result of the inverse text frequency index mean and the minimum inverse text frequency index mean until the fine-tuning data ratio is greater than or equal to the fine-tuning ratio threshold.
[0122] In one of the embodiments, the text parsing module 701 is also used to: obtain original text data and convert the original text data into markdown format data; parse the markdown format data to obtain multiple initial text corpora, and clean the initial text corpora to construct a corpus of the original text data.
[0123] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 8As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (Near Field Communication, NFC) or other technologies. When the computer program is executed by the processor, a method for extracting fine-tuning data of a large language model is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0124] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0125] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps corresponding to the methods described in the above embodiments are implemented.
[0126] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps corresponding to the methods described in the above embodiments are implemented.
[0127] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0128] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0129] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for extracting fine-tuning data for a large language model, characterized in that: The method comprises: Acquire original text data and construct a corpus of the original text data; the corpus includes multiple text corpora; the text corpora uses the minimum title of the original text data as corpus input and uses the text data corresponding to the minimum title as corpus output; Based on the corpus, the corpus input of each of the text corpora is divided into non-stop words, and the inverse text frequency index of each of the non-stop words in the corpus is calculated; Extract target text corpora from the corpus according to a set ratio; obtain the number of non-stop words in the corpus input of each target text corpus and the inverse text frequency index corresponding to the non-stop words, and calculate the mean of the inverse text frequency index of each target text corpus; construct a fitting function based on the mean of the inverse text frequency index of each target text corpus and the number of non-stop words in the corpus input of the target text corpus; use the fitting function to fit the mean of the inverse text frequency index of each target text corpus and the number of non-stop words in the corpus input of the target text corpus, and determine the minimum mean of the inverse text frequency index of the corpus; Based on the inverse text frequency index, calculating the mean inverse text frequency index of the non-stop words in the corpus input in each text corpus; The inverse text frequency index mean is compared with the minimum inverse text frequency index mean to obtain a comparison result, and according to the comparison result, it is determined whether the text corpus is fine-tuning data of a large language model.
2. The method for extracting fine-tuning data of a large language model according to claim 1, characterized in that: The step of dividing the corpus input of each of the text corpora into non-stop words based on the corpus, and calculating the inverse text frequency index of each of the non-stop words in the corpus includes: Constructing a stop word dataset of the corpus; Based on the stop word data set, traverse each corpus input of the text corpus to perform a word segmentation operation to obtain a word segmentation result, and extract non-stop words of each corpus input according to the word segmentation result; The inverse text frequency index of each of the non-stop words in the corpus is calculated.
3. The method for extracting large language model fine-tuning data according to claim 1, characterized in that: The step of calculating the inverse text frequency index mean of the non-stop words in the corpus input in each text corpus based on the inverse text frequency index comprises: Obtaining the number of non-stop words in the corpus input of each text corpus and the inverse text frequency index corresponding to the non-stop words; According to the number of non-stop words in the corpus input and the inverse text frequency index corresponding to each of the non-stop words, the mean inverse text frequency index of the corpus input of each of the text corpora is calculated.
4. The method for extracting large language model fine-tuning data according to claim 1, characterized in that: The comparing the inverse text frequency index mean with the minimum inverse text frequency index mean to obtain a comparison result, and determining whether the text corpus is fine-tuning data for a large language model according to the comparison result comprises: If the inverse text frequency index mean of the text corpus is greater than or equal to the minimum inverse text frequency index mean, then the text corpus is fine-tuning data for the large language model; If the inverse text frequency index mean of the text corpus is less than the minimum inverse text frequency index mean, the text corpus is not fine-tuning data for the large language model.
5. The method for extracting fine-tuning data of a large language model according to claim 4, characterized in that: The method further comprises: Determining the fine-tuning data ratio of the corpus according to the comparison result; Obtaining a fine-tuning ratio threshold of the corpus; If the fine-tuning data ratio is less than the fine-tuning ratio threshold, the fitting function is adjusted to adjust the minimum inverse text frequency index mean of the corpus, and the comparison result of the inverse text frequency index mean and the minimum inverse text frequency index mean is re-obtained until the fine-tuning data ratio is greater than or equal to the fine-tuning ratio threshold.
6. The method for extracting large language model fine-tuning data according to claim 1, characterized in that: The obtaining of original text data and constructing a corpus of the original text data includes: Obtaining original text data, and converting the original text data into markdown format data; The markdown format data is parsed to obtain a plurality of initial text corpora, and the initial text corpora are cleaned to construct a corpus of the original text data.
7. A system for extracting fine-tuning data for a large language model, characterized in that: The system comprises: A text parsing module, used to obtain original text data and construct a corpus of the original text data; the corpus includes multiple text corpora; the text corpora uses the minimum title of the original text data as corpus input and uses the text data corresponding to the minimum title as corpus output; A frequency index calculation module, used for dividing the corpus input of each of the text corpora into non-stop words based on the corpus, and calculating the inverse text frequency index of each of the non-stop words in the corpus; A numerical fitting module is used to extract target text corpora from the corpus according to a set ratio; obtain the number of non-stop words in the corpus input of each target text corpus and the inverse text frequency index corresponding to the non-stop words, and calculate the mean of the inverse text frequency index of each target text corpus; construct a fitting function according to the mean of the inverse text frequency index of each target text corpus and the number of non-stop words in the corpus input of the target text corpus; use the fitting function to fit the mean of the inverse text frequency index of each target text corpus and the number of non-stop words in the corpus input of the target text corpus, and determine the minimum mean of the inverse text frequency index of the corpus; An index mean calculation module, used for calculating the mean of the inverse text frequency index of the non-stop words in the corpus input in each text corpus based on the inverse text frequency index; The index mean filtering module is used to compare the inverse text frequency index mean with the minimum inverse text frequency index mean to obtain a comparison result, and determine whether the text corpus is fine-tuning data of a large language model based on the comparison result.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
