CN111339274A - Dialogue generation model training method, dialogue generation method and device - Google Patents

Dialogue generation model training method, dialogue generation method and device Download PDF

Info

Publication number
CN111339274A
CN111339274A CN202010117297.5A CN202010117297A CN111339274A CN 111339274 A CN111339274 A CN 111339274A CN 202010117297 A CN202010117297 A CN 202010117297A CN 111339274 A CN111339274 A CN 111339274A
Authority
CN
China
Prior art keywords
real
answer
sample data
group
question
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010117297.5A
Other languages
Chinese (zh)
Other versions
CN111339274B (en
Inventor
张荣升
邵建智
毛晓曦
范长杰
胡志鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202010117297.5A priority Critical patent/CN111339274B/en
Publication of CN111339274A publication Critical patent/CN111339274A/en
Application granted granted Critical
Publication of CN111339274B publication Critical patent/CN111339274B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/36Creation of semantic tools, e.g. ontology or thesauri

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present disclosure provides a dialogue generating model training method, a dialogue generating method and a device, including: acquiring multiple groups of sample data, wherein each group of sample data comprises a real question, a real answer matched with the real question and at least one similar answer corresponding to the real answer; coding according to the real questions and the similar answers in each group of sample data to obtain coded data respectively corresponding to the real questions and the similar answers in each group of sample data; obtaining a prediction dialogue corresponding to each group of sample data according to the coded data and the real answer corresponding to the real question and the similar answer in each group of sample data; and training to generate a dialogue generating model based on the predicted dialogue and the real answer respectively corresponding to each group of sample data. The similar answers in this embodiment add more available context information to the answer generation model, so that the dialog generation model can generate more informative replies and the generated dialog has diversity.

Description

Dialogue generation model training method, dialogue generation method and device
Technical Field
The present disclosure relates to the field of deep learning technologies, and in particular, to a method for training a dialog generation model, a method for generating a dialog, and an apparatus for generating a dialog.
Background
The dialog system is an important direction of deep learning application, and the current dialog system based on deep learning can be divided into two types according to implementation modes, wherein one type is a generative dialog system, and the generative dialog system receives characters input by a user and generates a reply based on the characters input by the user and a pre-trained model. The other is a retrieval type dialogue system, which is generally divided into two steps of candidate question answering recall and matching score ordering. The candidate question-answer pair recall is to retrieve similar questions in the corpus according to sentences input by the user and take out corresponding replies as a candidate set. And then, scoring the candidate replies in the user input and the candidate set by using the trained matching model to serve as the matching degree of the user input and the candidate replies in the candidate set, and then taking the candidate reply with the highest score as a final reply to be returned to the user.
The dialog generated by the generative dialog system lacks specific information in many cases, and the dialog generated by the retrievable dialog generation system lacks diversity although it does not lack specific information.
Disclosure of Invention
The embodiment of the disclosure at least provides a dialogue generation model training method, a dialogue generation method and a device.
In a first aspect, an embodiment of the present disclosure provides a method for training a dialog generation model, including: acquiring multiple groups of sample data, wherein each group of sample data comprises a real question, a real answer matched with the real question and at least one similar answer corresponding to the real answer; coding according to the real questions and the similar answers in each group of sample data to obtain coded data respectively corresponding to the real questions and the similar answers in each group of sample data; obtaining a prediction dialogue corresponding to each group of sample data according to the coded data corresponding to the real question and the similar answer in each group of sample data and the real answer; and training to generate the dialogue generating model based on the predicted dialogue and the real answer respectively corresponding to each group of the sample data.
In an optional embodiment, obtaining a set of the sample data includes: the acquiring multiple groups of sample data includes: acquiring a real question of each group of sample data in a plurality of groups of sample data and a real answer matched with the real question of each group of sample data; performing similar retrieval in a training corpus based on the real answers matched with the real questions of each group of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data; the training corpus comprises a plurality of training corpus pairs, and each training corpus pair comprises a real question and a real answer corresponding to the real question.
In an optional embodiment, the performing a similarity search in a training corpus based on the real answer matched with the real question of each set of sample data includes: sequentially performing first character matching on the real answer matched with the real question of each group of sample data and the real answer in each training corpus pair in the training corpus, and determining the real answer matched with the real question of each group of sample data and first similarity corresponding to the real answer in each training corpus pair respectively based on the result of the first character matching; and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data from the real answers in each training corpus pair based on the first similarity.
In an optional embodiment, the performing, in a training corpus, a similarity search based on the real answer matched to the real question of each group of sample data to obtain at least one similar answer corresponding to the real answer matched to the real question of each group of sample data includes: and performing similar retrieval in the training corpus based on the real questions and the matched real answers of each group of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data.
In an optional embodiment, the performing, in the training corpus, a similar search based on the real question of each group of sample data and the matched real answer to obtain at least one similar answer corresponding to the matched real answer to the real question of each group of sample data includes: taking the real question and the matched real answer of each group of sample data as a target dialogue pair, sequentially performing second character matching with each sample corpus pair in the training corpus, and determining a second similarity between each training corpus pair in the training corpus and the target dialogue pair respectively based on the result of the second character matching; and determining a plurality of target corpus pairs from each training corpus pair based on the second similarity, and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data based on the real answer in the target corpus pairs.
In an optional embodiment, the determining, based on the real answer in the target corpus pair, at least one similar answer corresponding to the real answer matched to the real question of each group of sample data includes: determining the matching degree between the real question of each group of sample data and the real answer in each target corpus pair; and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data from the real answers in each target corpus pair based on the matching degree.
In an optional implementation manner, the determining a matching degree between the real question of each group of sample data and the real answer in each target corpus pair includes: forming alternative dialogue pairs by the real questions of each group of sample data and the real answers in each target corpus pair; and obtaining the matching degree corresponding to each alternative dialogue based on a pre-trained dialogue matching model.
In an optional implementation manner, for a case that there are a plurality of similar answers corresponding to the real answer, the encoding according to the real question and the similar answer in each group of sample data to obtain encoded data corresponding to the real question and the similar answer in each group of sample data respectively includes: encoding the real problems in each group of sample data to obtain encoded data corresponding to the real problems in each group of sample data; splicing the similar answers in each group of sample data to generate spliced answers corresponding to each group of sample data; and coding the splicing answers corresponding to each group of sample data to obtain coded data corresponding to the similar answers in each group of sample data.
In an optional implementation manner, the obtaining, by the decoder, the predicted dialog corresponding to each group of sample data according to the encoded data corresponding to the real question and the similar answer in each group of sample data, respectively, includes: and carrying out multi-stage decoding processing according to the coded data corresponding to the real question and the similar answer and the real answer to obtain a prediction dialogue corresponding to each group of sample data.
In an optional implementation, the performing the multi-stage decoding process includes: for the case where the decoding process is any one of the decoding processes except the first-stage decoding process, with the decoder, the following process is performed: performing self-attention processing on the basis of the decoded data output by the previous-stage decoding processing and the real answer to obtain first intermediate characteristic data corresponding to the decoded data output by the previous-stage decoding processing; performing coding and decoding attention processing on the basis of the coded data corresponding to the real problem and the first intermediate characteristic data to obtain second intermediate characteristic data of the coded data corresponding to the real problem; coding and decoding attention processing is carried out on the basis of the coded data corresponding to the similar answers and the first intermediate characteristic data, and third intermediate characteristic data of the coded data corresponding to the similar answers are obtained; performing fusion processing on the second intermediate characteristic data and the third intermediate characteristic data to obtain target intermediate characteristic data, and performing characteristic extraction on the target intermediate characteristic data to obtain decoding data corresponding to the level of decoding processing; and obtaining a prediction dialogue corresponding to each group of sample data based on the decoded data output by the last-stage decoding processing.
In a second aspect, an embodiment of the present disclosure further provides a dialog generation method, including: acquiring a target problem; inputting the target question into a pre-trained dialogue generating model to obtain a target dialogue corresponding to the target question; the dialogue generating model is obtained by training based on the dialogue generating model training method of any one of the first aspect.
In a third aspect, an embodiment of the present disclosure further provides a dialog generation model training apparatus, including: the system comprises an acquisition module, a processing module and a display module, wherein the acquisition module is used for acquiring a plurality of groups of sample data, and each group of sample data comprises a real question, a real answer matched with the real question and at least one similar answer corresponding to the real answer; the encoding module is used for encoding according to the real questions and the similar answers in each group of sample data to obtain encoded data respectively corresponding to the real questions and the similar answers in each group of sample data; the decoding module is used for obtaining a prediction dialogue corresponding to each group of sample data according to coded data corresponding to the real question and the similar answer in each group of sample data and the real answer; and the training module is used for training based on the predicted dialogue and the real answer which respectively correspond to each group of sample data to generate the dialogue generating model.
In an optional implementation manner, the obtaining module is configured to obtain multiple sets of the sample data by: acquiring a real question of each group of sample data in a plurality of groups of sample data and a real answer matched with the real question of each group of sample data; performing similar retrieval in a training corpus based on the real answers matched with the real questions of each group of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data; the training corpus comprises a plurality of training corpus pairs, and each training corpus pair comprises a real question and a real answer corresponding to the real question.
In an optional embodiment, the obtaining module is configured to perform similarity search in a training corpus based on a real answer matching the real question of each group of sample data in the following manner: sequentially performing first character matching on the real answer matched with the real question of each group of sample data and the real answer in each training corpus pair in the training corpus, and determining the real answer matched with the real question of each group of sample data and first similarity corresponding to the real answer in each training corpus pair respectively based on the result of the first character matching; and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data from the real answers in each training corpus pair based on the first similarity.
In an optional implementation manner, the obtaining module is configured to perform similarity search in a training corpus based on a real answer matched with a real question of each group of sample data in the following manner, to obtain at least one similar answer corresponding to a real answer matched with a real question of each group of sample data: and performing similar retrieval in the training corpus based on the real questions and the matched real answers of each group of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data.
In an optional implementation manner, the obtaining module is configured to perform a similarity search in the training corpus based on the real question and the matched real answer of each group of sample data, and obtain at least one similar answer corresponding to the real answer matched to the real question of each group of sample data by: taking the real question and the matched real answer of each group of sample data as a target dialogue pair, sequentially performing second character matching with each sample corpus pair in the training corpus, and determining a second similarity between each training corpus pair in the training corpus and the target dialogue pair respectively based on the result of the second character matching; and determining a plurality of target corpus pairs from each training corpus pair based on the second similarity, and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data based on the real answer in the target corpus pairs.
In an optional embodiment, the obtaining module is configured to determine, for the real answer in the target corpus pair, at least one similar answer corresponding to the real answer matched to the real question of each group of sample data by using the following method: determining the matching degree between the real question of each group of sample data and the real answer in each target corpus pair; and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data from the real answers in each target corpus pair based on the matching degree.
In an optional implementation manner, the obtaining module is configured to determine a matching degree between the real question of each group of sample data and the real answer in each target corpus pair by using the following method: forming alternative dialogue pairs by the real questions of each group of sample data and the real answers in each target corpus pair; and obtaining the matching degree corresponding to each alternative dialogue based on a pre-trained dialogue matching model.
In an optional implementation manner, for a case that there are a plurality of similar answers corresponding to the real answer, the encoding module is configured to encode according to the real question and the similar answer in each group of sample data in the following manner, and obtain encoded data corresponding to the real question and the similar answer in each group of sample data respectively: encoding the real problems in each group of sample data to obtain encoded data corresponding to the real problems in each group of sample data; splicing the similar answers in each group of sample data to generate spliced answers corresponding to each group of sample data; and coding the splicing answers corresponding to each group of sample data to obtain coded data corresponding to the similar answers in each group of sample data.
In an optional implementation manner, the decoding module is configured to obtain the predicted dialog corresponding to each group of sample data according to the encoded data and the true answer that correspond to the true question and the similar answer in each group of sample data respectively by using the following method: and carrying out multi-stage decoding processing according to the coded data corresponding to the real question and the similar answer and the real answer to obtain a prediction dialogue corresponding to each group of sample data.
In an optional implementation, the decoding module is configured to perform a multi-stage decoding process in the following manner: for the case where the decoding process is any one of the decoding processes except the first-stage decoding process, with the decoder, the following process is performed: performing self-attention processing on the basis of the decoded data output by the previous-stage decoding processing and the real answer to obtain first intermediate characteristic data corresponding to the decoded data output by the previous-stage decoding processing; performing coding and decoding attention processing on the basis of the coded data corresponding to the real problem and the first intermediate characteristic data to obtain second intermediate characteristic data of the coded data corresponding to the real problem; coding and decoding attention processing is carried out on the basis of the coded data corresponding to the similar answers and the first intermediate characteristic data, and third intermediate characteristic data of the coded data corresponding to the similar answers are obtained; performing fusion processing on the second intermediate characteristic data and the third intermediate characteristic data to obtain target intermediate characteristic data, and performing characteristic extraction on the target intermediate characteristic data to obtain decoding data corresponding to the level of decoding processing; and obtaining a prediction dialogue corresponding to each group of sample data based on the decoded data output by the last-stage decoding processing.
In a fourth aspect, an embodiment of the present disclosure further provides a dialog generating device, including: an acquisition unit configured to acquire a target question; the generating unit is used for inputting the target question into a pre-trained dialogue generating model and obtaining a target dialogue corresponding to the target question; the dialogue generating model is obtained by training based on the dialogue generating model training method of any one of the first aspect.
In a fifth aspect, an embodiment of the present disclosure further provides a computer device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the computer device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect described above, or any one of the possible embodiments of the first aspect, or the steps of the embodiments of the second aspect described above.
In a sixth aspect, this disclosed embodiment also provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program, when executed by a processor, performs the steps in the first aspect, or any one of the possible implementations of the first aspect, or performs the steps in the implementation of the second aspect.
Each set of sample data acquired by the dialogue generating model training method provided by the disclosure comprises a real question, a real answer matched with the real question and at least one similar answer corresponding to the real answer, and in the process of training and generating the dialogue generating model based on the real question, the real answer and the at least one similar answer corresponding to the real question, the similar answers add more available background information to the answer generating model, so that the dialogue generating model can generate more informative replies.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly described below, and the drawings herein incorporated in and forming a part of the specification illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the technical solutions of the present disclosure. It is appreciated that the following drawings depict only certain embodiments of the disclosure and are therefore not to be considered limiting of its scope, for those skilled in the art will be able to derive additional related drawings therefrom without the benefit of the inventive faculty.
FIG. 1 is a flow chart illustrating a method for training a dialog generation model provided by an embodiment of the present disclosure;
FIG. 2 is a flow chart illustrating a specific method for obtaining a set of sample data provided by an embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating another specific method for obtaining a set of sample data according to an embodiment of the disclosure;
FIG. 4 is a flow chart illustrating a dialog generation method provided by an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a dialogue generating model training apparatus provided by an embodiment of the disclosure;
fig. 6 is a schematic diagram of a dialog generating device provided by an embodiment of the present disclosure;
fig. 7 shows a schematic diagram of a computer device provided by an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making creative efforts, shall fall within the protection scope of the disclosure.
Research shows that the generative dialogue system is mainly based on a seq2seq framework, wherein the input is a sentence, and the output is a sentence generated by a model. seq2seq consists of an encoder which encodes the input sentence into an intermediate representation vector and a decoder which is used to combine the output of the encoder with the already decoded partial sequence and decode the next output word. The encoder and the decoder can be realized in the form of a neural network structure such as a cyclic neural network, a convolutional neural network and the like, and in addition, attention mechanisms are mostly introduced into the existing generating dialogue system to enhance the information interaction between the encoder and the decoder so as to obtain a better decoding effect.
In a generative dialog system, since the training goal of generating a model is to maximize likelihood probability, the generated sentences tend to have better fluency, but are easy to generate general uninteresting replies. For example, a user inputs "the seabed scoops a hot pot really good and enjoys", a generative dialog system easily generates replies such as "i also feel as such", "haha, so" and the like, and the replies have no information and lack specificity, so that the dialog experience of the user is influenced.
The result of the retrieval type dialogue model is in the real language material, so that the retrieval type dialogue model has specificity and the reply quality is often higher. However, the search model cannot generate new sentences due to the existing corpus, and diversity is lacking. In addition, some corpora contain too specific information, such as names and places of specific scenes, and although the matching score is high, the corpora are not suitable for being used as a reply. For example, "Mao Do together play", "Atoko barbecue around school is enjoyable", where "Mao Do" and "Atoko" are both too background specific and not suitable as a reply to the user.
Based on the research, each set of sample data acquired by the training method of the dialog generation model provided by the disclosure comprises a real question, a real answer matched with the real question and at least one similar answer corresponding to the real answer, and in the process of training and generating the dialog generation model based on the real question, the real answer and the at least one similar answer corresponding to the real question, the similar answers add more available background information to the answer generation model, so that the dialog generation model can generate more informative replies. The above-mentioned drawbacks are the results of the inventor after practical and careful study, and therefore, the discovery process of the above-mentioned problems and the solutions proposed by the present disclosure to the above-mentioned problems should be the contribution of the inventor in the process of the present disclosure.
The technical solutions in the present disclosure will be described clearly and completely with reference to the accompanying drawings in the present disclosure, and it is to be understood that the described embodiments are only a part of the embodiments of the present disclosure, and not all of the embodiments. The components of the present disclosure, as generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making creative efforts, shall fall within the protection scope of the disclosure.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
To facilitate understanding of the present embodiment, first, a dialog generative model training method disclosed in the embodiments of the present disclosure is described in detail, where an execution subject of the dialog generative model training method provided in the embodiments of the present disclosure is generally a computer device with certain computing power, and the computer device includes, for example: the terminal device or server or other processing device, in some possible implementations, the dialog generation model training method may be implemented by a processor invoking computer-readable instructions stored in a memory.
The following describes a dialog generation model training method provided by the embodiment of the present disclosure, taking an execution subject as a terminal device as an example.
Referring to fig. 1, a flowchart of a dialog generation model training method provided in the embodiment of the present disclosure is shown, where the method includes steps S101 to S104, where:
s101: acquiring multiple groups of sample data, wherein each group of sample data comprises a real question, a real answer matched with the real question and at least one similar answer corresponding to the real answer;
s102: coding according to the real questions and the similar answers in each group of sample data to obtain coded data respectively corresponding to the real questions and the similar answers in each group of sample data;
s103: obtaining a prediction dialogue corresponding to each group of sample data according to the coded data corresponding to the real question and the similar answer in each group of sample data and the real answer;
s104: and training to generate the dialogue generating model based on the predicted dialogue and the real answer respectively corresponding to each group of the sample data.
The following describes each of the above-mentioned S101 to S104 in detail.
I: in the above S101, the similar answer corresponding to the real answer is the real answer with a certain similarity to the real answer.
Referring to fig. 2, an embodiment of the present disclosure further provides a specific method for acquiring multiple sets of sample data, including:
s201: and acquiring the real question of each group of sample data in the multiple groups of sample data and the real answer matched with the real question of each group of sample data.
Here, when a set of sample data is generated, the real question s and the real answer t in each set of sample data may be derived from a pre-constructed training corpus, or may be obtained in other manners, for example, by crawling dialog information from a network, obtaining a real question based on a question in the crawled dialog information, and obtaining a real answer based on an answer in the crawled dialog.
The pre-constructed training corpus comprises a plurality of training corpus pairs, and each training corpus pair comprises a real question and a real answer matched with the real question.
When the real question s and the real answer t in a set of sample data are from the training corpus, the real question in any training corpus of the training corpus may be used as the real question s in each set of sample data, and the real answer in any training corpus may be used as the real answer t in each set of sample data.
S202: and performing similar retrieval in a training corpus based on the real answers matched with the real questions of each group of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data.
Here, the similarity search may be performed in the training corpus, for example, in the following manner:
sequentially performing first character matching on the real answer t matched with the real question s of each group of sample data and the real answer in each training corpus pair in the training corpus, and determining the real answer t matched with the real question s of each group of sample data and first similarity corresponding to the real answer in each training corpus pair respectively based on the result of the first character matching;
and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data from the real answers in each training corpus pair based on the first similarity.
In one embodiment, for example, there are 10000 corpus pairs in the training corpus, where the ith corpus pair is expressed as: mi (si, ti), where si represents the real question in the ith corpus pair and ti represents the real answer in the ith corpus pair.
In the first character matching, t and ti are character matched.
When the real answer t in each group of sample data is first character-matched with the real answer ti in the i corpus pairs, for example, at least one of the following manners may be adopted:
matching the number of characters with the same character in t and ti, and characterizing a first similarity between t and ti through the number; the higher the number, the higher the first similarity between t and ti is considered.
Matching the number of the same characters in t and ti, and determining the number of the same characters occupying the percentage of the total number of the characters in ti based on the number of the same characters and the total number of the characters included in ti; characterizing a first similarity between t and ti by the percentage; the larger the percentage, the higher the first similarity between t and ti.
Matching the number of identical characters in t and ti, and determining the number of identical characters occupying the percentage of the total number of characters in t based on the number of identical characters and the total number of characters included in t; characterizing a first similarity between t and ti by the percentage; the larger the percentage, the higher the first similarity between t and ti.
The number of synonymous characters in t and ti are matched and a first similarity between t and ti is determined based on the number of synonymous characters. Here, in many cases, different real answers may include some characters different from each other, but the characters expressed with the same meaning, for example, the meanings expressed by "APP" and "application" are actually the same, so that the first similarity between t and ti can be determined by the number of characters with the same meaning in t and ti.
After the first similarity between the real answer in each training corpus pair in the training corpus and the real answer in the sample data is obtained, at least one real answer can be determined from each training corpus pair in the training corpus according to the sequence of the first similarity from large to small, and the at least one real answer is used as the similar answer corresponding to the real answer in the sample data.
Here, the number of similar answers may be specifically set according to actual requirements, and is not limited in the present disclosure.
In addition, similar search can be performed in the training corpus in other manners. For example, a feature extraction neural network may be used to obtain feature data of real answers in each training corpus pair in the training corpus in advance.
When the first similarity of the real answer in the corpus pair and the real answer in the sample data is determined, the distance between the feature data of the real answer in the corpus pair and the feature data of the real answer in the sample data can be calculated, and the first similarity is represented through the distance.
Referring to fig. 3, an embodiment of the present disclosure further provides another specific method for acquiring multiple sets of sample data, including:
s301: and acquiring the real questions of each group of sample data and the real answers matched with the real questions of each group of sample data.
Here, the implementation of S301 is similar to S201 described above, and is not described herein again.
S302: and performing similar retrieval in a training corpus based on the real questions and the matched real answers of each group of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data.
Here, the similarity search can be performed in the training corpus in the following manner:
taking the real questions and the matched real answers of each group of sample data as target dialogue pairs, sequentially performing second character matching with each training corpus pair in the training corpus, and determining second similarity between each training corpus pair in the training corpus and the target dialogue pairs respectively based on the result of the second character matching; and determining a plurality of target corpus pairs from each training corpus pair based on the second similarity, and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data based on the real answer in the target corpus pairs.
For example, when a set of sample data is generated, the real question of the obtained sample data is s, the real answer matched with the real question s is t, and the generated target dialog pair is (s, t).
And sequentially carrying out second character matching on each training corpus pair in the training corpus and the target dialogue pair (s, t).
For example, there are 10000 corpus pairs in the corpus, where the ith corpus pair is expressed as: mi (si, ti), where si represents the real question in the ith corpus pair and ti represents the real answer in the ith corpus pair.
When the second character matching is performed, the corpus consisting of s and t and the corpus consisting of si and ti are subjected to character matching.
Here, the specific manner of matching the second character is similar to that of matching the first character, and is not described herein again.
After obtaining the second similarity between the corpus pair and the target dialog pair in the training corpus, for example, the following method may be adopted to determine at least one similar answer corresponding to the real answer matched with the real question of each group of sample data based on the real answer in the target corpus pair:
determining the matching degree between the real question of each group of sample data and the real answer in each target corpus pair; and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data from the real answers in each target corpus pair based on the matching degree.
Here, for example, the degree of matching between the real question of the sample data and the real answer in each target corpus pair may be represented by the similarity between the real answer of the sample data and the real answer in each target corpus pair. And the higher the similarity between the real answer of the sample data and the real answer in the target corpus pair is, the higher the matching degree between the real question of the sample data and the real answer in the target corpus pair is.
Here, for example, the similarity between the true answer of the sample data and the true answer of the target corpus pair may be represented by calculating a distance between the feature data of the true answer of the sample data and the feature data of the true answer of the target corpus pair.
In addition, another specific method for determining a matching degree between a real question of sample data and a real answer in a target corpus pair is provided in the embodiments of the present disclosure, including:
forming alternative dialogue pairs by the real questions of each group of sample data and the real answers in each target corpus pair; and obtaining the matching degree corresponding to each alternative dialogue pair based on the pre-trained dialogue matching model.
Here, the dialogue matching model is trained by training corpus pairs, for example.
When a dialogue matching model is obtained through training, a positive sample is obtained based on each training corpus pair in the training corpus; and adds a match degree label to the positive sample. At this time, each positive sample includes: a real question, and a real answer that matches the real question. The matching degree label of the positive sample is 1.
In addition, a negative sample is required to be constructed, and a matching degree label is added to the negative sample. Wherein, each negative sample comprises: a real question, and answers that do not match the real question, and the matching degree label of each negative sample is 0. For example, the real problem is included in a negative example: "you have or not go to work with the company today", and the corresponding answer that does not match the real question is for example "we go to water and cook fish today".
A dialogue-matchability model is then trained based on the positive and negative samples.
When the dialogue matching degree model is applied, the alternative dialogue pairs are input into the trained dialogue matching degree model, and the matching degree between the real question of the sample data included in the alternative dialogue pairs and the real answer in the target corpus pairs is obtained.
The matching degree is between 0 and 1, the closer to 0, the lower the matching degree of the two characterizations, and the closer to 1, the higher the matching degree of the two characterizations.
And after the matching degree of each alternative dialogue pair is obtained, the real answer in the alternative dialogue pair with the matching degree meeting certain requirements is used as a similar answer corresponding to the real answer in the sample data.
The matching degree requirement is, for example: and determining similar answers according to the matching degree which is larger than a preset matching degree threshold or according to the sequence from large matching degree to small matching degree.
II: in S102, for example, an encoder may be used to encode the real question and the similar answer in each set of sample data.
Illustratively, the encoder includes, for example, one or more of: recurrent Neural Network (RNN), Long Short-Term Memory Network (LSTM), Convolutional Neural Network (CNN), and transform framework-based Neural networks.
Specifically, the following method may be adopted to obtain the encoded data corresponding to the real question and the similar answer respectively:
encoding the real problems in each group of sample data to obtain first encoded data corresponding to the real problems in each group of sample data;
and splicing the similar answers in the sample data to generate spliced answers corresponding to the sample data, and coding the spliced answers corresponding to each group of sample data to obtain coded data corresponding to the similar answers in each group of sample data.
For example, similar answers in certain sample data include: t1, t2 and t3, splicing the t1, t2 and t3 to obtain a splicing answer corresponding to each group of sample data.
In another embodiment of the present disclosure, the encoding data may also be used to perform encoding processing on the similar answers in each group of sample data respectively to obtain the encoding data corresponding to each similar answer, and then perform weighted summation on the encoding data corresponding to each similar answer, so as to obtain the encoding data corresponding to the similar answers in each group of sample data.
Here, when the encoded data corresponding to each similar answer is weighted and summed, the weights corresponding to each similar answer may be equal, or may be determined according to the similarity between each similar answer and the real answer in each set of sample data. The specific setting can be carried out according to the actual needs.
III: in S103, for example, a decoder may be used to obtain the predicted dialog corresponding to each set of sample data according to the encoded data corresponding to the real question and the similar answer in each set of sample data and the real answer.
Illustratively, the network structure of the decoder is similar to that of the encoder, e.g., if the encoder is an RNN, the decoder is typically also an RNN; if the encoder is a transform framework based neural network, the decoder is also typically a transform framework based neural network.
The embodiments of the present disclosure take a neural network in which an encoder and a decoder are both a transform framework as an example, and describe a decoding process of the decoder.
When a prediction dialog corresponding to sample data is generated, for example, multi-level decoding processing may be performed according to encoded data and a real answer that correspond to a real question and a similar answer in the sample data, so as to obtain a prediction dialog corresponding to each group of sample data.
For example, taking the example of generating a prediction dialog by a decoder, the decoder includes a 12-layer transform block structure, and each layer of transform block can perform a primary decoding process.
Each layer of transform block, when performing a primary decoding process:
a: for the case where the decoding process is the first-level decoding process, with the decoder, the following process is performed:
①, based on the real answer, Self-Attention processing (Self-Attention) is performed to obtain the first intermediate feature data corresponding to the real answer.
Here, when the multi-stage decoding process is performed by a decoder, each character in the prediction dialog is not obtained at once, but each character in the prediction dialog is predicted one by decoding a plurality of times. Therefore, when performing self-attention processing based on a real answer, a predicted position of a currently predicted character is confirmed first; and determining characters whose positions are smaller than the predicted position from the real answer based on the predicted position of the currently predicted character, and performing self-attention processing based on the determined characters. Here, the real question and the encoding result of the candidate answer are input to a decoder, and the process is supervised by the real answer to generate a prediction dialog.
For example, if the predicted position of the currently predicted character is the ith character in the whole prediction dialog, that is, the 1 st to (i-1) th characters are determined from the real answer, and the attention processing is performed to obtain the first intermediate feature data corresponding to the real answer.
②, performing coding and decoding Attention processing (Encoder-Decoder Attention) based on the coded data corresponding to the real problem and the first intermediate characteristic data to obtain second intermediate characteristic data of the coded data corresponding to the real problem;
③, and based on the coded data corresponding to the similar answer and the first intermediate characteristic data, performing coding and decoding attention processing to obtain third intermediate characteristic data of the coded data corresponding to the similar answer.
② above and ③ above are not performed in any order.
④, performing fusion processing based on the second intermediate characteristic data and the third intermediate characteristic data to obtain target intermediate characteristic data, and performing characteristic extraction on the target intermediate characteristic data to obtain decoding data corresponding to the level of decoding processing;
here, the first intermediate feature data and the second intermediate feature data may be fused by any one of splicing, superimposing, and adding and averaging the two.
B: for the case where the decoding process is any one of the decoding processes except the first-stage decoding process, with the decoder, the following process is performed:
①, performing self-attention processing based on the decoded data output by the previous decoding processing and the real answer to obtain first intermediate characteristic data corresponding to the decoded data output by the previous decoding processing;
②, performing coding and decoding attention processing based on the coded data corresponding to the real problem and the first intermediate characteristic data to obtain second intermediate characteristic data of the coded data corresponding to the real problem;
③, coding and decoding attention processing is carried out based on the coded data corresponding to the similar answers and the first intermediate characteristic data, and third intermediate characteristic data of the coded data corresponding to the similar answers are obtained;
④, performing fusion processing based on the second intermediate characteristic data and the third intermediate characteristic data to obtain target intermediate characteristic data, and performing characteristic extraction on the target intermediate characteristic data to obtain decoding data corresponding to the level of decoding processing;
and after the decoder is used for carrying out multi-stage decoding processing, obtaining the prediction dialog corresponding to each group of sample data based on the decoded data output by the last stage of decoding processing.
Here, when generating a prediction dialogue, generally, the prediction dialogue is formed by outputting one character or word by one character or word, and after a plurality of decoding processes, the characters or words output by all the decoding processes are combined.
IV: in the above S104, after the prediction dialogs corresponding to each group of sample data are obtained, the cross entropy loss of the model can be obtained based on the prediction dialogs and the real answers corresponding to each group of sample data, and then the model is trained to generate the dialog generation model according to the cross entropy loss.
After the multiple rounds of training in S102 to S104, when the number of rounds of training reaches the preset number of rounds, or when the encoder and the decoder converge, the training process of the dialog generation model is ended, and the dialog generation model with completed training is obtained.
Each set of sample data acquired by the dialogue generating model training method provided by the disclosure comprises a real question, a real answer matched with the real question and at least one similar answer corresponding to the real answer, and in the process of training and generating the dialogue generating model based on the real question, the real answer and the at least one similar answer corresponding to the real question, the similar answers add more available background information to the answer generating model, so that the dialogue generating model can generate more informative replies.
Referring to fig. 4, an embodiment of the present disclosure further provides a dialog generation method, including:
s401: acquiring a target problem;
s402: and inputting the target question into a pre-trained dialogue generating model to obtain a target dialogue corresponding to the target question.
The dialogue generating model is obtained by training based on the dialogue generating model training method of the embodiment of the disclosure.
The dialog generation model includes: an encoder and a decoder.
In the dialog generating method provided by the embodiment of the disclosure, each set of acquired sample data includes a real question, a real answer matched with the real question, and at least one similar answer corresponding to the real answer when the dialog generating model is trained, the similar answer adds more available background information to the answer generating model, so that the dialog generating model can generate more informative replies, and the generated dialog has diversity because of the dialog generating model based on encoding and decoding while overcoming the defect that the current generating dialog model lacks specific information.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
Based on the same inventive concept, a dialog generation model training device corresponding to the dialog generation model training method is also provided in the embodiments of the present disclosure, and because the principle of problem solving by the device in the embodiments of the present disclosure is similar to the above-mentioned dialog generation model training method in the embodiments of the present disclosure, the implementation of the device may refer to the implementation of the method, and repeated details are not repeated.
Referring to fig. 5, a schematic diagram of a dialog generation model training apparatus provided in an embodiment of the present disclosure is shown, where the apparatus includes: an acquisition module 51, an encoding module 52, a decoding module 53 and a training module 54; wherein the content of the first and second substances,
an obtaining module 51, configured to obtain multiple sets of sample data, where each set of sample data includes a real question, a real answer matched with the real question, and at least one similar answer corresponding to the real answer;
the encoding module 52 is configured to perform encoding according to the real questions and the similar answers in each group of sample data to obtain encoded data corresponding to the real questions and the similar answers in each group of sample data;
a decoding module 53, configured to obtain a prediction dialog corresponding to each group of sample data according to the coded data corresponding to the real question and the similar answer in each group of sample data respectively, and the real answer;
a training module 54, configured to obtain a predicted dialog corresponding to each group of sample data according to the coded data corresponding to the real question and the similar answer in each group of sample data, and the real answer.
In an optional implementation manner, the obtaining module 51 is configured to obtain multiple sets of the sample data by:
acquiring a real question of each group of sample data in a plurality of groups of sample data and a real answer matched with the real question of each group of sample data;
performing similar retrieval in a training corpus based on the real answers matched with the real questions of each group of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data;
the training corpus comprises a plurality of training corpus pairs, and each training corpus pair comprises a real question and a real answer corresponding to the real question.
In an alternative embodiment, the obtaining module 51 is configured to perform similarity search in a training corpus based on a real answer matching the real question of each set of sample data in the following manner:
sequentially performing first character matching on the real answer matched with the real question of each group of sample data and the real answer in each training corpus pair in the training corpus, and determining the real answer matched with the real question of each group of sample data and first similarity corresponding to the real answer in each training corpus pair respectively based on the result of the first character matching;
and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data from the real answers in each training corpus pair based on the first similarity.
In an optional embodiment, the obtaining module 51 is configured to perform similarity search in a training corpus based on a real answer matched with the real question of each group of sample data in the following manner, to obtain at least one similar answer corresponding to the real answer matched with the real question of each group of sample data:
and performing similar retrieval in the training corpus based on the real questions and the matched real answers of each group of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data.
In an optional embodiment, the obtaining module 51 is configured to perform similarity search in the training corpus based on the real question and the matched real answer of each group of sample data in the following manner, to obtain at least one similar answer corresponding to the real answer matched to the real question of each group of sample data:
taking the real question and the matched real answer of each group of sample data as a target dialogue pair, sequentially performing second character matching with each sample corpus pair in the training corpus, and determining a second similarity between each training corpus pair in the training corpus and the target dialogue pair respectively based on the result of the second character matching;
and determining a plurality of target corpus pairs from each training corpus pair based on the second similarity, and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data based on the real answer in the target corpus pairs.
In an optional embodiment, the obtaining module 51 is configured to determine, for the real answer in the target corpus pair, at least one similar answer corresponding to the real answer matched to the real question of each group of sample data in the following manner:
determining the matching degree between the real question of each group of sample data and the real answer in each target corpus pair;
and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data from the real answers in each target corpus pair based on the matching degree.
In an optional implementation manner, the obtaining module is configured to determine a matching degree between the real question of each group of sample data and the real answer in each target corpus pair by using the following method:
forming alternative dialogue pairs by the real questions of each group of sample data and the real answers in each target corpus pair;
and obtaining the matching degree corresponding to each alternative dialogue based on a pre-trained dialogue matching model.
In an optional implementation manner, for a case that there are a plurality of similar answers corresponding to the real answer, the encoding module 52 is configured to encode according to the real question and the similar answer in each group of sample data in the following manner, so as to obtain encoded data corresponding to the real question and the similar answer in each group of sample data respectively:
encoding the real problems in each group of sample data to obtain encoded data corresponding to the real problems in each group of sample data; and
splicing the similar answers in each group of sample data to generate a spliced answer corresponding to each group of sample data; and coding the splicing answers corresponding to each group of sample data to obtain coded data corresponding to the similar answers in each group of sample data.
In an optional implementation manner, the decoding module 53 is configured to obtain the predicted dialog corresponding to each group of sample data according to the encoded data corresponding to the real question and the similar answer in each group of sample data and the real answer in the following manner:
and carrying out multi-stage decoding processing according to the coded data corresponding to the real question and the similar answer and the real answer to obtain a prediction dialogue corresponding to each group of sample data.
In an optional implementation, the decoding module 53 is configured to perform a multi-stage decoding process in the following manner:
for the case where the decoding process is any one of the decoding processes except the first-stage decoding process, with the decoder, the following process is performed:
performing self-attention processing on the basis of the decoded data output by the previous-stage decoding processing and the real answer to obtain first intermediate characteristic data corresponding to the decoded data output by the previous-stage decoding processing;
performing coding and decoding attention processing on the basis of the coded data corresponding to the real problem and the first intermediate characteristic data to obtain second intermediate characteristic data of the coded data corresponding to the real problem;
coding and decoding attention processing is carried out on the basis of the coded data corresponding to the similar answers and the first intermediate characteristic data, and third intermediate characteristic data of the coded data corresponding to the similar answers are obtained;
performing fusion processing on the second intermediate characteristic data and the third intermediate characteristic data to obtain target intermediate characteristic data, and performing characteristic extraction on the target intermediate characteristic data to obtain decoding data corresponding to the level of decoding processing;
and obtaining a prediction dialogue corresponding to each group of sample data based on the decoded data output by the last-stage decoding processing.
The description of the processing flow of each module in the device and the interaction flow between the modules may refer to the related description in the above method embodiments, and will not be described in detail here.
Referring to fig. 6, a schematic diagram of a dialog generating device provided in an embodiment of the present disclosure is shown, where the dialog generating device includes: an acquisition unit 61, and a generation unit 62; wherein the content of the first and second substances,
an acquisition unit 61 for acquiring a target question;
and a generating unit 62, configured to input the target question into a dialog generation model trained in advance, and obtain a target dialog corresponding to the target question.
The dialogue generating model is obtained by training based on the dialogue generating model training method provided by the embodiment of the disclosure.
The embodiment of the present disclosure further provides a computer device 70, as shown in fig. 7, which is a schematic structural diagram of the computer device 70 provided in the embodiment of the present disclosure, and includes:
a processor 71, a memory 72, and a bus 73; the memory 72 is used for storing execution instructions and includes a memory 721 and an external memory 722; the memory 721 is also referred to as an internal memory, and is used for temporarily storing the operation data in the processor 71 and the data exchanged with the external memory 722 such as a hard disk, the processor 71 exchanges data with the external memory 722 through the memory 721, and when the computer device 700 is operated, the processor 71 communicates with the memory 72 through the bus 73, so that the processor 71 executes the following instructions in a user mode:
acquiring multiple groups of sample data, wherein each group of sample data comprises a real question, a real answer matched with the real question and at least one similar answer corresponding to the real answer;
coding according to the real questions and the similar answers in each group of sample data to obtain coded data respectively corresponding to the real questions and the similar answers in each group of sample data;
obtaining a prediction dialogue corresponding to each group of sample data according to the coded data corresponding to the real question and the similar answer in each group of sample data and the real answer;
and training to generate the dialogue generating model based on the predicted dialogue and the real answer respectively corresponding to each group of the sample data.
Alternatively, the following instructions are executed:
acquiring a target problem;
and inputting the target question into a pre-trained dialogue generating model to obtain a target dialogue corresponding to the target question.
The dialogue generating model is obtained by training based on the dialogue generating model training method provided by the embodiment of the disclosure.
Embodiments of the present disclosure also provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, performs the dialog generation model training method described in the above method embodiments, or performs the steps of the dialog generation method described in the above method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.
The dialog generation model training method or the computer program product of the dialog generation method provided in the embodiments of the present disclosure includes a computer-readable storage medium storing program codes, where instructions included in the program codes may be used to execute the dialog generation model training method described in the embodiments of the above-mentioned methods or execute steps of the dialog generation method described in the embodiments of the above-mentioned methods, which may be specifically referred to the embodiments of the above-mentioned methods, and are not described herein again.
The embodiments of the present disclosure also provide a computer program, which when executed by a processor implements any one of the methods of the foregoing embodiments. The computer program product may be embodied in hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK), or the like.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present disclosure. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used for illustrating the technical solutions of the present disclosure and not for limiting the same, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive of the technical solutions described in the foregoing embodiments or equivalent technical features thereof within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present disclosure, and should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (15)

