Question and answer processing method and question and answer model training method
By applying random masking and reinforcement learning to the pre-trained question-answering model, the error problem of the question-answering system in time-sensitive questions is solved, and the time concept understanding and response accuracy of the question-answering model are improved.
Patent Information
- Application Number
- CN202310526190.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-10
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2043-05-10
AI Technical Summary
Existing question-answering systems suffer from significant errors in answering time-sensitive questions, as the answers change over time, affecting the accuracy of the output.
By applying random masking to the pre-trained question-answering model, increasing the training samples for time and named entities, and combining this with reinforcement learning methods, the model's sensitivity and accuracy to time concepts are improved.
It improved the performance of the question-answering model on time-sensitive tasks, enhanced its understanding of time concepts, and improved the accuracy of the response results.
Smart Images

Figure CN116775820B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present specification relate to the technical field of computer technology, and particularly relate to a question and answer processing method. BACKGROUND
[0002] With the development of artificial intelligence technology, natural language processing is widely applied in various fields, such as government information retrieval, medical consultation, online teaching, online shopping, etc. The question and answer system provides a fast query and retrieval interface for users. Users can ask questions on the interactive interface, and the question and answer system can answer in an accurate and concise natural language. However, the current question and answer system does not perform well in time understanding, and the answers to many questions will change over time, which leads to a large error in the answers input by the question and answer system in different years, affecting the output accuracy of the question and answer model in the question and answer system. SUMMARY
[0003] Therefore, the embodiments of the present specification provide a question and answer processing method. One or more embodiments of the present specification also relate to a question and answer model training method, a text question and answer processing method, a question and answer processing device, a computing device, a computer readable storage medium, and a computer program to solve the technical defects in the prior art.
[0004] According to a first aspect of the embodiments of the present specification, a question and answer processing method is provided, comprising:
[0005] obtaining question information to be replied;
[0006] inputting the question information into a question and answer model to obtain a reply result corresponding to the question information;
[0007] The question and answer model is obtained by training a pre-trained question and answer model based on a training sample. The pre-trained question and answer model is obtained by training based on processing corpus information. The processing corpus information is obtained by randomly masking original corpus information. The original corpus information includes multiple times and multiple named entities.
[0008] According to a second aspect of the embodiments of the present specification, a question and answer model training method is provided, applied to a cloud side device, comprising:
[0009] obtaining a training sample;
[0010] inputting the training sample into a pre-trained question and answer model to obtain a predicted reply result, wherein the pre-trained question and answer model is obtained by training based on processing corpus information. The processing corpus information is obtained by randomly masking original corpus information. The original corpus information includes multiple times and multiple named entities.
[0011] Train the pre-trained question and answer model based on the predicted answer result, to obtain a question and answer model.
[0012] According to a third aspect of the embodiments of the present specification, a text question and answer processing method is provided, applied to an end-side device, comprising:
[0013] Receiving text question information for a target object;
[0014] Inputting the text question information into a question and answer model to obtain a text answer result corresponding to the target object, wherein the text answer result is associated with time information, and the question and answer model is obtained according to the question and answer model training method provided in the second aspect.
[0015] According to a fourth aspect of the embodiments of the present specification, a question and answer processing apparatus is provided, comprising:
[0016] An information acquisition module configured to acquire question information to be answered;
[0017] An information question and answer module configured to input the question information into a question and answer model to obtain an answer result corresponding to the question information; wherein the question and answer model is obtained by training a pre-trained question and answer model based on a training sample, the pre-trained question and answer model is obtained by training based on to-be-processed corpus information, the to-be-processed corpus information is obtained by randomly masking original corpus information, and the original corpus information includes multiple times and multiple named entities.
[0018] According to a fifth aspect of the embodiments of the present specification, a computing device is provided, comprising:
[0019] A memory and a processor;
[0020] The memory is configured to store computer executable instructions, and the processor is configured to execute the computer executable instructions, which implement the steps of the above method when executed by the processor.
[0021] According to a sixth aspect of the embodiments of the present specification, a computer readable storage medium is provided, which stores computer executable instructions, which implement the steps of the above method when executed by the processor.
[0022] According to a seventh aspect of the embodiments of the present specification, a computer program is provided, wherein when the computer program is executed in a computer, the computer executes the steps of the above method.
[0023] An embodiment of the present specification provides a question and answer processing method, obtaining question information to be replied; inputting the question information into a question and answer model to obtain a reply result corresponding to the question information; wherein the question and answer model is obtained by training a pre-trained question and answer model based on a training sample, and the pre-trained question and answer model is obtained by training based on to-be-processed corpus information, the to-be-processed corpus information is obtained by randomly masking original corpus information, and the original corpus information includes multiple times and multiple named entities.
[0024] In specific implementation, by inputting the question information to be replied into the question and answer model, the reply result corresponding to the question information is obtained, wherein the question and answer model can be obtained by training a pre-trained question and answer model based on a training sample, and in the pre-training stage, the original corpus information including multiple times and multiple named entities is randomly masked to obtain to-be-processed corpus information, so that the reply result can be output based on the time and named entity that are not masked in each iteration of the pre-training process of the question and answer model, that is, the time and named entity based on each iteration of the pre-training are changing, so that the pre-trained question and answer model can accurately identify the time and named entity, thereby improving the performance of the question and answer model in the time-sensitive question and answer task; by enhancing the learning of the association between the time and the named entity in the pre-training stage of the question and answer model, the model can be more sensitive to the time-related expression, and the output accuracy of the question and answer model can be improved. BRIEF DESCRIPTION OF DRAWINGS
[0025] Figure 1 FIG. 1 is a schematic diagram of an application scenario of a question and answer processing method provided by an embodiment of the present specification;
[0026] Figure 2 FIG. 2 is a flowchart of a question and answer processing method provided by an embodiment of the present specification;
[0027] Figure 3 FIG. 3 is a flowchart of a question and answer model training method provided by an embodiment of the present specification;
[0028] Figure 4 FIG. 4 is a flowchart of a text question and answer processing method provided by an embodiment of the present specification;
[0029] Figure 5 FIG. 5 is a process flowchart of a text question and answer processing method provided by an embodiment of the present specification;
[0030] Figure 6 FIG. 6 is a structural schematic diagram of a question and answer processing device provided by an embodiment of the present specification;
[0031] Figure 7 FIG. 7 is a structural block diagram of a computing device provided by an embodiment of the present specification. DETAILED DESCRIPTION
[0032] In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present description. However, the present description can be practiced without the specific details, and the present description can also be practiced using methodologies directly or indirectly similar to or variations of those described herein. Thus, the present description is not intended to be limited to the particular implementations disclosed herein, which can be practiced with or without various components, elements, compositions, or steps.
[0033] The terminology used in one or more embodiments of the present description is for the purpose of describing particular embodiments only and is not intended to be limiting of one or more embodiments of the present description. As used in one or more embodiments of the present description and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in one or more embodiments of the present description, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0034] It will be understood that, although the terms first, second, etc. can be used herein to describe various information, these terms are not intended to denote a temporal or chronological order. Rather, these terms are used only to distinguish one from another. For example, without departing from the scope of one or more embodiments of the present description, first can be termed second, and similarly, second can be termed first. The term "if' as used herein, can be interpreted as meaning "when" or "in response to determining" depending on the context.
[0035] 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 for analysis, stored data, displayed data, etc.) involved in one or more embodiments of the present description are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.
[0036] First, the nomenclature involved in one or more embodiments of the present description is explained.
[0037] Reinforcement Learning (RL): Also known as re-education, evaluation learning or enhancement learning, it is one of the paradigms and methodologies of machine learning, which is used to describe and solve the problem of maximizing the reward or achieving a specific goal through learning strategy in the interaction process between the agent and the environment.
[0038] Question-answering systems provide users with a quick query and retrieval interface. Users ask questions on the interactive interface, and the system can answer them accurately and concisely using natural language. However, the current lack of understanding of time in question-answering systems is a significant bottleneck in the development of artificial intelligence. Compared to traditional question-answering systems, time-sensitive question answering is far more complex. Time-sensitive question answering refers to the fact that in the real world, the answers to many questions change over time. For example, the answer to the question "Who is the chairman of Company A?" may be different in 2013 and 2023.
[0039] Current pre-trained language models perform poorly in time-related question-answering, exhibiting significant errors across different years. They perform well for near-modern times but poorly for "past" and "future" times. Therefore, to further explore the understanding of time concepts by question-answering models in question-answering systems, this application proposes an innovative solution based on information extraction pre-training and reinforcement learning to accurately extract time information from question-answering models.
[0040] It's important to note that time-sensitive question answering (TSA) is a relatively new task in natural language processing (NLP), adding a time dimension to traditional question answering tasks. Time-related questions can be broadly categorized into three types: 1. Time-time relationships; 2. Time-event relationships; 3. Event-event relationships. The difficulty of these three types increases progressively. Three levels of evaluation will be proposed for these types of questions. The first evaluation method provides only the question itself, such as "**Which team did **play for in May 2010?**", primarily testing the language model's memory ability; this is called Close-book QA (CBQA). The second level of evaluation can be understood as open-book QA (OBQA), where, in addition to the question, the context of the named entities in the question is also provided to the question answering model. This method is mainly used to test the model's ability to read text. The third level of evaluation is ReasonQA (Reason Question Answering). Besides providing the question, structured knowledge about the question is also provided to the language model. For example, for the question "**Which team did **play for in May 2010?**", the relevant structured knowledge includes each team **played for** and the duration of their service. This evaluation method primarily tests the question-answering model's ability to understand time spans.
[0041] This specification provides a question-and-answer processing method, and also relates to a question-and-answer model training method, a text question-and-answer processing method, a question-and-answer processing device, a computing device, a computer-readable storage medium, and a computer program, which will be described in detail in the following embodiments.
[0042] See Figure 1 , Figure 1 The diagram illustrates an application scenario of a question-and-answer processing method provided according to an embodiment of this specification.
[0043] It should be noted that the question-and-answer processing method provided in this embodiment can be applied to intelligent customer service question-and-answer scenarios on e-commerce platforms, intelligent robot question-and-answer scenarios, etc. The specific application scenarios can be adapted to different needs according to different project requirements, and this embodiment does not limit them. For ease of understanding, this embodiment takes the application scenario of users using intelligent robot question-and-answer systems as an example for explanation.
[0044] In practical applications, users submit questions to be answered to the intelligent robot question-and-answer system. The question-and-answer model in the system can output the corresponding answer to the question. It should be noted that in the question-and-answer scenario provided in this embodiment, the questions submitted by users can be associated with time information, such as: Which team did person A play for in 2010? What was the career status of person A? After receiving the question information, the question-and-answer system can input the question information into the question-and-answer model to output the corresponding result, and the answer can also be associated with time information.
[0045] It should be noted that, in order to improve the sensitivity to time information and enhance the accuracy of the response results, the question-answering model provided in this embodiment can be divided into two stages: a pre-training stage and a training stage using the pre-trained question-answering model. In the pre-training stage, the pre-trained question-answering model is trained using questions and corpus information. To enable the model to learn time sensitivity, the corpus information can include multiple times and multiple named entities to better extract the effective information between time and named entities. In the training stage, the model already possesses the ability to accurately extract and recognize time and named entities. Therefore, based on the pre-trained question-answering model, the question-answering model is further trained to enhance its sensitivity to time, improve its understanding of time, and increase the accuracy of the response results.
[0046] See Figure 2 , Figure 2 A flowchart of a question-and-answer processing method according to an embodiment of this specification is shown, which specifically includes the following steps.
[0047] It should be noted that the execution subject of the question-and-answer processing method provided in the embodiments of this specification can be applied to end-side devices or cloud-side devices, and this embodiment does not limit it in this way.
[0048] Step 202: Obtain information on questions to be answered.
[0049] In practical applications, the implementing entity can obtain information about questions awaiting answers. This information can be understood as the content of questions that users need to answer, and this content is related to time information, such as: Which team did person A play for in 2010? What is the status of person A's career? ...etc.
[0050] Step 204: Input the question information into the question-answering model to obtain the answer result corresponding to the question information.
[0051] The question answering model is obtained by training a pre-trained question answering model based on the training samples. The pre-trained question answering model is obtained by training the corpus information to be processed. The corpus information to be processed is obtained by randomly masking the original corpus information. The original corpus information includes multiple times and multiple named entities.
[0052] In practical applications, the implementing entity can input question information into the question-and-answer model to obtain the corresponding response. The response can be understood as the specific answer determined for the question information, and this response is associated with time information. Using the previous example, the response could be: Person A played for Team 1 in 2010; Person A worked for Company C1 between time 1 and time 2, and for Company C2 between time 3 and time 4, and so on. It should be noted that the question-and-answer model provided in this embodiment is sensitive to time information and can accurately understand time information, making the corresponding response more precise.
[0053] The question-answering model provided in this embodiment, to improve the model's understanding of the concept of time, can be trained in two stages. The first stage is the pre-training stage, in which the raw corpus information containing multiple times and multiple named entities is masked to obtain the corpus information to be processed, and the pre-trained question-answering model is trained based on the corpus information to be processed. The second stage is the training stage, in which the pre-trained question-answering model is trained on the training samples to obtain the question-answering model. It can be understood that since the raw corpus information input in the pre-training stage includes multiple times and multiple named entities, the output of the question-answering model in this stage is based on the analysis and processing of time and named entities, that is, the model's output response is related to time and named entities. The masking processing used in the pre-training stage refers to randomly masking the multiple times and multiple named entities contained in the raw corpus information. The mask ratio can be the same or different in each iteration, that is, the time and named entities on which the model output is based change in each iteration. In this way, the question-answering model's attention to time and named entities can be increased, making the question-answering model more sensitive to the concept of time.
[0054] For ease of understanding, this embodiment first introduces the model training phase. This question-answering system employs reinforcement learning, enabling the question-answering model to accurately learn time-sensitive question-answering tasks and improve its training performance. Specifically, before inputting the question information into the question-answering model and obtaining the corresponding response, the process further includes:
[0055] Obtain training samples, wherein the training samples include question text and training corpus;
[0056] Input the question text and the training corpus into the pre-trained question answering model to obtain the predicted response result;
[0057] Determine the result weight value corresponding to the predicted response result;
[0058] Based on the weight values of the results, the model parameters in the pre-trained question-answering model are adjusted to obtain the question-answering model.
[0059] The training corpus can be understood as the text content of the context associated with the question text, which contains the answer information corresponding to the question text, or content associated with the answer information. This embodiment does not limit this.
[0060] In practical applications, the executing entity can obtain training samples, which include question text and training corpus. The data content in the training samples is then input into a pre-trained question-answering model to obtain predicted response results. The pre-trained question-answering model can be understood as having undergone a pre-training phase and possessing the ability to understand time and named entities in the question text and training corpus. The specific training process is detailed in the following embodiment. Furthermore, the executing entity can obtain the predicted response results and determine corresponding result weight values for the predicted response results. The predicted response results may include multiple response contents, which is not limited in this embodiment. Accordingly, the result weight value can be understood as determining a corresponding weight value for each response content. This weight value can represent the degree of correctness or error of the response content, which is not limited here.
[0061] Finally, after determining the result weight value corresponding to the predicted response output of the pre-trained question-answering model, the executing entity can adjust the model parameters in the pre-trained question-answering model according to the result weight value. After multiple rounds of iterative training of the model, until the training stopping condition is reached, the question-answering model is obtained.
[0062] In one embodiment of this specification, determining the result weight value of the predicted response result can be understood as assigning a corresponding reward weight to the predicted response result, such as the reward function in reinforcement learning; specifically, determining the result weight value corresponding to the predicted response result includes:
[0063] From at least one response message in the predicted response results, determine the response message to be processed;
[0064] Determine the first weight corresponding to the response information to be processed;
[0065] Determine the second weight corresponding to the predicted response information set, wherein the predicted response information set is a set of other response information in the predicted response results except for the response information to be processed;
[0066] Based on the first weight and the second weight, the target weight value corresponding to the response information to be processed is determined;
[0067] Based on the target weight value, the result weight value corresponding to the predicted response result is determined.
[0068] In practical applications, during the training phase of a question-answering model, the predicted response output of the pre-trained question-answering model can include multiple response information. For example, in the question "Which team did person A play for in 2010?", the predicted response results could include Team1, Team2, and Team3. Furthermore, the executing entity can determine the corresponding weight value for each response information in the predicted response results to determine the result weight value corresponding to the predicted response results. Specifically, in at least one response information, the response information to be processed is determined, and the first weight corresponding to this response information is determined. Then, the second weight corresponding to the set of predicted response information is determined. The set of predicted response information can be understood as the set of response information other than the response information to be processed among the multiple response information in the predicted response results. Following the example above, if Team1 is determined to be the response information to be processed, then Team2 and Team3 can be combined to form a set of other response information. A set of predicted response information is formed. Accordingly, the first weight corresponding to Team1 can be determined, and the second weight corresponding to the set composed of Team2 and Team3 can be determined. Furthermore, based on the first and second weights, the target weight value corresponding to the response information to be processed can be determined. This target weight value can be understood as the reward function value for the response information to be processed. Through this reward function value, the model can learn whether the response information is correct or not, that is, to give the model corresponding positive and negative feedback. Finally, based on the target weight value corresponding to each response information to be processed, the result weight value corresponding to the predicted response result is generated. The result weight value can be understood as a set of multiple target weight values, which is used to adjust the model parameters in the question-answering model in the future.
[0069] In an optional embodiment, the first weight corresponding to the response information to be processed can be calculated with reference to the following formula 1:
[0070] p(x) = EM(θ(x), oj ) Formula 1
[0071] Where p(x) represents the first weight, i.e. the weight value of positive feedback, EM() can be understood as the reward function, θ(x) represents the model parameters, and Oj represents the response information to be processed.
[0072] Furthermore, in this embodiment, when determining the second weight corresponding to the predicted response information set, the second weight corresponding to the set can be determined after determining the sub-weights corresponding to each response information in the set; specifically, determining the second weight corresponding to the predicted response information set includes:
[0073] Determine the sub-weights corresponding to each response in the predicted response information set;
[0074] Based on the sub-weights corresponding to each response information, a second weight corresponding to the predicted response information set is determined.
[0075] In practical applications, the executing entity can determine the corresponding sub-weights for each response in the predicted response information set. The method for determining the sub-weights can refer to Formula 1 above, and each response can be represented as Oi (i is not equal to j). Furthermore, based on the sub-weights corresponding to each response, the second weight corresponding to the predicted response information set is determined, which can be referred to in Formula 2 below:
[0076] n(x) = max({EM(θ(x),o i )|i≠j}) Formula 2
[0077] Here, n(x) can be represented as the second weight, that is, the weight value of the negative feedback. Accordingly, among the sub-weights corresponding to multiple response information, the corresponding second weight can be determined by the max() function.
[0078] Based on this, the above method is used to assign corresponding reward weight values to each response in the model's output prediction response results, so that the model can learn the degree of difference between each response and the correct response; the specific method of determining the reward weight values is only shown as an example above and is not limited thereto.
[0079] Furthermore, after determining the first weight and second weight corresponding to each response information in the predicted response results, the target weight value corresponding to that response information can be determined, so as to determine the specific value of the corresponding reward score that the response information can be given, so that the model can better learn whether the response information is correct or not; specifically, the step of determining the target weight value corresponding to the response information to be processed based on the first weight and the second weight includes:
[0080] If the first weight is greater than or equal to the second weight, the first weight is determined as the target weight value corresponding to the response information to be processed; or
[0081] If the first weight is less than the second weight, the target weight value corresponding to the response information to be processed is determined based on the second weight.
[0082] In practical applications, the executing entity can determine the target weight value corresponding to each response information by judging the correlation between the first weight and the second weight. In this embodiment, the comparison of the first weight and the second weight is divided into two stages: one is when the first weight is greater than or equal to the second weight, and the other is when the first weight is less than the second weight. Specifically, when the first weight is greater than or equal to the second weight, the first weight is determined as the target weight value corresponding to the response information to be processed; or when the first weight is less than the second weight, the target weight value corresponding to the response information to be processed is determined based on the second weight.
[0083] In an optional embodiment, the target weight value corresponding to the response information to be processed can be determined with reference to the following formula 3:
[0084]
[0085] R(x) can be represented as the target weight value. Specifically, R(x) can be determined in two stages using the above formulas 1 and 2.
[0086] It should be noted that by determining the target weight value corresponding to each response, the degree of difference between each response in the predicted response output of the pre-trained question answering model can be determined. Specifically, for correct responses, corresponding reward weights can be awarded, and for incorrect responses, corresponding penalty weights can be given.
[0087] Based on this, the question-answering model can learn not only from correct answers but also from incorrect answers through the reward function. In addition, it should be emphasized that incorrect answers are also related to time during the training of the question-answering model.
[0088] Furthermore, before training the question-answering model, a pre-training stage is included to train the pre-trained question-answering model. To enhance the pre-trained model's understanding of time information, this embodiment provides a pre-training stage that randomly masks multiple times and named entities in the corpus information to train the pre-trained question-answering model's ability to accurately extract time and named entity information. Specifically, before inputting the question text and the training corpus into the pre-trained question-answering model, the following steps are also included:
[0089] Obtain pre-training samples, wherein the pre-training samples include question text and original corpus information, and the original corpus information includes multiple times and multiple named entities;
[0090] Randomly mask the multiple times and the multiple named entities to obtain the corpus information to be processed;
[0091] Input the question text and the corpus information to be processed into the initial question-answering model to obtain the original response result;
[0092] Based on the original response results, the initial question-answering model is trained to obtain a pre-trained question-answering model.
[0093] The original corpus information can be understood as the contextual content associated with the question text, and this contextual content may include multiple times and multiple named entities.
[0094] In practical applications, after obtaining pre-training samples, the executing entity masks the original corpus information in the pre-training samples to obtain the corpus information to be processed. Then, the question text and the corpus information to be processed are input into the initial question-answering model. The initial question-answering model can be understood as a basic question-answering model preceding the pre-trained model. This yields the original response result, which is then used to train the initial question-answering model. The model parameters in the initial question-answering model can be adjusted until the training stopping condition is met, thus obtaining the pre-trained question-answering model. The question text may contain time information, or it may be associated with the context time.
[0095] It should be noted that the pre-trained question-answering model should have the ability to accurately identify and extract time and named entities, so that the corresponding response information can be made based on the extracted time information and named entity information.
[0096] To enhance the attention given to temporal expressions and named entities in the pre-trained question-answering model, making subsequent question-answering models more sensitive to the concept of time, this embodiment can perform masking processing on the original corpus information to complete the pre-training of the masked language model; specifically, the random masking of the multiple times and the multiple named entities to obtain the corpus information to be processed includes:
[0097] Identify the original corpus information and determine the information locations corresponding to the multiple times and the multiple named entities;
[0098] Based on the information location, random masks are applied to the multiple times and the multiple named entities to obtain the corpus information to be processed.
[0099] In practical applications, the executing entity can determine and identify the original corpus information from the acquired pre-training samples. This can be understood as identifying text segments (context). A Named Entity Recognizer (NER) can be used to extract time expressions and named entities from these text segments. Simultaneously, the location information corresponding to each time expression and named entity can be determined. After clarifying the location information of the extracted information, the time expressions and named entities can be randomly masked based on this location information to obtain the corpus information to be processed. Specifically, some time expressions or named entities can be randomly replaced with [Mask], thus obtaining text segments containing a portion of [Mask], which can be used as the corpus information to be processed and input into the subsequent training process of the pre-trained question-answering model. The masking ratio can be preset and can be fixed or dynamically adjustable. For example, 50% of the time and 50% of the named entities can be masked in each iteration.
[0100] Based on this, the masked language model pre-training of the basic initial question-answering model using randomly replaced corpus provided in this embodiment can increase the model's attention to time expressions and named entities, making the model more sensitive to the concept of time.
[0101] Furthermore, this embodiment also provides a fine-tuning process for the question-answering model, further improving its accuracy; specifically, after obtaining the answer result corresponding to the question information, it also includes:
[0102] The response will be sent to the user.
[0103] Receive feedback from the user regarding the response result;
[0104] The model parameters in the question-and-answer model are adjusted based on the feedback information.
[0105] In practical applications, the executing entity can send the response results output by the question-and-answer model to the user. The user can provide corresponding feedback based on the response results. If there are multiple response results, the user can provide corresponding feedback for each response and send it back to the executing entity. Furthermore, the executing entity can adjust the model parameters in the question-and-answer model according to the feedback information, which can realize the model fine-tuning stage of the question-and-answer model and improve the output accuracy of the question-and-answer model.
[0106] In summary, the question-answering processing method provided in the embodiments of this specification proposes a pre-training method for extracting time spans, namely, randomly masking multiple times and multiple named entities in the corpus information, making the language model more sensitive to time-related expressions. In addition, a reinforcement learning algorithm for time-sensitive question answering is proposed, allowing the model to learn not only from correct answers but also from common errors. Thus, it can significantly improve the performance of the question-answering model on time-sensitive question-answering tasks and enhance the question-answering model's understanding of time concepts.
[0107] See Figure 3 , Figure 3 A flowchart of a question-answering model training method provided in one embodiment of this specification is shown, which specifically includes the following steps.
[0108] It should be noted that the question-answering model training method provided in this embodiment can be applied to cloud-side devices, and the trained question-answering model can be stored in the cloud to facilitate the provision of corresponding question-answering models to edge devices in the future to support time-related question-answering tasks.
[0109] Step 302: Obtain the training samples.
[0110] The training samples may include question text and / or corpus information, and the question text may be associated with time information. The corpus information may also be associated with time information, such as structured information with a time axis. This embodiment does not impose any limitations on this.
[0111] Step 304: Input the sample to be trained into the pre-trained question answering model to obtain the predicted response result. The pre-trained question answering model is trained based on the information of the corpus to be processed. The information of the corpus to be processed is obtained by randomly masking the original corpus information. The original corpus information includes multiple times and multiple named entities.
[0112] In practical applications, the training samples are input into the pre-trained question-answering model to obtain the predicted response results. The pre-trained question-answering model in the cloud device can be obtained through pre-training. During the training phase of the pre-trained question-answering model, multiple times and multiple named entities in the corpus information are processed by random masking to train the pre-trained question-answering model to learn the ability to accurately extract times and named entities, so that the subsequent question-answering model can quickly and accurately obtain the time and named entity information.
[0113] Step 306: Train the pre-trained question-answering model based on the predicted response results to obtain the question-answering model.
[0114] In practical applications, the executing entity can adjust the model parameters in the pre-trained question-answering model based on the predicted response results. In multiple rounds of iterative training, the training will continue until the training stopping condition is met, and the question-answering model will be obtained. The training stopping condition is not limited in this embodiment.
[0115] It should be noted that, based on the pre-trained question-answering model, in order to enhance the accurate answering ability of the question-answering model during the training process, reinforcement learning can be used to train the question-answering model. Specifically, a reward function can be used to assign corresponding evaluation weight values to the answer information in the predicted answer results of each iteration, so that the model can learn the positive and negative feedback information corresponding to each answer information, enabling the model to learn not only from correct answers but also from incorrect answers. The specific training process can be referred to the description of the two-stage model training process in the above embodiment, and will not be elaborated on in this embodiment.
[0116] In summary, the question-answering model training method provided in this embodiment, through a pre-training method that accurately extracts the time expression span of the pre-trained question-answering model, that is, randomly masks multiple times and multiple named entities in the corpus information, makes the language model more sensitive to time-related expressions. This not only improves the performance of the question-answering model on time-sensitive question-answering tasks, but also enhances the question-answering model's understanding of time concepts.
[0117] See Figure 4 , Figure 4 A flowchart of a text question-and-answer processing method provided in one embodiment of this specification is shown, which specifically includes the following steps.
[0118] It should be noted that the text question-and-answer processing method provided in this embodiment can be applied to edge devices. For ease of understanding, the text question-and-answer processing method provided in this embodiment can be applied to the question-and-answer scenario of intelligent robots, but it is not limited thereto.
[0119] Step 402: Receive text question information for the target object.
[0120] In practical applications, users present intelligent robots with text-based questions targeting a specific object. The target object can be understood as a concrete entity, such as a person, place, or item. The text question is a textual question related to that target object and is time-related, such as, "Which company did person A work for in 2010?" Here, person A can be understood as the target object, and "Which company did person A work for in 2010?" can be understood as the text question.
[0121] Step 404: Input the text question information into the question-answering model to obtain the text response result corresponding to the target object.
[0122] The text response result is associated with time information, and the question-answering model is obtained according to the above method.
[0123] In practical applications, after inputting the text question information into the question-answering model of the intelligent robot, a text response result corresponding to the target object can be obtained. The text response result is also related to time information. The question-answering model can accurately understand the time concept in the text question information and make a relatively accurate result. For example, the response content is: Person A worked for company C1 in 2010.
[0124] It should be noted that the question-answering model has the ability to understand the concept of time and can accurately output the answer result. The specific question-answering model training method can be referred to the description in the above embodiment, which includes training the pre-trained information extraction ability with time and named entity extraction, as well as the question-answering model answering ability of reinforcement learning; the specifics are not limited here.
[0125] Furthermore, the edge device can also obtain model parameters from the pre-trained question-answering model sent by the cloud device, enabling local training of a question-answering model that meets local project tasks; specifically, before inputting the text question information into the question-answering model, the process further includes:
[0126] Obtain the model parameters from the pre-trained question-answering model sent by the cloud-side device;
[0127] Obtain the training samples;
[0128] The question-answering model is trained based on the training samples and the model parameters.
[0129] In practical applications, the edge device can obtain the model parameters from the pre-trained question-answering model sent by the cloud device. The pre-training phase of this pre-trained question-answering model can be completed on the cloud device, thereby enabling the pre-trained question-answering model to accurately extract time and named entities, while achieving a certain level of sensitivity to time information. After obtaining the model parameters from the pre-trained question-answering model, the edge device can then obtain local training samples. Specifically, the training samples may include text questions associated with local projects and / or corpus information. Based on the training samples and the obtained model parameters from the pre-trained question-answering model, the question-answering model is trained on the edge device.
[0130] Furthermore, the correction information corresponding to the user's text response can be obtained more conveniently on the edge device, enabling fine-tuning of the question-answering model on the edge device; specifically, after obtaining the text response result corresponding to the target object, the process further includes:
[0131] Receive correction information corresponding to the user's response to the text;
[0132] Based on the correction information, the model parameters in the question-answering model are adjusted.
[0133] The correction information can be understood as the adjustment information corresponding to the text response results output by the question-answering model, such as information that modifies the text content, word order, etc. in the response results. This embodiment does not limit this.
[0134] In practical applications, after receiving the correction information corresponding to the user's text response, the edge device can determine the difference between the text response and the correction information, and then adjust the model parameters in the question-and-answer model accordingly to fine-tune the question-and-answer model and improve the output accuracy of the question-and-answer model.
[0135] Further, see Figure 5 , Figure 5 The present specification illustrates a flowchart of a text question-and-answer processing method according to an embodiment of this specification, which specifically includes the following steps.
[0136] Step 502: Receive text question information sent by the user targeting the object.
[0137] Specifically, the edge device can receive text question information from the user regarding a target object, which includes time-related information about a specific target object.
[0138] Step 504: Obtain the model parameters from the pre-trained question-answering model sent by the cloud-side device.
[0139] Specifically, the pre-trained question answering model can be obtained by pre-training on cloud-side devices. During the pre-training process in the cloud, the time and named entities are extracted from the corpus information in the samples, i.e., the context content, and a portion of the time and named entities are randomly masked to pre-train the question answering model.
[0140] Step 506: Obtain the training samples.
[0141] It should be noted that the training samples can be understood as training samples in the local area of the edge device, and the training samples are associated with the projects in the edge device. The specific project application scenarios are not limited in this regard.
[0142] Step 508: Train the question answering model based on the training samples and the model parameters.
[0143] Specifically, the question-answering model can be trained on the local device. The training process can also utilize reinforcement learning, which assigns weights to the predicted response results to enable the model to learn the content of correct responses as well as incorrect responses, thereby improving the model's understanding of the concept of time.
[0144] Step 510: Input the text question information into the question-answering model to obtain the text response result corresponding to the target object.
[0145] Step 512: Receive correction information corresponding to the user's text response result.
[0146] Specifically, users can correct the text response results on the terminal device to obtain correction information for the text response results, which facilitates the subsequent fine-tuning of the question-answering model.
[0147] Step 514: Based on the correction information, adjust the model parameters in the question-answering model.
[0148] In summary, in this embodiment, the model parameters of the pre-trained question-answering model in the cloud device are obtained on the edge device. This means that the pre-trained question-answering model has the ability to accurately extract time-related expressions, including random masking of multiple times and multiple named entities in the corpus information, making the language model more sensitive to time-related expressions. Furthermore, the question-answering model is trained locally on the edge device through reinforcement learning, which not only improves the performance of the question-answering model on time-sensitive question-answering tasks, but also enhances the question-answering model's understanding of time concepts.
[0149] Corresponding to the above method embodiments, this specification also provides embodiments of a question-and-answer processing device. Figure 6 A schematic diagram of a question-and-answer processing device according to one embodiment of this specification is shown. Figure 6 As shown, the device includes:
[0150] Information acquisition module 602 is configured to acquire information about questions that need to be answered;
[0151] The information question answering module 604 is configured to input the question information into the question answering model and obtain the answer result corresponding to the question information; wherein, the question answering model is obtained by training a pre-trained question answering model based on the training samples, the pre-trained question answering model is obtained by training the corpus information to be processed, the corpus information to be processed is obtained by randomly masking the original corpus information, and the original corpus information includes multiple times and multiple named entities.
[0152] Optionally, the device further includes:
[0153] The first model training module is configured to acquire training samples, wherein the training samples include question text and training corpus; input the question text and the training corpus into a pre-trained question answering model to obtain a predicted response result; determine the result weight value corresponding to the predicted response result; and adjust the model parameters in the pre-trained question answering model based on the result weight value to obtain a question answering model.
[0154] Optionally, the device further includes:
[0155] The second model training module is configured to acquire pre-training samples, wherein the pre-training samples include question text and original corpus information; randomly mask the multiple times and the multiple named entities respectively to obtain corpus information to be processed; input the question text and the corpus information to be processed into the initial question answering model to obtain the original response result; and train the initial question answering model based on the original response result to obtain the pre-trained question answering model.
[0156] Optionally, the question text carries a time, or the question text is associated with a context time.
[0157] Optionally, the first model training module is further configured to: determine a response to be processed from at least one response in the predicted response result; determine a first weight corresponding to the response to be processed; determine a second weight corresponding to the predicted response information set, wherein the predicted response information set is a set of other response information in the predicted response result excluding the response to be processed; determine a target weight value corresponding to the response to be processed based on the first weight and the second weight; and determine a result weight value corresponding to the predicted response result based on the target weight value.
[0158] Optionally, the first model training module is further configured to: determine the first weight as the target weight value corresponding to the response information to be processed when the first weight is greater than or equal to the second weight; or, determine the target weight value corresponding to the response information to be processed based on the second weight when the first weight is less than the second weight.
[0159] Optionally, the second model training module is further configured to: identify the original corpus information, determine the information positions corresponding to the plurality of times and the plurality of named entities; and, based on the information positions, randomly mask the plurality of times and the plurality of named entities to obtain the corpus information to be processed.
[0160] Optionally, the device further includes:
[0161] The model fine-tuning module is configured to send the response result to the user; receive feedback from the user regarding the response result; and adjust the model parameters in the question-and-answer model based on the feedback.
[0162] The question-answering processing device provided in this specification's embodiments obtains the corresponding answer result by inputting the question information to be answered into a question-answering model. The question-answering model can be trained on a pre-trained question-answering model based on training samples. During the pre-training stage, the raw corpus information, including multiple times and multiple named entities, is randomly masked to obtain the corpus information to be processed. This enables the pre-trained question-answering model to accurately identify time expressions and named entities, thereby improving the model's performance on time-sensitive question-answering tasks. By enhancing the learning of the correlation between time and named entities during the pre-training stage of the question-answering model, the model becomes more sensitive to time-related expressions and the output accuracy of the question-answering model is improved.
[0163] The above is an illustrative scheme of a question-and-answer processing device according to this embodiment. It should be noted that the technical solution of this question-and-answer processing device and the technical solution of the question-and-answer processing method described above belong to the same concept. For details not described in detail in the technical solution of the question-and-answer processing device, please refer to the description of the technical solution of the question-and-answer processing method described above.
[0164] Figure 7 A structural block diagram of a computing device 700 according to one embodiment of this specification is shown. The components of the computing device 700 include, but are not limited to, a memory 710 and a processor 720. The processor 720 is connected to the memory 710 via a bus 730, and a database 750 is used to store data.
[0165] The computing device 700 also includes an access device 740, which enables the computing device 700 to communicate via one or more networks 760. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 740 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, or a Near Field Communication (NFC) interface.
[0166] In one embodiment of this specification, the above-described components of the computing device 700 and Figure 7 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 7 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0167] The computing device 700 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 700 can also be a mobile or stationary server.
[0168] The processor 720 is used to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the above-mentioned question-answering, question-answering model training, and text question-answering processing methods.
[0169] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device belongs to the same concept as the technical solutions of the above-mentioned question answering, question answering model training, and text question answering processing methods. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solutions of the above-mentioned question answering, question answering model training, and text question answering processing methods.
[0170] An embodiment of this specification also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the above-described question-answering, question-answering model training, and text question-answering processing methods.
[0171] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium belongs to the same concept as the technical solutions of the above-described question-answering, question-answering model training, and text question-answering processing methods. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solutions of the above-described question-answering, question-answering model training, and text question-answering processing methods.
[0172] An embodiment of this specification also provides a computer program, wherein when the computer program is executed in a computer, the computer performs the steps of the above-described question-and-answer, question-and-answer model training, and text question-and-answer processing methods.
[0173] The above is an illustrative scheme of a computer program according to this embodiment. It should be noted that the technical solution of this computer program belongs to the same concept as the technical solutions of the above-mentioned question answering, question answering model training, and text question answering processing methods. For details not described in detail in the technical solution of the computer program, please refer to the description of the technical solutions of the above-mentioned question answering, question answering model training, and text question answering processing methods.
[0174] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0175] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added or removed according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0176] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0177] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0178] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments described herein. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A question-and-answer processing method, comprising: Training a pre-trained question-answering model includes: acquiring pre-training samples, wherein the pre-training samples include question text and original corpus information, the original corpus information including multiple times and multiple named entities; randomly masking the multiple times and multiple named entities respectively to obtain corpus information to be processed; inputting the question text and the corpus information to be processed into an initial question-answering model to obtain original response results; and training the initial question-answering model based on the original response results to obtain the pre-trained question-answering model. Training a question-answering model includes: acquiring a training sample, wherein the training sample includes question text and training corpus; inputting the question text and the training corpus into the pre-trained question-answering model to obtain a predicted response result; determining the result weight value corresponding to the predicted response result; and adjusting the model parameters in the pre-trained question-answering model based on the result weight value to obtain the question-answering model. Get information on questions that are yet to be answered; The question information is input into the question-answering model to obtain the corresponding answer.
2. The method according to claim 1, wherein the question text carries a time, or the question text is associated with a context time.
3. The method according to claim 1, wherein determining the result weight value corresponding to the predicted response result includes: From at least one response message in the predicted response results, determine the response message to be processed; Determine the first weight corresponding to the response information to be processed; Determine the second weight corresponding to the predicted response information set, wherein the predicted response information set is a set of other response information in the predicted response results except for the response information to be processed; Based on the first weight and the second weight, the target weight value corresponding to the response information to be processed is determined; Based on the target weight value, the result weight value corresponding to the predicted response result is determined.
4. The method according to claim 3, wherein determining the target weight value corresponding to the response information to be processed based on the first weight and the second weight includes: If the first weight is greater than or equal to the second weight, the first weight is determined as the target weight value corresponding to the response information to be processed; or If the first weight is less than the second weight, the target weight value corresponding to the response information to be processed is determined based on the second weight.
5. The method according to any one of claims 1-4, wherein randomly masking the plurality of times and the plurality of named entities to obtain the corpus information to be processed includes: Identify the original corpus information and determine the information locations corresponding to the multiple times and the multiple named entities; Based on the information location, random masks are applied to the multiple times and the multiple named entities to obtain the corpus information to be processed.
6. The method according to claim 1, further comprising, after obtaining the response result corresponding to the question information: The response will be sent to the user. Receive feedback from the user regarding the response result; The model parameters in the question-and-answer model are adjusted based on the feedback information.
7. A question-answering model training method, applied to cloud-based devices, comprising: Training a pre-trained question-answering model includes: acquiring pre-training samples, wherein the pre-training samples include question text and original corpus information, the original corpus information including multiple times and multiple named entities; randomly masking the multiple times and multiple named entities respectively to obtain corpus information to be processed; inputting the question text and the corpus information to be processed into an initial question-answering model to obtain original response results; and training the initial question-answering model based on the original response results to obtain the pre-trained question-answering model. Training a question-answering model includes: acquiring a training sample, wherein the training sample includes question text and training corpus; inputting the question text and the training corpus into the pre-trained question-answering model to obtain a predicted response result; determining the result weight value corresponding to the predicted response result; and adjusting the model parameters in the pre-trained question-answering model based on the result weight value to obtain a question-answering model.
8. A text question-answering processing method, applied to an edge device, comprising: Receive text-based question information for the target object; The text question information is input into the question-answering model to obtain the text response result corresponding to the target object, wherein the text response result is associated with time information, and the question-answering model is obtained according to the method described in claim 7.
9. The method according to claim 8, further comprising, before inputting the text question information into the question-answering model: Obtain the model parameters from the pre-trained question-answering model sent by the cloud-side device; Obtain the training samples; The question-answering model is trained based on the training samples and the model parameters.
10. The method according to claim 9, further comprising, after obtaining the text response result corresponding to the target object: Receive correction information corresponding to the user's response to the text; Based on the correction information, the model parameters in the question-answering model are adjusted.
11. A computing device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the method according to any one of claims 1 to 10.
12. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Question and answer model training method and device and question and answer method and device
CN114328841A
Learning and forgetting combined time-sensitive answer correctness prediction method
CN114997461A