Question answering model training method, text processing method and reward model training method

By using thought chain data to update sample questions in question and answer model training, and using the reward model to optimize score parameters, the problem that the reward model is difficult to accurately reflect the quality of the environment is solved, and the model training accuracy and prediction performance are improved.

CN118350463BActive Publication Date: 2024-09-27HUNDSUN TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410779372.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-17
Publication Date
2024-09-27
Estimated Expiration
2044-06-17

AI Technical Summary

Technical Problem

In the existing technology, the reward model in the reinforcement learning process is difficult to accurately reflect the quality of the environment, resulting in poor prediction performance of large models. An effective solution is urgently needed to improve the accuracy of model training.

Method used

By extracting the thought chain data of the sample question from the question and answer sample pair, updating it to the target sample question, and using the initial question and answer model and reward model for training, and adjusting the parameters of the model based on the optimization score until the training stop condition is obtained. Target question answering model.

Benefits of technology

It is possible to update sample questions through thought chain data so that they carry richer text information, and the reward model can give accurate scores, thus improving the training accuracy and prediction performance of the question and answer model to meet the needs of downstream business use.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118350463B
    Figure CN118350463B
Patent Text Reader

Abstract

The embodiments of this specification provide a question-answering model training method, a text processing method, and a reward model training method, wherein the question-answering model training method includes: extracting a sample question from a question-answering sample pair, and determining the thinking chain data corresponding to the sample question; using the thinking chain data to update the sample question to a target sample question, and inputting the target sample question into an initial question-answering model for processing to obtain a predicted answer; using a reward model associated with the initial question-answering model to score the predicted answer according to the sample answers in the question-answering sample pair to obtain an optimized score; adjusting the parameters of the initial question-answering model based on the optimized score until a target question-answering model that meets the training stop condition is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of machine learning technology, and in particular to a question-answering model training method, a text processing method, and a reward model training method. Background Art

[0002] With the development of computer technology, large models are being applied in more and more scenarios. This type of model can achieve satisfactory results for users on various tasks by using a large amount of data and computing resources. For example, text generation, text classification, named entity recognition, sentiment analysis, etc. can all be achieved through trained large models. In the prior art, reinforcement learning is a key part in the training process of large models; reinforcement learning, as a machine learning method, can learn and optimize the model by interacting with the environment and according to the rewards given by the environment. However, the bottleneck in the reinforcement learning process lies in the reward model. As the key to reinforcement learning, the reward model determines the reward obtained by the model after taking an action in the environment. If the reward model can accurately reflect the degree of good or bad action, reinforcement learning can effectively optimize the large model. However, due to the complexity of the actual application environment, it is difficult for the reward model to accurately reflect the quality of the current environment, resulting in the large model optimized on this basis not having better prediction performance. Therefore, an effective solution is urgently needed to solve the above problems. Summary of the invention

[0003] In view of this, the embodiments of this specification provide a question-answering model training method. One or more embodiments of this specification also relate to a text processing method, a reward model training method, a question-answering model training device, a text processing device, a reward model training device, a computing device, a computer-readable storage medium, and a computer program product to solve the technical defects existing in the prior art.

[0004] According to a first aspect of an embodiment of this specification, a question-answering model training method is provided, comprising:

[0005] Extracting sample questions from the question-answer sample pairs, and determining the thinking chain data corresponding to the sample questions;

[0006] Using the thought chain data, the sample question is updated to a target sample question, and the target sample question is input into an initial question-answering model for processing to obtain a predicted answer;

[0007] Using the reward model associated with the initial question-answer model, scoring the predicted answer according to the sample answers in the question-answer sample pair to obtain an optimized score;

[0008] The initial question-answering model is adjusted based on the optimization score until a target question-answering model that meets the training stop condition is obtained.

[0009] According to a second aspect of the embodiments of this specification, a text processing method is provided, including:

[0010] Receive question text uploaded by the client;

[0011] Determine the question domain information corresponding to the question text, and select a target question-answering model that matches the question domain information, wherein the target question-answering model is obtained by the question-answering model training method;

[0012] The question text is input into the target question-answering model for processing to obtain an answer text, and the answer text is fed back to the client.

[0013] According to a third aspect of an embodiment of this specification, a reward model training method is provided, including:

[0014] Obtain a reward sample and a score vector sample sequence corresponding to the reward sample, wherein the score vector sample sequence includes a standard score vector corresponding to each word unit in the reward sample;

[0015] Inputting the reward sample into the initial reward model for scoring to obtain a score vector prediction sequence, wherein the score vector prediction sequence includes a predicted score vector corresponding to each word unit in the reward sample;

[0016] Determining a target loss function preset by the initial reward model, wherein the target loss function includes a vector constraint term constraining a target score vector;

[0017] The target loss function is used to calculate the score vector sample sequence and the score vector prediction sequence, and the initial reward model is adjusted according to the calculation results until a reward model that meets the reward training stop condition is obtained.

[0018] According to a fourth aspect of an embodiment of this specification, a question-answering model training device is provided, comprising:

[0019] An extraction module is configured to extract sample questions from the question-answer sample pairs and determine the thought chain data corresponding to the sample questions;

[0020] An updating module is configured to update the sample question to a target sample question using the thought chain data, and input the target sample question into an initial question-answering model for processing to obtain a predicted answer;

[0021] A scoring module is configured to score the predicted answer according to the sample answers in the question and answer sample pairs using the reward model associated with the initial question and answer model to obtain an optimized score;

[0022] A parameter adjustment module is configured to adjust the parameters of the initial question-answering model based on the optimization score until a target question-answering model that meets the training stop condition is obtained.

[0023] According to a fifth aspect of the embodiments of this specification, there is provided a text processing device, including:

[0024] A receiving module is configured to receive question text uploaded by the client;

[0025] A determination module is configured to determine the question domain information corresponding to the question text, and select a target question-answering model that matches the question domain information, wherein the target question-answering model is obtained by the question-answering model training method;

[0026] The sending module is configured to input the question text into the target question-answering model for processing, obtain the answer text, and feed back the answer text to the client.

[0027] According to a sixth aspect of the embodiments of this specification, a reward model training device is provided, comprising:

[0028] A sample acquisition module is configured to acquire a reward sample and a score vector sample sequence corresponding to the reward sample, wherein the score vector sample sequence includes a standard score vector corresponding to each word unit in the reward sample;

[0029] A scoring sample module is configured to input the reward sample into an initial reward model for scoring, and obtain a score vector prediction sequence, wherein the score vector prediction sequence includes a predicted score vector corresponding to each word unit in the reward sample;

[0030] A determination function module is configured to determine a target loss function preset by the initial reward model, wherein the target loss function includes a vector constraint term constraining a target score vector;

[0031] The parameter adjustment model module is configured to use the target loss function to calculate the score vector sample sequence and the score vector prediction sequence, and adjust the parameters of the initial reward model according to the calculation results until a reward model that meets the reward training stop condition is obtained.

[0032] According to a seventh aspect of an embodiment of this specification, there is provided a computing device, including:

[0033] Memory and processor;

[0034] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the above-mentioned question-and-answer model training method, text processing method or reward model training method are implemented.

[0035] According to an eighth aspect of an embodiment of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, which, when executed by a processor, implement the steps of the above-mentioned question-and-answer model training method, text processing method or reward model training method.