1. A method for training a dialog generative model, comprising:
acquiring multiple groups of sample data, wherein each group of sample data comprises a real question, a real answer matched with the real question and at least one similar answer corresponding to the real answer;
coding according to the real questions and the similar answers in each group of sample data to obtain coded data respectively corresponding to the real questions and the similar answers in each group of sample data;
obtaining a prediction dialogue corresponding to each group of sample data according to the coded data corresponding to the real question and the similar answer in each group of sample data and the real answer;
and training to generate the dialogue generating model based on the predicted dialogue and the real answer respectively corresponding to each group of the sample data.
2. The training method of dialog generation model according to claim 1, wherein the obtaining of multiple sets of sample data comprises:
acquiring a real question of each group of sample data in a plurality of groups of sample data and a real answer matched with the real question of each group of sample data;
performing similar retrieval in a training corpus based on the real answers matched with the real questions of each group of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data;
the training corpus comprises a plurality of training corpus pairs, and each training corpus pair comprises a real question and a real answer corresponding to the real question.
3. The training method of dialog generation model according to claim 2, wherein the performing similarity search in a training corpus based on the real answer matching the real question of each set of sample data comprises:
sequentially performing first character matching on the real answer matched with the real question of each group of sample data and the real answer in each training corpus pair in the training corpus, and determining the real answer matched with the real question of each group of sample data and first similarity corresponding to the real answer in each training corpus pair respectively based on the result of the first character matching;
and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data from the real answers in each training corpus pair based on the first similarity.
4. The training method of dialog generation model according to claim 2, wherein the performing similarity search in a training corpus based on the real answer matching the real question of each group of sample data to obtain at least one similar answer corresponding to the real answer matching the real question of each group of sample data comprises:
and performing similar retrieval in the training corpus based on the real questions and the matched real answers of each group of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data.
5. The method for training a dialog generation model according to claim 4, wherein the performing a similarity search in the training corpus based on the real question and the matched real answer of each group of sample data to obtain at least one similar answer corresponding to the real answer matched to the real question of each group of sample data comprises:
taking the real question and the matched real answer of each group of sample data as a target dialogue pair, sequentially performing second character matching with each sample corpus pair in the training corpus, and determining a second similarity between each training corpus pair in the training corpus and the target dialogue pair respectively based on the result of the second character matching;
and determining a plurality of target corpus pairs from each training corpus pair based on the second similarity, and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data based on the real answer in the target corpus pairs.
6. The training method of dialog generation model according to claim 5, wherein the determining at least one similar answer corresponding to the true answer matching the true question of each group of sample data based on the true answer in the target corpus pair comprises:
determining the matching degree between the real question of each group of sample data and the real answer in each target corpus pair;
and determining at least one similar answer corresponding to the real answer matched with the real question of each group of sample data from the real answers in each target corpus pair based on the matching degree.
7. The training method of dialog generation model according to claim 6, wherein the determining the matching degree between the real question of each group of sample data and the real answer in each target corpus pair comprises:
forming alternative dialogue pairs by the real questions of each group of sample data and the real answers in each target corpus pair;
and obtaining the matching degree corresponding to each alternative dialogue based on a pre-trained dialogue matching model.
8. The method for training a dialog generation model according to any one of claims 1 to 7, wherein, for a case where there are a plurality of similar answers corresponding to the real answer, the encoding according to the real question and the similar answer in each group of the sample data to obtain encoded data corresponding to the real question and the similar answer in each group of the sample data respectively comprises:
encoding the real problems in each group of sample data to obtain encoded data corresponding to the real problems in each group of sample data; and
splicing the similar answers in each group of sample data to generate a spliced answer corresponding to each group of sample data; and coding the splicing answers corresponding to each group of sample data to obtain coded data corresponding to the similar answers in each group of sample data.
9. The training method of dialog generation model according to any one of claims 1 to 7, wherein obtaining the predicted dialog corresponding to each group of sample data according to the encoded data corresponding to the real question and the similar answer in each group of sample data and the real answer comprises:
and carrying out multi-stage decoding processing according to the coded data corresponding to the real question and the similar answer and the real answer to obtain a prediction dialogue corresponding to each group of sample data.
10. The dialog generation model training method of claim 9, wherein the performing a multi-stage decoding process comprises:
for the case where the decoding process is any one of the decoding processes except the first-stage decoding process, with the decoder, the following process is performed:
performing self-attention processing on the basis of the decoded data output by the previous-stage decoding processing and the real answer to obtain first intermediate characteristic data corresponding to the decoded data output by the previous-stage decoding processing;
performing coding and decoding attention processing on the basis of the coded data corresponding to the real problem and the first intermediate characteristic data to obtain second intermediate characteristic data of the coded data corresponding to the real problem;
coding and decoding attention processing is carried out on the basis of the coded data corresponding to the similar answers and the first intermediate characteristic data, and third intermediate characteristic data of the coded data corresponding to the similar answers are obtained;
performing fusion processing on the second intermediate characteristic data and the third intermediate characteristic data to obtain target intermediate characteristic data, and performing characteristic extraction on the target intermediate characteristic data to obtain decoding data corresponding to the level of decoding processing;
and obtaining a prediction dialogue corresponding to each group of sample data based on the decoded data output by the last-stage decoding processing.
11. A dialog generation method, comprising:
acquiring a target problem;
inputting the target question into a pre-trained dialogue generating model to obtain a target dialogue corresponding to the target question;
the dialog generation model is trained based on the dialog generation model training method of any one of claims 1-10.
12. A dialogue generating model training apparatus, comprising:
the system comprises an acquisition module, a processing module and a display module, wherein the acquisition module is used for acquiring a plurality of groups of sample data, and each group of sample data comprises a real question, a real answer matched with the real question and at least one similar answer corresponding to the real answer;
the encoding module is used for encoding according to the real questions and the similar answers in each group of sample data to obtain encoded data respectively corresponding to the real questions and the similar answers in each group of sample data;
the decoding module is used for obtaining a prediction dialogue corresponding to each group of sample data according to coded data corresponding to the real question and the similar answer in each group of sample data and the real answer;
and the training module is used for obtaining the prediction dialog corresponding to each group of sample data according to the coded data corresponding to the real question and the similar answer in each group of sample data and the real answer.
13. A dialog generation device, comprising:
an acquisition unit configured to acquire a target question;
the generating unit is used for inputting the target question into a pre-trained dialogue generating model and obtaining a target dialogue corresponding to the target question;
the dialog generation model is trained based on the dialog generation model training method of any one of claims 1-10.
14. A computer device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when a computer device is run, the machine-readable instructions, when executed by the processor, performing the steps of the dialog generation model training method according to any one of claims 1 to 10 or performing the steps of the dialog generation method according to claim 11.
15. A computer-readable storage medium, having stored thereon a computer program for performing, when being executed by a processor, the steps of the dialog generation model training method according to any one of claims 1 to 10 or the steps of the dialog generation method according to claim 11.
CN202010117297.5A 2020-02-25 2020-02-25 Dialogue generation model training method, dialogue generation method and device Active CN111339274B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010117297.5A CN111339274B (en) 2020-02-25 2020-02-25 Dialogue generation model training method, dialogue generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010117297.5A CN111339274B (en) 2020-02-25 2020-02-25 Dialogue generation model training method, dialogue generation method and device

