Model tuning method, device, equipment and storage medium

By retrieving data related to the initial question from the preset database, determining the target question-and-answer pairs and generating the target data set, the problem of directly inputting the data set in the vertical field results in less effective data, and improving the tuning effect of the model.

CN120371981BActive Publication Date: 2025-08-26INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510838221.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-20
Publication Date
2025-08-26
Estimated Expiration
2045-06-20

AI Technical Summary

Technical Problem

In the vertical field, the prior art directly inputs the data set to the model for training, resulting in less effective data and poor tuning effect.

Method used

By retrieving the first data related to the initial question from the preset database, determining the target question and answer pairs, and generating the target data set based on the target question and answer pairs and the initial data set, increasing the number of target questions in the target data set, and tuning the target model.

Benefits of technology

The effective data proportion in the target dataset is improved and the model's tuning effect in the vertical field is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371981B_ABST
    Figure CN120371981B_ABST
Patent Text Reader

Abstract

The present application discloses a model tuning method, apparatus, device and storage medium, which relates to the field of data processing technology, including obtaining an initial data set, wherein the initial question and answer pair includes an initial question and a corresponding initial answer. In order to extract data related to the initial question, first data corresponding to each initial question is retrieved from a preset database, where the first data is data related to the initial question, and then a target model is used to determine a target question and answer pair based on the first data and the initial question and answer pair. The target question is the corresponding initial question that the target model lacks an answer to. In order to improve the performance of model tuning, a target data set is generated based on the target question and answer pair and the initial data set, and then the target data set is used to tune the target model. Since the effective data in the target data set used to tune the target model is increased, the tuning effect of the target model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a model tuning method, apparatus, device, and storage medium. Background Art

[0002] In today's booming era of artificial intelligence (AI), models, with their powerful language understanding and generation capabilities, are demonstrating enormous potential for application in numerous fields, with growing demand particularly in vertical sectors. These sectors are often highly specialized, knowledge-intensive, and involve complex scenarios, placing higher demands on model accuracy, expertise, and adaptability.

[0003] Currently, when training models applied to vertical fields, the collected data sets are generally directly input into the model for training, resulting in less effective data and poor tuning effects. Summary of the Invention

[0004] The present application provides a model tuning method, apparatus, device and storage medium to at least solve the problem in related technologies of directly inputting collected data sets into the model for training, resulting in less effective data and poor tuning effect.

[0005] In a first aspect, the present application provides a model tuning method, the method comprising:

[0006] Obtain an initial data set; the initial data set includes multiple initial question-answer pairs; the initial question-answer pairs include initial questions and corresponding initial answers;

[0007] Retrieving first data corresponding to each initial question from a preset database; the first data is data related to the initial question;

[0008] Determining a target question-answer pair using a target model based on the first data and the initial question-answer pair; the target question-answer pair includes a target question and a corresponding initial answer and the corresponding first data; the target question is the corresponding initial question that the target model lacks an answer to;

[0009] generating a target dataset based on the target question-answer pair and the initial dataset; wherein the number of target questions included in the target dataset is greater than the number of initial questions determined to correspond to the target questions in the initial dataset;

[0010] Use the target dataset to tune the target model.

[0011] In a second aspect, the present application also provides a model tuning device, comprising:

[0012] Acquisition module, used to obtain the initial data set;

[0013] A retrieval module, configured to retrieve first data corresponding to each initial question from a preset database; the first data is data related to the initial question;

[0014] a determination module for determining a target question-answer pair using a target model and based on the first data and the initial question-answer pair; the target question-answer pair includes a target question and a corresponding initial answer and the corresponding first data; the target question is the corresponding initial question that the target model lacks an answer to;

[0015] A generation module is used to generate a target dataset based on the target question-answer pair and the initial dataset; the number of target questions included in the target dataset is greater than the number of initial questions determined to correspond to the target questions in the initial dataset; and a tuning module is used to tune the target model using the target dataset.

[0016] In a third aspect, the present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of the model tuning method provided in the first aspect above when executing the computer program.

[0017] In a fourth aspect, the present application also provides a computer-readable storage medium, in which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the model tuning method provided in the first aspect are implemented.

[0018] In a fifth aspect, the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the model tuning method provided in the first aspect above.

[0019] Through the model tuning method, device, equipment and storage medium provided by the present application, when it is necessary to train the target model, an initial data set is obtained. Wherein, the initial data set includes multiple initial question-answer pairs, and the initial question-answer pairs include initial questions and corresponding initial answers. In order to identify the questions that the target model lacks answers to, the first data corresponding to each initial question is retrieved from the preset database, wherein the first data is data related to the initial question. According to each initial question-answer pair and the corresponding first data and using the target model, a target question-answer pair is determined, the target question in the target question-answer pair is the corresponding initial question that the target model lacks answers to. In order to improve the target model's ability to answer the target question, a target data set is generated based on the target question-answer pair and the initial data set, wherein the number of target questions included in the target data set is greater than the number of initial questions determined to correspond to the target questions in the initial data set, thereby using the target data set to tune the target model, thereby increasing the proportion of valid data in the target data set and improving the model tuning effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0021] Figure 1 This is a diagram of an application scenario of the model tuning method provided in an embodiment of the present application;

[0022] Figure 2 A flowchart of a model tuning method provided in one embodiment of the present application;

[0023] Figure 3 A schematic diagram of a flow chart of a model tuning method provided in another embodiment of the present application;

[0024] Figure 4 A schematic diagram of the structure of a model tuning device provided in one embodiment of the present application;

[0025] Figure 5 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0026] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0027] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.

[0028] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0029] In today's era of booming artificial intelligence technology, models, with their powerful language understanding and generation capabilities, have demonstrated tremendous application potential in numerous fields, particularly in vertical domains where demand for applications is growing. Vertical domains are often highly specialized, knowledge-intensive, and involve complex scenarios, placing higher demands on model accuracy, expertise, and adaptability. To improve the performance of large language models in vertical domains, optimizing training data is crucial. Currently, when fine-tuning models for vertical domains, the obtained fine-tuning dataset is often directly fed into the model for training. Without identifying the actual deficiencies in the model, training is focused on these areas. This results in less valid data in the fine-tuning dataset, leading to poor model fine-tuning results.

[0030] Therefore, when facing the above technical problems, the data set used for tuning is no longer directly input into the model for tuning. Instead, the data that is missing from the model in the tuning data set is determined, thereby increasing the proportion of missing data, focusing on training the missing parts, and improving the performance of the model. Specifically, an initial data set is obtained, and the initial data set includes multiple initial question-answer pairs, and the initial question-answer pairs include initial questions and corresponding initial answers. In order to extract data related to the initial questions, the first data corresponding to each initial question is retrieved from a preset database including vertical field data corresponding to the target model. The first data is data related to the initial question, and then the target model is adopted and a target question-answer pair is determined based on the first data and the initial question-answer pair, wherein the target question-answer pair includes the target question and the corresponding initial answer and the corresponding first data, and the target question is the corresponding initial question that the target model lacks an answer to. In order to improve the performance of model tuning, the missing questions are trained intensively, and therefore a target data set is generated based on the target question-answer pair and the initial data set, wherein the number of target questions included in the target data set is greater than the number of initial questions determined as corresponding to the target questions in the initial data set, and then the target data set is used to tune the target model. Therefore, the effective data in the target data set used for tuning the target model is increased, thereby improving the tuning effect of the target model.

[0031] Figure 1 This is an application scenario diagram of the model tuning method provided in the embodiment of this application. Figure 1As shown, the application scenario provided by this embodiment includes: a server device 10 and a client device 20. The model tuning method is applied to the server device 10. The server device 10 receives a model tuning request triggered by a user on the client device 20, and after receiving the model tuning request, obtains an initial data set, which includes multiple initial question-answer pairs, each of which includes an initial question and a corresponding initial answer. The first data corresponding to each initial question is retrieved from a preset database, where the first data is data related to the initial question, and the preset database includes data in a vertical field corresponding to the target model. Further, based on the first data and the initial question-answer pair and using the target model, a target question-answer pair is determined, wherein the target question-answer pair includes a target question and a corresponding initial answer and the corresponding first data. The target question refers to the corresponding initial question that the target model lacks an answer to. Then, a target data set is generated based on the target question-answer pair and the initial data set, and the target model is tuned using the target data set. After the target model tuning is completed, the tuning result is sent to the client device 20, and the client device 20 displays the tuning result.

[0032] Figure 2 A flow chart of a model tuning method provided in an embodiment of the present application is shown as follows: Figure 2 The model tuning method provided in this embodiment is applied to a server device. The model tuning method provided in this embodiment specifically includes the following steps:

[0033] S201: Obtain an initial data set.

[0034] The initial data set includes multiple initial question-answer pairs, each of which includes an initial question and a corresponding initial answer.

[0035] The initial question refers to the question included in the initial data set, and the initial answer refers to the answer corresponding to the initial question.

[0036] Among them, the initial answer is the reference answer corresponding to the initial question. If the initial question is a non-open question, the initial answer is the standard answer to the initial question. If the initial question is an open question, the initial answer is the reference answer corresponding to the initial question.

[0037] Specifically, in this embodiment, the server device obtains the initial data set from a preset database.

[0038] S202: Retrieve first data corresponding to each initial question from a preset database.

[0039] The first data is data related to the initial question. The preset database includes data in the vertical field corresponding to the target model.

[0040] Optionally, the vertical field can be independently set according to demand, which is not limited in this embodiment.

[0041] Optionally, the data in the preset database may include but is not limited to text data, professional knowledge related to vertical fields, question-and-answer pairs related to vertical fields, etc., which are not limited in this embodiment.

[0042] Specifically, in this embodiment, the server device uses a preset technology and searches from a preset database according to each initial question to retrieve data related to the initial question, and uses the data related to the initial question as the first data corresponding to each initial question.

[0043] Optionally, the preset technology may be similarity search (Facebook AI Similarity Search, Faiss), etc., which is not limited in this embodiment.

[0044] S203: Using the target model and determining a target question-answer pair based on the first data and the initial question-answer pair.

[0045] The target question-answer pair includes a target question, a corresponding initial answer, and corresponding first data. The target question refers to the corresponding initial question that the target model lacks an answer to.

[0046] Specifically, in this embodiment, the server-side device inputs each initial question into the target model for answering, outputs the answer to the first initial question, then adds the first data corresponding to each initial question as additional context information to the prompt information of the target model, then inputs each initial question into the model again for answering, outputs the answer to the second initial question, and uses a preset model to score the first and second initial question answers based on the initial answers. If the score of the second initial question answer is greater than the score of the first initial question answer, the second initial question answer is determined as the target question according to the corresponding initial question. The target question, the corresponding initial answer, and the corresponding first data are then determined as a target question-answer pair.

[0047] Optionally, in this embodiment, the server-side device inputs each initial question into the target model for answering, outputs the answer to the first initial question, then adds the first data corresponding to each initial question as additional context information to the prompt information of the target model, then inputs each initial question into the model for answering, outputs the answer to the second initial question, uses the preset model to compare the effects of the first initial question answer and the second initial question answer based on the initial answer, and outputs the best answer among the initial questions. If the preset model outputs the answer to the second initial question, the answer to the second initial question is determined as the target question according to the corresponding initial question. The target question, the corresponding initial answer, and the corresponding first data are determined as the target question-answer pair.

[0048] The first answer to the initial question refers to the answer given by the target model to the initial question when the first data corresponding to each initial question is not added to the target model as context information. The second answer to the initial question refers to the answer given by the target model to the initial question when the first data corresponding to each initial question is added to the target model as context information.

[0049] Optionally, the preset model may be a general artificial intelligence model, etc., which is not limited in this embodiment.

[0050] Among them, the general artificial intelligence model refers to an artificial intelligence system with cross-domain knowledge understanding, multi-task processing, autonomous learning and reasoning capabilities.

[0051] It is understood that the initial answer is the reference answer to the initial question. If the initial question is a non-open-ended question, the initial answer is the standard answer to the initial question. If the initial question is an open-ended question, the initial answer is the reference answer to the initial question. Therefore, when using the preset model to compare the results, if the question is a non-open-ended question, the first and second initial answers are compared to see which one is closer to the initial answer. If the question is an open-ended question, the preset model is used to compare the first and second initial answers based on the initial answer to see which one is better.

[0052] Optionally, the target model may be a large language model (LLM), etc., which is not limited in this embodiment.

[0053] S204: Generate a target dataset based on the target question-answer pairs and the initial dataset. The number of target questions included in the target dataset is greater than the number of initial questions corresponding to the target questions in the initial dataset. It is understood that the target questions correspond to target question-answer pairs, and the number of target question-answer pairs in the target question-answer pairs is greater than the number of initial question-answer pairs corresponding to the initial questions determined as target questions in the initial dataset.

[0054] Specifically, in this embodiment, the server device increases the number of target question-answer pairs according to a preset multiple, and reads out the initial question-answer pairs that are not determined as the initial questions corresponding to the target questions from the initial data set, and randomly deletes the read initial question-answer pairs according to the preset multiple, and determines the target question-answer pairs with an increased number and the initial question-answer pairs with a reduced number as the target data set.

[0055] It can be understood that by increasing the number of target question-answer pairs according to a preset multiple, reading out the initial question-answer pairs that are not determined to be the initial questions corresponding to the target questions from the initial data set, and randomly deleting the read initial question-answer pairs according to the preset multiple, the number in the initial data set is ensured to remain unchanged.

[0056] Optionally, the preset multiple may be 0.2, 0.3 or 0.5, etc., and may be set independently according to needs, and is not limited in this embodiment.

[0057] Optionally, the number in the initial data set may be 100 or other positive integers, which is not limited in this embodiment.

[0058] S205: Optimize the target model using the target dataset.

[0059] Specifically, in this embodiment, the target data set is divided into a training set and a validation set, the target model is input, and fine-tuning is performed using a preset fine-tuning algorithm. After each training round, the target model is evaluated using the validation set until the preset evaluation index meets the preset stopping condition. The fine-tuning is stopped, indicating that the tuning is successful, and the adjusted target model is saved.

[0060] Optionally, the preset fine-tuning algorithm may be a low-rank adjustment algorithm, etc., which is not limited in this embodiment.

[0061] Among them, the low-rank adjustment algorithm is an efficient parameter fine-tuning method for pre-trained language models.

[0062] Optionally, the evaluation indicator may be accuracy, loss function, etc., which is not limited in this embodiment.

[0063] Optionally, the preset stopping condition may be that the accuracy meets the corresponding preset threshold, the loss function converges, etc., which is not limited in this embodiment.

[0064] Among them, before tuning the target model, a hyperparameter optimization search algorithm can be used to set the increase ratio of the target question-answer pairs in a preset range, and determine the target model with the best training effect during the fine-tuning process.

[0065] Optionally, the preset interval for the increase ratio of the target model may be [0.1, 0.3], or other range intervals, which is not limited in this embodiment.

[0066] For example, if the increase ratio is 0.3, the number of target question-answer pairs is increased by 1.3 times.

[0067] Specifically, when it is necessary to train the target model in a vertical field, an initial data set is obtained. The initial data set includes a plurality of initial question-answer pairs, and the initial question-answer pairs include initial questions and corresponding initial answers. In order to identify questions that the target model lacks answers to, the first data corresponding to each initial question is retrieved from a preset database including data in the vertical field corresponding to the target model, wherein the first data is data related to the initial question. According to each initial question-answer pair and the corresponding first data and using the target model, a target question-answer pair is determined. The target question in the target question-answer pair is the corresponding initial question that the target model lacks answers to. In order to improve the target model's ability to answer the target question, a target data set is generated based on the target question-answer pair and the initial data set, wherein the number of target questions included in the target data set is greater than the number of initial questions determined as corresponding to the target questions in the initial data set, thereby using the target data set to tune the target model, thereby increasing the proportion of valid data in the target data set and improving the model tuning effect.

[0068] As an optional implementation manner, based on the above embodiment, retrieving the first data corresponding to each initial question from a preset database includes:

[0069] Get target data from the preset database;

[0070] dividing the target data into first segments of a preset length;

[0071] Vectorizing the first segment to obtain a vectorized first segment, and determining the vectorized first segment as target segment data;

[0072] Perform keyword extraction on the first segment and construct a corresponding index to obtain the first segment with the index, and determine the first segment with the index as target keyword data;

[0073] Represent each initial problem as a vector to obtain each initial problem vector;

[0074] Performing vector searches in the target segment data based on each initial question vector to determine a first preset number of second segments corresponding to each initial question;

[0075] Perform keyword extraction on each initial question to obtain keywords corresponding to each initial question;

[0076] Perform keyword searches in the target keyword data based on the keywords corresponding to the initial questions to determine a second preset number of third segments corresponding to the initial questions;

[0077] The second segment and the third segment corresponding to each initial question are determined as the first data corresponding to each initial question.

[0078] The target data is data included in a preset database, including but not limited to data in the vertical field corresponding to the target model. The first segment refers to the segment into which the target data is divided. The target segment data is data including the vectorized first segment. The target keyword data is data including the indexed first segment. The second segment is a segment retrieved from the target segment data using a preset vector retrieval technique. The third segment is a segment retrieved from the target keyword data using a preset keyword retrieval technique. The initial question vector is the initial question represented by a vector.

[0079] Optionally, the first preset number can be set independently according to demand and is not limited in this embodiment.

[0080] Optionally, the second preset number can be set independently according to demand and is not limited in this embodiment.

[0081] Optionally, the preset length can be set independently according to needs and is not limited in this embodiment.

[0082] Optionally, the preset vector retrieval technology may be a similarity search algorithm, etc., which is not limited in this embodiment.

[0083] Optionally, the preset keyword search technology may be a distributed search engine, etc., which is not limited in this embodiment.

[0084] Among them, the distributed search engine can perform fast full-text search, structured search, keyword search, analysis and other operations on massive amounts of data.

[0085] Specifically, in this embodiment, the server device retrieves target data from a preset database and uses a preset text segmentation algorithm to divide the target data into first segments of a preset length. The server device then uses a preset vectorization technique to vectorize the first segments, thereby obtaining the vectorized first segments. The vectorized first segments are then identified as target segment data. Furthermore, a preset keyword extraction algorithm is used to extract keywords from the first segments and construct corresponding indexes, thereby obtaining indexed first segments. The indexed first segments are then identified as target keyword data. Each initial question is then vectorized using the preset vectorization technique to obtain each initial question vector. Furthermore, based on each initial question vector, a preset vector search technique is used to search the target segment data to retrieve a first preset number of second segments with the highest similarity to each initial question. A preset keyword extraction algorithm is then used to extract keywords from each initial question to obtain keywords corresponding to each initial question. Based on the keywords corresponding to each initial question, a preset keyword search technique is used to search the target keyword data to determine a second preset number of third segments corresponding to each initial question. The second and third segments corresponding to each initial question are then identified as the first data corresponding to each initial question.

[0086] Among them, the preset text segmentation algorithm refers to an algorithm that divides text based on the number of characters or sentences, which can be implemented through code tools, etc., and is not limited in this embodiment.

[0087] Optionally, the preset vectorization technology may be word vector conversion (Word to Vector, Word2Vec), document vector conversion (Document to Vector, Doc2Vec), etc., which is not limited in this embodiment.

[0088] Among them, word vector conversion is a technology that can convert words into continuous vector representations. Document vector conversion is a technology used to generate vector representations at the sentence, paragraph, or document level.

[0089] It is understandable that the similarity between the initial question and the first segment can be calculated, and then a preset number of segments with higher similarity can be selected as the second segment.

[0090] Optionally, the preset keyword extraction algorithm may be word frequency-inverse document frequency, etc., which is not limited in this embodiment.

[0091] Optionally, keyword extraction may also be implemented using a search engine, which is not limited in this embodiment.

[0092] Specifically, by obtaining the target data from the preset database, it is ensured to be highly relevant to the vertical field, and the target data is divided into the first segment, which is conducive to segmented retrieval. By vectorizing and keyword indexing the segments, vector retrieval and keyword retrieval of the segments are achieved, thereby ensuring semantic coverage and terminology accuracy, thereby improving the coverage and accuracy of the first data.

[0093] As an optional implementation, based on any of the above embodiments, using a target model and determining a target question-answer pair based on the first data and the initial question-answer pair includes:

[0094] Determining the first data corresponding to each initial question as prompt information for each initial question;

[0095] Inputting the initial question including the prompt information and the initial question excluding the prompt information into the target model respectively to ask questions to obtain a first answer and a second answer;

[0096] A target question-answer pair is determined based on the first answer and the second answer.

[0097] The first answer is the answer to the initial question including the prompt information, and the second answer is the answer to the initial question not including the prompt information.

[0098] Specifically, in this embodiment, the server-side device uses the first data corresponding to each initial question as the prompt information for each initial question, and inputs the initial question including the prompt information and the initial question excluding the prompt information into the target model for questioning, thereby obtaining the first answer corresponding to the initial question including the prompt information and the second answer corresponding to the initial question excluding the prompt information. A preset model is used to compare the effects of the first initial question answer and the second initial question answer based on the initial answers, and the corresponding better answer for each initial question is output. If the preset model outputs the answer to the second initial question, the answer to the second initial question is determined as the target question according to the corresponding initial question. The target question, the corresponding initial answer, and the corresponding first data are determined as the target question-answer pair.

[0099] It can be understood that by adopting the retrieval enhancement generation technology, obtaining the first data from the preset database, and generating the corresponding first answer using the first data as context information, the accuracy and relevance of the model are improved.

[0100] Among them, Retrieval Augmented Generation (RAG) is an artificial intelligence technology framework that combines information retrieval technology with generative models, aiming to improve the quality, accuracy and professionalism of generated content.

[0101] Specifically, by using the first data as the prompt information for the initial question, and letting the target model answer the initial question with and without the prompt information respectively, the questions that the target model is not good at can be determined based on the effect of the target model's answers. If the answer without prompt information is better than the answer with prompt information, it means that the target model has a good grasp of the question. If the answer without prompt information is not as good as the answer with prompt information, it means that the target model lacks a grasp of the question, thereby achieving accurate positioning of the target question.

[0102] As an optional implementation, based on any of the above embodiments, determining a target question-answer pair based on the first answer and the second answer includes:

[0103] Scoring the first answer and the second answer based on the initial answers corresponding to the initial questions to obtain a first score and a second score;

[0104] Subtract the first score from the second score to obtain a score difference;

[0105] Comparing the score difference with a preset difference threshold;

[0106] If the score difference is greater than the preset difference threshold, the initial question corresponding to the score difference is determined as the target question;

[0107] A target question, a corresponding initial answer, and corresponding first data are determined as a target question-answer pair.

[0108] The first score is the score of the first answer to the initial question, and the second score is the score of the second answer to the initial question.

[0109] Specifically, in this embodiment, the server-side device uses a preset model to score the answer to the first initial question and the answer to the second initial question based on the initial answer, and outputs the score of the first answer and the second answer for each initial question. The server-side device subtracts the first score from the second score to obtain a score difference, and compares the score difference with a preset difference threshold. If the score difference is greater than the preset difference threshold, it indicates that the first score is higher than the second score. The initial question corresponding to the score difference is determined as the target question, and the target question, the corresponding initial answer, and the corresponding first data are determined as the target question-answer pair.

[0110] Optionally, the preset difference threshold can be independently set according to needs and is not limited in this embodiment.

[0111] Specifically, by scoring the first answer and the second answer corresponding to each initial question according to the initial answer, the effect of the target model's answer is quantified, and the first score and the second score corresponding to each initial question are subtracted, and the score difference is compared with the preset difference threshold to determine the corresponding question whose first answer is better than the second answer, thereby determining the target question, and then determining the target question and answer pair, and improving the judgment efficiency through automated comparison.

[0112] As an optional implementation, based on any of the above embodiments, generating a target dataset based on the target question-answer pair and the initial dataset includes:

[0113] Get the preset multiple;

[0114] Oversample the target question-answer pair by a preset multiple to obtain the first question-answer pair;

[0115] Undersample the initial question-answer pairs in the initial dataset that are not determined to correspond to the target question by a preset multiple to obtain a second question-answer pair;

[0116] The first question-answer pair and the second question-answer pair are determined as target datasets.

[0117] Oversampling refers to increasing the number of target question-answer pairs, while undersampling refers to reducing the number of initial question-answer pairs in the initial dataset that were not identified as corresponding to the target question. The first question-answer pair refers to the target question-answer pair after oversampling, and the second question-answer pair refers to the initial question-answer pair in the initial dataset after undersampling that was not identified as corresponding to the target question.

[0118] Specifically, in this embodiment, the server device randomly selects a question-answer pair from the target question-answer pair and replicates it by a preset multiple to obtain a first question-answer pair, and randomly deletes the initial question-answer pairs in the initial data set that are not determined to correspond to the target question by a preset multiple to obtain a second question-answer pair. The first question-answer pair and the second question-answer pair are used as the target question-answer pair.

[0119] It can be understood that the target question is the corresponding initial question that the target model determined from the initial data set lacks to answer.

[0120] For example, assuming the preset multiplier is 0.3, the initial dataset includes 100 initial question-answer pairs, of which 50 target questions are determined, and the number of corresponding target question-answer pairs is 50; the number of initial question-answer pairs that are not determined to correspond to the target questions is also 50. The number of target question-answer pairs increases to 65, and the number of initial question-answer pairs in the initial dataset that are not determined to correspond to the target questions decreases to 35.

[0121] Here, 65 is 50 plus 50 times 0.3, and 35 is 50 minus 50 times 0.3.

[0122] Optionally, the preset multiple may be 0.2, 0.3 or 0.5, etc., and may be set independently according to needs, and is not limited in this embodiment.

[0123] Specifically, since the target question in the target question-answer pair is the question that the target model lacks to answer, the target question-answer pair is oversampled by a preset multiple, the initial question-answer pairs that are not determined to correspond to the target question in the initial data set are undersampled by a preset multiple, and the target data set is generated, thereby increasing the amount of valid data in the target data set, allowing the target model to focus on training the lacking questions, thereby improving the optimization effect of the target model and improving the performance of the target model in vertical fields.

[0124] As an optional implementation manner, based on any of the above embodiments, the first data includes multiple segments;

[0125] Before determining the target question, the corresponding initial answer, and the corresponding first data as a target question-answer pair, the method further includes:

[0126] Deduplication processing is performed on the second segment and the third segment in the first data corresponding to the target problem to obtain deduplication-free first data;

[0127] Construct a target segment set corresponding to each target problem;

[0128] Add the segments in the first data after deduplication corresponding to each target question to the corresponding target segment set;

[0129] The following operations are performed in a loop until all the segments in the first data after deduplication corresponding to the target problem are traversed, and the target segment set corresponding to the output target problem is determined as the first data of the target problem;

[0130] Operations include:

[0131] Inputting the first data after removing duplicates of the currently traversed segment and the corresponding target question into the target model to obtain a third answer;

[0132] Score the third answer to obtain a third score;

[0133] Compare the third rating to the first rating;

[0134] If the third score is less than the first score, the currently traversed segment is determined as the target segment;

[0135] If the third score is greater than or equal to the first score, the currently traversed segment in the target segment set corresponding to the target question is deleted;

[0136] Continue traversing to the next fragment in the target fragment set.

[0137] The target segment set refers to the set of first data after deduplication for the target question. The third answer refers to the answer obtained by inputting the target model with the target question after removing the deduplication of the first data from the currently traversed segment and the corresponding target question. The third score is the score of the third answer to the initial question. The target segment refers to the segment whose third score is less than the first score after deleting the traversed segment.

[0138] Specifically, in this embodiment, since the first segment and the second segment may overlap, the server-side device deduplicates the second segment and the third segment in the first data corresponding to each target question, thereby obtaining the deduplicated first data corresponding to each target question, and constructing a target segment set corresponding to each target question, placing the deduplicated first data corresponding to each target question into the target segment set corresponding to each target question. The following loop operation is then executed for each target question in sequence until all segments in the deduplicated first data corresponding to the target question have been traversed, and the target segment set corresponding to the output target question is determined as the first data of the target question. The loop operation includes: deleting the current traversed segment, and inputting the deduplicated first data of the currently traversed segment and the corresponding target question into the target model to obtain a third answer, and using a preset model to score the third answer according to the initial answer corresponding to the target question to obtain a third score, and comparing the third score with the first score. If the third score is less than the first score, it means that the currently deleted segment is knowledge that the target model has not mastered, so the currently traversed segment is determined as the target segment. If the third score is greater than or equal to the first score, it means that the currently deleted segment is knowledge that the target model has mastered, and deletion will not have any effect on the answer. Therefore, the currently traversed segment in the target segment set corresponding to the target question is deleted, and then the next segment in the target segment set is traversed.

[0139] Specifically, by testing the fragments in the deduplicated first data corresponding to each target question, it is possible to determine which fragments affect the quality of the answer generated by the target model and which fragments have no effect on the answer generated by the target model. By inputting the deduplicated first data after deleting any fragment into the target model for answer output, scoring the answer, and comparing it with the first score, it is possible to determine which are the key fragments corresponding to the target question, and thus retain the key fragments. This can save computing resources when optimizing the model, and can also improve the tuning effect of the target model.

[0140] As an optional implementation manner, based on any of the above embodiments, before using the target dataset to tune the target model, the method further includes:

[0141] Determine the number of target question-answer pairs in the target dataset;

[0142] If the number of target question-answer pairs is less than a preset threshold, the step of adopting the target model and determining the target question-answer pairs based on the first data and the initial question-answer pairs is re-executed.

[0143] Optionally, the preset quantity threshold can be independently set according to actual needs and is not limited in this embodiment.

[0144] Specifically, in this embodiment, before using the target model dataset to tune the target model, the server-side device reads the number of target question-answer pairs included in the target dataset and compares the number of target question-answer pairs with a preset number threshold. If the number of target question-answer pairs is less than the preset number threshold, the step of using the target model and determining the target question-answer pairs based on the first data and the initial question-answer pairs is re-executed to reacquire the target question-answer pairs, until the number of target question-answer pairs is greater than the preset number threshold, and then the target dataset is used to tune the target model.

[0145] Specifically, by determining the number of target question-answer pairs included in the target dataset and comparing it with a preset threshold, we can ensure that the target dataset used when tuning the target model contains a sufficient number of target question-answer pairs, thereby improving the success rate of model tuning.

[0146] Figure 3 A flow chart of a model tuning method provided in another embodiment of the present application is shown in FIG. Figure 3 The model tuning method provided in this embodiment is applied to a server device. The model tuning method provided in this embodiment specifically includes the following steps:

[0147] S301: Obtain an initial data set.

[0148] S302: Obtain target data from a preset database, divide the target data into first segments of preset length, perform vectorization representation, keyword extraction, and index construction on the first segments, thereby determining target segment data and target keyword data.

[0149] S303: Vectorize each initial question to obtain each initial question vector.

[0150] S304: Using a preset vector search technique, the similarity between each initial question vector and each segment in the target segment data is calculated. The similarities corresponding to each initial question are ranked from high to low, and the segments with the highest preset ranking are determined as the second segments corresponding to each initial question. Using a preset keyword search technique, the target keyword data is searched based on the keywords corresponding to each initial question to determine a second preset number of third segments corresponding to each initial question. The second and third segments corresponding to each initial question are determined as the first data corresponding to each initial question.

[0151] The number of the pre-set top-ranked segments may be a first pre-set number.

[0152] S305: Using the first data corresponding to each initial question as prompt information for each initial question, and inputting the initial question including the prompt information and the initial question not including the prompt information into the target model for questioning, thereby obtaining a first answer and a second answer.

[0153] The first answer is the answer corresponding to the initial question including the prompt information; the second answer is the answer corresponding to the initial question not including the prompt information.

[0154] S306: The initial answer, the first answer, and the second answer are input into a preset model. The preset model is used to compare the effects of the first answer and the second answer based on the initial answer, and the best answer corresponding to each initial question is output. If the preset model outputs the first answer, the first answer is determined as the target question according to the corresponding initial question. The target question, the corresponding initial answer, and the corresponding first data are then determined as a target question-answer pair.

[0155] Optionally, the preset model may be an inference model, etc., which is not limited in this embodiment.

[0156] S307: Deduplication processing is performed on the second segment and the third segment in the first data corresponding to the target question, so as to obtain deduplication first data.

[0157] S308: Construct a target segment set corresponding to each target problem, and add the segments in the deduplicated first data corresponding to each target problem to the corresponding target segment set, execute a preset loop, obtain the target segment set corresponding to each target problem after executing the loop, and determine the target segment set corresponding to each target problem after executing the loop as the first data of the target problem.

[0158] S309: Oversample the target question-answer pair by a preset multiple to obtain a first question-answer pair, and undersample the initial question-answer pairs in the initial data set that are not determined to correspond to the target question by a preset multiple to obtain a second question-answer pair, and determine the first question-answer pair and the second question-answer pair as the target data set.

[0159] S310, determining the number of target question-answer pairs in the target dataset.

[0160] S311, determining whether the number of target question-answer pairs is less than a preset number threshold.

[0161] S312: If the number of target question-answer pairs is greater than or equal to a preset threshold, the target model is tuned using the target dataset.

[0162] If the number of target question-answer pairs is less than the preset threshold, the corresponding step of S306 is executed again.

[0163] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.

[0164] Figure 4 This is a schematic diagram of the structure of the model tuning device provided in one embodiment of the present application. Figure 4 As shown, the execution subject of the above-mentioned model tuning method is a model tuning device. The model tuning device can be implemented by a computer program; it can also be implemented by a medium storing the relevant computer program, such as a USB flash drive and / or optical disk, or it can also be implemented by a physical device integrated or installed with the relevant computer program, such as an electronic device. The electronic device can be a computer or a server device. The model tuning device provided in this embodiment is located in the electronic device, and the model tuning device 40 provided in this embodiment includes: an acquisition module 41, a retrieval module 42, a determination module 43, a generation model 44, and a tuning module 45.

[0165] Specifically, the acquisition module 41 is used to obtain the initial data set; the retrieval module 42 is used to retrieve the first data corresponding to each initial question from a preset database; the first data is data related to the initial question; the determination module 43 is used to adopt the target model and determine the target question and answer pair based on the first data and the initial question and answer pair; the target question and answer pair includes the target question and the corresponding initial answer and the corresponding first data; the target question refers to the corresponding initial question that the target model lacks an answer to; the generation module 44 is used to generate the target data set based on the target question and answer pair and the initial data set; the number of target questions included in the target data set is greater than the number of initial questions determined to correspond to the target questions in the initial data set; the tuning module 45 is used to use the target data set to tune the target model.

[0166] Optionally, when the retrieval module 42 retrieves the first data corresponding to each initial question from the preset database, it is specifically used to: obtain the target data in the preset database; divide the target data into first segments of a preset length; vectorize the first segment to obtain the vectorized first segment, and determine the vectorized first segment as the target segment data; perform keyword extraction on the first segment, and construct a corresponding index to obtain the indexed first segment, and determine the indexed first segment as the target keyword data; vectorize each initial question to obtain each initial question vector; perform vector retrieval in the target segment data based on each initial question vector, and determine the first preset number of second segments corresponding to each initial question; perform keyword extraction on each initial question to obtain the keyword corresponding to each initial question; perform keyword retrieval in the target keyword data based on the keyword corresponding to each initial question, and determine the second preset number of third segments corresponding to each initial question; determine the second segment and the third segment corresponding to each initial question as the first data corresponding to each initial question.

[0167] Optionally, the determination module 43, when adopting the target model and determining the target question-answer pair based on the first data and the initial question-answer pair, is used to determine the first data corresponding to each initial question as the prompt information of each initial question; the initial question including the prompt information and the initial question not including the prompt information are respectively input into the target model for asking questions to obtain a first answer and a second answer; and the target question-answer pair is determined based on the first answer and the second answer.

[0168] Optionally, the determination module 43, when determining the target question-answer pair based on the first answer and the second answer, is used to score the first answer and the second answer based on the initial answers corresponding to each initial question to obtain a first score and a second score; subtract the first score from the second score to obtain a score difference; compare the score difference with a preset difference threshold; if the score difference is greater than the preset difference threshold, determine the initial question corresponding to the score difference as the target question; and determine the target question, the corresponding initial answer, and the corresponding first data as the target question-answer pair.

[0169] Optionally, the generation model 44 is configured to obtain a preset multiple when generating a target dataset based on the target question-answer pair and the initial dataset; oversample the target question-answer pair by the preset multiple to obtain a first question-answer pair; undersample the initial question-answer pairs in the initial dataset that are not determined to correspond to the target question by the preset multiple to obtain a second question-answer pair; and determine the first question-answer pair and the second question-answer pair as the target dataset. Optionally, the first data includes multiple segments.

[0170] The model tuning device also includes a processing module, a model building module, an adding module and an execution module.

[0171] Correspondingly, the processing module is used to deduplicate the second and third segments in the first data corresponding to the target question before determining the target question, the corresponding initial answer and the corresponding first data as the target question-answer pair to obtain the deduplicated first data; a model is constructed to construct a target segment set corresponding to each target question; an adding module is used to add the segments in the deduplicated first data corresponding to each target question to the corresponding target segment set; an execution module is used to loop the following operations until all the segments in the deduplicated first data corresponding to the target question are traversed, and the target segment set corresponding to the output target question is determined as the first data of the target question; the operations include: inputting the deduplicated first data and the corresponding target question after removing the currently traversed segment into the target model to obtain a third answer; scoring the third answer to obtain a third score; comparing the third score with the first score; if the third score is less than the first score, determining the currently traversed segment as the target segment; if the third score is greater than or equal to the first score, deleting the currently traversed segment in the target segment set corresponding to the target question; and continuing to traverse the next segment in the target segment set.

[0172] Optionally, a determination module 43 is used to determine the number of target question-answer pairs in the target dataset before using the target dataset to tune the target model; an execution module is used to re-execute the step of using the target model and determining the target question-answer pairs based on the first data and the initial question-answer pairs if the number of target question-answer pairs is less than a preset threshold.

[0173] For the description of the features in the embodiment corresponding to the model tuning device, please refer to the relevant description of the embodiment corresponding to the model tuning method, and no further details will be given here.

[0174] Figure 5 This is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. Figure 5 As shown, the electronic device 50 provided in an embodiment of the present application includes: a memory 52 and a processor 51.

[0175] The memory 52 stores a computer program, and the processor 51 is configured to run the computer program to execute the steps in any of the above-mentioned model tuning method embodiments.

[0176] The specific implementation process of the processor 51 can be found in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here in this embodiment.

[0177] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the application may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.

[0178] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage.

[0179] A bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, the buses in the drawings of this application are not limited to just one bus or just one type of bus.

[0180] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned model tuning method embodiments when running.

