Question answering model training method, question answering method, device, equipment and storage medium
By using multi-round dialogue content and auxiliary training tasks, a question and answer model considering multiple rounds of question and answer is constructed, which solves the problem of contextual logic inconsistency caused by a single round of question and answer in the existing technology, and improves the response accuracy and dialogue effect.
Patent Information
- Application Number
- CN202110325654.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-26
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-03-26
AI Technical Summary
The existing question and answer model only considers a single round of question and answer when modeling, resulting in illogical logic in the context of the reply content and low accuracy.
Using multiple rounds of dialogue content as training samples, a question and answer model is built by adding personal identifiers, segmenting dialogue sequences, replacement and mask processing, and considering multiple rounds of question and answer situations to improve the contextual fluency of the matching logic.
It improves the response accuracy of the question and answer model, ensures that the contextual logic of the dialogue results is smoother, and enhances the satisfaction of the dialogue effect.
Smart Images

Figure CN113033664B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and more specifically, to a question-answering model training method, a question-answering method, a device, an equipment, and a storage medium. Background Art
[0002] With the development of artificial intelligence technology, more and more complex conversational robots have emerged. According to functional classification, conversational robots include task-based conversational robots, chat robots, and customer chat robots. Among them, for any type of conversational robot, there is a complex conversation process behind it.
[0003] In the related technology, there are often multiple dialogue response modules, the most common of which are retrieval-based response modules and generative response modules. These modules will output multiple candidate replies after receiving the same user input, and input the multiple candidate replies and the user into the question-answering model to obtain the matching score between each candidate reply and the user input, and then use the candidate reply with the highest matching score as the robot's final reply content for the user input.
[0004] However, when modeling the above question-answering model, only the matching relationship between the return of the dialogue response module and the user input is considered, that is, only a single round of question-answering is considered, which may lead to the contextual logic of the final reply content being illogical, resulting in low accuracy in the reply to the user input. Summary of the invention
[0005] The purpose of this application is to provide a question-answering model training method, question-answering method, device, equipment and storage medium to address the problem of low response accuracy in the prior art.
[0006] In a first aspect, an embodiment of the present application provides a question-answering model training method, the method comprising:
[0007] Acquire a training sample, wherein the training sample includes: a plurality of continuous multi-round dialogue contents, each round of dialogue contents includes an input content sample and a reply content sample, and the training sample is annotated with indication information of whether the input content sample of the last round of each of the multi-round dialogue contents and the reply content sample of the last round match;
[0008] Model training is performed according to the training samples to obtain a question-answering model.
[0009] Optionally, performing model training according to the training samples to obtain a question-answering model includes:
[0010] Adding corresponding person identifiers to the input content sample and the reply content sample respectively to obtain training samples after adding the person identifiers;
[0011] Model training is performed based on the training samples after adding the person identifier to obtain the question-answering model.
[0012] Optionally, performing model training according to the training samples to obtain a question-answering model includes:
[0013] Segmenting the dialogue sequence formed by the multiple rounds of dialogue content to obtain a historical dialogue sequence and a predicted dialogue sequence, wherein the dialogue time of the historical dialogue sequence is before the dialogue time of the predicted dialogue sequence;
[0014] According to the historical dialogue sequence and the predicted dialogue sequence, two groups of training samples are obtained respectively, wherein the two groups of training samples are annotated with indication information of whether the historical dialogue sequence is replaced and indication information of whether the predicted dialogue sequence is replaced;
[0015] Model training is performed based on the two groups of training samples to obtain the question-answering model.
[0016] Optionally, obtaining two groups of training samples according to the historical dialogue sequence and the predicted dialogue sequence respectively includes:
[0017] Replace any dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence to obtain a first negative dialogue sample;
[0018] A first positive dialogue sample is obtained according to the historical dialogue sequence and the unreplaced dialogue sequence in the predicted dialogue sequence; the two groups of training samples include: the first negative dialogue sample and the first positive dialogue sample.
[0019] Optionally, segmenting the dialogue sequence formed by the multiple rounds of dialogue content to obtain the historical dialogue sequence and the predicted dialogue sequence includes:
[0020] According to the preset conversation content sequence number, the conversation sequence composed of the multiple rounds of conversation content is segmented to obtain the historical conversation sequence and the predicted conversation sequence; the historical conversation sequence includes: the conversation content of the preset conversation content sequence number, and the conversation content before the preset conversation content sequence number.
[0021] Optionally, before segmenting the dialogue sequence consisting of the plurality of consecutive dialogue rounds according to the preset dialogue content sequence numbers to obtain the historical dialogue sequence and the predicted dialogue sequence, the method further comprises:
[0022] The preset conversation content sequence number is randomly determined from a plurality of conversation content sequence numbers of the conversation sequence.
[0023] Optionally, replacing the dialogue content of any dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence to obtain a first negative dialogue sample includes:
[0024] According to a preset probability value, randomly selecting a dialogue content to be replaced from the dialogue content of any dialogue sequence;
[0025] The to-be-replaced conversation content is replaced to obtain the first negative conversation sample.
[0026] Optionally, performing model training according to the training samples to obtain a question-answering model includes:
[0027] Performing masking processing on a portion of the dialogue sequences formed by the multiple rounds of dialogue contents to obtain a masked sequence;
[0028] The question-answering model is obtained by performing model training based on the masked sequence and the sequence in the dialogue sequence that has not been masked, wherein the dialogue sequence in the dialogue sequence that has not been masked is annotated with the original dialogue content corresponding to the partial sequence.
[0029] Optionally, performing model training according to the training samples to obtain a question-answering model includes:
[0030] Replacing a portion of a sequence corresponding to the same person identifier in a dialogue sequence formed by each of the multiple rounds of dialogue content to obtain a second negative dialogue sample of the same person identifier;
[0031] Obtaining a second positive dialogue sample of the same person identifier according to an unreplaced sequence corresponding to the same person identifier in the dialogue sequence;
[0032] A logic training sample is obtained according to the second negative dialogue sample and the second positive dialogue sample, wherein the logic training sample is annotated with indication information indicating that the second negative dialogue sample is replaced and indication information indicating that the second positive dialogue sample is not replaced.
[0033] Model training is performed according to the logic training samples to obtain the question-answering model.
[0034] In a second aspect, another embodiment of the present application provides a question-answering method, the method comprising:
[0035] Processing the input content according to a plurality of preset dialogue response models to obtain a plurality of candidate response contents corresponding to the input content;
[0036] Inputting the input content, multiple rounds of historical conversation content continuous with the input content, and the multiple candidate reply contents into a pre-trained question-answering model to obtain a matching degree between each candidate reply content and the input content, wherein the pre-trained question-answering model is trained according to the method described in any one of the first aspects;
[0037] According to the matching degree, final reply content for the input content is determined from the multiple candidate reply contents.
[0038] In a third aspect, another embodiment of the present application provides a question-answering model training device, comprising:
[0039] An acquisition module is used to acquire training samples, wherein the training samples include: a plurality of continuous multi-round dialogue contents, each round of dialogue contents includes an input content sample and a reply content sample, and the training samples are annotated with indication information of whether the input content sample of the last round of each of the multi-round dialogues and the reply content sample of the last round match;
[0040] The training module is used to perform model training based on the training samples to obtain a question-answering model.
[0041] Optionally, the training module is specifically used to:
[0042] Adding corresponding person identifiers to the input content sample and the reply content sample respectively to obtain training samples after adding the person identifiers;
[0043] Model training is performed based on the training samples after adding the person identifier to obtain the question-answering model.
[0044] Optionally, the training module is specifically used to:
[0045] Segmenting the dialogue sequence formed by the multiple rounds of dialogue content to obtain a historical dialogue sequence and a predicted dialogue sequence, wherein the dialogue time of the historical dialogue sequence is before the dialogue time of the predicted dialogue sequence;
[0046] According to the historical dialogue sequence and the predicted dialogue sequence, two groups of training samples are obtained respectively, wherein the two groups of training samples are annotated with indication information of whether the historical dialogue sequence is replaced and indication information of whether the predicted dialogue sequence is replaced;
[0047] Model training is performed based on the two groups of training samples to obtain the question-answering model.
[0048] Optionally, the training module is specifically used to:
[0049] Replace any dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence to obtain a first negative dialogue sample;
[0050] A first positive dialogue sample is obtained according to the historical dialogue sequence and the unreplaced dialogue sequence in the predicted dialogue sequence; the two groups of training samples include: the first negative dialogue sample and the first positive dialogue sample.
[0051] Optionally, the training module is specifically used to:
[0052] According to the preset conversation content sequence number, the conversation sequence composed of the multiple rounds of conversation content is segmented to obtain the historical conversation sequence and the predicted conversation sequence; the historical conversation sequence includes: the conversation content of the preset conversation content sequence number, and the conversation content before the preset conversation content sequence number.
[0053] Optionally, it also includes:
[0054] The determination module is used to randomly determine the preset dialogue content sequence number from multiple dialogue content sequence numbers of the dialogue sequence.
[0055] Optionally, the training module is specifically used to:
[0056] According to a preset probability value, randomly selecting the dialogue content to be replaced from the dialogue content of any dialogue sequence;
[0057] The to-be-replaced conversation content is replaced to obtain the first negative conversation sample.
[0058] Optionally, the training module is specifically used to:
[0059] Performing masking processing on a portion of the dialogue sequences formed by the multiple rounds of dialogue contents to obtain a masked sequence;
[0060] The question-answering model is obtained by performing model training based on the masked sequence and the sequence in the dialogue sequence that has not been masked, wherein the dialogue sequence in the dialogue sequence that has not been masked is annotated with the original dialogue content corresponding to the partial sequence.
[0061] Optionally, the training module is specifically used to:
[0062] Replacing a portion of a sequence corresponding to the same person identifier in a dialogue sequence formed by each of the multiple rounds of dialogue content to obtain a second negative dialogue sample of the same person identifier;
[0063] Obtaining a second positive dialogue sample of the same person identifier according to an unreplaced sequence corresponding to the same person identifier in the dialogue sequence;
[0064] A logic training sample is obtained according to the second negative dialogue sample and the second positive dialogue sample, wherein the logic training sample is annotated with indication information indicating that the second negative dialogue sample is replaced and indication information indicating that the second positive dialogue sample is not replaced.
[0065] Model training is performed according to the logic training samples to obtain the question-answering model.
[0066] In a fourth aspect, another embodiment of the present application provides a question-answering device, including:
[0067] A processing module, used to process the input content according to a plurality of preset dialogue response models to obtain a plurality of candidate reply contents corresponding to the input content;
[0068] an input module, configured to input the input content, multiple rounds of historical conversation content continuous with the input content, and the multiple candidate reply contents into a pre-trained question-answering model, to obtain a matching degree between each candidate reply content and the input content, wherein the pre-trained question-answering model is trained according to the method described in any one of the first aspects;
[0069] A determination module is used to determine the final reply content of the input content from the multiple candidate reply contents according to the matching degree.
[0070] In the fifth aspect, another embodiment of the present application provides a question-answering model training device, comprising: a processor, a memory and a bus, the memory storing a computer program executable by the processor, when the question-answering model training device is running, the processor communicates with the memory through the bus, and the processor executes the computer program to execute any one of the methods described in the first aspect.
[0071] In the sixth aspect, another embodiment of the present application provides a question-and-answer device, comprising: a processor, a memory and a bus, wherein the memory stores a computer program executable by the processor, and when the question-and-answer device is running, the processor communicates with the memory via the bus, and the processor executes the computer program to execute any one of the methods described in the first aspect.
[0072] In the seventh aspect, another embodiment of the present application provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method described in any one of the first aspect and the second aspect is executed.
[0073] The present application provides a question-answering model training method, a question-answering method, an apparatus, a device and a storage medium, and relates to the field of artificial intelligence technology, wherein the question-answering model training method includes: obtaining training samples, the training samples include: a plurality of continuous multi-round dialogue contents, each round of dialogue contents includes an input content sample and a reply content sample, the training samples are annotated with indication information of whether the input content sample of the last round and the reply content sample of the last round in each multi-round dialogue content match, and the model is trained according to the training samples to obtain a question-answering model. When modeling the question-answering model, the present application takes into account the multi-round question-answering situation, and the dialogue results returned by the question-answering model when performing the matching logic can make the context logic smoother and improve the reply accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0075] Figure 1 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 1 ;
[0076] Figure 2 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 2 ;
[0077] Figure 3 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 3 ;
[0078] Figure 4 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 4 ;
[0079] Figure 5 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 5 ;
[0080] Figure 6 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 6 ;
[0081] Figure 7 A schematic diagram of the process of the question-answering method provided in an embodiment of the present application is shown;
[0082] Figure 8A schematic diagram of the structure of a question-answering model training device provided in an embodiment of the present application is shown;
[0083] Fig. 9 A schematic diagram of the structure of the question-answering device provided in an embodiment of the present application is shown;
[0084] Fig.10 A schematic diagram of the structure of a question-answering model training device provided in an embodiment of the present application is shown;
[0085] Fig.11 A schematic diagram of the structure of a question-and-answer device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0086] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of order, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0087] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0088] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0089] With the development of artificial intelligence technology, more and more complex conversational robots have emerged. The main functions of conversational robots include but are not limited to the following categories: task-based conversational robots used to solve tasks such as helping people book air tickets and check the weather; chat robots used to help people relax and entertain, and chat with companions; some customer service chat robots that help people reduce the pressure of manual customer service.
[0090] Behind any of the above-mentioned types of robots is a complex dialogue process. In real scenarios, most dialogue robots are passively triggered, that is, each response of the dialogue robot is triggered by user input. Depending on the system design framework, there will be several different dialogue response function modules, the most common of which are retrieval response modules and generative response modules. After receiving the same user input, these modules will generate or retrieve several different outputs according to their own module characteristics. The sorting module (i.e., the question-answering model), which is the final component of the overall function, comprehensively considers the matching degree between the return of each dialogue response function module and the user input as a metric score, and uses the metric score as the score returned by each dialogue response function module. Then, the return value of the dialogue response function module with the highest score is used as the final return of the robot, that is, the candidate response with the highest metric score is used as the final response content of the robot for the user input, where the return value of each dialogue response function module is a candidate response.
[0091] The existing ranking module is a single-round question-answering model. The single-round question-answering model refers to the modeling process that only considers the user input and the response text obtained by the upstream module based on the user input, and outputs the matching score. During the model training phase, a number of existing single-round paired dialogue data, such as user input and collected real responses, will be prepared as positive samples for single-round question-answering model training; negative samples required for model training are obtained by negative sampling, which means keeping the user input unchanged and using random sampling and word co-occurrence sampling as the sampling method for negative samples. This question-answering model is actually a positive and negative binary classification model, whose loss function is cross entropy. Its training goal is to make the model learn the difference between positive and negative samples as much as possible, so that the model can perceive which examples are likely to match the positive samples.
[0092] In the inference stage of the question-answering model, for the trained question-answering model, when each user input comes and the upstream module (i.e., the dialogue response function module) returns a value based on the user input, the question-answering model will concatenate the current user input and the return value of the upstream module, and after the neural network changes, it will output a value between [0, 1] as the matching score between the return value of the upstream module and the user input. The higher the value, the more the return value matches the user input. Under such a model structure, if multiple upstream modules have return values for the current user input, then multiple single-round question-answering model inference stages will be performed.
[0093] However, the existing technical solutions only consider the matching relationship between the upstream module return and the current user input in modeling, that is, only consider the single-round question and answer situation. In such a scenario, it cannot be guaranteed that the matching between the user input and the return value of the upstream module satisfies a certain contextual semantic relationship; and considering that when the user uses the dialogue system, the user will naturally consider the context to observe the return value of the current robot, so the matching score of the return value of the existing solution may not be accurate enough, that is, it may cause the final reply content context logic to be incoherent, so that the reply accuracy rate for the user input is not high, which will cause a logical fault, resulting in a situation of semantic obstruction. For example: the user inputs "playing games, how about you?", if only from this input, as the focus of the model, then the final reply content determined by the question and answer model may be "I am good at playing games", but in fact the content of the multi-round dialogue is: "The weather is good today, what are you doing?", "Playing games, how about you?", it can be seen that the user actually wants to ask "What are you doing?", so a sentence like "I am good at playing games" causes a logical fault and semantic obstruction.
[0094] In addition, because the existing technical solutions regard the sorting problem as a question-answering model when modeling, and because in the question-answering model, the content of the reply must be a sentence with internal logical self-consistency, the existing modeling method cannot handle well some return values with internal logical incoherence caused by the upstream module, that is, it does not take into account the possible logical inconsistency of the upstream module, resulting in some candidate replies that are logically inconsistent themselves getting higher scores.
[0095] Based on the above problems, the present application provides a question-answering model training method. When modeling the question-answering model, multiple rounds of question-answering situations are taken into consideration. The dialogue results returned by the question-answering model when performing matching logic can make the context logic smoother and improve the accuracy of the response. In addition, considering that the existing technical solutions did not take into account the possible logical inconsistency of the upstream module during modeling, resulting in some candidate responses that are logically inconsistent themselves obtaining higher scores, the present application uses several different self-learning auxiliary tasks during the modeling process to enable the question-answering model to implicitly improve the syntactic and lexical information of logically consistent sentences, so as to better meet the coherence of semantic information and the coherence of topic content style habits, thereby improving the scores of candidate responses that are more in line with the context sequence semantics, thereby improving the accuracy of the question-answering model and the satisfaction with the dialogue effect.
[0096] The question-answering model training method provided in this application is described in detail below in conjunction with several specific embodiments.
[0097] Figure 1 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 1The execution subject of this embodiment may be a question-answering model training device, such as a conversational robot, a terminal device, a server, etc. Figure 1 As shown, the method may include:
[0098] S101. Obtain training samples, where the training samples include: a plurality of consecutive multi-round dialogue contents, where each round of dialogue contents includes an input content sample and a reply content sample, and the training samples are annotated with indication information of whether the input content sample of the last round and the reply content sample of the last round in each multi-round dialogue match.
[0099] S102: Perform model training based on training samples to obtain a question-answering model.
[0100] Among them, multiple consecutive multi-round dialogue contents can be obtained from a preset dialogue content database, and each round of dialogue content includes an input content sample and a reply content sample. For a dialogue robot, the input content sample can be a content sample spoken by the user, such as "what day is today", and the reply content sample can be a content sample returned to the user by the dialogue robot, such as "today is Monday".
[0101] Exemplarily, multiple rounds of conversation content may include, for example, a first-round input content sample: "The weather is nice today", a first-round reply content sample: "Yes, it's very suitable for sunbathing, what are you doing", a second-round input content sample: "Playing games, what about you?", a second-round reply content sample: "I'm playing games".
[0102] It should be noted that the multi-round dialogue content can be three-round dialogue content or four-round dialogue content. The number of multi-round dialogue content can be selected according to actual conditions. This embodiment does not specifically limit the number of rounds of dialogue content and the number of multi-round dialogue content.
[0103] The training sample is annotated with indication information of whether the input content sample of the last round and the reply content sample of the last round in each round of multi-round dialogue content match, wherein, if the input content sample and the reply content sample match, it indicates that the reply content sample is an accurate reply to the input content sample, for example, the input content sample is: "What day is today", and the reply content sample is "Today is Monday"; if the input content sample and the reply content sample do not match, it indicates that the reply content sample is not an accurate reply to the input content sample, for example, the input content sample is "What day is today", and the reply content sample is "I am eating".
[0104] If the indication information indicates that the input content samples of the last round and the reply content samples of the last round match, it means that the input content samples of the last round and the reply content samples of the last round are both positive samples, that is, the input content sample is: "What day is today", and the reply content sample is "Today is Monday", which is a group of positive samples; if the indication information indicates that the input content samples of the last round and the reply content samples of the last round do not match, it means that the input content samples of the last round and the reply content samples of the last round are both negative samples, that is, the input content sample is "What day is today", and the reply content sample is "I am eating" is a group of negative samples.
[0105] That is to say, the last round of input content samples and the last round of reply content samples in each multi-round dialogue content are taken as a benchmark, combined with the multi-round input content samples and the multi-round reply content samples before the last round, that is, multiple rounds of question and answer situations are taken into consideration, and then the model is trained according to the training samples to obtain the question and answer model. In this way, multiple rounds of question and answer situations are integrated and introduced in the question and answer model training process, which solves the problem that when the user input is strongly correlated with the above information, the negative impact brought by the above information is not considered. After introducing the specific historical information of the previous rounds, the user's true thoughts can be implicitly introduced.
[0106] The question-answering model training method of this embodiment obtains training samples, which include: multiple consecutive multi-round dialogue contents, each round of dialogue contents includes input content samples and reply content samples, and the training samples are annotated with indication information of whether the input content samples of the last round and the reply content samples of the last round in each multi-round dialogue match, and the model is trained according to the training samples to obtain a question-answering model. When modeling the question-answering model, this embodiment takes into account the multi-round question-answering situation, and the dialogue results returned by the question-answering model when performing matching logic can make the context logic smoother and improve the reply accuracy.
[0107] For example, in order to make it easier for the question-answering model to learn relevant information from multiple rounds and improve the accuracy of responses, explicit person input can be used in the modeling process. Figure 2 To explain, Figure 2 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 2 ,like Figure 2 As shown, step S102 may include:
[0108] S201. Add corresponding person identifiers to an input content sample and a reply content sample respectively to obtain training samples after adding the person identifiers.
[0109] S202: Perform model training based on the training samples after adding the person identifier to obtain a question-answering model.
[0110] The person identifier corresponding to the input content sample may be identification information of the speaker corresponding to the input content sample, and the person identifier corresponding to the reply content sample may be identification information of the speaker corresponding to the reply content sample.
[0111] Add the corresponding personal identifier to the input content sample to obtain the input content sample after the personal identifier is added, add the corresponding personal identifier to the reply content sample to obtain the reply content sample after the personal identifier is added, and the training samples after the personal identifier is added include: the input content sample after the personal identifier is added and the reply content sample after the personal identifier is added.
[0112] Exemplarily, the person identifier corresponding to the input content sample may be, for example, "you", and the person identifier corresponding to the reply content sample may be, for example, "I", that is, all content input by the user is explicitly marked with "you said", and all content returned by the conversational robot is explicitly marked with "I said".
[0113] Exemplarily, the training samples may include two consecutive rounds of multi-round conversation content, the two consecutive rounds of multi-round conversation content include the first round input content sample and the first round reply content sample, the second round input content sample and the second round reply content sample, then the training samples after adding the person identifier may include the first round input content sample after adding the identifier, the first round reply content sample after adding the identifier, the second round input content sample after adding the identifier, and the second round reply content sample after adding the identifier. For example, you say: "The weather is nice today", I say: "Yes, it's very suitable for basking in the sun, what are you doing", you say: "Playing games, what about you?", I say: "I'm playing games".
[0114] Corresponding person identifiers are added to the input content sample and the reply content sample respectively to obtain training samples after adding the person identifiers. Then, a model is trained based on the training samples after adding the person identifiers to obtain a question-answering model. Such explicit identifiers can help the question-answering model explicitly learn the relationship between person objects.
[0115] The question-answering model training method of this embodiment adds corresponding person identifiers to the input content sample and the reply content sample, respectively, obtains the training sample after adding the person identifier, and performs model training based on the training sample after adding the person identifier to obtain the question-answering model. By explicitly using the explicit identifier, it helps the question-answering model to explicitly learn the relationship between the person object, and thus better understand the relationship between the input content sample and the reply content sample, thereby improving the reply accuracy.
[0116] Exemplarily, in order to enable the question-answering model to better learn the semantically logical relationship, during model training, the present application also designs several self-learning auxiliary training tasks, including: the next dialogue segment prediction task, the sentence-level masked language model task, and the semantically incoherent sentence recognition task.
[0117] The first auxiliary training task: Due to the natural sequential relationship between dialogues, the next dialogue content segment usually shows strong semantic relevance with the previous segment in the context. Inspired by this feature, a more general response prediction task with dialogue context is designed, named prediction of the next dialogue segment, to fully utilize the sequential relationship of dialogue data and enhance the model's ability to measure semantic relevance. Such an auxiliary task can help the model implicitly perceive which response or historical information is relatively logical given a certain amount of historical information or response segment. Specifically, the next dialogue prediction task requires the model to predict whether two sequences are continuous and related. Figure 3 The examples are described below.
[0118] Figure 3 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 3 ,like Figure 3 As shown, step S102 may include:
[0119] S301. Segment the dialogue sequence consisting of the contents of each multi-round dialogue to obtain a historical dialogue sequence and a predicted dialogue sequence.
[0120] The dialogue sequence formed by each round of dialogue content may be a dialogue sequence obtained by sorting the input content samples and the reply content samples of each round of dialogue content in each round of dialogue content.
[0121] For example, the multi-turn conversation content can include, for example, the first-round input content sample: "The weather is nice today", the first-round reply content sample: "Yes, it's very suitable for sunbathing. What are you doing?", the second-round input content sample: "Playing games. What about you?", the second-round reply content sample: "I'm reading and sunbathing", the third-round input content sample: "Then you are leisurely and interesting", the third-round reply content sample: "You can also live such a life, put down the computer and get close to nature", the fourth-round input content sample: "I refuse", the fourth-round reply content sample: "Sure enough, it's you". Therefore, the conversation sequence formed by this multi-turn conversation content can be c = <u1: The weather is nice today, u2: Yes, it's very suitable for sunbathing. What are you doing?, u3: Playing games. What about you?, u4: I'm reading and sunbathing, u5: Then you are leisurely and interesting, u6: You can also live such a life, put down the computer and get close to nature, u7: I refuse, u8: Sure enough, it's you>, where c represents the conversation sequence and u_ represents the conversation content serial number.
[0122] Segment the conversation sequence formed by each multi-turn conversation content into two parts, denoted as: c_left and c_right. c_left is the historical conversation sequence and c_right is the predicted conversation sequence. Among them, the conversation time of the historical conversation sequence is before the conversation time of the predicted conversation sequence. That is to say, the conversation time of c_left is before the conversation time of c_right, that is, the time when the input text content sample and the reply content sample in c_left are said is earlier than the time when the input text content and the reply content sample in c_right are said.
[0123] Optionally, step S301 may include:
[0124] Segment the conversation sequence formed by each multi-turn conversation content according to the preset conversation content serial number to obtain the historical conversation sequence and the predicted conversation sequence.
[0125] Among them, the preset conversation content serial number can be a fixed conversation content serial number or a randomly determined conversation content serial number. For example, it can be serial number 4. Then, according to the preset conversation content serial number, segment the conversation content formed by each multi-turn conversation content to obtain the historical conversation sequence and the predicted conversation sequence. The historical conversation sequence includes: the conversation content of the preset conversation content serial number and the conversation content before the preset conversation content serial number.
[0126] Taking the above example as an example, if the preset conversation content is 4, then segment the conversation sequence formed by the multi-turn conversation content into c_left and c_right. c_left is the conversation sequence from u1 to u3, and c_right is the conversation sequence from u5 to u8.
[0127] Optionally, before segmenting the dialogue sequence consisting of multiple rounds of dialogue content according to a preset dialogue content sequence number to obtain the historical dialogue sequence and the predicted dialogue sequence, the method further includes:
[0128] A preset conversation content sequence number is randomly determined from a plurality of conversation content sequence numbers of the conversation sequence.
[0129] If the preset conversation content sequence number is randomly determined, then before segmenting the conversation sequence, the preset conversation content sequence number can also be randomly determined from multiple conversation content sequence numbers of the conversation sequence, so that segmentation of the conversation sequence is more flexible.
[0130] S302: Obtain two groups of training samples according to the historical dialogue sequence and the predicted dialogue sequence.
[0131] S303: Perform model training based on the two groups of training samples to obtain a question-answering model.
[0132] The two sets of training samples are annotated with indication information of whether the historical dialogue sequence is replaced, and indication information of whether the predicted dialogue sequence is replaced.
[0133] If both the historical dialogue sequence and the predicted dialogue sequence are not replaced, it means that the historical dialogue sequence and the predicted dialogue sequence are both a set of positive dialogue samples, which together form two sets of training samples. The two sets of training samples are annotated with indication information that the historical dialogue sequence is not replaced and indication information that the predicted dialogue sequence is not replaced.
[0134] If the historical dialogue sequence or the predicted dialogue sequence is replaced, it means that there is a group of positive dialogue samples and a group of negative dialogue samples in the historical dialogue sequence and the predicted dialogue sequence, which together form two groups of training samples. The two groups of training samples are annotated with indication information that the historical dialogue sequence or the predicted dialogue sequence is replaced, and indication information that one of them is not replaced.
[0135] Then, the model is trained based on the two groups of training samples to obtain a question-answering model. That is to say, during the training process, the model input is two groups of training samples, and the goal of the model training is to determine whether the historical dialogue sequence and the predicted dialogue sequence are replaced.
[0136] It should be noted that the training samples in step S101 include the contents of each multiple round of dialogue, and the training samples are marked with indication information on whether the input content sample of the last round and the reply content sample of the last round in each multiple round of dialogue content match. The two groups of training samples in this embodiment are determined by the training samples in step S101, that is, the training samples in step S101 include the two groups of training samples. Therefore, when the model is trained according to the two groups of training samples, the question-answering model can be trained in parallel based on multiple rounds of question-answering situations and the prediction task of the next dialogue segment.
[0137] The question-answering model training method of this embodiment divides the dialogue sequence composed of each multi-round dialogue content to obtain a historical dialogue sequence and a predicted dialogue sequence, obtains two sets of training samples based on the historical dialogue sequence and the predicted dialogue sequence, respectively, and performs model training based on the two sets of training samples to obtain a question-answering model. In the embodiment, the question-answering model can better learn the logical and coherent relationship in semantics through this auxiliary learning task, so as to reduce the scores of candidate replies that are not logically self-consistent and increase the scores of candidate replies that are more consistent with the semantics of the context sequence, thereby improving the accuracy of the question-answering model and the satisfaction with the dialogue effect.
[0138] Combine the following Figure 4 The embodiment describes a possible implementation method of two sets of training samples. Figure 4 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 4 ,like Figure 4 As shown, step S302 includes:
[0139] S401: Replace any dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence to obtain a first negative dialogue sample.
[0140] S402: Obtain a first positive dialogue sample according to the historical dialogue sequence and the unreplaced dialogue sequence in the predicted dialogue sequence.
[0141] Any dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence is replaced, and the replaced dialogue sequence is the first negative dialogue sample. The unreplaced dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence is used as the first positive dialogue sample, wherein the two groups of training samples include: the first negative dialogue sample and the first positive dialogue sample.
[0142] If the historical dialogue sequence is replaced, it means that the historical dialogue sequence is the first negative dialogue sample, and correspondingly, the predicted dialogue sequence is the first positive dialogue sample. The two groups of training samples are annotated with: indication information that the historical dialogue sequence is replaced, and indication information that the predicted dialogue sequence is not replaced. Then, model training is performed based on the replaced historical dialogue sequence and the predicted dialogue sequence to obtain a question-answering model.
[0143] Similarly, if the historical dialogue sequence has not been replaced, it means that the historical dialogue sequence is the first positive dialogue sample, and correspondingly, the predicted dialogue sequence is the first negative dialogue sample. The two groups of training samples are annotated with: indication information that the historical dialogue sequence has not been replaced, and indication information that the predicted dialogue sequence has been replaced. Then, the model is trained based on the historical dialogue sequence and the replaced predicted dialogue sequence to obtain a question-answering model.
[0144] Optionally, step S401 includes:
[0145] Randomly select the dialogue content to be replaced from the dialogue content of any dialogue sequence according to a preset probability value.
[0146] Replace the dialogue content to be replaced to obtain the first negative dialogue sample.
[0147] The preset probability value can be the number of parts to be replaced selected from the dialogue content of any dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence. For example, if the preset probability value is 50%, and the historical dialogue sequence is the dialogue sequence to be replaced, then 50% of the dialogue content to be replaced can be randomly selected from the dialogue content of the historical dialogue sequence, and the other content is used to replace the 50% of the dialogue content to be replaced to obtain the first negative dialogue sample.
[0148] Taking the above example, c_left is the dialogue sequence of u1 to u3, c_right is the dialogue sequence of u5 to u8, the preset probability value is 30%, and c_left is the dialogue sequence to be replaced. c_left = <u1: The weather is nice today, u2: Yeah, it's very suitable for sunbathing. What are you doing, u3: Playing games. What about you?>. Then, "Yeah, it's very suitable for sunbathing. What are you doing" of u2 can be randomly replaced with "What day of the week is today". After replacement, c_left = <u1: The weather is nice today, u2: What day of the week is today, u3: Playing games. What about you?>.
[0149] In the question-and-answer model training method of this embodiment, the dialogue content of any dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence is replaced to obtain the first negative dialogue sample, and the first positive dialogue sample is obtained according to the dialogue sequence of the non-replaced dialogue content in the historical dialogue sequence and the predicted dialogue sequence. In this embodiment, by constructing negative and positive dialogue samples for model training, the question-and-answer model can better learn the logical coherence relationship in semantics, so that the scores of candidate replies with inconsistent logic are reduced, and the scores of candidate replies that are more in line with the semantic context of the context sequence are increased, thereby improving the accuracy of the question-and-answer model and the satisfaction of the dialogue effect.
[0150] The second auxiliary training task: Inspired by the current mainstream pre-trained language models, use word-level masked language modeling to guide the model to learn the semantic and syntactic features of the word sequence in the bidirectional context, that is, by masking some words in a sentence and using the unmasked context to restore these masked words. Specifically, all the words in one randomly sampled sentence from all the dialogues are masked, and then the model is allowed to use the sentence information in the remaining context to predict the content of the masked sentence. By learning to predict the appropriate words suitable for the surrounding dialogue context, the model can implicitly obtain the syntactic and lexical information of logically consistent sentences in the context of the given context. The following is combined with Figure 5The embodiments will be described.
[0151] Figure 5 The flowchart of the Q&A model training method provided by the embodiments of the present application is shown Figure 5 , as Figure 5 shown, step S102 may include:
[0152] S501. Mask a partial sequence in the dialogue sequence composed of each multi-round dialogue content to obtain a masked sequence.
[0153] S502. Train a model based on the masked sequence and the sequence in the dialogue sequence that is not masked to obtain a Q&A model.
[0154] Among them, the partial sequence in the dialogue sequence composed of each multi-round dialogue content may be the sequence corresponding to at least one input content sample and / or the sequence corresponding to at least one reply content sample in the dialogue sequence.
[0155] Mask a partial sequence in the dialogue sequence composed of each multi-round dialogue content to obtain a masked sequence, and then train a model based on the masked sequence and the sequence in the dialogue sequence that is not masked to obtain a Q&A model, where the sequence in the dialogue sequence that is not masked is labeled with the original dialogue content corresponding to the partial sequence.
[0156] For example, the dialogue sequence composed of multi-round dialogue content may be c = <u1: The weather is nice today, u2: Yeah, it's very suitable for sunbathing. What are you doing? u3: Playing games. What about you?, u4: I'm reading and sunbathing, u5: Then you are leisurely and interesting, u6: You can also live such a life. Put down the computer and get close to nature, u7: I refuse, u8: You are really something>. Randomly mask the sequence 3 in this dialogue sequence to obtain a masked sequence, and the masked sequence is denoted as
[0157] u3 = [MASK][MASK][MASK][MASK][MASK][MASK][MASK], where
[0158] [MASK] represents a specific character for masking. u3 has a total of 7 characters, so here it becomes a sentence composed of 7 [MASK].
[0159] Then, the model is trained based on the masked sequence (i.e. u3) and the unmasked sequences in the dialogue sequence (i.e. u1-u2, u4-u8) to obtain a question-answering model, in which the unmasked sequences (i.e. u1-u2, u4-u8) are annotated with the original dialogue content corresponding to some sequences (i.e. u3) (i.e. playing games, how about you?). That is to say, during the training process, the model input is the masked sequence and the unmasked sequence in the dialogue sequence, and the goal of the model training is to predict what the [MASK] in the masked sequence should really be.
[0160] It should be noted that the training samples in step S101 include the contents of each multiple round of dialogue, and the training samples are marked with indication information on whether the input content sample of the last round and the reply content sample of the last round in each multiple round of dialogue content match, and the mask sequence and the sequence that are not masked in the dialogue sequence in this embodiment are determined by the training samples in step S101, that is, the training samples in step S101 include the mask sequence and the sequence that are not masked. Therefore, in this embodiment, the question-answering model can be trained in parallel based on multiple rounds of question-answering situations and the masked language model task at the sentence level.
[0161] The question-answering model training method of this embodiment performs masking on a portion of the dialogue sequence composed of each multi-round dialogue content to obtain a masked sequence, and performs model training based on the masked sequence and the sequence that is not masked in the dialogue sequence to obtain a question-answering model. In this embodiment, by learning to predict appropriate utterances that are suitable for the surrounding dialogue context, the model can implicitly obtain the syntactic and lexical information of a logically self-consistent sentence in a given context, thereby improving the accuracy of the question-answering model and the satisfaction of the dialogue effect.
[0162] The third auxiliary training task: From the study of normal conversations, we can find that conversations from the same conversation share similar topics, and speeches from the same speaker in the same conversation tend to maintain the same personality or style. Based on this feature, such a task can be constructed through the semantic coherence of sentences. That is, the content from the same interlocutor in a conversation is regarded as a positive sample, and negative samples are constructed by random sampling. Based on such a task, the model can implicitly obtain that the current response must be related to the topic content discussed above, and the scores of sentences that meet the same topic content can be improved. Next, combined with Figure 6 The examples are described below.
[0163] Figure 6 The process diagram of the question-answering model training method provided in the embodiment of the present application is shown Figure 6 ,like Figure 6 As shown, step S102 may include:
[0164] S601. Replace the partial sequences corresponding to the same person identifier in the dialogue sequence composed of the contents of multiple rounds of conversations to obtain the second negative dialogue sample for the same person identifier.
[0165] S602. Obtain the second positive dialogue sample for the same person identifier according to the un-replaced sequences corresponding to the same person identifier in the dialogue sequence.
[0166] S603. Obtain the logical training sample according to the second negative dialogue sample and the second positive dialogue sample.
[0167] S604. Perform model training according to the logical training sample to obtain the question-answering model.
[0168] Among them, the sequences corresponding to the same person identifier in the dialogue sequence composed of the contents of multiple rounds of conversations refer to the sequences corresponding to the contents spoken by the same speaker in this dialogue sequence.
[0169] The partial sequences corresponding to the same person identifier can be at least one sequence corresponding to the same person identifier. Taking the above example, the dialogue sequence composed of the contents of multiple rounds of conversations can be c = <u1: The weather is nice today, u2: Yeah, it's very suitable for sunbathing. What are you doing? u3: Playing games. What about you? u4: I'm reading and sunbathing. u5: Then you are leisurely and interesting. u6: You can also live such a life. Put down the computer and get close to nature. u7: I refuse. u8:不愧是你>. Among them, u1, u3, u5, u7 belong to the conversations of the same interlocutor, and u2, u4, u6, u8 are the conversations of the same interlocutor. The conversations belonging to the same speaker maintain a certain logical topic coherence internally.
[0170] Then other content can be used to replace the partial sequences corresponding to the same person identifier in this dialogue sequence to obtain the second negative dialogue sample for the same person identifier. For example, replace u7 "I refuse" with "New Year's Day is a legal holiday in China". Among them, since u1, u3, and u5 are all talking about the scene of chatting and playing games, and the last sentence is a statement-related sentence, which belongs to the content that destroys the same speaker. Such a sample is the second negative dialogue sample for model training.
[0171] Then, the un-replaced sequences corresponding to the same person identifier in the dialogue sequence are used as the second positive dialogue sample for the same person identifier. According to the second negative dialogue sample and the second positive dialogue sample, the logical training sample is obtained. The logical training sample is marked with the indication information that the second negative dialogue sample is replaced and the indication information that the second positive dialogue sample is not replaced. That is, during the training process, the model inputs are the second negative dialogue sample and the second positive dialogue sample, and the goal of model training is to judge whether the second negative dialogue sample is replaced.
[0172] It should be noted that the training samples in step S101 include the contents of each multiple round of dialogue, and the training samples are marked with indication information of whether the input content sample of the last round and the reply content sample of the last round in each multiple round of dialogue content match. The second negative dialogue sample and the second positive dialogue sample in this embodiment are determined by the training samples in step S101, that is, the training samples in step S101 include the second negative dialogue sample and the second positive dialogue sample. Therefore, in this embodiment, the question-answering model can be trained in parallel based on multiple rounds of question-answering situations and semantically incoherent sentence recognition tasks.
[0173] The question-answering model training method of this embodiment replaces a part of the sequence corresponding to the same person identifier in the dialogue sequence composed of each multi-round dialogue content to obtain a second negative dialogue sample of the same person identifier, obtains a second positive dialogue sample of the same person identifier based on the unreplaced sequence corresponding to the same person identifier in the dialogue sequence, obtains a logical training sample based on the second negative dialogue sample and the second positive dialogue sample, and performs model training based on the logical training sample to obtain a question-answering model. In this embodiment, the model can implicitly learn the logic and coherence of the same speaker, thereby improving the accuracy of the question-answering model and the satisfaction of the dialogue effect.
[0174] It should be noted that the above method embodiment describes the process of training the question-answering model based on considering multiple rounds of question-answering situations, respectively combining personal identifiers and three auxiliary training tasks. In practical applications, the model training can also be carried out in parallel by comprehensively combining multiple rounds of question-answering situations, personal identifiers, and three auxiliary training tasks to obtain a question-answering model. By explicitly introducing historical information, the question-answering model can take certain historical information into consideration when sorting, so that the dialogue results returned when matching logic can make the context logic relatively smoother. Through several different self-learning auxiliary tasks, the question-answering model can implicitly improve the syntactic and lexical information of logically self-consistent sentences, implicitly and better meet the coherence of semantic information and the coherence of topic content style habits, so that sentences that meet the above characteristics can get higher matching scores, thereby improving the satisfaction with the dialogue effect and the accuracy of the sorting model.
[0175] Figure 7 A schematic diagram of the process of the question-answering method provided in the embodiment of the present application is shown. Figure 6 As shown, the method may include:
[0176] S701: Process input content according to multiple preset dialogue response models to obtain multiple candidate reply contents corresponding to the input content.
[0177] Among them, the input content is the user input to be replied, and the dialogue response model is used to return candidate response content based on the input content. Multiple dialogue response models may include, for example: a retrieval response model and a generative response model. The input content is input into multiple dialogue response models respectively to obtain a candidate response content output by each dialogue response model.
[0178] S702: Input the input content, multiple rounds of historical conversation content that are continuous with the input content, and multiple candidate reply content into a pre-trained question-answering model to obtain a matching degree between each candidate reply content and the input content.
[0179] Each round of continuous historical conversation content includes: historical input content and historical reply content. The historical reply content can be returned by the conversation robot based on the historical input content. The input content, multiple rounds of historical conversation content continuous with the input content, and multiple candidate reply contents are input into the pre-trained question-answering model to obtain the matching degree of each candidate reply content and the input content. The pre-trained question-answering model is based on Figures 1 to 5 The method shown in the embodiment is trained.
[0180] Among them, the input content, multiple rounds of historical conversation content continuous with the input content, and multiple candidate reply contents can all be added with corresponding personal identifiers. For example, the personal identifier corresponding to the input content can be, for example, "you", and the personal identifier corresponding to the candidate reply content can be, for example, "I". The personal identifier corresponding to the historical input content in each round of historical conversation content can be, for example, "you", and the personal identifier corresponding to the historical reply content can be, for example, "I". That is, the input content is marked with "you said", the candidate reply content is marked with "I said", the historical input content is marked with "you said", and the historical reply content is marked with "I said".
[0181] For example, the content of continuous multi-round historical dialogue includes you saying: "The weather is nice today", I saying: "Yes, it's very suitable for basking in the sun, what are you doing", and the input content is you saying "playing games, what about you?" Taking two dialogue response models as an example, the candidate response content includes: I said: "I'm playing games", I said "Today is Monday".
[0182] You say: "It's a nice day today", I say: "Yes, it's very suitable for sunbathing, what are you doing", you say: "Playing games, how about you?", I say: "I'm playing games", I say "Today is Monday" are input into the pre-trained question-answering model, and the matching degree between the candidate reply content I say: "I'm playing games" and the input content you say: "Playing games, how about you?" and the matching degree between the candidate reply content I say "Today is Monday" and the input content you say: "Playing games, how about you?" can be obtained. The matching degree can be represented by a value between [0, 1], and the higher the value, the better the match with the input content. Among them, the matching degree between the candidate reply content I say "Today is Monday" and the input content you say: "Playing games, how about you?" can be 0.1, and the matching degree between the candidate reply content I say: "I'm playing games" and the input content you say: "Playing games, how about you?" can be 0.8.
[0183] S703: Determine final reply content for the input content from a plurality of candidate reply contents according to the matching degree.
[0184] Specifically, the candidate reply content with the highest matching degree can be selected from multiple candidate reply contents as the final reply content of the input content, that is, the conversation robot can return the candidate reply content with the highest matching degree to the user. Taking the above example, I said: "I am playing games" as the final reply content of the input content and you said "playing games, how about you?". The conversation results returned by the question-and-answer model when performing matching logic can make the matching metric of the candidate reply content that best matches the user input the highest, thereby improving the reply accuracy.
[0185] Of course, multiple candidate reply contents with a matching degree greater than a preset matching degree may also be returned to the user, and this embodiment does not specifically limit this.
[0186] The question-answering method of this embodiment processes input content according to multiple preset dialogue response models to obtain multiple candidate reply contents corresponding to the input content, inputs the input content, multiple rounds of historical dialogue contents continuous with the input content, and multiple candidate reply contents into a pre-trained question-answering model to obtain a matching degree between each candidate reply content and the input content, and determines the final reply content of the input content from the multiple candidate reply contents based on the matching degree. The dialogue results returned by the question-answering model when performing matching logic can make the context logic smoother and improve the reply accuracy.
[0187] Figure 8 FIG. 1 shows a schematic diagram of the structure of the question-answering model training device provided in an embodiment of the present application. The question-answering model training device 10 can be integrated into a question-answering model training device. Figure 8 As shown, the question-answering model training device 10 includes:
[0188] The acquisition module 11 is used to acquire training samples, wherein the training samples include: a plurality of continuous multi-round dialogue contents, each round of dialogue contents includes an input content sample and a reply content sample, and the training samples are annotated with indication information of whether the input content sample of the last round of each of the multi-round dialogues and the reply content sample of the last round match;
[0189] The training module 12 is used to perform model training according to the training samples to obtain a question-answering model.
[0190] Optionally, the training module 12 is specifically used for:
[0191] Adding corresponding person identifiers to the input content sample and the reply content sample respectively to obtain training samples after adding the person identifiers;
[0192] Model training is performed based on the training samples after adding the person identifier to obtain the question-answering model.
[0193] Optionally, the training module 12 is specifically used for:
[0194] Segmenting the dialogue sequence formed by the multiple rounds of dialogue content to obtain a historical dialogue sequence and a predicted dialogue sequence, wherein the dialogue time of the historical dialogue sequence is before the dialogue time of the predicted dialogue sequence;
[0195] According to the historical dialogue sequence and the predicted dialogue sequence, two groups of training samples are obtained respectively, wherein the two groups of training samples are annotated with indication information of whether the historical dialogue sequence is replaced and indication information of whether the predicted dialogue sequence is replaced;
[0196] Model training is performed based on the two groups of training samples to obtain the question-answering model.
[0197] Optionally, the training module 12 is specifically used for:
[0198] Replace any dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence to obtain a first negative dialogue sample;
[0199] A first positive dialogue sample is obtained according to the historical dialogue sequence and the unreplaced dialogue sequence in the predicted dialogue sequence; the two groups of training samples include: the first negative dialogue sample and the first positive dialogue sample.
[0200] Optionally, the training module 12 is specifically used for:
[0201] According to the preset conversation content sequence number, the conversation sequence composed of the multiple rounds of conversation content is segmented to obtain the historical conversation sequence and the predicted conversation sequence; the historical conversation sequence includes: the conversation content of the preset conversation content sequence number, and the conversation content before the preset conversation content sequence number.
[0202] Optionally, it also includes:
[0203] The determination module 13 is used to randomly determine the preset conversation content sequence number from a plurality of conversation content sequence numbers of the conversation sequence.
[0204] Optionally, the training module 12 is specifically used for:
[0205] According to a preset probability value, randomly selecting a dialogue content to be replaced from the dialogue content of any dialogue sequence;
[0206] The to-be-replaced conversation content is replaced to obtain the first negative conversation sample.
[0207] Optionally, the training module is specifically used to:
[0208] Performing masking processing on a portion of the dialogue sequences formed by the multiple rounds of dialogue contents to obtain a masked sequence;
[0209] The question-answering model is obtained by performing model training based on the masked sequence and the sequence in the dialogue sequence that has not been masked, wherein the dialogue sequence in the dialogue sequence that has not been masked is annotated with the original dialogue content corresponding to the partial sequence.
[0210] Optionally, the training module 12 is specifically used for:
[0211] Replacing a portion of a sequence corresponding to the same person identifier in a dialogue sequence formed by each of the multiple rounds of dialogue content to obtain a second negative dialogue sample of the same person identifier;
[0212] Obtaining a second positive dialogue sample of the same person identifier according to an unreplaced sequence corresponding to the same person identifier in the dialogue sequence;
[0213] A logic training sample is obtained according to the second negative dialogue sample and the second positive dialogue sample, wherein the logic training sample is annotated with indication information indicating that the second negative dialogue sample is replaced and indication information indicating that the second positive dialogue sample is not replaced.
[0214] Model training is performed according to the logic training samples to obtain the question-answering model.
[0215] The question-answering model training device of this embodiment, the implementation process and implementation principle can refer to the question-answering model training method provided in the above method embodiment, and will not be repeated here.
[0216] Fig. 9 FIG. 2 shows a schematic diagram of the structure of the question-answering device provided in an embodiment of the present application. The question-answering device 20 can be integrated into a question-answering device, for example, a conversational robot. Fig. 9 As shown, the question-answering device 20 includes:
[0217] A processing module 21 is used to process the input content according to a plurality of preset dialogue response models to obtain a plurality of candidate response contents corresponding to the input content;
[0218] An input module 22, configured to input the input content, multiple rounds of historical conversation content continuous with the input content, and the multiple candidate reply contents into a pre-trained question-answering model to obtain a matching degree between each candidate reply content and the input content, wherein the pre-trained question-answering model is trained according to the method described in any one of the first aspects;
[0219] The determination module 23 is used to determine the final reply content of the input content from the multiple candidate reply contents according to the matching degree.
[0220] The question-and-answer device of this embodiment, its implementation process and implementation principle can refer to the question-and-answer method provided in the above method embodiment, and will not be described in detail here.
[0221] Fig.10 The structure diagram of the question-answering model training device provided in the embodiment of the present application is shown as follows: Fig.10 As shown, the question-answering model training device 30 includes: a processor 31, a memory 32 and a bus 33. The memory 32 stores a computer program executable by the processor 31. When the question-answering model training device 30 is running, the processor 31 communicates with the memory 32 through the bus 33, and the processor 31 executes the computer program to execute the question-answering model training method provided by the above method embodiment.
[0222] Fig.11 The structure diagram of the question-answering device provided in the embodiment of the present application is shown as follows: Fig.11 As shown, the question-and-answer device 40 includes: a processor 41, a memory 42 and a bus 43. The memory 42 stores a computer program executable by the processor 41. When the question-and-answer device 40 is running, the processor 41 communicates with the memory 42 through the bus 43, and the processor 41 executes the computer program to execute the question-and-answer method provided by the above method embodiment.
[0223] The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above method embodiment is executed.
[0224] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0225] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or part of the technical solution that contributes to the prior art or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program code.
[0226] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.
Claims
1. A question-answering model training method, characterized in that: include: Acquire a training sample, wherein the training sample includes: a plurality of continuous multi-round dialogue contents, each round of dialogue contents includes an input content sample and a reply content sample, and the training sample is annotated with indication information of whether the input content sample of the last round of each of the multi-round dialogue contents and the reply content sample of the last round match; Performing model training according to the training samples to obtain a question-answering model; The step of performing model training according to the training samples to obtain a question-answering model includes: Adding corresponding person identifiers to the input content sample and the reply content sample respectively to obtain training samples after adding the person identifiers, wherein the person identifier corresponding to the input content sample is identification information of the speaker corresponding to the input content sample, and the person identifier corresponding to the reply content sample is identification information of the speaker corresponding to the reply content sample; Model training is performed based on the training samples after adding the person identifier to obtain the question-answering model.
2. The method according to claim 1, characterized in that The step of performing model training according to the training samples to obtain a question-answering model includes: Segmenting the dialogue sequence formed by the multiple rounds of dialogue content to obtain a historical dialogue sequence and a predicted dialogue sequence, wherein the dialogue time of the historical dialogue sequence is before the dialogue time of the predicted dialogue sequence; According to the historical dialogue sequence and the predicted dialogue sequence, two groups of training samples are obtained respectively, wherein the two groups of training samples are annotated with indication information of whether the historical dialogue sequence is replaced and indication information of whether the predicted dialogue sequence is replaced; Model training is performed based on the two groups of training samples to obtain the question-answering model.
3. The method according to claim 2, characterized in that The step of obtaining two sets of training samples according to the historical dialogue sequence and the predicted dialogue sequence respectively includes: Replace any dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence to obtain a first negative dialogue sample; A first positive dialogue sample is obtained according to the historical dialogue sequence and the unreplaced dialogue sequence in the predicted dialogue sequence; the two groups of training samples include: the first negative dialogue sample and the first positive dialogue sample.
4. The method according to claim 2, characterized in that: The segmenting of the dialogue sequence formed by the multiple rounds of dialogue contents to obtain the historical dialogue sequence and the predicted dialogue sequence includes: According to the preset conversation content sequence number, the conversation sequence composed of the multiple rounds of conversation content is segmented to obtain the historical conversation sequence and the predicted conversation sequence; the historical conversation sequence includes: the conversation content of the preset conversation content sequence number, and the conversation content before the preset conversation content sequence number.
5. The method according to claim 4, characterized in that Before segmenting the dialogue sequence consisting of the plurality of consecutive dialogue rounds according to the preset dialogue content sequence numbers to obtain the historical dialogue sequence and the predicted dialogue sequence, the method further includes: The preset conversation content sequence number is randomly determined from a plurality of conversation content sequence numbers of the conversation sequence.
6. The method according to claim 3, characterized in that: The replacing the dialogue content of any dialogue sequence in the historical dialogue sequence and the predicted dialogue sequence to obtain a first negative dialogue sample includes: According to a preset probability value, randomly selecting the dialogue content to be replaced from the dialogue content of any dialogue sequence; The to-be-replaced conversation content is replaced to obtain the first negative conversation sample.
7. The method according to claim 1, characterized in that The step of performing model training according to the training samples to obtain a question-answering model includes: Performing masking processing on a portion of the dialogue sequences formed by the multiple rounds of dialogue contents to obtain a masked sequence; The question-answering model is obtained by performing model training based on the masked sequence and the sequence in the dialogue sequence that has not been masked, wherein the dialogue sequence in the dialogue sequence that has not been masked is annotated with the original dialogue content corresponding to the partial sequence.
8. The method according to claim 1, characterized in that The step of performing model training according to the training samples to obtain a question-answering model includes: Replacing a portion of a sequence corresponding to the same person identifier in a dialogue sequence formed by each of the multiple rounds of dialogue content to obtain a second negative dialogue sample of the same person identifier; Obtaining a second positive dialogue sample of the same person identifier according to an unreplaced sequence corresponding to the same person identifier in the dialogue sequence; Obtaining a logic training sample according to the second negative dialogue sample and the second positive dialogue sample, wherein the logic training sample is annotated with indication information indicating that the second negative dialogue sample is replaced and indication information indicating that the second positive dialogue sample is not replaced; Model training is performed according to the logic training samples to obtain the question-answering model.
9. A question-answering method, characterized in that: include: Processing the input content according to a plurality of preset dialogue response models to obtain a plurality of candidate response contents corresponding to the input content; Inputting the input content, multiple rounds of historical conversation content continuous with the input content, and the multiple candidate reply content into a pre-trained question-answering model to obtain a matching degree between each candidate reply content and the input content, wherein the pre-trained question-answering model is trained according to the method according to any one of claims 1 to 8; According to the matching degree, final reply content for the input content is determined from the multiple candidate reply contents.
10. A question-answering model training device, characterized in that: include: An acquisition module is used to acquire training samples, wherein the training samples include: a plurality of continuous multi-round dialogue contents, each round of dialogue contents includes an input content sample and a reply content sample, and the training samples are annotated with indication information of whether the input content sample of the last round of each of the multi-round dialogues and the reply content sample of the last round match; A training module, used to perform model training based on the training samples to obtain a question-answering model; The training module is specifically used for: Adding corresponding person identifiers to the input content sample and the reply content sample respectively to obtain training samples after adding the person identifiers; Model training is performed based on the training samples after adding the person identifier to obtain the question-answering model, the person identifier corresponding to the input content sample is the identification information of the speaker corresponding to the input content sample, and the person identifier corresponding to the reply content sample is the identification information of the speaker corresponding to the reply content sample.
11. A question-answering device, characterized in that: include: A processing module, used to process the input content according to a plurality of preset dialogue response models to obtain a plurality of candidate reply contents corresponding to the input content; An input module, used to input the input content, multiple rounds of historical conversation content continuous with the input content, and the multiple candidate reply content into a pre-trained question-answering model to obtain a matching degree between each candidate reply content and the input content, wherein the pre-trained question-answering model is trained according to the method according to any one of claims 1 to 8; A determination module is used to determine the final reply content of the input content from the multiple candidate reply contents according to the matching degree.
12. A question-answering model training device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores a computer program executable by the processor. When the question-answering model training device is running, the processor communicates with the memory via the bus, and the processor executes the computer program to perform the method described in any one of claims 1 to 8.
13. A question-answering device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores a computer program executable by the processor, and when the question-answering device is running, the processor communicates with the memory via the bus, and the processor executes the computer program to perform the method according to claim 9.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Context-based topic updating data processing method and apparatus
CN105704013A
Intelligent robot chat context implementation method and system based on corpus annotation
CN110059169A
Information processing method, session response method and device
CN110162600A
Model training method and device, dialogue system evaluation method and device, equipment and storage medium
CN110188331A
A method for training dialog state tracking classifier and computer equipment
CN110245221A