Publications (2)

Publication Number Publication Date
CN111339274A true CN111339274A (en) 2020-06-26
CN111339274B CN111339274B (en) 2024-01-26

Family

ID=71181838

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010117297.5A Active CN111339274B (en) 2020-02-25 2020-02-25 Dialogue generation model training method, dialogue generation method and device

Country Status (1)

Country Link
CN (1) CN111339274B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112131368A (en) * 2020-09-27 2020-12-25 平安国际智慧城市科技股份有限公司 Dialog generation method and device, electronic equipment and storage medium
CN112417118A (en) * 2020-11-19 2021-02-26 上海交通大学 Dialog generation method based on marked text and neural network
CN112685536A (en) * 2020-12-25 2021-04-20 中国平安人寿保险股份有限公司 Text conversation method, text conversation device, electronic equipment and storage medium
CN116737888A (en) * 2023-01-11 2023-09-12 北京百度网讯科技有限公司 Training method of dialogue generation model and method and device for determining reply text

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108491433A (en) * 2018-02-09 2018-09-04 平安科技(深圳)有限公司 Chat answer method, electronic device and storage medium
CN110008322A (en) * 2019-03-25 2019-07-12 阿里巴巴集团控股有限公司 Art recommended method and device under more wheel session operational scenarios
CN110287296A (en) * 2019-05-21 2019-09-27 平安科技(深圳)有限公司 A kind of problem answers choosing method, device, computer equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108491433A (en) * 2018-02-09 2018-09-04 平安科技(深圳)有限公司 Chat answer method, electronic device and storage medium
CN110008322A (en) * 2019-03-25 2019-07-12 阿里巴巴集团控股有限公司 Art recommended method and device under more wheel session operational scenarios
CN110287296A (en) * 2019-05-21 2019-09-27 平安科技(深圳)有限公司 A kind of problem answers choosing method, device, computer equipment and storage medium

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112131368A (en) * 2020-09-27 2020-12-25 平安国际智慧城市科技股份有限公司 Dialog generation method and device, electronic equipment and storage medium
CN112131368B (en) * 2020-09-27 2024-02-09 深圳平安智慧医健科技有限公司 Dialogue generation method and device, electronic equipment and storage medium
CN112417118A (en) * 2020-11-19 2021-02-26 上海交通大学 Dialog generation method based on marked text and neural network
CN112417118B (en) * 2020-11-19 2023-04-07 上海交通大学 Dialog generation method based on marked text and neural network
CN112685536A (en) * 2020-12-25 2021-04-20 中国平安人寿保险股份有限公司 Text conversation method, text conversation device, electronic equipment and storage medium
CN112685536B (en) * 2020-12-25 2024-06-07 中国平安人寿保险股份有限公司 Text dialogue method, text dialogue device, electronic equipment and storage medium
CN116737888A (en) * 2023-01-11 2023-09-12 北京百度网讯科技有限公司 Training method of dialogue generation model and method and device for determining reply text
CN116737888B (en) * 2023-01-11 2024-05-17 北京百度网讯科技有限公司 Training method of dialogue generation model and method and device for determining reply text

