CN111339274B - 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
CN111339274B
CN111339274B CN202010117297.5A CN202010117297A CN111339274B CN 111339274 B CN111339274 B CN 111339274B CN 202010117297 A CN202010117297 A CN 202010117297A CN 111339274 B CN111339274 B CN 111339274B
Authority
CN
China
Prior art keywords
real
sample data
answer
answers
similar
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.)
Active
Application number
CN202010117297.5A
Other languages
Chinese (zh)
Other versions
CN111339274A (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

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 disclosure provides a dialogue generation model training method, a dialogue generation method and a device, comprising the following steps: obtaining a plurality of 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; according to the coded data and the real answers 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; training is performed based on the prediction dialogue and the real answer respectively corresponding to each group of sample data to generate a dialogue generation model. In this embodiment, the similar answers add more available background information to the answer generation model, so that the dialogue generation model can generate more informative replies, and the generated dialogues have diversity.

Description

Dialogue generation model training method, dialogue generation method and device
Technical Field
The disclosure relates to the technical field of deep learning, in particular to a dialogue generation model training method, a dialogue generation method and a dialogue generation device.
Background
The dialogue system is an important direction of deep learning application, and the current dialogue system based on deep learning can be divided into two types according to implementation modes, one is a generating dialogue system, and the generating dialogue system accepts 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 retrievable dialogue system, which is generally divided into two steps, candidate question-answering versus recall and matching scoring. The candidate question-answer pair recall is to search out similar questions in the corpus according to sentences input by the user, and take out corresponding replies as candidate sets. And then scoring the candidate replies in the user input and candidate set by using the trained matching model to serve as the matching degree of the user input and the candidate replies, and then taking out the candidate replies with the highest scores to serve as final replies to be returned to the user.
In many cases, the generated conversations lack specific information, and the conversations generated by the search conversations generation system lack diversity, although the conversations generated by the generation conversations do 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 dialogue generation device.
In a first aspect, an embodiment of the present disclosure provides a dialog generation model training method, including: obtaining a plurality of 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 questions and the similar answers in each group of sample data and the real answers; training is carried out based on the prediction dialogue and the real answer which are respectively corresponding to each group of the sample data so as to generate the dialogue generation model.
In an alternative embodiment, acquiring a set of the sample data includes: the acquiring multiple sets of sample data includes: acquiring a real problem of each group of sample data in a plurality of groups of sample data and a real answer matched with the real problem 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 answers 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 performing similar retrieval in the training corpus based on the real answer matched with the real questions of each set of sample data includes: sequentially performing first character matching on the real answers matched with the real questions of each group of sample data and the real answers in each training corpus pair in the training corpus, and determining first similarity corresponding to the real answers in each training corpus pair respectively on the basis of the result of the first character matching; based on the first similarity, at least one similar answer corresponding to a real answer matched with the real question of each set of sample data is determined from the real answers in each training corpus pair.
In an alternative embodiment, the performing similar search in the training corpus based on the real answer matched with the real questions of each set of sample data to obtain at least one similar answer corresponding to the real answer matched with the real questions of each set 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 answers matched with the real questions of each group of sample data.
In an alternative embodiment, the performing similar search in the training corpus based on the real questions of each set of sample data and the matched real answers to obtain at least one similar answer corresponding to the real answer matched to the real questions of each set of sample data includes: taking the real questions and the matched real answers of each group of sample data as target dialogue pairs, sequentially carrying out second character matching with each sample corpus pair in the training corpus, and determining second similarity between each training corpus pair in the training corpus and the target dialogue pair respectively based on the second character matching result; 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 a real answer matched with the real question of each set of sample data based on the real answer in the target corpus pairs.
In an alternative embodiment, the determining, based on the real answers in the target corpus pair, at least one similar answer corresponding to the real answer matched with the real question of each set of sample data includes: determining the matching degree between the real questions of each group of sample data and the real answers in each target corpus pair; and determining at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data from the real answers in each target corpus pair based on the matching degree.
In an alternative embodiment, the determining the matching degree between the real questions of each set of sample data and the real answers in each of the target corpus pairs includes: the real questions of each group of sample data and the real answers of each target corpus pair form alternative dialogue pairs; and obtaining the matching degree corresponding to each alternative dialogue pair based on a pre-trained dialogue matching model.
In an optional implementation manner, for a case that there are multiple similar answers corresponding to the real answer, the encoding is performed according to the real questions and the similar answers in each set of sample data, so as to obtain encoded data respectively corresponding to the real questions and the similar answers in each set of sample data, where the encoding includes: carrying out coding processing on the real problems in each group of sample data to obtain coded data corresponding to the real problems in each group of sample data; splicing similar answers in each group of sample data to generate spliced answers corresponding to each group of sample data; and carrying out coding processing on 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.
In an optional implementation manner, the obtaining, by using a decoder, a prediction dialogue corresponding to each set of sample data according to the coded data corresponding to the real question and the similar answer in each set of sample data and the real answer includes: and carrying out multistage decoding processing according to the coded data respectively corresponding to the real questions and the similar answers and the real answers to obtain a prediction dialogue corresponding to each group of sample data.
In an alternative embodiment, the performing a multi-level decoding process includes: for the case where the decoding process is any one of the decoding processes except the first-stage decoding process, the following procedure is performed with the decoder: based on the decoded data output by the previous stage decoding process and the real answer, performing self-attention processing to obtain first intermediate characteristic data corresponding to the decoded data output by the previous stage decoding process; performing coding and decoding attention processing based on the coded data corresponding to the real problem and the first intermediate feature data to obtain second intermediate feature data of the coded data corresponding to the real problem; and performing coding and decoding attention processing based on the coded data corresponding to the similar answer and the first intermediate feature data to obtain third intermediate feature data of the coded data corresponding to the similar answer; performing fusion processing based on the second intermediate feature data and the third intermediate feature data to obtain target intermediate feature data, and performing feature extraction on the target intermediate feature data to obtain decoding data corresponding to the decoding processing; and obtaining a prediction dialogue corresponding to each group of sample data based on the decoded data output by the final stage of decoding processing.
In a second aspect, an embodiment of the present disclosure further provides a dialog generating method, including: acquiring a target problem; inputting the target problem into a pre-trained dialogue generation model to obtain a target dialogue corresponding to the target problem; the dialog generation model is trained based on the dialog generation model training method of any of the first aspects.
In a third aspect, an embodiment of the present disclosure further provides a dialog generation model training device, including: the system comprises an acquisition module, a processing module and a processing 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 coding module is used for 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; the decoding module is used for obtaining a prediction dialogue corresponding to each group of sample data according to the coded data corresponding to the real questions and the similar answers in each group of sample data and the real answers; and the training module is used for training based on the prediction dialogue and the real answer respectively corresponding to each group of the sample data so as to generate the dialogue generation model.
In an alternative embodiment, the obtaining module is configured to obtain multiple sets of the sample data in the following manner: acquiring a real problem of each group of sample data in a plurality of groups of sample data and a real answer matched with the real problem 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 answers 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 is configured to perform similar search in the training corpus based on the real answer matched with the real questions of each set of sample data in the following manner: sequentially performing first character matching on the real answers matched with the real questions of each group of sample data and the real answers in each training corpus pair in the training corpus, and determining first similarity corresponding to the real answers in each training corpus pair respectively on the basis of the result of the first character matching; based on the first similarity, at least one similar answer corresponding to a real answer matched with the real question of each set of sample data is determined from the real answers in each training corpus pair.
In an alternative embodiment, the obtaining module is configured to perform similar search in the training corpus based on the real answer matched with the real question of each set of sample data in the following manner, so as to obtain at least one similar answer corresponding to the real answer matched with the real question of each set 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 answers matched with the real questions of each group of sample data.
In an optional implementation manner, the obtaining module is configured to perform similar search in the training corpus based on the real questions and the matched real answers of each set of sample data in the following manner, so as to obtain at least one similar answer corresponding to the real answer matched with the real questions of each set of sample data: taking the real questions and the matched real answers of each group of sample data as target dialogue pairs, sequentially carrying out second character matching with each sample corpus pair in the training corpus, and determining second similarity between each training corpus pair in the training corpus and the target dialogue pair respectively based on the second character matching result; 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 a real answer matched with the real question of each set of sample data based on the real answer in the target corpus pairs.
In an alternative embodiment, the obtaining module is configured to determine, from the real answers in the target corpus pair, at least one similar answer corresponding to the real answer matched with the real question of each set of sample data in the following manner: determining the matching degree between the real questions of each group of sample data and the real answers in each target corpus pair; and determining at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data from the real answers in each target corpus pair based on the matching degree.
In an alternative embodiment, the obtaining module is configured to determine a matching degree between the real questions of each set of sample data and the real answers in each of the target corpus pairs by using the following manner: the real questions of each group of sample data and the real answers of each target corpus pair form alternative dialogue pairs; and obtaining the matching degree corresponding to each alternative dialogue pair based on a pre-trained dialogue matching model.
In an optional implementation manner, for a case that there are multiple similar answers corresponding to the real answer, the encoding module is configured to encode according to the real questions and the similar answers in each set of sample data in the following manner, so as to obtain encoded data corresponding to the real questions and the similar answers in each set of sample data respectively: carrying out coding processing on the real problems in each group of sample data to obtain coded data corresponding to the real problems in each group of sample data; splicing similar answers in each group of sample data to generate spliced answers corresponding to each group of sample data; and carrying out coding processing on 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.
In an optional implementation manner, the decoding module is configured to obtain a prediction dialogue corresponding to each set of sample data according to the encoded data and the true answer corresponding to the true question and the similar answer in each set of sample data in the following manner: and carrying out multistage decoding processing according to the coded data respectively corresponding to the real questions and the similar answers and the real answers to obtain a prediction dialogue corresponding to each group of sample data.
In an alternative embodiment, the decoding module is configured to perform multi-stage decoding in the following manner: for the case where the decoding process is any one of the decoding processes except the first-stage decoding process, the following procedure is performed with the decoder: based on the decoded data output by the previous stage decoding process and the real answer, performing self-attention processing to obtain first intermediate characteristic data corresponding to the decoded data output by the previous stage decoding process; performing coding and decoding attention processing based on the coded data corresponding to the real problem and the first intermediate feature data to obtain second intermediate feature data of the coded data corresponding to the real problem; and performing coding and decoding attention processing based on the coded data corresponding to the similar answer and the first intermediate feature data to obtain third intermediate feature data of the coded data corresponding to the similar answer; performing fusion processing based on the second intermediate feature data and the third intermediate feature data to obtain target intermediate feature data, and performing feature extraction on the target intermediate feature data to obtain decoding data corresponding to the decoding processing; and obtaining a prediction dialogue corresponding to each group of sample data based on the decoded data output by the final stage of decoding processing.
In a fourth aspect, an embodiment of the present disclosure further provides a dialog generating apparatus, including: an acquisition unit configured to acquire a target problem; the generation unit is used for inputting the target problem into a pre-trained dialogue generation model to obtain a target dialogue corresponding to the target problem; the dialog generation model is trained based on the dialog generation model training method of any of the first aspects.
In a fifth aspect, embodiments of the present disclosure further provide 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 the computer device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect, or any of the possible implementations of the first aspect, or the steps of the implementations of the second aspect.
In a sixth aspect, the disclosed embodiments further provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the first aspect, or any of the possible implementations of the first aspect, or performs the steps of the implementations of the second aspect.
Each set of sample data obtained by the dialogue generation model training method 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 the dialogue generation model based on the real question, the real answer and the at least one similar answer corresponding to the real question, the similar answer adds more available background information for the answer generation model, so that the dialogue generation model can generate more informative replies, and the generated dialogue is diversified due to the dialogue generation mode based on encoding and decoding while overcoming the defect that the current generation type dialogue model lacks specific information.
The foregoing objects, features and advantages of the disclosure will be more readily apparent from the following detailed description of the preferred embodiments taken in conjunction with the accompanying drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for the embodiments are briefly described below, which are incorporated in and constitute a part of the specification, these drawings showing embodiments consistent with the present disclosure and together with the description serve to illustrate the technical solutions of the present disclosure. It is to be understood that the following drawings illustrate only certain embodiments of the present disclosure and are therefore not to be considered limiting of its scope, for the person of ordinary skill in the art may admit to other equally relevant drawings without inventive effort.
FIG. 1 illustrates a flow chart of a dialog generation model training method provided by an embodiment of the present disclosure;
FIG. 2 illustrates a flow chart of a particular method of acquiring a set of sample data provided by an embodiment of the present disclosure;
FIG. 3 illustrates a flow chart of another particular method of acquiring a set of sample data provided by embodiments of the present disclosure;
FIG. 4 illustrates a flow chart of a dialog generation method provided by an embodiment of the present disclosure;
FIG. 5 illustrates a schematic diagram of a dialog generation model training device provided by an embodiment of the present disclosure;
FIG. 6 shows a schematic diagram of a dialog generation 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 disclosure.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are only some embodiments of the present disclosure, but not all embodiments. The components of the embodiments of the present disclosure, which are 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 provided in the accompanying drawings is not intended to limit the scope of the disclosure, as claimed, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be made by those skilled in the art based on the embodiments of this disclosure without making any inventive effort, are intended to be within the scope of this disclosure.
It has been found that the generative dialog system is based mainly on the seq2seq framework, the input of which is a sentence and the output of which is a sentence generated by the model. The seq2seq is composed of an encoder for encoding the input sentence into an intermediate representation vector and a decoder for combining the output of the encoder and the already decoded partial sequence to decode the next output word. The realization forms of the encoder and the decoder can be a neural network structure such as a cyclic neural network, a convolutional neural network and the like, and in addition, the existing generation dialogue system mostly introduces attention mechanisms to strengthen the information interaction between the encoder and the decoder so as to obtain better decoding effect.
In a generative dialog system, since the training goal of the generative model is to maximize likelihood probability, the generated sentences tend to have better fluency, but general fun replies are easy to generate. For example, when a user inputs "the submarine fishing chafing dish is really delicious", the generating dialogue system easily generates replies such as "i feel like well", "haha so that" and the like, and the replies have no information and lack of specificity, so that dialogue experience of the user can be affected.
The result of the search dialogue model is in the real corpus, so that the result has specificity and the recovery quality is high. But the search model cannot generate new sentences and lacks diversity because of the existing corpus. In addition, some corpora contain too specific information, such as names, places, etc. of specific scenes, and although matching scores are high, the corpora are not suitable as replies. Such as "Mao Zong play o together", "a Kang Shaokao near school is good" where "Mao Zong", "a kang" are too background-specific to be suitable as a reply to the user.
Based on the above study, each set of sample data obtained by the dialogue generation model training method provided by the disclosure includes 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 the dialogue generation model based on the real question, the real answer, and the at least one similar answer corresponding to the real question, the similar answer adds more available background information to the answer generation model, so that the dialogue generation model can generate more informative replies, and the generated dialogue also has diversity due to the dialogue generation mode based on encoding and decoding while overcoming the defect of the specific information of the current generation type dialogue model. The present invention is directed to a method for manufacturing a semiconductor device, and a semiconductor device manufactured by the method.
The following description of the embodiments of the present disclosure will be made clearly and fully with reference to the accompanying drawings in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present disclosure. 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 provided in the accompanying drawings is not intended to limit the scope of the disclosure, as claimed, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be made by those skilled in the art based on the embodiments of this disclosure without making any inventive effort, are intended to be within the scope of this disclosure.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
For the sake of understanding the present embodiment, first, a detailed description will be given of a dialog generation model training method disclosed in an embodiment of the present disclosure, where an execution subject of the dialog generation model training method provided in the embodiment of the present disclosure is generally a computer device with a certain computing capability, where 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 way of a processor invoking computer readable instructions stored in a memory.
The dialog generation model training method provided by the embodiment of the present disclosure is described below by taking an execution subject as a terminal device as an example.
Referring to fig. 1, a flowchart of a dialog generation model training method according to an embodiment of the disclosure is shown, where the method includes steps S101 to S104, where:
s101: obtaining a plurality of 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 questions and the similar answers in each group of sample data and the real answers;
s104: training is carried out based on the prediction dialogue and the real answer which are respectively corresponding to each group of the sample data so as to generate the dialogue generation model.
The following describes the above-mentioned S101 to S104 in detail, respectively.
I: in 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 disclosure further provides a specific method for obtaining multiple sets of sample data, including:
s201: and acquiring the real questions of each group of sample data in the plurality of groups of sample data and the real answers matched with the real questions of each group of sample data.
Here, when generating a set of sample data, the real questions s and the real answers t in each set of sample data may be derived from a pre-built training corpus, or may be obtained by other means, for example, crawling dialogue information from a network, obtaining real questions based on the crawled questions in the dialogue information, and obtaining real answers based on the crawled answers in the dialogue.
The pre-built 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.
In the case that the real questions s and the real answers t in one set of sample data originate from the training corpus, the real questions in any training remainder pair in the training corpus can be used as the real questions s in each set of sample data, and the real answers in any training corpus pair can be used as the real answers t in each set of sample data.
S202: and carrying out 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 answers matched with the real questions of each group of sample data.
Here, for example, the following manner may be adopted to perform similar search in the training corpus:
sequentially carrying out first character matching on the real answers t matched with the real questions s of each group of sample data and the real answers in each training corpus pair in the training corpus, and determining the real answers t matched with the real questions s of each group of sample data based on the result of the first character matching, wherein the real answers t respectively correspond to the real answers in each training corpus pair;
based on the first similarity, at least one similar answer corresponding to a real answer matching the real question of each set of sample data is determined from the real answers in each of the training corpus pairs.
In an implementation, 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 questions in the ith training corpus pair and ti represents the real answers in the ith training corpus pair.
In the first character matching, t and ti are character matched.
When the real answer t in each set of sample data and the real answer ti in the ii corpus pairs are subjected to the first character matching, at least one of the following modes can be adopted, for example:
matching the number of the same characters in t and ti, and representing the first similarity between t and ti through the number; the higher the number, the higher the first degree of 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 based on the number of the same characters and the total number of the characters included in ti, wherein the number of the same characters occupies a percentage of the total number of the characters in ti; characterizing a first similarity between t and ti by the percentage; the greater this percentage, 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 based on the number of the same characters and the total number of the characters included in t, wherein the number of the same characters occupies a percentage of the total number of the characters in t; characterizing a first similarity between t and ti by the percentage; the greater this percentage, the higher the first similarity between t and ti is considered.
The number of characters having the same meaning in t and ti are matched, and a first similarity between t and ti is determined based on the number of characters having the same meaning. Here, in many cases, some characters are included in different real answers, but the expressed meanings are the same, for example, the meaning of the expression of "APP" and "application" is actually the same, so that the first similarity between t and ti can be determined by the number of characters having the same meaning in t and ti.
After obtaining the first similarity between the real answers in each training corpus pair in the training corpus and the real answers in the sample data, determining at least one real answer from each training corpus pair in the training corpus according to the order of the first similarity from large to small, and taking the at least one real answer as a similar answer corresponding to the real answer in the sample data.
Here, the number of similar answers may be specifically set according to actual needs, and is not limited in this disclosure.
In addition, other ways of performing similar searches in the training corpus are also possible. 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 determining the first similarity between the real answer in the training corpus and the real answer in the sample data, calculating the distance between the feature data of the real answer in the training corpus and the feature data of the real answer in the sample data, and characterizing the first similarity through the distance.
Referring to fig. 3, another specific method for acquiring multiple sets of sample data is provided in an embodiment of the present disclosure, including:
s301: and acquiring the real questions of each group of sample data and 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 will not be described here again.
S302: and carrying out similar retrieval in a training corpus based on the real questions of each group of sample data and the matched real answers to obtain at least one similar answer corresponding to the real answers matched with the real questions of each group of sample data.
Here, the similarity search may 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 carrying out 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 pair respectively based on a result of the second character matching; a plurality of target corpus pairs are determined from each of the training corpus pairs based on the second similarity, and at least one similar answer corresponding to a real answer matching the real question of each set of sample data is determined based on the real answer of the target corpus pairs.
For example, when a set of sample data is generated, the real question of the sample data is s, the real answer matching the real question s is t, and the generated target dialogue pair is (s, t).
And sequentially carrying out second character matching on each training corpus pair in the training corpus with 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 questions in the ith training corpus pair and ti represents the real answers in the ith training corpus pair.
And in the process of performing second character matching, performing character matching on the corpus formed by s and t and the corpus formed by si and ti.
Here, the specific manner of the second character matching is similar to the specific manner of the first character matching described above, and will not be described herein.
After obtaining the second similarity between the training corpus pair and the target dialogue pair in the training corpus, for example, the following manner may be adopted to determine, based on the real answer in the target corpus pair, at least one similar answer corresponding to the real answer matched with the real question of each set of sample data:
determining the matching degree between the real questions of each group of sample data and the real answers in each target corpus pair; and determining at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data from the real answers in each target corpus pair based on the matching degree.
Here, the real questions of the sample data may be represented, for example, by the similarity between the real answers of the sample data and the real answers of the respective target corpus pairs, and the matching between the real questions of the sample data and the real answers of the respective target corpus pairs. And the higher the similarity between the real answer of the sample data and the real answer in the target corpus pair, the higher the matching degree between the real question of the sample data and the real answer in the target corpus pair is represented.
Here, for example, the distance between the feature data of the real answer of the sample data and the feature data of the real answer in the target corpus pair may be calculated, and the similarity between the real answer of the sample data and the real answer in the target corpus pair may be represented by the distance.
In addition, the embodiment of the disclosure also provides another specific method for determining the matching degree between the real question of the sample data and the real answer in the target corpus pair, which comprises the following steps:
the real questions of each group of sample data and the real answers in each target corpus pair form alternative dialogue pairs; and obtaining the corresponding matching degree of each alternative dialogue based on a pre-trained dialogue matching model.
The dialogue matching model is here trained, for example, by individual training corpus pairs in a training corpus.
When a dialogue matching model is obtained through training, a positive sample is obtained based on each training corpus pair in a training corpus; and adds a matching degree label to the positive sample. At this time, each positive sample includes: a real question, and a real answer matching the real question. The matching degree label of the positive sample is 1.
In addition, it is also necessary to construct a negative sample and add a matching degree label to the negative sample. Wherein, each negative sample comprises: a real question and an answer that does not match the real question, and the match degree label of each negative sample is 0. For example, a real problem is included in a negative example: "you have today to go to work on the company" and the answer that corresponds to the real question is, for example, "we have today to go to the draft and boil fish to the water".
A dialogue matching degree 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 questions of the sample data included in the alternative dialogue pairs and the real answers in the target corpus pairs is obtained.
The matching degree is between 0 and 1, and the closer to 0, the lower the matching degree representing the two is, the closer to 1, and the higher the matching degree representing the two is.
And after the matching degree of each alternative dialogue pair is obtained, taking the real answer in the alternative dialogue pair with the matching degree meeting certain requirements as a similar answer corresponding to the real answer in the sample data.
The matching degree requirement is, for example: and the matching degree is larger than a preset matching degree threshold value, or the similar answers are determined according to the sequence of the matching degree from large to small.
II: in S102 described above, an encoder may be employed, for example, to encode the true questions and similar answers in each set of sample data.
Illustratively, the encoder includes, for example, one or more of the following: a recurrent neural network (Recurrent Neural Network, RNN), a Long Short-Term Memory network (LSTM), a convolutional neural network (Convolutional Neural Network, CNN), a neural network based on a transducer framework.
Specifically, the following method may be adopted to obtain the encoded data corresponding to the real questions and the similar answers respectively:
carrying out coding processing on the real problems in each group of sample data to obtain first coded data corresponding to the real problems in each group of sample data;
And splicing similar answers in the sample data to generate spliced answers corresponding to the sample data, and carrying out coding processing on 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: and 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 be used to encode the similar answers in each set of sample data, so as to obtain encoded data corresponding to each similar answer, and then the encoded data corresponding to each similar answer is weighted and summed to obtain encoded data corresponding to the similar answer in each set of sample data.
Here, when the encoded data corresponding to each of the similar answers is weighted and summed, the weights corresponding to each of the similar answers may be equal, or may be determined according to the similarity between each of the similar answers and the real answer in each of the sample data sets. The specific setting can be carried out according to the actual needs.
III: in S103, a decoder may be used to obtain a prediction dialogue corresponding to each set of sample data according to the encoded data and the real answer corresponding to each set of sample data.
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 neural network based on a transducer framework, the decoder is typically also a neural network based on a transducer framework.
The decoding process of the decoder will be described by taking a neural network in which the encoder and the decoder are both a transducer framework as an example.
When the prediction dialogue corresponding to the sample data is generated, for example, multi-stage decoding processing can be performed according to the coded data and the real answer respectively corresponding to the real questions and the similar answers in the sample data, so as to obtain the prediction dialogue corresponding to each group of sample data.
For example, taking the example of generating a prediction session using a decoder, which includes a 12-layer transformer block structure, each layer transformer block is capable of performing a primary decoding process.
Each layer transformer block, when performing a primary decoding process:
a: for the case where the decoding process is the first-stage decoding process, the following procedure is performed with the decoder:
(1) based on the real answer, self-Attention processing (Self-Attention) is performed to obtain first intermediate feature data corresponding to the real answer.
Here, when the multi-level decoding process is performed by the decoder, each character in the prediction session is not obtained at one time, but is predicted one by a plurality of times. Thus, in performing self-attention processing based on the true answer, the predicted position of the currently predicted character is first determined; and determining a character having a position 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 character. Here, the encoded results of the real questions and the candidate answers are input to the decoder, and the process is supervised with the real answers to generate a prediction dialogue.
For example, if the predicted position of the currently predicted character is the i-th bit in the entire prediction dialogue, that is, the 1 st to (i-1) -th characters are determined from the real answer, the self-attention process is performed, and the first intermediate feature data corresponding to the real answer is obtained.
(2) Performing encoding and decoding attention processing (Encoder-Decoder Attention) based on the encoded data corresponding to the real problem and the first intermediate feature data to obtain second intermediate feature data of the encoded data corresponding to the real problem;
(3) and performing coding and decoding attention processing based on the coded data corresponding to the similar answer and the first intermediate feature data to obtain third intermediate feature data of the coded data corresponding to the similar answer.
The above (2) and the above (3) are not performed in sequence.
(4) Performing fusion processing based on the second intermediate feature data and the third intermediate feature data to obtain target intermediate feature data, and performing feature extraction on the target intermediate feature data to obtain decoding data corresponding to the stage 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, the following procedure is performed with the decoder:
(1) 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;
(2) 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;
(3) 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, so that third intermediate characteristic data of the coded data corresponding to the similar answers are obtained;
(4) performing fusion processing based on the second intermediate feature data and the third intermediate feature data to obtain target intermediate feature data, and performing feature extraction on the target intermediate feature data to obtain decoding data corresponding to the stage of decoding processing;
after the multi-stage decoding process is performed by the decoder, a prediction dialogue corresponding to each set of sample data is obtained based on the decoded data output by the last stage decoding process.
Here, when generating a prediction dialogue, the prediction dialogue is generally formed by outputting characters or words one by one in units of characters or words, and performing the decoding process a plurality of times to output the characters or words from all the decoding processes.
IV: in S104, after obtaining the prediction dialogs corresponding to each set of sample data, the cross entropy loss of the model can be obtained based on the prediction dialogs and the real answers corresponding to each set of sample data, and then training is performed according to the cross entropy loss to generate the dialog generation model.
After the multiple training in S102 to S104, when the number of training rounds reaches a preset number of training rounds, or when the encoder and the decoder converge, the training process of the dialogue generating model is ended, and the dialogue generating model with completed training is obtained.
Each set of sample data obtained by the dialogue generation model training method 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 the dialogue generation model based on the real question, the real answer and the at least one similar answer corresponding to the real question, the similar answer adds more available background information for the answer generation model, so that the dialogue generation model can generate more informative replies, and the generated dialogue is diversified due to the dialogue generation mode based on encoding and decoding while overcoming the defect that the current generation type dialogue model lacks specific information.
Referring to fig. 4, an embodiment of the present disclosure further provides a dialog generating method, including:
s401: acquiring a target problem;
s402: and inputting the target problem into a pre-trained dialogue generation model to obtain a target dialogue corresponding to the target problem.
The dialog generation model is trained based on the dialog generation model training method of an embodiment of the present disclosure.
The dialog generation model includes: an encoder and a decoder.
In the dialogue generation method provided by the embodiment of the disclosure, when the dialogue generation model is trained, each set of acquired 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, and the similar answer adds more available background information to the answer generation model, so that the dialogue generation model can generate more informative replies, and the generated dialogue also has diversity due to the fact that the dialogue generation model based on encoding and decoding is used while the fact that the current generation type dialogue model lacks specific information is overcome.
It will be appreciated by those skilled in the art that in the above-described method of the specific embodiments, the written order of steps is not meant to imply a strict order of execution but rather should be construed according to the function and possibly inherent logic of the steps.
Based on the same inventive concept, the embodiment of the disclosure further provides a dialogue generation model training device corresponding to the dialogue generation model training method, and since the principle of solving the problem by the device in the embodiment of the disclosure is similar to that of the dialogue generation model training method in the embodiment of the disclosure, the implementation of the device can refer to the implementation of the method, and the repetition is omitted.
Referring to fig. 5, a schematic diagram of a dialog generating model training device according to an embodiment of the disclosure is shown, where the device includes: an acquisition module 51, an encoding module 52, a decoding module 53, and a training module 54; wherein,
an obtaining module 51, configured to obtain a plurality of 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 encode according to the real questions and the similar answers in each set of sample data, and obtain encoded data corresponding to the real questions and the similar answers in each set of sample data;
a decoding module 53, configured to obtain a prediction dialogue 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;
the training module 54 is configured to obtain a prediction dialogue 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.
In an alternative embodiment, the obtaining module 51 is configured to obtain multiple sets of the sample data in the following manner:
acquiring a real problem of each group of sample data in a plurality of groups of sample data and a real answer matched with the real problem 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 answers 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 similar search in the training corpus based on the real answer matched with the real questions of each set of sample data in the following manner:
sequentially performing first character matching on the real answers matched with the real questions of each group of sample data and the real answers in each training corpus pair in the training corpus, and determining first similarity corresponding to the real answers in each training corpus pair respectively on the basis of the result of the first character matching;
Based on the first similarity, at least one similar answer corresponding to a real answer matched with the real question of each set of sample data is determined from the real answers in each training corpus pair.
In an alternative embodiment, the obtaining module 51 is configured to perform similar search in the training corpus based on the real answer matched with the real question of each set of sample data in the following manner, so as to obtain at least one similar answer corresponding to the real answer matched with the real question of each set 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 answers matched with the real questions of each group of sample data.
In an alternative embodiment, the obtaining module 51 is configured to perform similar search in the training corpus based on the real questions and the matched real answers of each set of sample data in the following manner, so as to obtain at least one similar answer corresponding to the real answer matched with the real questions of each set of sample data:
taking the real questions and the matched real answers of each group of sample data as target dialogue pairs, sequentially carrying out second character matching with each sample corpus pair in the training corpus, and determining second similarity between each training corpus pair in the training corpus and the target dialogue pair respectively based on the second character matching result;
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 a real answer matched with the real question of each set of sample data based on the real answer in the target corpus pairs.
In an alternative embodiment, the obtaining module 51 is configured to determine, from the real answers in the target corpus pair, at least one similar answer corresponding to the real answer matched to the real question of each set of sample data in the following manner:
determining the matching degree between the real questions of each group of sample data and the real answers in each target corpus pair;
and determining at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data from the real answers in each target corpus pair based on the matching degree.
In an alternative embodiment, the obtaining module is configured to determine a matching degree between the real questions of each set of sample data and the real answers in each of the target corpus pairs by using the following manner:
the real questions of each group of sample data and the real answers of each target corpus pair form alternative dialogue pairs;
And obtaining the matching degree corresponding to each alternative dialogue pair based on a pre-trained dialogue matching model.
In an alternative embodiment, 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 questions and the similar answers in each set of sample data in the following manner, to obtain encoded data corresponding to the real questions and the similar answers in each set of sample data respectively:
carrying out coding processing on the real problems in each group of sample data to obtain coded data corresponding to the real problems in each group of sample data; and
splicing similar answers in each group of sample data to generate spliced answers corresponding to each group of sample data; and carrying out coding processing on 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.
In an alternative embodiment, the decoding module 53 is configured to obtain the prediction session corresponding to each set of sample data according to the encoded data and the real answer corresponding to the real question and the similar answer in each set of sample data in the following manner:
And carrying out multistage decoding processing according to the coded data respectively corresponding to the real questions and the similar answers and the real answers to obtain a prediction dialogue corresponding to each group of sample data.
In an alternative embodiment, the decoding module 53 is configured to perform the 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, the following procedure is performed with the decoder:
based on the decoded data output by the previous stage decoding process and the real answer, performing self-attention processing to obtain first intermediate characteristic data corresponding to the decoded data output by the previous stage decoding process;
performing coding and decoding attention processing based on the coded data corresponding to the real problem and the first intermediate feature data to obtain second intermediate feature data of the coded data corresponding to the real problem;
and performing coding and decoding attention processing based on the coded data corresponding to the similar answer and the first intermediate feature data to obtain third intermediate feature data of the coded data corresponding to the similar answer;
performing fusion processing based on the second intermediate feature data and the third intermediate feature data to obtain target intermediate feature data, and performing feature extraction on the target intermediate feature data to obtain decoding data corresponding to the decoding processing;
And obtaining a prediction dialogue corresponding to each group of sample data based on the decoded data output by the final stage of decoding processing.
The process flow of each module in the apparatus and the interaction flow between the modules may be described with reference to the related descriptions in the above method embodiments, which are not described in detail herein.
Referring to fig. 6, a schematic diagram of a dialog generating apparatus according to an embodiment of the disclosure is provided, where the apparatus includes: an acquisition unit 61, and a generation unit 62; wherein,
an acquisition unit 61 for acquiring a target problem;
the generating unit 62 is configured to input the target question into a pre-trained dialogue generating model, and obtain a target dialogue corresponding to the target question.
The dialog generation model is obtained by training based on the dialog generation 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, including:
a processor 71, a memory 72, and a bus 73; memory 72 is used to store execution instructions, including memory 721 and external memory 722; the memory 721 is also referred to as an internal memory, and is used for temporarily storing operation data in the processor 71 and 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 running, the processor 71 and the memory 72 communicate through the bus 73, so that the processor 71 executes the following instructions in a user mode:
Obtaining a plurality of 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 questions and the similar answers in each group of sample data and the real answers;
training is carried out based on the prediction dialogue and the real answer which are respectively corresponding to each group of the sample data so as to generate the dialogue generation model.
Alternatively, the following instructions are executed:
acquiring a target problem;
and inputting the target problem into a pre-trained dialogue generation model to obtain a target dialogue corresponding to the target problem.
The dialog generation model is obtained by training based on the dialog generation model training method provided by the embodiment of the disclosure.
The disclosed embodiments also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the dialog generation model training method described in the method embodiments above, or performs the steps of the dialog generation method described in the method embodiments above. Wherein the storage medium may be a volatile or nonvolatile 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 code, where the program code includes instructions for executing the dialog generation model training method described in the above method embodiment, or executing the steps of the dialog generation method described in the above method embodiment, and specifically, reference may be made to the above method embodiment, which is not repeated herein.
The disclosed embodiments also provide a computer program which, when executed by a processor, implements any of the methods of the previous embodiments. The computer program product may be realized in particular by means of hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied as a computer storage medium, and in another alternative embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), or the like.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described system and apparatus may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown 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 may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present disclosure may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in 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 essence or a part contributing to the prior art or a part of the technical solution, or in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in the embodiments of the present disclosure. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Finally, it should be noted that: the foregoing examples are merely specific embodiments of the present disclosure, and are not intended to limit the scope of the disclosure, but the present disclosure is not limited thereto, and those skilled in the art will appreciate that while the foregoing examples are described in detail, it is not limited to the disclosure: any person skilled in the art, within the technical scope of the disclosure of the present disclosure, may modify or easily conceive changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features thereof; such modifications, changes or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the disclosure, and are intended to be included within the scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (15)

1. A dialog generation model training method, comprising:
obtaining a plurality of 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; wherein the at least one similar answer included in each set of sample data is obtained by performing similar retrieval in a training corpus based on the real answer included in each set of sample data or the real answer and the real question included in each set of sample data; the training corpus comprises a plurality of training corpus pairs, and each training corpus pair comprises a real problem and a real answer corresponding to the real problem;
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 questions and the similar answers in each group of sample data and the real answers;
training is carried out based on the prediction dialogue and the real answer which are respectively corresponding to the sample data of each group so as to generate a dialogue generation model.
2. The dialog generation model training method of claim 1, wherein the acquiring multiple sets of sample data comprises:
acquiring a real problem of each group of sample data in a plurality of groups of sample data and a real answer matched with the real problem of each group of sample data;
and carrying out 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 answers matched with the real questions of each group of sample data.
3. The dialogue generation model training method as claimed in claim 2, wherein the performing similar search in the training corpus based on the real answers matched with the real questions of each set of sample data comprises:
Sequentially performing first character matching on the real answers matched with the real questions of each group of sample data and the real answers in each training corpus pair in the training corpus, and determining first similarity corresponding to the real answers in each training corpus pair respectively on the basis of the result of the first character matching;
based on the first similarity, at least one similar answer corresponding to a real answer matched with the real question of each set of sample data is determined from the real answers in each training corpus pair.
4. The dialogue generation model training method as claimed in claim 2, wherein the performing similar search in the training corpus based on the real answer matched with the real question of each set of sample data to obtain at least one similar answer corresponding to the real answer matched with the real question of each set 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 answers matched with the real questions of each group of sample data.
5. The dialogue generation model training method as claimed in claim 4, wherein the performing similar search in the training corpus based on the real questions of each set of sample data and the matched real answers to obtain at least one similar answer corresponding to the real answer matched with the real questions of each set of sample data comprises:
taking the real questions and the matched real answers of each group of sample data as target dialogue pairs, sequentially carrying out second character matching with each sample corpus pair in the training corpus, and determining second similarity between each training corpus pair in the training corpus and the target dialogue pair respectively based on the second character matching result;
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 a real answer matched with the real question of each set of sample data based on the real answer in the target corpus pairs.
6. The dialog generation model training method of claim 5, wherein the determining at least one similar answer corresponding to a true answer matching the true question of each set of sample data based on the true answers in the target corpus pair comprises:
Determining the matching degree between the real questions of each group of sample data and the real answers in each target corpus pair;
and determining at least one similar answer corresponding to the real answer matched with the real questions of each group of sample data from the real answers in each target corpus pair based on the matching degree.
7. The dialog generation model training method of claim 6, wherein the determining the degree of matching between the real questions of each set of sample data and the real answers in each of the target corpus pairs comprises:
the real questions of each group of sample data and the real answers of each target corpus pair form alternative dialogue pairs;
and obtaining the matching degree corresponding to each alternative dialogue pair based on a pre-trained dialogue matching model.
8. The dialog generation model training method of any of claims 1-7, wherein for a case where there are multiple similar answers corresponding to the real answer, the encoding according to the real questions and the similar answers in each set of sample data to obtain encoded data respectively corresponding to the real questions and the similar answers in each set of sample data includes:
Carrying out coding processing on the real problems in each group of sample data to obtain coded data corresponding to the real problems in each group of sample data; and
splicing similar answers in each group of sample data to generate spliced answers corresponding to each group of sample data; and carrying out coding processing on 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.
9. The dialogue generation model training method as claimed in any one of claims 1 to 7, wherein obtaining the prediction dialogue corresponding to each set of sample data based on the coded data corresponding to the real question and the similar answer in each set of sample data, and the real answer, respectively, comprises:
and carrying out multistage decoding processing according to the coded data respectively corresponding to the real questions and the similar answers and the real answers 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-level decoding process comprises:
for the case where the decoding process is any one of the decoding processes except the first-stage decoding process, the following procedure is performed with the decoder:
Based on the decoded data output by the previous stage decoding process and the real answer, performing self-attention processing to obtain first intermediate characteristic data corresponding to the decoded data output by the previous stage decoding process;
performing coding and decoding attention processing based on the coded data corresponding to the real problem and the first intermediate feature data to obtain second intermediate feature data of the coded data corresponding to the real problem;
and performing coding and decoding attention processing based on the coded data corresponding to the similar answer and the first intermediate feature data to obtain third intermediate feature data of the coded data corresponding to the similar answer;
performing fusion processing based on the second intermediate feature data and the third intermediate feature data to obtain target intermediate feature data, and performing feature extraction on the target intermediate feature data to obtain decoding data corresponding to the decoding processing;
and obtaining a prediction dialogue corresponding to each group of sample data based on the decoded data output by the final stage of decoding processing.
11. A dialog generation method, comprising:
acquiring a target problem;
inputting the target problem into a pre-trained dialogue generation model to obtain a target dialogue corresponding to the target problem;
The dialog generation model is trained based on the dialog generation model training method of any of claims 1-10.
12. A dialog generation model training device comprising:
the system comprises an acquisition module, a processing module and a processing 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; wherein the at least one similar answer included in each set of sample data is obtained by performing similar retrieval in a training corpus based on the real answer included in each set of sample data or the real answer and the real question included in each set of sample data; the training corpus comprises a plurality of training corpus pairs, and each training corpus pair comprises a real problem and a real answer corresponding to the real problem;
the coding module is used for 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;
the decoding module is used for obtaining a prediction dialogue corresponding to each group of sample data according to the coded data corresponding to the real questions and the similar answers in each group of sample data and the real answers;
And the training module is used for training based on the prediction dialogue and the real answer respectively corresponding to each group of the sample data so as to generate a dialogue generation model.
13. A dialog generation device, comprising:
an acquisition unit configured to acquire a target problem;
the generation unit is used for inputting the target problem into a pre-trained dialogue generation model to obtain a target dialogue corresponding to the target problem;
the dialog generation model is trained based on the dialog generation model training method of any of claims 1-10.
14. A computer device, comprising: a processor, a memory and a bus, said memory storing machine readable instructions executable by said processor, said processor and said memory communicating via the bus when the computer device is running, said machine readable instructions when executed by said processor performing the steps of the dialog generation model training method of any of claims 1 to 10 or the steps of the dialog generation method of claim 11.
15. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when executed by a processor, performs the steps of the dialog generation model training method of any of claims 1 to 10 or performs the steps of the dialog generation method of 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 CN111339274A (en) 2020-06-26
CN111339274B true 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)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112131368B (en) * 2020-09-27 2024-02-09 深圳平安智慧医健科技有限公司 Dialogue generation method and device, electronic equipment and storage medium
CN112417118B (en) * 2020-11-19 2023-04-07 上海交通大学 Dialog generation method based on marked text and neural network
CN112685536B (en) * 2020-12-25 2024-06-07 中国平安人寿保险股份有限公司 Text dialogue method, text dialogue device, electronic equipment and storage medium
CN116737888B (en) * 2023-01-11 2024-05-17 北京百度网讯科技有限公司 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