[0181] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0182] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any of the above-mentioned model tuning method embodiments are implemented.

[0183] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned model tuning method embodiments are implemented.

[0184] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0185] The above is a detailed introduction to a device information display method provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

Claims

1. A model tuning method, characterized in that: The method comprises: Acquire an initial data set; the initial data set includes a plurality of initial question-answer pairs; the initial question-answer pairs include initial questions and corresponding initial answers; Retrieving first data corresponding to each of the initial questions from a preset database; the first data is data related to the initial question; Determining a target question-answer pair using a target model based on the first data and the initial question-answer pair; the target question-answer pair includes a target question, the corresponding initial answer, and the corresponding first data; the target question is the corresponding initial question that the target model lacks an answer to; Get the preset multiple; Oversampling the target question-answer pair by the preset multiple to obtain a first question-answer pair; Undersampling the initial question-answer pairs in the initial data set that are not determined to correspond to the target question by the preset multiple to obtain second question-answer pairs; Determining the first question-answer pair and the second question-answer pair as a target data set; the number of target questions included in the target data set is greater than the number of initial questions determined to correspond to the target questions in the initial data set; The target model is tuned using the target dataset.

2. The model tuning method according to claim 1, characterized in that: The retrieving first data corresponding to each of the initial questions from a preset database includes: Acquire target data from the preset database; Dividing the target data into first segments of a preset length; Vectorizing the first segment to obtain a vectorized first segment, and determining the vectorized first segment as target segment data; Perform keyword extraction on the first segment and construct a corresponding index to obtain an indexed first segment, and determine the indexed first segment as target keyword data; Representing each of the initial problems by vectors to obtain initial problem vectors; Performing vector searches in the target segment data based on each of the initial question vectors to determine a first preset number of second segments corresponding to each of the initial questions; Perform keyword extraction on each of the initial questions to obtain keywords corresponding to each of the initial questions; Perform keyword searches in the target keyword data based on the keywords corresponding to the initial questions, and determine a second preset number of third segments corresponding to the initial questions; The second segment and the third segment corresponding to each of the initial questions are determined as the first data corresponding to each of the initial questions.

3. The model tuning method according to claim 2, characterized in that: The adopting the target model and determining a target question-answer pair based on the first data and the initial question-answer pair includes: determining the first data corresponding to each of the initial questions as prompt information for each of the initial questions; Inputting the initial question including the prompt information and the initial question not including the prompt information into the target model respectively to ask questions, so as to obtain a first answer and a second answer; The target question-answer pair is determined based on the first answer and the second answer.

4. The model tuning method according to claim 3, characterized in that: Determining the target question-answer pair based on the first answer and the second answer includes: Scoring the first answer and the second answer based on the initial answers corresponding to the initial questions to obtain a first score and a second score; subtracting the first score from the second score to obtain a score difference; Comparing the score difference with a preset difference threshold; If the score difference is greater than the preset difference threshold, determining the initial question corresponding to the score difference as the target question; The target question, the corresponding initial answer, and the corresponding first data are determined as the target question-answer pair.

5. The model tuning method according to claim 4, characterized in that: The first data includes a plurality of segments; Before determining the target question, the corresponding initial answer, and the corresponding first data as the target question-answer pair, the method further includes: performing deduplication processing on the second segment and the third segment in the first data corresponding to the target problem to obtain deduplicated first data; Constructing a target segment set corresponding to each of the target problems; Adding the segments in the first data after deduplication corresponding to each target question to the corresponding target segment set; Looping through the following operations until all segments in the deduplicated first data corresponding to the target question are traversed, and outputting the target segment set corresponding to the target question as the first data of the target question; The operations include: Inputting the deduplicated first data excluding the currently traversed segment and the corresponding target question into the target model to obtain a third answer; scoring the third answer to obtain a third score; comparing the third score with the first score; If the third score is less than the first score, determining the currently traversed segment as the target segment; If the third score is greater than or equal to the first score, deleting the currently traversed segment in the target segment set corresponding to the target question; Continue traversing the next fragment in the target fragment set.

6. The model tuning method according to claim 1, characterized in that: Before optimizing the target model using the target dataset, the method further includes: Determining the number of target question-answer pairs in the target dataset; If the number of the target question-answer pairs is less than a preset threshold, the step of adopting the target model and determining the target question-answer pairs based on the first data and the initial question-answer pairs is re-executed.

7. A model tuning device, characterized in that: include: Acquisition module, used to obtain the initial data set; The initial data set includes multiple initial question-answer pairs; The initial question-answer pair includes an initial question and a corresponding initial answer; A retrieval module, configured to retrieve first data corresponding to each of the initial questions from a preset database; the first data being data related to the initial question; a determination module, configured to adopt a target model and determine a target question-answer pair based on the first data and the initial question-answer pair; The target question-answer pair includes a target question, the corresponding initial answer, and the corresponding first data; The target question refers to the corresponding initial question that the target model lacks an answer to; The acquisition module is also used to obtain the preset multiple; a sampling module, configured to oversample the target question-answer pair by the preset multiple to obtain a first question-answer pair; The sampling module is further configured to perform undersampling by the preset multiple on the initial question-answer pairs in the initial data set that are not determined to correspond to the target question, so as to obtain second question-answer pairs; The determination module is further configured to determine the first question-answer pair and the second question-answer pair as a target data set; the number of target questions included in the target data set is greater than the number of initial questions determined to correspond to the target questions in the initial data set; A tuning module is used to tune the target model using the target data set.

8. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the model tuning method according to any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the model tuning method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Classification model training method and device, electronic equipment and storage medium

    CN112560912A

  • Information search method and device, equipment, storage medium and program product

    CN119807368A