A sample selection method, device, terminal device and medium
Sample selection in large language models is solved by Shapley approximation calculation method, which has not fully considered the example interaction in the prior art, improves model performance and reduces the computational workload.
Patent Information
- Application Number
- CN202411063230.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-08-05
AI Technical Summary
When prior art performs sample selection for large language models, the potential impact of interactions between examples on model effects is not fully considered, resulting in poor performance of large language models.
Sample selection is performed using Shapley approximation calculation method. Considering the potential impact of interactions between examples on model effects, the preferred samples are selected through clustering analysis and Shapley value calculation.
Improve the performance of the large language model, allowing it to better guide the model to respond correctly to prompts, while reducing the workload of Shapley's calculations and improving computing efficiency.
Smart Images

Figure CN118981648B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of large model technology, and in particular to a sample optimization method, device, terminal equipment and medium. Background Art
[0002] With the continuous development of large language models, large language models represented by ChatGPT and GPT-4 have attracted widespread attention worldwide. These large language models can support humans to express tasks and requirements in the form of natural language, and can efficiently understand the input text instructions (prompts) and generate text outputs that meet the requirements. Large language models have the ability to learn in context, and do not need to adjust model parameters. They can master the solution strategy of new tasks by analyzing a small number of examples. For example, by providing a series of problem examples and their corresponding expected results before testing the problem, prompts can be constructed to guide the model to respond correctly. Therefore, the number and type of examples in the prompt have a significant impact on the model performance.
[0003] At present, when example samples are prioritized for a large language model, usually only the individual similarity between each example and the problem to be solved is considered for selection, and the potential impact of the interaction between examples on the model effect is not involved, resulting in poor performance of the large language model. Therefore, the present invention proposes a sample optimization method, apparatus, terminal device and medium, which use Shapley approximate calculation for sample optimization, consider the potential impact of the interaction between examples on the model effect, so that the optimized samples can better guide the prompts of the model to respond correctly, improve the performance of the large language model, and at the same time can reduce Shapley calculation and improve Shapley calculation efficiency. Summary of the invention
[0004] The object of the present invention is to provide a sample optimization method, apparatus, terminal device and medium to solve the problems raised in the above background technology.
[0005] To achieve the above object, the present invention provides the following technical solution: a sample optimization method, comprising:
[0006] Determine the target model and obtain training data based on the target model;
[0007] The training data is standardized according to the large language model to obtain standardized training data;
[0008] Perform vectorization processing on the standardized training data to obtain training data vector information;
[0009] Performing cluster analysis on the training samples based on the training data vector information, and selecting category representatives according to the cluster analysis results to obtain initial sample samples and determine the initial sample sample set;
[0010] Perform Shapley approximation calculation on the initial sample set to obtain the Shapley approximation value of the initial sample;
[0011] Further screening is performed according to the Shapley approximation of the initial sample to obtain the preferred sample.
[0012] Preferably, the training data includes: basic data information, historical data information and result data information. When the training data is standardized according to the large language model, the training data is standardized based on a standardized template, wherein the standardized template includes: a first conversion template, a second conversion template and a third conversion template. When the first conversion template is used to standardize the basic information, feature extraction is performed on the basic data information to obtain basic feature information, and the basic feature information is listed and arranged in a fixed sequence to obtain a basic feature information sequence; when the second conversion template is used to standardize the historical data information, the historical data information is converted into a natural text description by enumeration; when the third conversion template is used to standardize the result data information, binarization is performed on the result data information to obtain a standardized value of the result data information.
[0013] Preferably, when performing vectorization processing on the standardized training data, a text vectorization model is used to perform vectorization processing on the standardized training data in sequence according to samples, and the standardized training data is converted into a vector form to obtain training data vector information, wherein the text vectorization model performs model learning training before performing vectorization processing on each example in the initial example set.
[0014] Preferably, cluster analysis is performed on the training samples based on the training data vector information, including:
[0015] Determine clustering features for training samples and analyze the distribution of training samples based on training data vector information;
[0016] Determine the number of cluster categories;
[0017] Determine the initial cluster center based on the number of cluster categories combined with the training data vector information;
[0018] Cluster analysis and initial cluster center optimization are performed according to the training data vector information to obtain cluster analysis results.
[0019] Preferably, when selecting category representatives according to the cluster analysis results, the size of the initial example sample set is determined, and the relationship between the size of the initial example sample set and the number of cluster categories in the cluster analysis results is analyzed. When the size of the initial example sample set is equal to the number of cluster categories in the cluster analysis results, a category representative is selected from each cluster according to the cluster analysis results. When the size of the initial example sample set is greater than the number of cluster categories in the cluster analysis results, the size of the initial example sample set is divided into a first value and a second value according to a division rule, a category representative is selected from each cluster according to the first value, and then the size of the cluster category in the cluster analysis results is analyzed, and the cluster category is screened according to the size to obtain a cluster category screening result, and a category representative is selected from each cluster category of the cluster category screening result according to the second value in the cluster category screening result;
[0020] When selecting category representatives according to the cluster analysis results, a target number of training samples are also selected from the cluster analysis results as a verification example sample set.
[0021] Preferably, performing Shapley approximation calculation on the initial sample set includes:
[0022] Determine the cutoff threshold;
[0023] Initialize the Shapley value of each initial example sample;
[0024] Taking each initial example sample as a research object in turn, performing full permutation on the remaining initial example samples in the initial example sample set to obtain an analysis sequence of the research object;
[0025] Traverse the analysis sequence of the research object to analyze the sequence sub-elements, and judge the analysis results in combination with the cutoff threshold to obtain the result accuracy of the sequence sub-elements;
[0026] The Shapley value is calculated according to the result accuracy of the sequence sub-elements to obtain the Shapley approximation of the research object.
[0027] Preferably, further screening is performed according to the Shapley approximation of the initial sample, including:
[0028] Arrange the Shapley approximation values of the initial sample according to size to obtain the sequence to be screened;
[0029] Determine the target number of optimal samples;
[0030] Screen the sequence to be screened in order according to the preferred sample target number to obtain target sub-data;
[0031] The training data is traced back according to the target sub-data to obtain the preferred samples.
[0032] A sample optimization device comprises: a data acquisition module, a first processing module, a second processing module, a cluster analysis module, an analysis and calculation module and a sample screening module;
[0033] The data acquisition module is used to determine the target model and acquire training data according to the target model;
[0034] The first processing module is used to perform standardization processing on the training data according to the large language model to obtain standardized training data;
[0035] The second processing module is used to perform vectorization processing on the standardized training data to obtain training data vector information;
[0036] The cluster analysis module is used to perform cluster analysis on the training samples based on the training data vector information, and select category representatives according to the cluster analysis results to obtain initial sample samples and determine the initial sample sample set;
[0037] The analysis and calculation module is used to perform Shapley approximation calculation on the initial sample set to obtain the Shapley approximation value of the initial sample;
[0038] The sample screening module is used to further screen the initial sample according to the Shapley approximation to obtain the preferred sample.
[0039] The present invention adopts Shapley calculation to realize sample selection of target model, so that when determining sample samples of large language model, mutual influence between different sample examples is fully considered, and Shapley value is used to realize quantitative analysis of sample examples, so that better sample examples can be screened out according to more intuitive data, so that when the large language model reorganizes prompt language for the result of target model, it can better guide the model to correctly respond to prompts based on sample examples, thereby improving the performance of large language model, and adopts Shapley approximate calculation, so that when the initial sample set is large, the calculation workload can be effectively reduced within the allowable error range, thereby improving the efficiency of Shapley approximate calculation.
[0040] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0041] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0043] Figure 1 A schematic diagram of the steps of the sample optimization method of the present invention;
[0044] Figure 2 This is a schematic diagram of step 4 in the sample optimization method of the present invention;
[0045] Figure 3 This is a partial processing flow diagram of step 4 in the sample optimization method of the present invention;
[0046] Figure 4 This is a schematic diagram of step 5 in the sample optimization method of the present invention;
[0047] Figure 5 This is a schematic diagram of step six in the sample optimization method of the present invention;
[0048] Figure 6 It is a schematic diagram of the sample optimization device described in the present invention. DETAILED DESCRIPTION
[0049] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0050] like Figure 1 As shown, an embodiment of the present invention provides a sample optimization method, including:
[0051] Step 1: Determine the learning model and obtain training data based on the learning model;
[0052] Step 2: Standardize the training data according to the large language model to obtain standardized training data;
[0053] Step 3: Perform vectorization processing on the standardized training data to obtain training data vector information;
[0054] Step 4: Perform cluster analysis on the training samples based on the training data vector information, and select category representatives according to the cluster analysis results to obtain initial sample samples and determine the initial sample set;
[0055] Step 5: Perform Shapley approximation calculation on the initial sample set to obtain the Shapley approximation value of the initial sample;
[0056] Step 6: Further screen according to the Shapley approximation of the initial sample to obtain the preferred sample.
[0057] In the above technical solution, the target model is a machine model that obtains results based on the response information of the large language model.
[0058] In the above technical solution, the training data is data information that the large language model and the machine model jointly process and respond to request training information. When obtaining the training data, the training data is obtained based on the large language model and the target model.
[0059] In the above technical solution, the training data is structured information. When the training data is standardized according to the large language model, the training data is converted into a natural language text form that can be understood by the large language model.
[0060] In the above technical solution, when the target model is a transaction risk prediction model, the large language model obtains transaction information and processes the transaction information. The transaction risk prediction model then predicts the processed transaction information to obtain a transaction information prediction result. The large language model then combines prompts for the transaction information prediction result to obtain a transaction information prediction result prompt, thereby providing feedback for the transaction information prediction result prompt.
[0061] The above technical solution adopts Shapley calculation to realize sample selection for the target model, so that when determining the sample of the large language model, the mutual influence between different sample examples is fully considered, and the Shapley value is used to realize the quantitative analysis of the sample examples, so that better sample examples can be screened out based on more intuitive data, and then the large language model can better guide the model to correctly respond to prompts based on the sample examples when reorganizing the prompt language for the result of the target model, thereby improving the performance of the large language model, and the Shapley approximate calculation is adopted, so that when the initial sample set is large, the calculation workload can be effectively reduced within the allowable error range, thereby improving the efficiency of the Shapley approximate calculation.
[0062] In an embodiment provided by the present invention, the training data includes: basic data information, historical data information and result data information. When the training data is standardized according to the large language model, the training data is standardized based on a standardized template, wherein the standardized template includes: a first conversion template, a second conversion template and a third conversion template. When the first conversion template is used to perform standardized processing on the basic information, feature extraction is performed on the basic data information to obtain basic feature information, and the basic feature information is listed and arranged according to a fixed sequence to obtain a basic feature information sequence; when the second conversion template is used to perform standardized processing on the historical data information, the historical data information is converted into a natural text description by enumeration; when the third conversion template is used to perform standardized processing on the result data information, binarization is performed according to the result data information to obtain a standardized value of the result data information.
[0063] In the above technical solution, the basic data information includes: account information and transaction dimension information, and the historical data information is based on the historical transaction information of the same account.
[0064] In the above technical solution, the first conversion template can be a form in which each feature is expressed in a column name and column value manner, and then all the features are separated by commas, such as: "Gender: Male, Age: 35 years old..." It can also be a form in which each feature is expressed in a more natural way, and then all the features are separated by commas, such as: "Gender is male, age is 35 years old..."
[0065] In the above technical solution, the historical data information is obtained by aggregating the account ID and integrating all the transaction information in the history of this account. When the second conversion template is used to perform standardized processing on the historical data information, the historical data information is converted into a natural text description by enumeration, for example: "1. At xx time, at xx place, xx merchant purchased xx, with a transaction amount of xx yuan; 2. At xx time, at xx place, xx merchant purchased xx, with a transaction amount of xx yuan; 3. At xx time, at xx place, xx merchant purchased xx, with a transaction amount of xx yuan;..."
[0066] In the above technical solution, when the result data information is binarized, when the result data information is a normal transaction, the standardized value of the result data information is 0, and when the result data information is an abnormal transaction, the standardized value of the result data information is 1.
[0067] The above technical solution converts the training data into a natural language text form that can be understood by the large language model by performing standardized processing on the training data according to the large language model, so that the large language model can better process and construct prompts, providing convenience for the large language model, and providing data analysis support for the target model through historical data information, so that it can be analyzed in combination with historical features, providing accuracy guarantee for the target model, and improving the accuracy of the target model.
[0068] In one embodiment provided by the present invention, when performing vectorization processing on standardized training data, a text vectorization model is used to perform vectorization processing on the standardized training data in sequence according to samples, and the standardized training data is converted into a vector form to obtain training data vector information, wherein the text vectorization model performs model learning training before performing vectorization processing on each example in the initial example set.
[0069] In the above technical solution, the text vectorization model includes: a vector conversion unit and a vector output unit, the vector conversion unit includes a plurality of conversion sub-units, each conversion sub-unit corresponds to a basic feature, and each conversion sub-unit establishes a neural network model based on the feature data information conversion rule. When the text vectorization model performs vectorization processing on the initial example, the vector conversion unit identifies and converts the feature data information on the standardized training data through the conversion sub-unit to obtain the feature data information sub-vector, and then the vector output unit combines the feature data information sub-vectors to obtain the training data vector information.
[0070] The above technical solution adopts the text vectorization model, which can not only realize batch processing of standardized training data, so that vector information can be quickly obtained for a large number of samples, but also ensure the standardization of the training data vector information, so that the standardized training data of each sample can be converted into vector form according to unified rules, ensuring the uniformity of the training data vector information and providing convenience for subsequent sample clustering.
[0071] like Figure 2 As shown, in one embodiment provided by the present invention, cluster analysis is performed on training samples based on training data vector information, including:
[0072] A1. Determine clustering features for training samples and analyze the distribution of training samples based on training data vector information;
[0073] A2. Determine the number of cluster categories;
[0074] A3. Determine the initial cluster center based on the number of cluster categories and the training data vector information;
[0075] A4. Perform cluster analysis and optimize the initial cluster center based on the training data vector information to obtain the cluster analysis results.
[0076] In the above technical solution, when determining the number of cluster categories, the number of cluster categories can be directly determined based on personal experience, or the optimal number of cluster categories can be determined after performing distance analysis on the distribution of training samples.
[0077] The above technical solution realizes feature analysis of training samples by performing cluster analysis on training samples, so that training samples with similar clustering features constitute a cluster category, so that the diversity of training samples can be taken into account when selecting example samples, avoiding the situation where the preferred sample has only a single feature, resulting in large errors in the prompts determined by the big data model.
[0078] like Figure 3 As shown, in one embodiment provided by the present invention, when selecting category representatives according to the cluster analysis results, the size of the initial example sample set is determined, and the relationship between the size of the initial example sample set and the number of cluster categories in the cluster analysis results is analyzed. When the size of the initial example sample set is equal to the number of cluster categories in the cluster analysis results, a category representative is selected from each cluster according to the cluster analysis results. When the size of the initial example sample set is greater than the number of cluster categories in the cluster analysis results, the size of the initial example sample set is divided into a first value and a second value according to a division rule, a category representative is selected from each cluster according to the first value, and then the size of the cluster category in the cluster analysis results is analyzed, and the cluster category is screened according to the size to obtain a cluster category screening result, and a category representative is selected from each cluster category in the cluster category screening result according to the second value in the cluster category screening result;
[0079] When selecting category representatives according to the cluster analysis results, a target number of training samples are also selected from the cluster analysis results as a verification example sample set.
[0080] In the above technical solution, the target number of the verification example sample set can be set according to demand.
[0081] In the above technical solution, the second value is smaller than the number of cluster categories in the cluster analysis result.
[0082] In the above technical solution, the first value is determined according to the relationship between the size of the initial example sample set and the number of cluster categories in the cluster analysis result, and can be 1, or 2, 3, 4, 5, ...
[0083] In the above technical scheme, when category representatives are selected from each cluster category of the cluster category filtering results according to the second value in the cluster category filtering results, when the second value is a multiple of the number of cluster categories in the cluster category filtering results, the same number of category representatives are selected from each cluster category of the cluster category filtering results, and when the second value is not a multiple of the number of cluster categories in the cluster category filtering results, the size proportion of each cluster category of the cluster category filtering results is analyzed, and the size proportion of each cluster category in the cluster category filtering results is divided according to the second value to obtain the cluster category proportion, and then category representatives are selected from each cluster category of the cluster category filtering results according to the cluster category proportion.
[0084] The above technical solution selects category representatives according to the results of cluster analysis so that the selected sample examples have obvious distinguishing features, thereby ensuring the comprehensiveness of the initial example sample set, so that the preferred samples can provide more comprehensive data information support for the large language model, reduce the error of the large language model, and enable the large language model to obtain more accurate prompts.
[0085] like Figure 4 As shown, in one embodiment provided by the present invention, Shapley approximation calculation is performed on an initial sample set, including:
[0086] B1. Determine the cutoff threshold;
[0087] B2, initialize the Shapley value of each initial example sample;
[0088] B3, taking each initial example sample as a research object in turn, performing full permutation on the remaining initial example samples in the initial example sample set to obtain an analysis sequence of the research object;
[0089] B4. Traverse the analysis sequence of the research object to analyze the sequence sub-elements, and judge the analysis results in combination with the cutoff threshold to obtain the result accuracy of the sequence sub-elements;
[0090] B5. Calculate the Shapley value based on the result accuracy of the sequence sub-elements to obtain the Shapley approximation of the research object.
[0091] In the above technical solution, the truncation threshold is pre-set. The smaller the truncation threshold is, the higher the accuracy of the Shapley approximation calculation is, and the higher the complexity of the calculation is.
[0092] In the above technical solution, when initializing the Shapley value of each initial example sample, the Shapley value of each initial example sample is set to 0.
[0093] In the above technical solution, when performing a full permutation on the remaining initial example samples in the initial example sample set, the research object in the initial example sample set is removed to determine the remaining initial example samples, and then a full permutation is performed on the remaining initial example samples. For example, if the example set is D = {T1, T2, T3}, when the research object is T1, the full permutation of the remaining examples is: T2, T3, T2T3, T3T2.
[0094] In the above technical solution, when traversing the analysis sequence of the research object for sequence sub-element analysis and making a judgment on the analysis result in combination with the truncation threshold, when the sequence sub-element is used as an example sample, the accuracy of the large language model for the validation example sample set is obtained, and the difference value of the accuracy of the large language model for the validation example sample set when different sequence sub-elements are used as example samples is analyzed. When the difference value is less than the truncation threshold, the accuracy of the large language model for the validation example sample set is approximately equal when the current sequence sub-element and the subsequent sequence sub-elements are used as example samples. Therefore, when calculating the Shapley value according to the result accuracy of the sequence sub-elements, the accuracy of the large language model for the validation example sample set when the sequence sub-elements are used as example samples is cumulatively summed to obtain the Shapley approximation value of the research object. The specific implementation process is as follows:
[0095] For t = 1 to tau
[0096] i. PI(t) is a full permutation of set P, calculate V(PI(t))
[0097] ii. For j = 1 to m
[0098] 1. If V(PI(t)[:,j]) - V(PI(t)) < epsilon, then V(PI(t)[:,j]) = V(PI(t)[:,j - 1])
[0099] 2. Otherwise calculate V(PI(t)[:,j])
[0100] iii. For i = 1 to n
[0101] 1. SV(i) += V(PI(t)[:,i]) - V(PI(t)[:,i - 1])
[0102] The above technical solution introduces Shapley value into the calculation of example value. Through the quantitative analysis of Shapley value, the interaction between each example can be comprehensively considered, and the average marginal contribution of all examples can be analyzed and evaluated, so as to select a better example combination. It can also make the selection of samples as examples more efficient and fair, so that the preferred samples are more compatible with the large language model, and thus the preferred samples can be better used as examples of the large language model, thereby improving the accuracy of the large language model. And when calculating the Shapley value, the truncation threshold is used for approximate calculation, which reduces the amount of calculation while ensuring the accuracy of the Shapley calculation, so that the Shapley calculation can be realized in a shorter time, improving the efficiency of the Shapley calculation.
[0103] like Figure 5 As shown, in one embodiment provided by the present invention, further screening according to the Shapley approximation of the initial example sample includes:
[0104] C1. Arrange the Shapley approximation values of the initial sample according to size to obtain the sequence to be screened;
[0105] C2. Determine the target number of preferred samples;
[0106] C3, screening the sequence to be screened in order according to the preferred sample target number to obtain target sub-data;
[0107] C4. Tracing the training data according to the target sub-data to obtain the preferred samples.
[0108] In the above technical solution, the preferred sample target number can be set and adjusted according to demand.
[0109] In the above technical solution, when the sequence to be screened is screened in order according to the preferred target number of samples, the selection is performed in order from large to small according to the Shapley approximation value.
[0110] In the above technical solution, the target sub-data is the Shapley approximation of the selected sample example.
[0111] The above technical solution arranges the Shapley approximation values of the initial example samples according to size so that the initial example samples have a more intuitive evaluation order, so that they can be directly screened in the sequence to be screened according to the target number of preferred samples, providing convenience for the screening of preferred samples, and selecting them in order from large to small according to the Shapley approximation values, so that the preferred samples have specific significant features, so that the preferred samples can better learn and train for the target model.
[0112] like Figure 6As shown, the present invention provides a sample optimization device, characterized in that it includes: a data acquisition module, a first processing module, a second processing module, a cluster analysis module, an analysis and calculation module and a sample screening module;
[0113] The data acquisition module is used to determine the target model and acquire training data according to the target model;
[0114] The first processing module is used to perform standardization processing on the training data according to the large language model to obtain standardized training data;
[0115] The second processing module is used to perform vectorization processing on the standardized training data to obtain training data vector information;
[0116] The cluster analysis module is used to perform cluster analysis on the training samples based on the training data vector information, and select category representatives according to the cluster analysis results to obtain initial sample samples and determine the initial sample sample set;
[0117] The analysis and calculation module is used to perform Shapley approximation calculation on the initial sample set to obtain the Shapley approximation value of the initial sample;
[0118] The sample screening module is used to further screen the initial sample according to the Shapley approximation to obtain the preferred sample.
[0119] In the above technical solution, the data acquisition module, the first processing module, the second processing module, the cluster analysis module, the analysis and calculation module and the sample screening module are connected in sequence.
[0120] The above technical scheme adopts Shapley calculation to realize sample selection of target model, so that when determining the sample sample of large language model, the mutual influence between different sample examples is fully considered, and the quantitative analysis of sample examples is realized by using Shapley value, so that better sample examples can be screened out according to more intuitive data, so that the large language model can better guide the model to correctly respond to prompts based on sample examples when the prompts are reorganized for the result of the target model, thereby improving the performance of the large language model, and adopts Shapley approximate calculation, so that when the initial sample set is large, the calculation workload can be effectively reduced within the error tolerance range, and the efficiency of Shapley approximate calculation is improved. The training data is converted into a natural language text form that can be understood by the large language model through the first processing module, so that the large language model can better process and construct prompts, providing convenience for the large language model, and the standardized training data can be converted into a vector form according to a unified rule through the second processing model, ensuring the uniformity of the training data vector information, and providing convenience for subsequent sample clustering. And the initial sample samples in the initial sample sample set have diversified characteristics through the cluster analysis module, so that the initial sample sample set is more comprehensive, thereby ensuring the comprehensiveness of the preferred sample. In addition, the analysis and calculation module uses Shapley approximation calculation, which can not only efficiently obtain the Shapley approximation of the sample example, but also fully consider the mutual influence between different sample examples, making the preferred sample more representative.
[0121] An embodiment of the present invention provides a terminal device, comprising: a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein when the processor executes the computer-readable instructions, the steps of any one of the preferred sample methods in each embodiment of the aforementioned preferred sample method are implemented.
[0122] An embodiment of the present invention provides a computer-readable storage medium, which stores computer-readable instructions. When the computer-readable instructions are executed by a processor, the steps of any one of the preferred sample methods in each embodiment of the aforementioned preferred sample method are implemented.
[0123] Those skilled in the art should understand that the first and second in the present invention merely refer to different application stages.
[0124] Other embodiments of the present disclosure will be readily apparent to those skilled in the art after considering the specification and practicing the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0125] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A sample optimization method, characterized in that: The sample optimization method comprises: Determine a target model and obtain training data; the training data includes: basic data information, historical data information and result data information. When the training data is standardized according to the large language model, the training data is standardized based on a standardized template, wherein the standardized template includes: a first conversion template, a second conversion template and a third conversion template. When the first conversion template is used to standardize the basic information, feature extraction is performed on the basic data information to obtain basic feature information, and the basic feature information is listed and arranged according to a fixed sequence to obtain a basic feature information sequence; when the second conversion template is used to standardize the historical data information, the historical data information is converted into a natural text description by enumeration; when the third conversion template is used to standardize the result data information, binarization is performed according to the result data information to obtain a standardized value of the result data information; The training data is standardized according to the large language model to obtain standardized training data; when the standardized training data is vectorized, the standardized training data is vectorized according to samples in sequence using the text vectorization model, and the standardized training data is converted into a vector form to obtain training data vector information, wherein the text vectorization model performs model learning training before vectorizing each example in the initial example set; Perform vectorization processing on the standardized training data to obtain training data vector information; Based on the training data vector information, cluster analysis is performed on the training samples, and category representatives are selected according to the cluster analysis results to obtain initial example samples and determine the initial example sample set; wherein, when the category representatives are selected according to the cluster analysis results, the size of the initial example sample set is determined, and the relationship between the size of the initial example sample set and the number of cluster categories in the cluster analysis results is analyzed. When the size of the initial example sample set is equal to the number of cluster categories in the cluster analysis results, category representatives are selected from each cluster according to the cluster analysis results. When the size of the initial example sample set is greater than the number of cluster categories in the cluster analysis results, the size of the initial example sample set is divided into a first value and a second value according to a division rule, and category representatives are selected from each cluster according to the first value. Then, the size of the cluster category in the cluster analysis results is analyzed, and the cluster category is screened according to the size to obtain the cluster category screening results, and in the cluster category screening results, category representatives are selected from each cluster category of the cluster category screening results according to the second value. When the category representatives are selected according to the cluster analysis results, a target number of training samples are also selected from the cluster analysis results as the verification example sample set; Performing Shapley approximation calculation on the initial sample set to obtain the Shapley approximation value of the initial sample, including: determining a cutoff threshold; initializing the Shapley value of each initial sample; taking each initial sample as a research object in turn, and performing full permutation on the remaining initial sample samples in the initial sample set to obtain an analysis sequence of the research object; traversing the analysis sequence of the research object to perform sequence sub-element analysis, and judging the analysis result in combination with the cutoff threshold to obtain the result accuracy of the sequence sub-element; performing Shapley value calculation based on the result accuracy of the sequence sub-element to obtain the Shapley approximation value of the research object; Further screening is performed according to the Shapley approximation of the initial sample to obtain the preferred sample, including: arranging the Shapley approximation of the initial sample according to size to obtain a sequence to be screened; determining the target number of preferred samples; screening the sequence to be screened in order according to the target number of preferred samples to obtain target sub-data; and tracing the training data according to the target sub-data to obtain the preferred sample.
2. The sample selection method according to claim 1, characterized in that: Perform cluster analysis on training samples based on training data vector information, including: Determine clustering features for training samples and analyze the distribution of training samples based on training data vector information; Determine the number of cluster categories; Determine the initial cluster center based on the number of cluster categories combined with the training data vector information; Cluster analysis and initial cluster center optimization are performed according to the training data vector information to obtain cluster analysis results.
3. A sample optimization device, characterized in that: include: Data acquisition module, first processing module, second processing module, cluster analysis module, analysis and calculation module and sample screening module; The data acquisition module is used to determine the target model and acquire training data according to the target model; the training data includes: basic data information, historical data information and result data information. When the training data is standardized according to the large language model, the training data is standardized based on the standardized template, wherein the standardized template includes: a first conversion template, a second conversion template and a third conversion template. When the first conversion template is used to perform standardized processing on the basic information, feature extraction is performed on the basic data information to obtain basic feature information, and the basic feature information is listed and arranged according to a fixed sequence to obtain a basic feature information sequence; when the second conversion template is used to perform standardized processing on the historical data information, the historical data information is converted into a natural text description by enumeration; when the third conversion template is used to perform standardized processing on the result data information, binarization is performed according to the result data information to obtain a standardized value of the result data information; The first processing module is used to perform standardization processing on the training data according to the large language model to obtain standardized training data; when performing vectorization processing on the standardized training data, a text vectorization model is used to perform vectorization processing on the standardized training data according to samples in sequence, and the standardized training data is converted into a vector form to obtain training data vector information, wherein the text vectorization model performs model learning training before performing vectorization processing on each example in the initial example set; The second processing module is used to perform vectorization processing on the standardized training data to obtain training data vector information; The cluster analysis module is used to perform cluster analysis on the training samples based on the training data vector information, and select category representatives according to the cluster analysis results to obtain initial example samples and determine the initial example sample set; wherein, when selecting category representatives according to the cluster analysis results, the size of the initial example sample set is determined, and the relationship between the size of the initial example sample set and the number of cluster categories in the cluster analysis results is analyzed. When the size of the initial example sample set is equal to the number of cluster categories in the cluster analysis results, a category representative is selected from each cluster according to the cluster analysis results. When the size of the initial example sample set is greater than the number of cluster categories in the cluster analysis results, the size of the initial example sample set is divided into a first value and a second value according to a division rule, a category representative is selected from each cluster according to the first value, and then the size of the cluster category in the cluster analysis results is analyzed, and the cluster category is screened according to the size to obtain a cluster category screening result, and in the cluster category screening result, a category representative is selected from each cluster category of the cluster category screening result according to the second value; when selecting category representatives according to the cluster analysis results, a target number of training samples are also selected from the cluster analysis results as a verification example sample set; The analysis and calculation module is used to perform Shapley approximation calculation on the initial sample set to obtain the Shapley approximation value of the initial sample, including: determining a cutoff threshold; initializing the Shapley value of each initial sample; taking each initial sample as a research object in turn, and performing full permutation on the remaining initial sample samples in the initial sample set to obtain an analysis sequence of the research object; traversing the analysis sequence of the research object to perform sequence sub-element analysis, and judging the analysis result in combination with the cutoff threshold to obtain the result accuracy rate of the sequence sub-element; performing Shapley value calculation according to the result accuracy rate of the sequence sub-element to obtain the Shapley approximation value of the research object; The sample screening module is used to further screen according to the Shapley approximation of the initial sample to obtain the preferred sample, including: arranging the Shapley approximation of the initial sample according to size to obtain a sequence to be screened; determining the target number of preferred samples; screening the sequence to be screened in order according to the target number of preferred samples to obtain target sub-data; and tracing the training data according to the target sub-data to obtain the preferred sample.
4. A terminal device, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the computer readable instructions, the steps of the preferred sample method according to any one of claims 1 to 2 are implemented.
5. A computer-readable storage medium storing computer-readable instructions, characterized in that: When the computer readable instructions are executed by a processor, the steps of the preferred sample method according to any one of claims 1 to 2 are implemented.
Citation Information
Patent Citations
Sample optimization training method of convolutional neural network and computer readable storage medium
CN115169534A
Robot task analysis method and device based on large language model and readable medium
CN116861921A