Also Published As

Publication number Publication date
CN111339274A (en) 2020-06-26

Similar Documents

Publication Publication Date Title
CN111339274B (en) Dialogue generation model training method, dialogue generation method and device
CN108681610B (en) generating type multi-turn chatting dialogue method, system and computer readable storage medium
CN107632987B (en) A kind of dialogue generation method and device
CN108763444B (en) Method for solving video question-answering by using layered coding decoder network mechanism
US20180329884A1 (en) Neural contextual conversation learning
CN108595436B (en) Method and system for generating emotional dialogue content and storage medium
KR102133825B1 (en) Voice conversation method and system of enhanced word features
CN108734276A (en) A kind of learning by imitation dialogue generation method generating network based on confrontation
CN108959388B (en) Information generation method and device
CN110245224B (en) Dialog generation method and device
CN108108428B (en) Method, input method and system for constructing language model
CN111324736B (en) Man-machine dialogue model training method, man-machine dialogue method and system
CN112463942B (en) Text processing method, text processing device, electronic equipment and computer readable storage medium
CN114048301B (en) Satisfaction-based user simulation method and system
CN111753076A (en) Dialogue method, dialogue device, electronic equipment and readable storage medium
CN110069612A (en) A kind of reply generation method and device
CN112765333B (en) Automatic dialogue generation method and system based on emotion and prompt word combination
CN110851575A (en) Dialogue generating system and dialogue realizing method
CN110597968A (en) Reply selection method and device
CN115186147B (en) Dialogue content generation method and device, storage medium and terminal
KR20210145490A (en) Method and apparatus for improving quality of attention based sequence-to-sequence model
CN110516053B (en) Dialogue processing method, device and computer storage medium
CN112163080A (en) Generation type dialogue system based on multi-round emotion analysis
CN110955765A (en) Corpus construction method and apparatus of intelligent assistant, computer device and storage medium
CN114416949A (en) Dialogue generation model training method, dialogue reply generation method, dialogue generation device, dialogue reply generation medium

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