[0036] According to the ninth aspect of the embodiments of this specification, a computer program product is provided, including a computer program or instructions, which, when executed by a processor, implement the steps of the above-mentioned question-and-answer model training method, text processing method or reward model training method.

[0037] The question-answering model training method provided in the present embodiment can first extract sample questions from the question-answering sample pairs and determine the thinking chain data corresponding to the sample questions in order to accurately reflect the prediction accuracy of the question-answering model after the current sample pair is trained through the reward model during the question-answering model training process. On this basis, in order to enable short questions and answers to still strengthen the training question-answering model, the sample questions can be updated to target sample questions using the thinking chain data at this time, so that more text content can be reflected through the target sample questions. After that, the target sample questions can be input into the initial question-answering model for processing to obtain predicted answers. On this basis, since the sample questions are updated to target sample questions, the reward model can give a score that can accurately reflect the model prediction accuracy when scoring the model prediction accuracy, that is, the predicted answers are scored according to the sample answers in the question-answering sample pairs using the reward model associated with the initial question-answering model to obtain the optimized score. Finally, the initial question-answering model is adjusted based on the optimized score until the target question-answering model that meets the training stop condition is obtained. In the reinforcement learning stage of the question-answering model, the sample questions can be updated through the thinking chain data, so that the sample questions carry richer text information. After being predicted by the question-answering model, the reward model can give more accurate scores for the sample questions, thereby accurately reflecting the degree to which the question-answering model needs to be optimized through the scoring results. Subsequent training based on this can effectively improve the model training accuracy, so that it can meet downstream business needs during the application stage. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 is a schematic diagram of a question-answering model training method provided by an embodiment of this specification;

[0039] Figure 2is a flowchart of a question-answering model training method provided by an embodiment of this specification;

[0040] Figure 3 It is a schematic diagram of a reward model scoring result in a question-answering model training method provided in one embodiment of this specification;

[0041] Figure 4 is a flowchart of a text processing method provided by an embodiment of this specification;

[0042] Figure 5 is a flow chart of a reward model training method provided by an embodiment of this specification;

[0043] Figure 6 is a process flow chart of a question-answering model training method provided by an embodiment of this specification;

[0044] Figure 7 It is a structural schematic diagram of a question-answering model training device provided by an embodiment of this specification;

[0045] Figure 8 is a structural schematic diagram of a text processing device provided by an embodiment of this specification;

[0046] Fig. 9 It is a structural diagram of a reward model training device provided by an embodiment of this specification;

[0047] Fig.10 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0048] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0049] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0050] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0051] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0052] In one or more embodiments of this specification, a large model refers to a deep learning model with large-scale model parameters, which usually contains hundreds of millions, tens of billions, hundreds of billions, trillions, or even more than 10 trillion model parameters. A large model can also be called a foundation model / foundation model. The large model is pre-trained with large-scale unlabeled corpus to produce a pre-trained model with more than 100 million parameters. This model can adapt to a wide range of downstream tasks, and the model has good generalization ability, such as a large-scale language model (LLM), a multi-modal pre-training model, etc.

[0053] When the big model is used in practice, only a small number of samples are needed to fine-tune the pre-trained model and it can be applied to different tasks. The big model can be widely used in natural language processing (NLP), computer vision and other fields. Specifically, it can be applied to computer vision tasks such as visual question answering (VQA), image caption (IC), image generation, as well as natural language processing tasks such as text-based sentiment classification, text summary generation, and machine translation. The main application scenarios of the big model include digital assistants, intelligent robots, search, online education, office software, e-commerce, intelligent design, etc.

[0054] In this specification, a question-answering model training method is provided. One or more embodiments of this specification also involve a text processing method, a reward model training method, a question-answering model training device, a text processing device, a reward model training device, a computing device, a computer-readable storage medium, and a computer program product, which are described in detail one by one in the following embodiments.

[0055] See also Figure 1 As shown in the schematic diagram, the question-answering model training method provided in this embodiment can accurately reflect the prediction accuracy of the question-answering model after the current sample pair is trained through the reward model during the question-answering model training process. The sample question can be first extracted from the question-answering sample pair, and the thinking chain data corresponding to the sample question can be determined; on this basis, in order to enable the short question and answer to still strengthen the training question-answering model, the sample question can be updated to the target sample question using the thinking chain data at this time, so that more text content can be reflected through the target sample question, and then the target sample question can be input into the initial question-answering model for processing to obtain a predicted answer; on this basis, since the sample question is updated to the target sample question, the reward model can give a score that can accurately reflect the model prediction accuracy when scoring the model prediction accuracy, that is, the reward model associated with the initial question-answering model is used to score the predicted answer according to the sample answer in the question-answering sample pair, so as to obtain an optimized score; finally, the initial question-answering model is adjusted based on the optimized score until the target question-answering model that meets the training stop condition is obtained. In the reinforcement learning stage of the question-answering model, the sample questions can be updated through the thinking chain data, so that the sample questions carry richer text information. After being predicted by the question-answering model, the reward model can give more accurate scores for the sample questions, thereby accurately reflecting the degree to which the question-answering model needs to be optimized through the scoring results. Subsequent training based on this can effectively improve the model training accuracy, so that it can meet downstream business needs during the application stage.

[0056] See also Figure 2 , Figure 2 A flowchart of a question-answering model training method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0057] Step S202, extracting sample questions from the question-answer sample pairs, and determining the thought chain data corresponding to the sample questions.

[0058] The question-answering model training method provided in this embodiment can be applied to a large model used in any question-answering scenario, such as a large model for answering financial questions in a financial scenario; another example, a large model for answering questions of different subjects in a teaching scenario; another example, a large model for answering development questions in a development scenario, etc. This embodiment does not make any limitation here.

[0059] Specifically, the question-answer sample pair refers to the sample pair used for training the question-answer model associated with the target domain, which consists of a sample question and a sample answer. The sample question is used as the model input, and the sample answer is used as a label for use in the model training stage or the reinforcement learning stage. In practical applications, the sample question and the sample pair exist in the form of text and train the question-answering model. Correspondingly, the thinking chain data specifically refers to the data that can be modified for the sample question, and its purpose is to enrich the short sample question so that the sample question can have richer text information, so as to facilitate the subsequent model training and use, so that the model can more easily capture the semantic association relationship in the text. In other words, the thinking chain data can be understood as a data structure used to update the sample question, which is used to replace, update or add characters to the sample question, so that the sample question can be changed to a target sample question with richer text information for subsequent use. It can also be understood that the thinking chain data is to add the problem content that the model can think about in the sample question, so that the model can learn the knowledge calmly and improve the prediction accuracy and generalization ability. It can be understood as complicating the short sample question, prompting the model to capture the semantic association relationship in the complex text, so as to improve the model training accuracy.

[0060] Based on this, in order to be able to accurately reflect the prediction accuracy of the question-answering model after the current sample is trained through the reward model during the question-answering model training process, the sample question can be first extracted from the question-answering sample pair, and the thinking chain data corresponding to the sample question can be determined; on this basis, in order to enable short questions and answers to still strengthen the training question-answering model, the sample question can be updated to the target sample question using the thinking chain data at this time, so that more text content can be reflected through the target sample question, and then the target sample question can be input into the initial question-answering model for processing to obtain the predicted answer; on this basis, since the sample question is updated to the target sample question, the reward model can give a score that can accurately reflect the model prediction accuracy when scoring the model prediction accuracy, that is, the reward model associated with the initial question-answering model is used to score the predicted answer according to the sample answer in the question-answering sample pair, so as to obtain the optimized score; finally, the initial question-answering model is adjusted based on the optimized score until the target question-answering model that meets the training stop conditions is obtained.

[0061] Furthermore, when determining the thought chain data corresponding to the sample question, in order to ensure that the updated sample question can be used for model training and avoid introducing redundant information that affects the model training accuracy, the thought chain data can be selected according to the question type. In this embodiment, the specific implementation method is as follows:

[0062] Determine the question type corresponding to the sample question, and select candidate thinking chain data matching the question type in the target database as thinking chain data;

[0063] Specifically, the problem type specifically refers to the type of field to which the positioning problem belongs, and different types correspond to different thinking chain data. Correspondingly, the target database specifically refers to a database that stores candidate thinking chain data associated with multiple problem types. Correspondingly, the candidate thinking chain data specifically refers to the thinking chain data selected for the sample problem in the target database. In specific implementation, the operation of selecting the candidate thinking chain data can be achieved by calculating the text similarity, that is, by calculating the text similarity between the sample problem and the thinking chain data, and then sorting them according to the similarity, and selecting the candidate thinking chain data with the highest priority as the thinking chain data corresponding to the sample problem.

[0064] Based on this, after screening out sample questions from question-answer sample pairs, we can first determine the question type corresponding to the sample question. After that, we can select candidate thinking chain data that matches the question type from the target database that stores a large number of thinking chain databases as thinking chain data; so that we can subsequently update the sample questions to target sample questions, thereby realizing the training of the question-answering model.

[0065] For example, a question-answering sample pair for training a question-answering model is obtained, which includes a sample question {What is the result of 1*1+2*2? Answer the result only} and a sample answer {5}. On this basis, in order to improve the prediction accuracy of the question-answering model, the thinking chain data matching the sample question can be loaded, such as {need to answer the thinking process}, so that the sample question can be changed in combination with the thinking chain data later, so that the sample question can contain richer question information, so that during the question-answering model training stage, the reward model can combine the question and answer to give an accurate score, thereby training a question-answering model that meets the usage requirements.

[0066] In practical applications, different thinking chain data can be set for different scenarios. For example, in financial scenarios, you can add "return to the thinking process and output the results in the required format" thinking chain data at the end of the question, so that the model can give new answers in combination with new questions. In this process, a set of answers can be given by the trained large model, and another set of answers can be given by the large model that needs to be trained. After that, by setting rules for judgment, select the positive answers from the set of answers of the trained large model and the negative answers from the set of answers of the large model that needs to be trained. In addition, the positive answers are required to have steps and logic, and the negative answers can be unreasonable problem analysis, incorrect classification, incorrect output format, etc. In this way, positive and negative sample pairs are constructed and combined with the reward model to continue to train the large model that needs to be trained, so that the large model that meets the needs can be trained and deployed in the application scenario.

[0067] In summary, by setting multiple thinking chain data and supporting selection according to question type during the model training phase, it can be effectively ensured that the update of sample questions will not tamper with the meaning of the question itself, and the purpose of reinforcement learning can be achieved, thereby improving the accuracy of model training.

[0068] Step S204: Use the thought chain data to update the sample question into a target sample question, and input the target sample question into the initial question-answering model for processing to obtain a predicted answer.

[0069] Specifically, after reading the sample questions and their corresponding thinking chain data from the question-answer sample pairs mentioned above, further, in order to enable the question-answering model to learn the thinking process and improve the ability of the reward model to give accurate scores for questions of different lengths when scoring, the sample questions can be updated to target sample questions using the thinking chain data, so as to add thinking knowledge that enables the model to learn to the sample questions. After that, the target sample questions can be input into the initial question-answering model for processing, so as to obtain the predicted answers, and then use the reward model for scoring, thereby completing the model optimization processing in combination with the scoring results.

[0070] Among them, the target sample question specifically refers to the question text obtained after updating the sample question using the thinking chain data, and the target sample question carries the text content that enables the question-answering model to learn and think about knowledge; accordingly, the initial question-answering model specifically refers to a large language model that can give answers based on the question. Correspondingly, the predicted answer specifically refers to the predicted answer text output by the initial question-answering model for the target sample question. It should be noted that since the target sample question carries the text content corresponding to the thinking chain data, and the purpose of the text content is to enable the model to learn and think about knowledge, the predicted answer output by the initial question-answering model will have the predicted answer text corresponding to the sample question, and also the solution idea text of the sample question, so that the target sample question and the currently obtained predicted answer can be combined to complete a more accurate scoring in the future, so that the question-answering model can determine the parameters that need to be strengthened and weakened from the score to ensure the model's prediction accuracy and generalization ability.

[0071] Furthermore, when updating the sample question, in order to avoid errors during the update and affect the content of the sample question itself, a word unit matching method can be used. In this embodiment, the specific implementation method is as follows:

[0072] In the sample problem, a word unit to be changed that matches the thought chain data is determined, and the word unit to be changed is updated using the thought chain data to obtain a target sample problem.

[0073] Specifically, the word unit to be changed specifically refers to the word unit in the sample problem that matches the thinking chain data and needs to be changed. Based on this, after obtaining the thinking chain data, the word unit to be changed that matches the thinking chain data can be determined in the sample problem, and then the thinking chain data is used to update the word unit to be changed. According to the update result, the target sample problem can be obtained, and then the model can be trained.

[0074] Using the above example, after obtaining the sample question {What is the result of 1*1+2*2? Only answer the result} and the thinking chain data {Need to answer the thinking process}, the thinking chain data {Need to answer the thinking process} can be used to update the sample question {What is the result of 1*1+2*2? Only answer the result}. According to the updated result, the target sample question {What is the result of 1*1+2*2? Need to answer the thinking process} will be obtained. Further, the target sample question can be input into the question-answering model for processing. At this time, the predicted answer is {First, we calculate the first step 1*1=1, the second step calculates 2*2=4, and the third step adds the results of the first two steps together 1+4=5, so the final result is 5}. The predicted answer includes not only the answer to the question, but also the steps to solve the problem. After that, the reward model is used to score on this basis, so as to realize the reinforcement learning of the question-answering model and improve the accuracy of the model's answer.

[0075] In summary, by updating the sample problem by matching the word units to be changed, it can be ensured that the core content of the updated target sample problem remains unchanged from the original sample problem, but it can have the thinking knowledge that enables the model to learn, so as to achieve the purpose of improving the model prediction accuracy for samples of different lengths.

[0076] Step S206, using the reward model associated with the initial question-answer model to score the predicted answer according to the sample answers in the question-answer sample pair to obtain an optimized score.

[0077] Specifically, after obtaining the predicted answer output by the initial question-answering model, further, considering that the purpose of the reward model is to encourage the initial question-answering model to be optimized more accurately in the reinforcement stage, the scoring result of the reward model is the standard for determining the quality of the optimization of the question-answering model. In order to improve the scoring accuracy of the reward model, when scoring, the reward model will complete the scoring in combination with the predicted answer containing the step content and the answer content. In other words, the reward model associated with the initial question-answering model can be used to score the predicted answer according to the sample answer in the question-answering sample pair, so as to output an optimized score that can reflect the current prediction ability of the model, so that the model can be adjusted in combination with the optimized score in the future. Among them, the higher the optimization score, the higher the model prediction accuracy, and vice versa, the lower the optimization score, the lower the model prediction accuracy, and the optimization score, in addition to the overall score, can also be a sequence composed of the corresponding scores of each token, so that the prediction accuracy of the initial question-answering model on each token can be more fine-grained, so that the subsequent optimization can be more targeted.

[0078] Among them, the reward model is the reward model deployed and trained for the initial question-answering model in the reinforcement learning stage, and the input of the reward model is the concatenation of the predicted answer, the target sample question and the sample answer, and the output is the optimization score.

[0079] Furthermore, when using the reward model for scoring, in order to enable the reward model to give an optimized score with higher accuracy and greater interpretability, the question and answer can be concatenated and then input into the reward model for scoring. In this embodiment, the specific implementation method is as follows:

[0080] Loading the reward model associated with the initial question-answer model, and splicing the target sample question and the predicted answer into an optimized text; extracting a sample answer from the question-answer sample pair, and using the reward model to score the optimized text according to the sample answer to obtain an optimized score.

[0081] Specifically, the optimized text refers to the text content obtained by splicing the target sample question and the predicted answer, which is used to input the reward model, and the reward model is used to evaluate the accuracy of the output results of the current question-answering model.

[0082] Based on this, after obtaining the predicted answer containing step information and answer information, you can first load the reward model associated with the initial question-answering model, and at the same time, you can splice the target sample question and the predicted answer. According to the splicing result, you can get the optimized text; then extract the sample answer from the question-answer sample pair; after that, you can use the reward model to score the optimized text according to the sample answer, and you can optimize the score for subsequent model optimization.

[0083] Continuing with the above example, after getting the predicted answer {first we calculate the first step 1*1=1, the second step calculates 2*2=4, and the third step adds the results of the first two steps together 1+4=5, so the final result is 5}, we can concatenate the predicted answer with the target sample question {What is the result of 1*1+2*2? You need to answer the thinking process} to get the optimized text {What is the result of 1*1+2*2? You need to answer the thinking process; first we calculate the first step 1*1=1, the second step calculates 2*2=4, and the third step adds the results of the first two steps together 1+4=5, so the final result is 5}. Furthermore, extract the sample answer {5} from the question and answer sample pair and input it into the reward model together with the optimized text for scoring; assuming that the question and answer model gives a set of answers to the question that are 5 and 3 respectively, the score distribution of each token in the two predicted answers is as follows Figure 3 As shown in the figure, the token score can reflect the prediction ability of the question-answering model, so as to facilitate the subsequent accurate model optimization.

[0084] In summary, by using the reward model to score the optimized text, it can be ensured that the reward model gives a more accurate score for the predicted answer. This score can reflect the predictive ability of the question-answering model, so the model can be tuned more accurately in the future.

[0085] In addition, in order to enable the reward model to fully and accurately reflect the scores corresponding to texts of different lengths, improve the generalization ability of the reward model, and thus enable the question-answering model to obtain better reinforcement learning, the reward model can be trained in the following way. In this embodiment, the specific implementation method is as follows:

[0086] Obtain a reward sample and a score vector sample sequence corresponding to the reward sample, wherein the score vector sample sequence includes a standard score vector corresponding to each character unit in the reward sample; input the reward sample into an initial reward model for scoring to obtain a score vector prediction sequence, wherein the score vector prediction sequence includes a predicted score vector corresponding to each character unit in the reward sample; calculate a loss value based on the score vector sample sequence and the score vector prediction sequence, and adjust the initial reward model based on the loss value until a reward model that meets the reward training stop condition is obtained.

[0087] Specifically, the reward sample specifically refers to the positive / negative samples composed of the question text, the answer text and the real answer text, which are used to train the reward model. Correspondingly, the score vector sample sequence specifically refers to the sequence composed of the standard score vectors corresponding to each character unit in the reward sample, and the standard score vector corresponding to each character unit is the vector expression of the real score corresponding to each character unit. Correspondingly, the score vector prediction sequence specifically refers to the sequence composed of the predicted score vectors obtained after the reward model scores each character unit. In other words, the predicted score vector contained in the score vector prediction sequence is the vector expression of the predicted score corresponding to each character unit.

[0088] Based on this, in the training stage of the reward model, in order to enable the reward model to have a more accurate scoring ability, so that the question-answering model can be more accurately tuned in the reinforcement learning stage, the reward samples and the score vector sample sequence corresponding to the reward samples can be obtained first, wherein the score vector sample sequence is composed of the standard score vector corresponding to each word unit in the reward sample; thereafter, the reward samples can be input into the initial reward model for scoring, at which time the score vector prediction sequence obtained after the reward model scores the reward samples will be obtained, wherein the score vector prediction sequence is composed of the predicted score vector corresponding to each word unit in the reward sample. After obtaining the score vector prediction sequence output by the reward model, the loss value can be calculated by combining the score vector sample sequence and the score vector prediction sequence, and then the initial reward model can be adjusted based on the loss value until a reward model that meets the reward training stop condition is obtained.

[0089] In practical applications, when calculating the loss value by combining the prediction results and labels, the calculation is completed through the loss function of the following formula (1):

[0090] (1)

[0091] Among them, Loss is the loss value, and The predicted score vector and the real score vector output by the reward model after scoring each token in the reward sample (if the lengths are different, padding can be used to force completion). (.) represents the sigmoid function.

[0092] In addition, the reward training stop condition specifically refers to the condition for stopping the training of the reward model, which includes but is not limited to the loss value comparison condition, the verification set verification condition or the number of iterations condition. During the specific implementation, it can be selected according to actual needs, and this embodiment does not make any limitations here.

[0093] In summary, by training the reward model, the reward model can have a more accurate score output when predicting answers and scoring them, so that the question-answering model can complete parameter adjustment according to the more accurate score output by the reward model during the reinforcement learning stage.

[0094] Furthermore, considering that the loss function used by the reward model in the training phase pays more attention to the score of the last token input, in order to strengthen this feature and support the reward model to give a higher accuracy score for texts of different lengths, a loss function containing a vector constraint term can be used to complete the loss calculation. In this embodiment, the specific implementation method is as follows:

[0095] Determine a target loss function preset for the initial reward model, wherein the target loss function includes a vector constraint term for constraining a target score vector; use the target loss function to calculate the score vector sample sequence and the score vector prediction sequence to obtain a loss value, and perform a step of adjusting parameters of the initial reward model based on the loss value.

[0096] Specifically, the target loss function refers to a loss function that includes a vector constraint term that constrains the target score vector. This loss function can be understood as the loss function obtained by adding the vector constraint term to the above formula (1). The target score vector specifically refers to the score vector corresponding to the last token in the reward sample input by the reward model, and the vector constraint term is the calculation term that constrains the score vector corresponding to the last token.

[0097] Based on this, combined with the above formula (1), it can be seen that the loss function is mainly to increase the distance between the overall score vectors. However, in the subsequent reinforcement learning training process, the question-answering model actually focuses on using the score vector of the last token. Therefore, in order to increase the encouragement for the difference in the score value of the last token, a vector constraint term can be added to the loss function. After that, the target loss function can be used to calculate the score vector sample sequence and the score vector prediction sequence to obtain the loss value, and then the step of adjusting the parameters of the initial reward model based on the loss value can be executed.

[0098] In practical applications, by adding the encouragement for the difference of the score vector of the last token on the basis of the loss function of formula (1), we can obtain the loss function corresponding to formula (2):