Also Published As

Publication number Publication date
CN111339274B (en) 2024-01-26

Similar Documents

Publication Publication Date Title
CN111339274A (en) Dialogue generation model training method, dialogue generation method and device
CN107632987B (en) A kind of dialogue generation method and device
CN107944027B (en) Method and system for creating semantic key index
CN108595436B (en) Method and system for generating emotional dialogue content and storage medium
CN109858044B (en) Language processing method and device, and training method and device of language processing system
CN109582767A (en) Conversational system processing method, device, equipment and readable storage medium storing program for executing
Isbilen et al. Chunk‐based memory constraints on the cultural evolution of language
CN111966800A (en) Emotional dialogue generation method and device and emotional dialogue model training method and device
CN112765333B (en) Automatic dialogue generation method and system based on emotion and prompt word combination
CN111737439B (en) Question generation method and device
CN114511860A (en) Difference description statement generation method, device, equipment and medium
CN116415650A (en) Method, device and storage medium for generating dialogue language model and generating dialogue
CN110597968A (en) Reply selection method and device
CN112364148A (en) Deep learning method-based generative chat robot
CN117453898B (en) Cross-modal question-answering processing method and device based on thinking chain
CN114048301B (en) Satisfaction-based user simulation method and system
CN112163080A (en) Generation type dialogue system based on multi-round emotion analysis
CN115186147A (en) Method and device for generating conversation content, storage medium and terminal
CN114648032A (en) Training method and device of semantic understanding model and computer equipment
CN114912020A (en) Multi-sub-target dialogue recommendation method based on user preference graph
KR102334268B1 (en) A system for predicting user drop out rate based on artificial intelligence learning and method thereof
CN117194619A (en) Multi-round dialogue question-answering method and system based on historical position coding
CN111061851B (en) Question generation method and system based on given facts
CN115617959A (en) Question answering method and device
CN114610861B (en) End-to-end dialogue method integrating knowledge and emotion based on variational self-encoder

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant