Data processing method and device
By retrieving and scoring models in the knowledge base, the problem of low response accuracy in the data processing model is solved, and the accuracy and efficiency of the response are improved by using the scoring model and language model.
Patent Information
- Application Number
- CN202411218288.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-31
- Publication Date
- 2024-12-03
AI Technical Summary
When existing data processing models use the knowledge base to output replies, the answer accuracy is low due to the different degree of correlation between the data and the problem in the knowledge base.
By retrieving matching target alternative data in the knowledge base and determining their scores using the scoring model, selecting the problem data module with the appropriate type, filtering out high-rated data to generate replies, including training of word embedding models and large language models, Adjust the dataset proportions and use the scoring adapter and dock model for scoring.
Improve the accuracy of the reply, ensure that the generated reply is more in line with user needs, and enhance the accuracy and efficiency of data processing.
Smart Images

Figure CN119066176A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data processing method and device. Background Art
[0002] With the development of information technology, some electronic devices are now able to use data processing models to analyze questions input by users and output answers to the questions in combination with the data contained in a pre-established knowledge base.
[0003] In the related art, when using a data processing model to output an answer, you can first search for data related to the question in the knowledge base based on the question, and then input the question and the data related to the question into the data processing model together to obtain an answer to the question.
[0004] The problem with this solution is that different data in the knowledge base have different degrees of relevance to questions. Inputting all the data related to the question into the data processing model will result in less accurate answers output by the model. Summary of the invention
[0005] To this end, this application discloses the following technical solutions:
[0006] The first aspect of the present application provides a data processing method, comprising:
[0007] Get problem data;
[0008] Retrieving a plurality of target candidate data matching the question data from a knowledge base according to the question data, the knowledge base including the plurality of candidate data obtained by processing a reference file;
[0009] Determine the score of each target candidate data by using a target output module of a scoring model, wherein the scoring model has a plurality of output modules for outputting scores, and the target output module is one of the plurality of output modules determined according to the type of the problem data;
[0010] The target candidate data whose corresponding scores meet the screening conditions are processed to obtain answer data corresponding to the question data.
[0011] Optionally, determining the target output module according to the type of the problem data includes:
[0012] Obtaining an evaluation data set corresponding to the type of the question data, the evaluation data set comprising sample question data and reference answer data corresponding to the sample question data;
[0013] Determining the accuracy of the plurality of output modules according to the evaluation data set;
[0014] A target output module is determined among the plurality of output modules according to the accuracies of the plurality of output modules.
[0015] Optionally, the candidate data of the knowledge base is obtained by processing the reference document with a word embedding model;
[0016] The training process of the word embedding model includes:
[0017] Obtaining a first data set, the first data set comprising first corpus data in a first language and second corpus data in a second language translated from the first corpus data;
[0018] Obtain word embedding model input data containing random noise according to the first data set;
[0019] The word embedding model is trained according to the word embedding model input data.
[0020] Optionally, the processing of the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data includes:
[0021] Using a large language model to process the target candidate data whose corresponding scores meet the screening conditions, to obtain answer data corresponding to the question data;
[0022] The training process of the large language model includes:
[0023] obtaining a second data set;
[0024] Performing weight decomposition low-rank adaptive training on the large language model according to the second data set;
[0025] Adjusting the proportions of data of different categories in the second data set to obtain an adjusted second data set;
[0026] Low-rank adaptive training is performed on the large language model according to the adjusted second data set.
[0027] Optionally, the scoring model includes a second base model and a scoring adapter, and the second base model and the scoring adapter both have multiple output modules;
[0028] The process of training the scoring model includes:
[0029] Training the output module of the second base model and the output module of the scoring adapter according to the third data set to obtain trained output modules;
[0030] The second base model including the trained output module and the scoring adapter including the trained output module are trained to obtain the scoring model.
[0031] Optionally, the candidate data of the knowledge base is obtained by processing the reference document with a word embedding model;
[0032] The processing of the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data includes:
[0033] Using a large language model to process the target candidate data whose corresponding scores meet the screening conditions, to obtain answer data corresponding to the question data;
[0034] The word embedding model includes a word embedding adapter, the scoring model includes a scoring adapter, and the large language model includes a first base model and a large language adapter;
[0035] The large language adapter is used to adjust the first base model to obtain the large language model;
[0036] The word embedding adapter is used to adjust the first base model to obtain the output of the word embedding model;
[0037] The scoring adapter is used to adjust the first base model to obtain the scoring model.
[0038] Optionally, also include:
[0039] Obtaining historical data, wherein the historical data includes determining the scores of each of the historical data using a target output module of a scoring model in the historical question data and the historical answer data;
[0040] The processing of the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data includes:
[0041] The target candidate data and the historical data whose corresponding scores satisfy the screening conditions are processed to obtain answer data corresponding to the question data.
[0042] Optionally, the target output module using the scoring model determines the score of each target candidate data, including:
[0043] When the data amount of the target candidate data is greater than the data amount threshold, compressing the target candidate data to obtain compressed target candidate data;
[0044] Determine the score of each of the compressed target candidate data using the target output module of the scoring model;
[0045] The processing of the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data includes:
[0046] The compressed target candidate data whose corresponding scores meet the screening conditions are processed to obtain answer data corresponding to the question data.
[0047] Optionally, the processing of the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data includes:
[0048] The prompt template and the target candidate data whose corresponding scores meet the screening conditions are input into the large language model, so that the large language model processes the target candidate data according to the prompt template to obtain the answer data corresponding to the question data, and the prompt template is used to indicate the processing method of the large language model.
[0049] A second aspect of the present application provides a data processing device, including:
[0050] An acquisition unit, used for acquiring question data;
[0051] A retrieval unit, configured to retrieve a plurality of target candidate data matching the question data from a knowledge base according to the question data, wherein the knowledge base includes a plurality of candidate data obtained by processing a reference file;
[0052] a determination unit, configured to determine the score of each target candidate data by using a target output module of a scoring model, wherein the scoring model has a plurality of output modules for outputting scores, and the target output module is one of the plurality of output modules determined according to the type of the problem data;
[0053] The processing unit is used to process the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0055] Figure 1 is a flow chart of a data processing method provided in an embodiment of the present application;
[0056] Figure 2 is a flow chart of another data processing method provided in an embodiment of the present application;
[0057] Figure 3 It is a schematic diagram of the fusion of an adapter and a base model provided in an embodiment of the present application;
[0058] Figure 4 It is a structural diagram of a data processing system provided in an embodiment of the present application;
[0059] Figure 5 It is a structural diagram of a data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0061] This application embodiment provides a data processing method, see Figure 1 , is a flow chart of the method, and the method may include the following steps.
[0062] S101, obtaining problem data.
[0063] Question data may be entered by the user.
[0064] The question data may include data in various forms, for example, any one or more of text data, audio data, video data and image data.
[0065] S102, searching a knowledge base according to the question data to obtain a plurality of target candidate data matching the question data, wherein the knowledge base includes a plurality of candidate data obtained by processing a reference file.
[0066] The knowledge base may be pre-established before executing S102. The knowledge base may be established in the following manner:
[0067] Obtain at least one reference document, divide the reference documents into multiple different parts, and then use a word embedding model to process the multiple parts of the divided reference documents, and convert each part into feature vector data representing the corresponding content. Different parts correspond to different feature vector data. A set of multiple feature vector data can be used as a knowledge base. These feature vector data are equivalent to the alternative data of step S102.
[0068] The method of segmenting the reference file can be referred to in the related art, which will not be described in detail. As an example, when the reference file includes a document, the layout and table detector and text recognition technology in the related art can be used to process the document, thereby segmenting the document into multiple parts.
[0069] Optionally, when each part of the reference document contains a lot of content, a data processing model that can understand the file content (such as a large language model) can be used to extract the content summary of each part, and then the content summary is processed using a word embedding model to obtain the feature vector data corresponding to each part.
[0070] Based on the constructed knowledge base, multiple candidate data contained in the knowledge base may be compared with the problem data in S102, and the candidate data matching the problem data may be determined as the target candidate data.
[0071] The comparison method can be to process the question data with a word embedding model to obtain question vector data that represents the content of the question data, and then calculate the similarity between the question vector data and multiple alternative data in the knowledge base. If the similarity between an alternative data and the question vector data is greater than a certain threshold, it is determined that the alternative data and the question data match.
[0072] See also Figure 2 In some embodiments, if target candidate data matching the problem data cannot be retrieved in the knowledge base, a search tool can be used to search for text, video, image and other data related to the problem data on the Internet, and then the searched related data can be processed in the same manner as the reference file, and the processed feature vector data can be determined as the target candidate data.
[0073] S103, using the target output module of the scoring model to determine the score of each target candidate data, the scoring model has multiple output modules for outputting scores, and the target output module is one of the multiple output modules determined according to the type of the problem data.
[0074] In this embodiment, the scoring model can be used to process each target candidate data to obtain a score for each target candidate data. The score of the target candidate data can represent the role of the target candidate data in answering the question data. The higher the score, the greater the role of the corresponding target candidate data in generating the answer data, and the lower the score, the smaller the role of the corresponding target candidate data in generating the answer data.
[0075] As an example, the question data may be "Please recommend several laptops with strong gaming performance", and the target candidate data retrieved in S102 may include "A laptop is a portable computer device that usually includes a touchpad and a flip screen", "Among the current mainstream laptops, XX model and YY model laptops of a certain brand have strong gaming performance". After being processed by the scoring model, it can be determined that the score of the former target candidate data is lower, and the score of the latter target candidate data is higher.
[0076] The scoring model may have multiple output modules for outputting scores, and each output module may output scores corresponding to the target candidate data. For the same target candidate data and question data, the scores output by different output modules may be different.
[0077] When it is necessary to output a score, a target output module suitable for the current question data can be selected from multiple output modules according to the type of question data, and the target candidate data can be processed using this output module to obtain the score corresponding to the target candidate data.
[0078] Optionally, the process of determining the target output module may include the following steps:
[0079] A1, obtaining an evaluation data set corresponding to the type of question data, the evaluation data set including sample question data and reference answer data corresponding to the sample question data;
[0080] A2, determine the accuracy of multiple output modules based on the evaluation data set;
[0081] A3, determining a target output module from among the multiple output modules according to the accuracies of the multiple output modules.
[0082] In step A1, multiple evaluation data sets may be pre-established, each of which corresponds to a type of problem data. The types of problem data may be divided from multiple dimensions.
[0083] For example, the above-mentioned evaluation data sets may include English-type evaluation data sets and Chinese-type evaluation data sets, may include humanities and social sciences-type evaluation data sets and natural sciences-type evaluation data sets, may include game-type evaluation data sets and clothing and accessories-type evaluation data sets, etc.
[0084] Each evaluation data set may include at least one sample question data and reference answer data corresponding to each sample question data, and these reference answer data may be obtained by manual editing.
[0085] After obtaining the question data, a data processing model (such as a large language model) with question analysis and understanding capabilities can be used to analyze the type of the question data, and then an evaluation data set corresponding to the type is selected from multiple pre-established evaluation data sets to execute step A2.
[0086] For example, if the question data belongs to the humanities and social sciences type, then step A2 is performed according to the evaluation data set of the humanities and social sciences type; if the question data belongs to the game type, then step A2 is performed according to the evaluation data set of the game type.
[0087] In step A2, for any output module X, matching alternative data can be retrieved in the knowledge base based on the sample question data, and the retrieved alternative data can be processed according to the output module X to obtain scores of these alternative data. The alternative data whose scores meet the screening conditions are processed to obtain sample answer data corresponding to the sample question data, and then the sample answer data and the reference answer data are compared, and the similarity between the two is determined as the accuracy of the output module X.
[0088] By processing the sample problem data according to the multiple output modules in the above manner, the accuracies corresponding to the multiple output modules can be obtained.
[0089] Optionally, the accuracy of the output module can also be determined as follows:
[0090] For each sample question data, after retrieving the alternative data related to the sample data from the knowledge base, the reference scores of these alternative data are determined through manual labeling or other trained model scoring methods, and then these alternative data are processed according to the output module to obtain the output module scores corresponding to these alternative data. The similarity between the reference scores corresponding to each sample data and the output module scores is determined as the accuracy of the output module.
[0091] In step A3, the output module with the highest accuracy among the multiple output modules may be determined as the target output module.
[0092] S104, processing the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data.
[0093] The screening condition may include that the corresponding score is greater than a certain score threshold. In this case, the question data and each target candidate data with a score greater than the score threshold may be processed to obtain the response data.
[0094] The screening conditions may also include corresponding scores for data with higher scores among the target candidate data. In this case, the target candidate data may be sorted from large to small according to the scores, and the top N target candidate data may be determined as the target candidate data that meet the screening conditions. The question data and the top N target candidate data may be processed to obtain the reply data.
[0095] The beneficial effects of this embodiment are:
[0096] When generating reply data, the retrieved target candidate data are processed using a target output module adapted to the type of question data to obtain scores for the target candidate data, and then reply data are generated based on the target candidate data whose scores meet the screening conditions. This helps to filter out target candidate data that have less effect on answering the question in the retrieved target candidate data, thereby improving the accuracy of the generated reply data and making the reply data more in line with the needs of the user who asked the question.
[0097] In the above embodiment, the training process of the word embedding model includes:
[0098] Obtaining a first data set, the first data set comprising first corpus data in a first language and second corpus data in a second language translated from the first corpus data;
[0099] Obtain word embedding model input data containing random noise according to the first data set;
[0100] The word embedding model is trained based on the word embedding model input data.
[0101] In this embodiment, any open source data processing model can be selected as the initial model, and the initial model is trained in the above manner to obtain a word embedding model.
[0102] As an example, the Bge-large model, the BCE embedding model, or the Qwen 1.5chat model can be selected as the initial model.
[0103] The first dataset can be obtained as follows:
[0104] Obtain an open source dataset containing the first corpus data. For example, if the first language is English, you can obtain open source datasets containing English corpus such as MLDF, bge-m3-data, and msmarco passage ranking;
[0105] Then, a portion of the first corpus data in the data set is translated from the first language to the second language, thereby obtaining second corpus data. The translated second corpus data and the first corpus data in the open source data set constitute the first data set.
[0106] After obtaining the first data set, randomly generated noise data may be added to each first corpus data and second corpus data contained in the first data set to obtain word embedding model input data containing the noise data.
[0107] For example, random English words are added to the English corpus, and random Chinese phrases, words, or phrases are added to the Chinese corpus.
[0108] After obtaining the word embedding model input data, the word embedding model input data can be used to train the initial model to obtain a word embedding model. The training method can be found in relevant technical information and will not be described in detail in this embodiment.
[0109] Optionally, when training the word embedding model, the training can be based on the Low-Rank Adaptation (LoRA) technology, and the training parameters can be configured as batchsize=8, 2 epochs to end the training, lora_rank=32, lora_alpha=64.
[0110] Among them, batchsize represents the number of samples used in each training, epoch represents the iterative process, and an iterative process may include the process of the model processing batchsize samples and obtaining the corresponding processing results. lora_rank represents the dimension of the parameters trained based on LoRA technology, and lora_alpha represents the degree of influence of the parameters trained based on LoRA technology on the output results of the model.
[0111] The beneficial effects of this embodiment are:
[0112] When training a word embedding model, random noise data is added to the corpus data used for training. This method can improve the generalization ability of the trained word embedding model and enable the word embedding model to handle a variety of complex data.
[0113] See also Figure 2 In this embodiment, a large language model may be used to process the question data and target candidate data that meet the screening conditions to obtain the answer data corresponding to the question data. That is, step S104 may include:
[0114] The large language model is used to process the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data.
[0115] The above large language model for generating reply data can be trained as follows:
[0116] obtaining a second data set;
[0117] Perform weight decomposition low-rank adaptive training on the large language model according to the second data set;
[0118] Adjusting the proportions of data of different categories in the second data set to obtain an adjusted second data set;
[0119] The large language model is trained with low rank adaptive training based on the adjusted second dataset.
[0120] In the above training process, any open source data processing model with dialogue capability can be selected as the initial model for training. For example, the qwen1.5-7B-chat model can be selected as the initial model.
[0121] The second data set may include an open source conversation data set, may also include historical question data and corresponding historical answer data obtained in the past, and may also include conversation data obtained through a search engine search.
[0122] After obtaining the second data set, the second data set can be used to train the initial model based on the Weight-Decomposed Low-Rank Adaptation (DoRA) technique.
[0123] During training, the number of iterations can be set to 3, that is, the training ends after executing 3 iterations, and the batchsize of samples used in each training can be set to 8.
[0124] After the above training is completed, the proportions of data of different categories in the second data set can be adjusted to obtain the second data set.
[0125] The adjustment method may be to divide the sample data contained in the second data set into four categories: long questions and long answers, short questions and short answers, long questions and short answers, and short questions and long answers. Long questions and long answers refer to the lengths of questions and answers in the sample data being greater than a specific first length threshold; short questions and short answers refer to the lengths of questions and answers in the sample data being less than a specific second length threshold; long questions and short answers refer to the lengths of questions in the sample data being greater than the first length threshold, and the lengths of answers being less than the second length threshold; short questions and long answers refer to the lengths of questions in the sample data being less than the second length threshold, and the lengths of answers being greater than the first length threshold.
[0126] The first length threshold and the second length threshold can be set as needed, and the two can be equal or unequal.
[0127] After dividing into multiple categories, the proportions of sample data of multiple categories in the second data set may be adjusted so that the proportions of sample data of different categories in the second data set after adjustment meet specific proportion conditions.
[0128] As an example, the sample data of the above four categories can be adjusted to each account for 1 / 4 of the total sample volume by increasing the samples of the short question and short answer categories and reducing the samples of the long question and short answer categories. The data set thus obtained is used as the adjusted second data set.
[0129] Then, according to the adjusted second data set, the model trained in the previous step is continued to be trained based on the LoRA technology to obtain a large language model for generating reply data in this embodiment. When training based on the LoRA technology, the number of iterative processes can be 2, and the number of samples used for training batchsize can be set to 8.
[0130] Optionally, the scoring model may include a second base model and a scoring adapter, wherein the second base model and the scoring adapter each have a plurality of output modules;
[0131] The process of training a scoring model can include:
[0132] The output module of the second base model and the output module of the scoring adapter are trained according to the third data set to obtain a trained output module;
[0133] The second base model including the trained output module and the scoring adapter including the trained output module are trained to obtain a scoring model.
[0134] In this embodiment, the data set used to train the scoring model may include open source data sets such as bge-m3-data, quoratrain data, and fevertrain data.
[0135] The second base model may be any common data processing model, for example, Qwen1.5-7B-Chat.
[0136] The scoring adapter can be used to adjust the second base model so that the second base model has the function of scoring the target candidate data.
[0137] See the method for adjusting the second base model with the scoring adapter. Figure 3 .
[0138] like Figure 3 As shown, both the second base model and the scoring adapter include multiple linear layers. When it is necessary to obtain the score of the target candidate data, the target candidate data can be input into the second base model. At this time, the linear layer of the second base model and the linear layer of the scoring adapter are used together to process the input data, and the final result is the score of the target candidate data.
[0139] Multiple output modules of the scoring model can be added to the linear layers of the second base model and the scoring adapter. For example, an output module (head) can be added to each layer starting from the 12th layer of the second base model, and an output module can also be added to each layer of the adapter.
[0140] When the scoring model is used to determine the scores of the target candidate data, the target output module among the output modules may be determined in the aforementioned manner, and then the target candidate data that meets the conditions may be screened according to the scores of the target output modules.
[0141] The above training processes can all be carried out based on LoRA technology.
[0142] In some optional embodiments, the scoring model as a whole, that is, the second base model including the output module and the scoring adapter including the output module, may also be directly trained to obtain the scoring model.
[0143] Optionally, the entire scoring model may be directly trained first. If it is found that the scoring model cannot converge when trained in this way, the output module may be trained first and then the second base model and the adapter may be trained in the aforementioned manner.
[0144] In some optional embodiments, Figure 2 The word embedding model, large language model, and scoring model shown can share a base model. That is, when training the word embedding model, large language model, and scoring model, the adapters corresponding to these models can be trained.
[0145] Among them, the word embedding model may include a word embedding adapter, the scoring model may include a scoring adapter, and the large language model may include a first base model and a large language adapter.
[0146] Each adapter is used to adjust the corresponding first base model so that the base model has the capabilities of the corresponding adapter.
[0147] The first base model may be a general data processing model, such as a Qwen1.5-7B-Chat model.
[0148] In this case, when it is necessary to retrieve the target candidate data, the first base model can be adjusted using a word embedding adapter so that the first base model has the functions of the aforementioned word embedding model, and then the aforementioned steps of retrieving the target candidate data are implemented based on the first base model and the word embedding adapter.
[0149] When it is necessary to determine the score of the target candidate data, the first base model can be adjusted with a scoring adapter so that the first base model has the functions of the aforementioned scoring model, and then the score of the target candidate data is determined based on the first base model and the scoring adapter.
[0150] When it is necessary to generate answer data corresponding to the question data, the first base model can be adjusted using a large language adapter so that the first base model has the function of generating answer data. Then, the question data and target candidate data that meet the conditions are processed based on the first base model and the large language adapter to obtain answer data.
[0151] The method of adjusting the base model based on the adapter can refer to the method of adjusting the second base model based on the scoring adapter in the aforementioned embodiment, which will not be described in detail.
[0152] The beneficial effects of this embodiment are:
[0153] The data volume of the adapter is generally much smaller than the data volume of the base model. Sharing a base model and implementing different functions based on the base model and different adapters can significantly reduce the storage space occupied when applying the method of this embodiment.
[0154] Optionally, the data processing method of this embodiment may further include the following steps:
[0155] Obtain historical data, including historical question data and historical answer data
[0156] The target output module of the scoring model is used to determine the score of each historical data.
[0157] The historical data includes historical question data input by the same user obtained before obtaining the question data in S101, and historical answer data generated according to the method of this embodiment for these historical question data. Each piece of historical data may include a historical question data and corresponding historical answer data.
[0158] In the case of determining the score of the historical data, the step S104 of generating the reply data in the above embodiment may include:
[0159] The target candidate data and historical data whose corresponding scores meet the screening conditions are processed to obtain the answer data corresponding to the question data.
[0160] The screening conditions for historical data can refer to the screening conditions for target candidate data in the aforementioned embodiment, which will not be described in detail.
[0161] When generating reply data, the target candidate data and historical data that meet the screening conditions, as well as the question data obtained in S101, can be input into the large language model used to generate reply data, and the reply data is generated after being processed by the large language model.
[0162] The beneficial effects of this embodiment are:
[0163] The historical data is combined to generate a response to the current question data, thereby enhancing the correlation between the response data generated during multiple questions and answers and the historical data.
[0164] Optionally, the target output module of the scoring model is used to determine the score of each target candidate data, including:
[0165] When the data volume of the target candidate data is greater than the data volume threshold, compressing the target candidate data to obtain compressed target candidate data;
[0166] The target output module of the scoring model is used to determine the score of each compressed target candidate data.
[0167] The data volume threshold can be determined based on the processing capabilities of the scoring model and the large language model used to generate the response data. For example, when the amount of input data is greater than a certain value, the processing time of the scoring model and the large language model increases significantly, and the value can be determined as the data volume threshold.
[0168] The target candidate data may be compressed in the following manner:
[0169] The scoring model generates a summary of the target candidate data according to the content of the target candidate data, and determines the summary as the compressed target filing data obtained after compression.
[0170] In the case of obtaining compressed target candidate data, the step S104 of generating reply data in the aforementioned embodiment may include:
[0171] The compressed target candidate data whose corresponding scores meet the screening conditions are processed to obtain the answer data corresponding to the question data.
[0172] In the above embodiment, the compressed target candidate data and question data that meet the screening conditions can be input into the large language model together, and processed by the large language model to generate corresponding answer data.
[0173] Determining the scoring and response data based on the compressed target candidate data can reduce the amount of data that needs to be processed when scoring and generating response data, thereby improving processing efficiency and saving computing resources.
[0174] Optionally, when processing the target candidate data whose corresponding scores meet the filtering conditions and obtaining the reply data corresponding to the question data, the prompt template and the corresponding target candidate data whose scores meet the filtering conditions can also be input into the large language model, so that the large language model processes the target candidate data according to the prompt template to obtain the reply data corresponding to the question data. The prompt template is used to instruct the processing method of the large language model.
[0175] For example, a prompt template may instruct a large language model to generate response data in one or more of the following ways:
[0176] Prioritize obtaining target candidate data from the knowledge base, and then search for data from the Internet through search tools when target candidate data cannot be retrieved from the knowledge base;
[0177] Combine historical data to generate response data;
[0178] The generated answer data and the input question data are kept in the same language;
[0179] The generated response data does not contain specific phrases;
[0180] When accurate answer data cannot be generated based on the question data, answer data for prompting the user to input more information may be generated.
[0181] The data processing method of this embodiment can be Figure 4 The data processing system shown implements.
[0182] The system can obtain a reference document, and then process the reference document using a document understanding model with document understanding capabilities to obtain a document summary corresponding to the reference document. After the document summary is processed by a word embedding model to obtain corresponding candidate data, the candidate data is stored in a knowledge base.
[0183] After obtaining the question data, on the one hand, a prompt template can be added to the question data, and then the question data with the prompt template added can be output to a large language model for generating answer data.
[0184] On the other hand, a word embedding model can be used to retrieve target candidate data that matches the question data in the knowledge base according to the method of the aforementioned embodiment, and then the target candidate data can be screened using a scoring model to obtain target candidate data that meet the screening conditions, and the target candidate data that meet the screening conditions can also be input into the large language model. Thus, the large language model can generate response data based on the input target candidate data that meet the screening conditions and the question data with a prompt template.
[0185] The generated answer data and the corresponding question data may be stored as historical data in a history database.
[0186] The word embedding model, the scoring model and the large language model can be integrated with each other, that is, the three can share a first base model, and by applying different adapters, such as the aforementioned word embedding adapter, the scoring adapter and the large language adapter, the first base model has corresponding processing capabilities.
[0187] When the large language model is working, you can use the search tool to search for data from the Internet according to the instructions of the prompt template, and generate reply data based on the searched data. You can also obtain historical data stored in the historical database according to the instructions of the prompt template, and generate reply data based on the historical data.
[0188] In addition, when detecting target candidate data, if target candidate data matching the problem data cannot be retrieved in the knowledge base, a search tool can be used to search for target candidate data matching the problem data on the Internet.
[0189] The present application also provides a data processing device. Figure 5 , is a schematic diagram of the device, and the device may include the following units.
[0190] An obtaining unit 501 is used to obtain question data;
[0191] A retrieval unit 502 is used to retrieve a plurality of target candidate data matching the question data from a knowledge base according to the question data, wherein the knowledge base includes a plurality of candidate data obtained by processing a reference file;
[0192] A determination unit 503 is used to determine the score of each target candidate data by using a target output module of the scoring model, the scoring model has multiple output modules for outputting scores, and the target output module is one of the multiple output modules determined according to the type of the question data;
[0193] The processing unit 504 is used to process the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data.
[0194] Optionally, when the determination unit 503 determines the target output module according to the type of the problem data, it can be used to:
[0195] Obtaining an evaluation data set corresponding to the type of question data, the evaluation data set including sample question data and reference answer data corresponding to the sample question data;
[0196] Determine the accuracy of multiple output modules based on the evaluation data set;
[0197] A target output module is determined among the plurality of output modules according to the accuracies of the plurality of output modules.
[0198] Optionally, candidate data of the knowledge base is obtained by processing reference documents by a word embedding model;
[0199] The training process of the word embedding model includes:
[0200] Obtaining a first data set, the first data set comprising first corpus data in a first language and second corpus data in a second language translated from the first corpus data;
[0201] Obtain word embedding model input data containing random noise according to the first data set;
[0202] The word embedding model is trained based on the word embedding model input data.
[0203] Optionally, when the processing unit 504 processes the target candidate data whose corresponding scores meet the screening conditions and obtains the answer data corresponding to the question data, it can be used to:
[0204] Use the large language model to process the target candidate data whose scores meet the screening conditions, and obtain the answer data corresponding to the question data;
[0205] The training process of a large language model includes:
[0206] obtaining a second data set;
[0207] Perform weight decomposition low-rank adaptive training on the large language model according to the second data set;
[0208] Adjusting the proportions of data of different categories in the second data set to obtain an adjusted second data set;
[0209] The large language model is trained with low rank adaptive training based on the adjusted second dataset.
[0210] Optionally, the scoring model includes a second base model and a scoring adapter, and the second base model and the scoring adapter both have multiple output modules;
[0211] The process of training a scoring model includes:
[0212] The output module of the second base model and the output module of the scoring adapter are trained according to the third data set to obtain a trained output module;
[0213] The second base model including the trained output module and the scoring adapter including the trained output module are trained to obtain a scoring model.
[0214] Optionally, candidate data of the knowledge base is obtained by processing reference documents by a word embedding model;
[0215] When the processing unit 504 processes the target candidate data whose corresponding scores meet the screening conditions and obtains the answer data corresponding to the question data, it can be used for:
[0216] Use the large language model to process the target candidate data whose scores meet the screening conditions, and obtain the answer data corresponding to the question data;
[0217] The word embedding model includes a word embedding adapter, the scoring model includes a scoring adapter, and the large language model includes a first base model and a large language adapter;
[0218] The large language adapter is used to adjust the first base model to obtain a large language model;
[0219] The word embedding adapter is used to adjust the first base model to obtain the output of the word embedding model;
[0220] The scoring adapter is used to adjust the first base model to obtain a scoring model.
[0221] Optionally, the determining unit 503 is further configured to:
[0222] Obtain historical data, including historical question data and historical answer data
[0223] Determine the score of each historical data using the target output module of the scoring model;
[0224] When the processing unit 504 processes the target candidate data whose corresponding scores meet the screening conditions and obtains the answer data corresponding to the question data, it can be used for:
[0225] The target candidate data and historical data whose corresponding scores meet the screening conditions are processed to obtain the answer data corresponding to the question data.
[0226] Optionally, when the determination unit 503 determines the score of each target candidate data using the target output module of the scoring model, it can be used to:
[0227] When the data volume of the target candidate data is greater than the data volume threshold, compressing the target candidate data to obtain compressed target candidate data;
[0228] Determine the score of each compressed target candidate data using the target output module of the scoring model;
[0229] When the processing unit 504 processes the target candidate data whose corresponding scores meet the screening conditions and obtains the answer data corresponding to the question data, it can be used for:
[0230] The compressed target candidate data whose corresponding scores meet the screening conditions are processed to obtain the answer data corresponding to the question data.
[0231] Optionally, when the processing unit 504 processes the target candidate data whose corresponding scores meet the screening conditions and obtains the answer data corresponding to the question data, it can be used to:
[0232] The prompt template and the corresponding target candidate data whose scores meet the screening conditions are input into the large language model, so that the large language model processes the target candidate data according to the prompt template to obtain the answer data corresponding to the question data. The prompt template is used to instruct the large language model on the processing method.
[0233] The working principle of the data processing device of this embodiment can be found in the relevant steps of the data processing method provided in any embodiment of the present application, and will not be described in detail again.
[0234] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0235] For the convenience of description, the above system or device is described by dividing it into various modules or units according to its functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0236] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.
[0237] Finally, it should be noted that, in this article, relational terms such as first, second, third and fourth are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0238] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A data processing method, comprising: Get problem data; Retrieving a plurality of target candidate data matching the question data from a knowledge base according to the question data, the knowledge base including the plurality of candidate data obtained by processing a reference file; Determine the score of each target candidate data by using a target output module of a scoring model, wherein the scoring model has a plurality of output modules for outputting scores, and the target output module is one of the plurality of output modules determined according to the type of the problem data; The target candidate data whose corresponding scores meet the screening conditions are processed to obtain answer data corresponding to the question data.
2. The method according to claim 1, determining the target output module according to the type of the problem data, comprising: Obtaining an evaluation data set corresponding to the type of the question data, the evaluation data set comprising sample question data and reference answer data corresponding to the sample question data; Determining the accuracy of the plurality of output modules according to the evaluation data set; A target output module is determined among the plurality of output modules according to the accuracies of the plurality of output modules.
3. According to the method of claim 1, the candidate data of the knowledge base is obtained by processing the reference document by a word embedding model; The training process of the word embedding model includes: Obtaining a first data set, the first data set comprising first corpus data in a first language and second corpus data in a second language translated from the first corpus data; Obtain word embedding model input data containing random noise according to the first data set; The word embedding model is trained according to the word embedding model input data.
4. According to the method of claim 1, the processing of the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data comprises: Using a large language model to process the target candidate data whose corresponding scores meet the screening conditions, to obtain answer data corresponding to the question data; The training process of the large language model includes: obtaining a second data set; Performing weight decomposition low-rank adaptive training on the large language model according to the second data set; Adjusting the proportions of data of different categories in the second data set to obtain an adjusted second data set; Low-rank adaptive training is performed on the large language model according to the adjusted second data set.
5. The method according to claim 1, wherein the scoring model comprises a second base model and a scoring adapter, wherein the second base model and the scoring adapter each have a plurality of output modules; The process of training the scoring model includes: Training the output module of the second base model and the output module of the scoring adapter according to the third data set to obtain trained output modules; The second base model including the trained output module and the scoring adapter including the trained output module are trained to obtain the scoring model.
6. The method according to claim 1, wherein the candidate data of the knowledge base is obtained by processing the reference document by a word embedding model; The processing of the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data includes: Using a large language model to process the target candidate data whose corresponding scores meet the screening conditions, to obtain answer data corresponding to the question data; The word embedding model includes a word embedding adapter, the scoring model includes a scoring adapter, and the large language model includes a first base model and a large language adapter; The large language adapter is used to adjust the first base model to obtain the large language model; The word embedding adapter is used to adjust the first base model to obtain the output of the word embedding model; The scoring adapter is used to adjust the first base model to obtain the scoring model.
7. The method according to claim 1, further comprising: Obtaining historical data, the historical data including historical question data and historical answer data Determine the score of each of the historical data using the target output module of the scoring model; The processing of the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data includes: The target candidate data and the historical data whose corresponding scores satisfy the screening conditions are processed to obtain answer data corresponding to the question data.
8. The method according to claim 1, wherein the step of determining the score of each target candidate data by using the target output module of the scoring model comprises: When the data amount of the target candidate data is greater than the data amount threshold, compressing the target candidate data to obtain compressed target candidate data; Determine the score of each of the compressed target candidate data using the target output module of the scoring model; The processing of the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data includes: The compressed target candidate data whose corresponding scores meet the screening conditions are processed to obtain answer data corresponding to the question data.
9. The method according to claim 1, wherein the processing of the target candidate data corresponding to the scores that meet the screening conditions to obtain the answer data corresponding to the question data comprises: The prompt template and the target candidate data whose corresponding scores meet the screening conditions are input into the large language model, so that the large language model processes the target candidate data according to the prompt template to obtain the answer data corresponding to the question data, and the prompt template is used to indicate the processing method of the large language model.
10. A data processing device, comprising: An acquisition unit, used for acquiring question data; A retrieval unit, configured to retrieve a plurality of target candidate data matching the question data from a knowledge base according to the question data, wherein the knowledge base includes a plurality of candidate data obtained by processing a reference file; a determination unit, configured to determine the score of each target candidate data by using a target output module of a scoring model, wherein the scoring model has a plurality of output modules for outputting scores, and the target output module is one of the plurality of output modules determined according to the type of the problem data; The processing unit is used to process the target candidate data whose corresponding scores meet the screening conditions to obtain the answer data corresponding to the question data.
Citation Information
Patent Citations
Question processing method and device based on knowledge base, equipment, medium and product
CN112966089A
Retrieval method and device of knowledge base and storage medium
CN116756295A
E-commerce customer service question answering method and device, equipment and medium
CN117131180A
Text matching method and device in question and answer system
CN117421410A
Intelligent question and answer method and device, storage medium and intelligent equipment
CN118349650A