[0099] (2)

[0100] The value of λ can be set according to actual needs, such as 0.4, etc., and this embodiment does not make any limitation here.

[0101] Combining formulas (1) and (2), we can see that, considering that the reward model will give a high score to each token of the positive sample and a low score to each token of the negative sample in the theoretical state; however, in reality, since the reward model has not been fully trained, the average score of the tokens of the positive sample may be higher than the average score of the negative sample, but the score corresponding to a single individual token may be lower than the score of the negative sample. Therefore, in order to constrain this situation, a vector constraint term is added on the basis of the loss function of formula (1). It is used to consider the premise that the last token score vector is emphasized in the reinforcement learning stage, and add constraints on the last token score vector, thereby ensuring that the loss function corresponding to formula (2) can effectively adjust the reward model parameters, so that it can be applied to the question-answering model training stage and have a more accurate scoring ability.

[0102] In summary, by using the target loss function containing vector constraints to adjust the parameters of the reward model, it is possible to add constraints on the score vector that are emphasized in the reinforcement learning stage to the loss function, and optimize the reward model on this basis. This allows the reward model to give reasonable scores based on the constraints when scoring, thereby improving the model optimization effect in the reinforcement learning stage.

[0103] Furthermore, in order to improve the generalization ability of the reward model, the loss function can also be optimized in combination with SimCSE. In this embodiment, the specific implementation method is as follows:

[0104] Determine an initial loss function preset for the initial reward model; update the initial loss function in response to a model optimization request submitted for the initial reward model, wherein the model optimization request is used to add semantic learning information to the initial loss function; determine a target loss function based on the update result, and execute the step of determining the target loss function preset for the initial reward model.

[0105] Specifically, an optimization request refers to a request to add semantic learning information to the initial loss function after the initial loss function is obtained. The request is used to change the loss function during the reward model optimization phase so that the changed loss function can enable the reward model to have better generalization capabilities.

[0106] Based on this, the initial loss function preset by the initial reward model can be determined first; thereafter, the initial loss function can be updated in response to a model optimization request submitted for the initial reward model, and the model optimization request is used to add semantic learning information to the initial loss function; thereafter, the target loss function can be determined based on the update result, and the step of determining the target loss function preset by the initial reward model can be executed.

[0107] In practical applications, when optimizing the loss function corresponding to the above formula (2), the SimCSE (Simple Contrastive Learning of Sentence Embeddings) method can be used. The main idea of ​​SimCSE is to train the sentence embedding model through contrastive learning. Specifically, it takes two independent copies of the same sentence as positive sample pairs, and then trains the model by maximizing the cosine similarity of the embedding vectors of the two copies and minimizing the similarity with other sentences (negative samples). The advantage of SimCSE is that it is simple and effective. It does not require complex data preprocessing or labels, only the original text data is required. In addition, SimCSE can also be used in combination with pre-trained language models (such as BERT, RoBERTa, etc.) to further improve performance. The loss function of SimCSE is a contrast loss function, which is in the following form:

[0108] L simcse = -log(exp(sim(u, v) / τ) / Σexp(sim(u, v') / τ)) (3)

[0109] Among them, u and v are the embedding vectors of two independent copies of the same sentence, v' is the embedding vector of other sentences, sim(u, v) represents the cosine similarity between u and v, τ is a temperature parameter, and Σ represents the sum of all negative sample pairs. The goal of this loss function is to maximize the similarity of positive sample pairs and minimize the similarity with negative sample pairs. By optimizing this loss function, the model can learn to generate embedding vectors that can accurately represent the semantics of sentences. Therefore, based on the loss function of formula (3) above, the loss function of formula (2) is optimized to obtain the target loss function shown in formula (4):

[0110] (4)

[0111] Through the loss function shown in the above formula (4), the generalization ability of the reward model can be improved, so that the prediction accuracy of the model can be improved in the reinforcement learning stage.

[0112] Step S208: Adjust the parameters of the initial question-answering model based on the optimization score until a target question-answering model that meets the training stop condition is obtained.

[0113] Specifically, after obtaining the optimization score output by the reward model as mentioned above, further, since the optimization score can reflect the strength of the current question-answering model's prediction ability, the parameter adjustment direction of the question-answering model in the reinforcement learning stage can be determined based on the optimization score. Based on this, the initial question-answering model can be adjusted based on the optimization score until the target question-answering model that meets the training stop conditions is obtained.

[0114] Among them, the training stop condition specifically refers to the condition for stopping the training of the question-answering model, which includes but is not limited to the loss value comparison condition, the verification set verification condition or the number of iterations condition. During the specific implementation, it can be selected according to actual needs, and this embodiment does not make any limitation here.

[0115] Furthermore, in the model parameter adjustment stage, a model optimization strategy can be constructed by combining the optimization score and sample answers. Based on this strategy, the parameters that need to be strengthened and weakened in the question-answering model can be clearly identified, thereby improving the model prediction accuracy. In this embodiment, the specific implementation method is as follows:

[0116] Constructing a model optimization strategy for the initial question-answering model according to the optimization score and the sample answer; adjusting the parameters of the initial question-answering model according to the model optimization strategy, and detecting whether the adjusted initial question-answering model meets the training stop condition; if not, using the adjusted initial question-answering model as the initial question-answering model, and executing the step of extracting sample questions from the question-answering sample pair; if so, using the adjusted initial question-answering model as the target question-answering model.

[0117] Specifically, the model optimization strategy refers to an optimization strategy for planning the initial question-answering model in combination with the optimization score and sample answers. This strategy can strengthen the parameters that need to be improved in the model and weaken the overly strong parameters in the model, thereby improving the model's prediction accuracy and avoiding model overfitting.

[0118] Based on this, in the model parameter adjustment stage, a model optimization strategy can be first constructed for the initial question and answer model based on the optimization score and sample answers; thereafter, the initial question and answer model can be adjusted according to the model optimization strategy, and it can be detected whether the initial question and answer model after the adjustment meets the training stop condition; if not, it means that the question and answer model still needs to be trained, so the initial question and answer model after the adjustment can be used as the initial question and answer model, and the execution step S202 is returned; until after a certain parameter adjustment process, the model meets the training stop condition, and the initial question and answer model after the adjustment can be used as the target question and answer model, and can be deployed in specific business scenarios.

[0119] Using the above example, after obtaining the reward model for the optimized text {What is the result of 1*1+2*2? The thinking process needs to be answered; first, we calculate the first step 1*1=1, the second step 2*2=4, and the third step adds the results of the first two steps together 1+4=5, so the final result is 5} to get the optimization score. At this time, we can adjust the parameters of the question-answering model based on the optimization score. After adjusting the parameters, the question-answering model is verified through the validation set. If it is determined that it has not yet reached the expected prediction accuracy, then new samples need to be selected for further training. After the verification set is verified and it is determined that it meets the expected prediction accuracy, the question-answering model can be deployed to downstream business scenarios to provide question-answering services to users.

[0120] The question-answering model training method provided in the present embodiment can first extract sample questions from the question-answering sample pairs and determine the thinking chain data corresponding to the sample questions in order to accurately reflect the prediction accuracy of the question-answering model after the current sample pair is trained through the reward model during the question-answering model training process. On this basis, in order to enable short questions and answers to still strengthen the training question-answering model, the sample questions can be updated to target sample questions using the thinking chain data at this time, so that more text content can be reflected through the target sample questions. After that, the target sample questions can be input into the initial question-answering model for processing to obtain predicted answers. On this basis, since the sample questions are updated to target sample questions, the reward model can give a score that can accurately reflect the model prediction accuracy when scoring the model prediction accuracy, that is, the predicted answers are scored according to the sample answers in the question-answering sample pairs using the reward model associated with the initial question-answering model to obtain the optimized score. Finally, the initial question-answering model is adjusted based on the optimized score until the target question-answering model that meets the training stop condition is obtained. In the reinforcement learning stage of the question-answering model, the sample questions can be updated through the thinking chain data, so that the sample questions carry richer text information. After being predicted by the question-answering model, the reward model can give more accurate scores for the sample questions, thereby accurately reflecting the degree to which the question-answering model needs to be optimized through the scoring results. Subsequent training based on this can effectively improve the model training accuracy, so that it can meet downstream business needs during the application stage.

[0121] See also Figure 4 , Figure 4 A flowchart of a text processing method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0122] Step S402, receiving the question text uploaded by the client;

[0123] Step S404, determining the question domain information corresponding to the question text, and selecting a target question-answering model that matches the question domain information, wherein the target question-answering model is obtained by the question-answering model training method;

[0124] Step S406: input the question text into the target question-answering model for processing, obtain the answer text, and feed back the answer text to the client.

[0125] Specifically, the question text refers to the text to be answered uploaded by the client. Correspondingly, the question domain information refers to the information describing the domain to which the question belongs, and different question-answering models can be deployed in different domains, so that the question-answering model can specifically answer questions. Correspondingly, the answer text refers to the answer obtained after predicting the question text.

[0126] Based on this, after receiving the question text uploaded by the client, we can first determine the problem domain information corresponding to the question text. At this time, we can select the target question-answering model that matches the problem domain information, and then input the question text into the target question-answering model for processing to obtain the answer text, which can be fed back to the client for user reference.

[0127] For example, the user inputs the question text {Who is the author of song A}, then you can choose to match the question-answering model in the music field for processing and obtain the answer text {A}. At the same time, you can also add an introduction about user A and feed it back to the user client for the user to view. The answer content viewed by the user on the client can be {The author of song A is A, male, ** years old, born in ****, and his representative works include ****}.

[0128] See also Figure 5 , Figure 5 A flow chart of a reward model training method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0129] Step S502, obtaining a reward sample and a score vector sample sequence corresponding to the reward sample, wherein the score vector sample sequence includes a standard score vector corresponding to each word unit in the reward sample;

[0130] Step S504, inputting the reward sample into the initial reward model for scoring, and obtaining a score vector prediction sequence, wherein the score vector prediction sequence includes a predicted score vector corresponding to each word unit in the reward sample;

[0131] Step S506, determining a target loss function preset by the initial reward model, wherein the target loss function includes a vector constraint term constraining a target score vector;

[0132] Step S508, using the target loss function to calculate the score vector sample sequence and the score vector prediction sequence, and adjusting the parameters of the initial reward model according to the calculation results until a reward model that meets the reward training stop condition is obtained.

[0133] It should be noted that the reward model training method provided in this embodiment is a training method corresponding to the reward model used in the above-mentioned question-and-answer model training method. The description of the reward model training method provided in this embodiment can be found in the description of the reward model training in the above-mentioned embodiment. This embodiment will not go into any further details here.

[0134] The following combination Figure 6 , taking the application of the question-answering model training method provided in this specification in a question-answering interaction scenario as an example, the question-answering model training method is further described. Among them, Figure 6 A processing flow chart of a question-answering model training method provided in an embodiment of the present specification is shown, which specifically includes the following steps.

[0135] Step S602: extract sample questions from the question-answer sample pairs.

[0136] Step S604, determine the question type corresponding to the sample question, and select candidate thinking chain data matching the question type in the target database as thinking chain data.

[0137] Step S606, determining the word unit to be changed that matches the thought chain data in the sample question.

[0138] Step S608, using the thought chain data to update the word unit to be changed to obtain the target sample question.

[0139] Step S610: input the target sample question into the initial question-answering model for processing to obtain a predicted answer.

[0140] Step S612, loading the reward model associated with the initial question-answering model, and concatenating the target sample question and the predicted answer into an optimized text.

[0141] Step S614, extracting sample answers from the question and answer sample pairs, and using the reward model to score the optimized text according to the sample answers to obtain an optimization score.

[0142] Step S616, adjusting the parameters of the initial question-answering model based on the optimization score until a target question-answering model that meets the training stop condition is obtained.

[0143] Step S618, receiving the question text uploaded by the client.

[0144] Step S620, input the question text into the target question-answering model for processing, obtain the answer text, and feed back the answer text to the client.

[0145] To sum up, in order to be able to accurately reflect the prediction accuracy of the question-answering model after the current sample is trained through the reward model during the question-answering model training process, the sample question can be first extracted from the question-answering sample pair, and the thinking chain data corresponding to the sample question can be determined; on this basis, in order to enable short questions and answers to still strengthen the training question-answering model, the sample question can be updated to the target sample question using the thinking chain data at this time, so that more text content can be reflected through the target sample question, and then the target sample question can be input into the initial question-answering model for processing to obtain the predicted answer; on this basis, since the sample question is updated to the target sample question, the reward model can give a score that can accurately reflect the model prediction accuracy when scoring the model prediction accuracy, that is, the reward model associated with the initial question-answering model is used to score the predicted answer according to the sample answer in the question-answering sample pair, so as to obtain the optimized score; finally, the initial question-answering model is adjusted based on the optimized score until the target question-answering model that meets the training stop conditions is obtained. In the reinforcement learning stage of the question-answering model, the sample questions can be updated through the thinking chain data, so that the sample questions carry richer text information. After being predicted by the question-answering model, the reward model can give more accurate scores for the sample questions, thereby accurately reflecting the degree to which the question-answering model needs to be optimized through the scoring results. Subsequent training based on this can effectively improve the model training accuracy, so that it can meet downstream business needs during the application stage.

[0146] Corresponding to the above method embodiment, this specification also provides a question-answering model training device embodiment, Figure 7 FIG. 1 is a schematic diagram showing a structure of a question-answering model training device provided by an embodiment of the present specification. Figure 7 As shown, the device comprises:

[0147] An extraction module 702 is configured to extract sample questions from the question-answer sample pairs and determine the thought chain data corresponding to the sample questions;

[0148] An updating module 704 is configured to update the sample question to a target sample question using the thought chain data, and input the target sample question into an initial question-answering model for processing to obtain a predicted answer;

[0149] A scoring module 706 is configured to score the predicted answer according to the sample answer in the question and answer sample pair by using the reward model associated with the initial question and answer model to obtain an optimized score;

[0150] The parameter adjustment module 708 is configured to adjust the parameters of the initial question-answering model based on the optimization score until a target question-answering model that meets the training stop condition is obtained.

[0151] In an optional embodiment, the extraction module 702 is further configured to:

[0152] Determine the question type corresponding to the sample question, and select candidate thinking chain data matching the question type in the target database as thinking chain data;

[0153] The updating module 704 is further configured to: determine the word units to be changed that match the thought chain data in the sample problem, and update the word units to be changed using the thought chain data to obtain the target sample problem.

[0154] In an optional embodiment, the scoring module 706 is further configured to:

[0155] Loading the reward model associated with the initial question-answer model, and splicing the target sample question and the predicted answer into an optimized text; extracting a sample answer from the question-answer sample pair, and using the reward model to score the optimized text according to the sample answer to obtain an optimized score.

[0156] In an optional embodiment, the parameter adjustment module 708 is further configured to:

[0157] Constructing a model optimization strategy for the initial question-answering model according to the optimization score and the sample answer; adjusting the parameters of the initial question-answering model according to the model optimization strategy, and detecting whether the adjusted initial question-answering model meets the training stop condition; if not, using the adjusted initial question-answering model as the initial question-answering model, and executing the step of extracting sample questions from the question-answering sample pair; if so, using the adjusted initial question-answering model as the target question-answering model.

[0158] In an optional embodiment, the device further includes:

[0159] The reward model training module is configured to obtain a reward sample and a score vector sample sequence corresponding to the reward sample, wherein the score vector sample sequence includes a standard score vector corresponding to each character unit in the reward sample; input the reward sample into the initial reward model for scoring to obtain a score vector prediction sequence, wherein the score vector prediction sequence includes a predicted score vector corresponding to each character unit in the reward sample; calculate a loss value based on the score vector sample sequence and the score vector prediction sequence, and adjust the initial reward model based on the loss value until a reward model that meets the reward training stop condition is obtained.

[0160] In an optional embodiment, the reward model training module is further configured as follows:

[0161] Determine a target loss function preset for the initial reward model, wherein the target loss function includes a vector constraint term for constraining a target score vector; use the target loss function to calculate the score vector sample sequence and the score vector prediction sequence to obtain a loss value, and perform a step of adjusting parameters of the initial reward model based on the loss value.

[0162] In an optional embodiment, the reward model training module is further configured as follows:

[0163] Determine an initial loss function preset for the initial reward model; update the initial loss function in response to a model optimization request submitted for the initial reward model, wherein the model optimization request is used to add semantic learning information to the initial loss function; determine a target loss function based on the update result, and execute the step of determining the target loss function preset for the initial reward model.

[0164] The question-answering model training device provided in the present embodiment can first extract sample questions from the question-answering sample pairs and determine the thinking chain data corresponding to the sample questions in order to accurately reflect the prediction accuracy of the question-answering model after the current sample pair is trained through the reward model during the question-answering model training process. On this basis, in order to enable short questions and answers to still strengthen the training question-answering model, the thinking chain data can be used to update the sample questions to target sample questions, so that more text content can be reflected through the target sample questions. After that, the target sample questions can be input into the initial question-answering model for processing to obtain predicted answers. On this basis, since the sample questions are updated to the target sample questions, the reward model can give a score that can accurately reflect the model prediction accuracy when scoring the model prediction accuracy, that is, the reward model associated with the initial question-answering model is used to score the predicted answers according to the sample answers in the question-answering sample pairs, so as to obtain the optimized score. Finally, the parameters of the initial question-answering model are adjusted based on the optimized score until the target question-answering model that meets the training stop condition is obtained. In the reinforcement learning stage of the question-answering model, the sample questions can be updated through the thinking chain data, so that the sample questions carry richer text information. After being predicted by the question-answering model, the reward model can give more accurate scores for the sample questions, thereby accurately reflecting the degree to which the question-answering model needs to be optimized through the scoring results. Subsequent training based on this can effectively improve the model training accuracy, so that it can meet downstream business needs during the application stage.

[0165] The above is a schematic scheme of a question-answering model training device of this embodiment. It should be noted that the technical scheme of the question-answering model training device and the technical scheme of the question-answering model training method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the question-answering model training device can be found in the description of the technical scheme of the question-answering model training method mentioned above.

[0166] Corresponding to the above method embodiment, this specification also provides a text processing device embodiment, Figure 8 FIG. 1 shows a schematic diagram of the structure of a text processing device provided by an embodiment of the present specification. Figure 8 As shown, the device comprises:

[0167] The receiving module 802 is configured to receive the question text uploaded by the client;

[0168] A determination module 804 is configured to determine the question domain information corresponding to the question text, and select a target question-answering model that matches the question domain information, wherein the target question-answering model is obtained by the question-answering model training method;

[0169] The sending module 806 is configured to input the question text into the target question-answering model for processing, obtain the answer text, and feed back the answer text to the client.

[0170] The above is a schematic scheme of a text processing device of this embodiment. It should be noted that the technical scheme of the text processing device and the technical scheme of the above text processing method belong to the same concept, and the details not described in detail in the technical scheme of the text processing device can be referred to the description of the technical scheme of the above text processing method.

[0171] Corresponding to the above method embodiment, this specification also provides a reward model training device embodiment, Fig. 9 FIG. 1 is a schematic diagram showing the structure of a reward model training device provided by an embodiment of the present specification. Fig. 9 As shown, the device comprises:

[0172] The sample acquisition module 902 is configured to acquire a reward sample and a score vector sample sequence corresponding to the reward sample, wherein the score vector sample sequence includes a standard score vector corresponding to each word unit in the reward sample;

[0173] The scoring sample module 904 is configured to input the reward sample into the initial reward model for scoring, and obtain a score vector prediction sequence, wherein the score vector prediction sequence includes a predicted score vector corresponding to each word unit in the reward sample;

[0174] A determination function module 906 is configured to determine a target loss function preset by the initial reward model, wherein the target loss function includes a vector constraint term constraining a target score vector;

[0175] The parameter adjustment model module 908 is configured to use the target loss function to calculate the score vector sample sequence and the score vector prediction sequence, and adjust the parameters of the initial reward model according to the calculation results until a reward model that meets the reward training stop condition is obtained.

[0176] The above is a schematic scheme of a reward model training device of this embodiment. It should be noted that the technical scheme of the reward model training device and the technical scheme of the above-mentioned reward model training method belong to the same concept, and the details not described in detail in the technical scheme of the reward model training device can be found in the description of the technical scheme of the above-mentioned reward model training method.

[0177] Fig.10 The block diagram of a computing device 1000 according to an embodiment of the present specification is shown. The components of the computing device 1000 include but are not limited to a memory 1010 and a processor 1020. The processor 1020 is connected to the memory 1010 via a bus 1030, and the database 1050 is used to store data.

[0178] The computing device 1000 also includes an access device 1040 that enables the computing device 1000 to communicate via one or more networks 1060. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1040 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, and a near field communication (NFC).

[0179] In one embodiment of the present specification, the above components of the computing device 1000 and Fig.10 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.10 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0180] The computing device 1000 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 1000 may also be a mobile or stationary server.

[0181] Among them, the processor 1020 is used to execute the following computer executable instructions, which, when executed by the processor, implement the steps of the above-mentioned question and answer model training method, text processing method or reward model training method.

[0182] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the question-answering model training method, text processing method or reward model training method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be found in the description of the technical scheme of the question-answering model training method, text processing method or reward model training method mentioned above.

[0183] An embodiment of the present specification also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the above-mentioned question-and-answer model training method, text processing method or reward model training method.

[0184] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the question-answering model training method, text processing method or reward model training method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be found in the description of the technical scheme of the question-answering model training method, text processing method or reward model training method mentioned above.

[0185] An embodiment of the present specification also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps of the above-mentioned question-and-answer model training method, text processing method, or reward model training method.

[0186] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of the computer program product and the technical scheme of the question-answering model training method, text processing method or reward model training method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the computer program product can be found in the description of the technical scheme of the question-answering model training method, text processing method or reward model training method mentioned above.

[0187] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0188] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0189] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0190] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0191] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can understand and use this specification well.

Claims

1. A question-answering model training method, It is characterized in that include: Extracting sample questions from the question-answer sample pairs, and determining the thinking chain data corresponding to the sample questions; Determine the word unit to be changed that matches the thought chain data in the sample question, update the word unit to be changed using the thought chain data, obtain a target sample question, and input the target sample question into the initial question-answering model for processing to obtain a predicted answer, wherein the predicted answer includes the predicted answer text corresponding to the sample question and the solution idea text corresponding to the sample question; Using the reward model associated with the initial question-answer model, scoring the predicted answer according to the sample answers in the question-answer sample pair to obtain an optimized score; Adjusting parameters of the initial question-answering model based on the optimization score until a target question-answering model that meets a training stop condition is obtained; Among them, the training of the reward model includes: obtaining a reward sample and a score vector sample sequence corresponding to the reward sample, wherein the score vector sample sequence includes a standard score vector corresponding to each character unit in the reward sample; inputting the reward sample into the initial reward model for scoring to obtain a score vector prediction sequence, wherein the score vector prediction sequence includes a predicted score vector corresponding to each character unit in the reward sample; using a preset target loss function to calculate the loss value for the score vector sample sequence and the score vector prediction sequence, and adjusting the parameters of the initial reward model based on the loss value until a reward model that meets the reward training stop condition is obtained; wherein the target loss function includes a vector constraint term that constrains the target score vector corresponding to the last character unit.

2. The question-answering model training method according to claim 1, It is characterized in that The determining of the thinking chain data corresponding to the sample question includes: Determine the question type corresponding to the sample question, and select candidate thinking chain data matching the question type in the target database as thinking chain data.

3. The question-answering model training method according to claim 1, It is characterized in that The step of scoring the predicted answer according to the sample answer in the question and answer sample pair by using the reward model associated with the initial question and answer model to obtain an optimized score includes: Loading a reward model associated with the initial question-answering model, and concatenating the target sample question and the predicted answer into an optimized text; A sample answer is extracted from the question-answer sample pair, and the optimized text is scored according to the sample answer using the reward model to obtain an optimization score.

4. The question-answering model training method according to claim 1, It is characterized in that The adjusting parameters of the initial question-answering model based on the optimization score until a target question-answering model that satisfies a training stop condition is obtained includes: Constructing a model optimization strategy for the initial question-answering model according to the optimization score and the sample answers; Adjusting the parameters of the initial question-answering model according to the model optimization strategy, and detecting whether the adjusted initial question-answering model meets the training stop condition; If not, the adjusted initial question-answering model is used as the initial question-answering model, and the step of extracting sample questions from the question-answering sample pairs is performed; If so, the initial question-answering model after parameter adjustment is used as the target question-answering model.

5. The question-answering model training method according to claim 1, It is characterized in that Also includes: Determining an initial loss function preset by the initial reward model; updating the initial loss function in response to a model optimization request submitted for the initial reward model, wherein the model optimization request is used to add semantic learning information to the initial loss function; The target loss function is determined according to the update result, and the step of calculating the loss value of the score vector sample sequence and the score vector prediction sequence using the preset target loss function is performed.

6. A text processing method, It is characterized in that include: Receive question text uploaded by the client; Determine the question domain information corresponding to the question text, and select a target question-answering model that matches the question domain information, wherein the target question-answering model is obtained by the question-answering model training method according to any one of claims 1 to 5; The question text is input into the target question-answering model for processing to obtain an answer text, and the answer text is fed back to the client.

7. A reward model training method, It is characterized in that include: Obtain a reward sample and a score vector sample sequence corresponding to the reward sample, wherein the score vector sample sequence includes a standard score vector corresponding to each word unit in the reward sample; Inputting the reward sample into the initial reward model for scoring to obtain a score vector prediction sequence, wherein the score vector prediction sequence includes a predicted score vector corresponding to each word unit in the reward sample; Determining a target loss function preset by the initial reward model, wherein the target loss function includes a vector constraint term for constraining a target score vector corresponding to a last word unit; The target loss function is used to calculate the score vector sample sequence and the score vector prediction sequence, and the initial reward model is adjusted according to the calculation results until a reward model that meets the reward training stop condition is obtained.

8. A question-answering model training device, It is characterized in that include: An extraction module is configured to extract sample questions from the question-answer sample pairs and determine the thought chain data corresponding to the sample questions; An updating module is configured to determine a word unit to be changed that matches the thought chain data in the sample question, update the word unit to be changed using the thought chain data, obtain a target sample question, and input the target sample question into the initial question-answering model for processing to obtain a predicted answer, wherein the predicted answer includes a predicted answer text corresponding to the sample question and a solution idea text corresponding to the sample question; A scoring module is configured to score the predicted answer according to the sample answers in the question and answer sample pairs using the reward model associated with the initial question and answer model to obtain an optimized score; A parameter adjustment module is configured to adjust the parameters of the initial question-answering model based on the optimization score until a target question-answering model that meets the training stop condition is obtained; Among them, the training of the reward model includes: obtaining a reward sample and a score vector sample sequence corresponding to the reward sample, wherein the score vector sample sequence includes a standard score vector corresponding to each character unit in the reward sample; inputting the reward sample into the initial reward model for scoring to obtain a score vector prediction sequence, wherein the score vector prediction sequence includes a predicted score vector corresponding to each character unit in the reward sample; using a preset target loss function to calculate the loss value for the score vector sample sequence and the score vector prediction sequence, and adjusting the parameters of the initial reward model based on the loss value until a reward model that meets the reward training stop condition is obtained; wherein the target loss function includes a vector constraint term that constrains the target score vector corresponding to the last character unit.

9. A text processing device, It is characterized in that include: A receiving module is configured to receive question text uploaded by the client; A determination module, configured to determine the question domain information corresponding to the question text, and select a target question-answering model that matches the question domain information, wherein the target question-answering model is obtained by the question-answering model training method according to any one of claims 1 to 5; The sending module is configured to input the question text into the target question-answering model for processing, obtain the answer text, and feed back the answer text to the client.

10. A reward model training device, It is characterized in that include: A sample acquisition module is configured to acquire a reward sample and a score vector sample sequence corresponding to the reward sample, wherein the score vector sample sequence includes a standard score vector corresponding to each word unit in the reward sample; A scoring sample module is configured to input the reward sample into an initial reward model for scoring, and obtain a score vector prediction sequence, wherein the score vector prediction sequence includes a predicted score vector corresponding to each word unit in the reward sample; A determination function module is configured to determine a target loss function preset by the initial reward model, wherein the target loss function includes a vector constraint term constraining a target score vector corresponding to the last word unit; The parameter adjustment model module is configured to use the target loss function to calculate the score vector sample sequence and the score vector prediction sequence, and adjust the parameters of the initial reward model according to the calculation results until a reward model that meets the reward training stop condition is obtained.

11. A computing device, It is characterized in that include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the method described in any one of claims 1 to 7 are implemented.

12. A computer-readable storage medium, It is characterized in that It stores computer executable instructions, which, when executed by a processor, implement the steps of the method described in any one of claims 1 to 7.

13. A computer program product, It is characterized in that The method comprises a computer program or an instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.