CN114610855A - Dialog reply generation method and device, electronic equipment and storage medium - Google Patents

Dialog reply generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114610855A
CN114610855A CN202210255616.8A CN202210255616A CN114610855A CN 114610855 A CN114610855 A CN 114610855A CN 202210255616 A CN202210255616 A CN 202210255616A CN 114610855 A CN114610855 A CN 114610855A
Authority
CN
China
Prior art keywords
dialogue
abstract
dialog
training
information
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
CN202210255616.8A
Other languages
Chinese (zh)
Other versions
CN114610855B (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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202210255616.8A priority Critical patent/CN114610855B/en
Publication of CN114610855A publication Critical patent/CN114610855A/en
Application granted granted Critical
Publication of CN114610855B publication Critical patent/CN114610855B/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/34Browsing; Visualisation therefor
    • G06F16/345Summarisation for human users
    • 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/35Clustering; Classification

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Artificial Intelligence (AREA)
  • Human Computer Interaction (AREA)
  • Computational Linguistics (AREA)
  • Machine Translation (AREA)

Abstract

The invention relates to an artificial intelligence technology, and discloses a dialog reply generation method, which comprises the following steps: the method comprises the steps of carrying out effective information labeling and abstract extraction on a plurality of rounds of dialogue corpora to obtain standard dialogue sets and abstract information, respectively carrying out training and verification by utilizing the standard dialogue sets and the abstract information to obtain a standard judgment model and a standard abstract extraction model, constructing dialogue sequences based on the abstract information and the plurality of rounds of dialogue corpora, and training the plurality of rounds of dialogue models based on the dialogue sequences. And splicing the dialogs which meet the standard after the dialogs are judged by using the standard judgment model to obtain a dialog splicing sequence, inputting the dialog splicing sequence into a dialog abstract obtained by the standard abstract extraction model and a user question, splicing the dialog abstract and the user question, and inputting a plurality of rounds of dialog models to obtain a user reply. In addition, the invention also relates to a block chain technology, and the summary information can be stored in the nodes of the block chain. The invention also provides a dialog reply generation device, electronic equipment and a storage medium. The invention can improve the efficiency of generating the dialog reply.

Description

Dialog reply generation method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a dialog reply generation method and device, electronic equipment and a storage medium.
Background
The historical dialogue information usually contains a lot of useful key information which can be used as reference data for answering the existing user questions so as to more accurately and intuitively analyze the appropriate response to the user questions. The current common mode for processing historical dialogue information by multiple rounds of dialogues is to directly splice historical dialogue records and questions input by a current user together to serve as an input sequence to be delivered to a multiple round of dialogue model for processing, and the model generates a proper reply. However, unprocessed historical dialogs are sometimes too long, the effective information density is low, and if too many historical dialogs are reserved, too long input results in that the occupied memory is increased and the generation speed is slow when the model generates an answer; if the number of the reserved historical conversation turns is too small, the effective information is too small, and the reply quality generated by the final model is poor. It is therefore desirable to provide a method for improving the efficiency of dialog reply generation while ensuring accuracy.
Disclosure of Invention
The invention provides a dialog reply generation method, a dialog reply generation device and a storage medium, and aims to improve the efficiency of dialog reply generation.
In order to achieve the above object, the present invention provides a dialog reply generation method, including:
acquiring a preset number of multi-turn dialogue corpora, and carrying out effective information labeling on the multi-turn dialogue corpora to obtain a labeled dialogue set;
extracting the abstract of the effective marked dialogue in the marked dialogue set to obtain abstract information;
carrying out dialogue division on the labeling dialogue set according to a preset first division ratio to obtain a training dialogue set and a verification dialogue set, and carrying out information division on the abstract information according to a preset second division ratio to obtain training abstract information and verification abstract information;
training and verifying a preset effective information judgment model based on the training session set and the verification session set to obtain a standard judgment model;
splicing the abstract information and the effective labeling dialogue corresponding to the abstract information to obtain a training splicing sequence, training a preset abstract extraction model by using the training splicing sequence to obtain an initial abstract extraction model, and verifying the initial abstract extraction model by using the verification abstract information to obtain a standard abstract extraction model;
constructing a dialogue sequence based on the summary information and the multi-turn dialogue corpus, and training by using the dialogue sequence to obtain a multi-turn dialogue model;
obtaining user questions and multiple rounds of historical conversations, carrying out conversation judgment on the multiple rounds of historical conversations by using the standard judgment model, and carrying out splicing treatment on the conversations which are judged to be in accordance with a preset standard to obtain a conversation splicing sequence;
and inputting the dialogue splicing sequence into the standard abstract extraction model to obtain a dialogue abstract, splicing the dialogue abstract and the user question, and inputting the dialogue abstract and the user question into the multi-turn dialogue model to obtain a user reply.
Optionally, the training and verifying a preset effective information judgment model based on the training session set and the verification session set to obtain a standard judgment model, including:
performing sequence conversion on the training dialogs in the training dialog set to obtain an input sequence;
converting the input sequence into a dialogue number by utilizing a Chinese dictionary in the effective information judgment model;
converting the training dialogue into a corresponding category number according to whether the training dialogue contains effective information;
inputting the conversation number and the category number into a cross entropy loss function in the effective information judgment model to obtain a cross entropy loss value;
updating the parameter weight of the effective information judgment model based on the cross entropy loss value and the gradient descending back propagation algorithm to obtain an initial judgment model;
and carrying out verification processing on the initial judgment model by using the verification dialogue set, and outputting the initial judgment model as a standard judgment model when the verification processing is passed.
Optionally, the performing, by using the verification dialog set, verification processing on the initial judgment model includes:
performing dictionary conversion on the verification dialog set to obtain a conversion dialog set;
inputting the conversion dialog set into the initial judgment model to obtain a prediction classification result;
calculating a verification value based on the prediction classification result and a preset real classification result, and judging the magnitude between the verification value and a preset verification threshold value;
determining the verification process as a process failure when the verification value is less than the verification threshold;
when the verification value is greater than or equal to the verification threshold, determining that the verification process passes.
Optionally, the training a preset abstract extraction model by using the training concatenation sequence to obtain an initial abstract extraction model includes:
converting the training splicing sequence into a splicing label by using a dictionary in the abstract extraction model;
marking the position corresponding to the summary dialogue in the splicing label as a preset summary label;
inputting the splicing labels and the abstract labels into the abstract extraction model to obtain a cross entropy loss value;
and carrying out iterative optimization on the abstract extraction model based on the cross entropy loss value to obtain an initial abstract extraction model.
Optionally, the constructing a dialog sequence based on the summary information and the multiple rounds of dialog corpora includes:
extracting conversation corpora with preset turns in the multi-turn conversation corpora, and segmenting the conversation corpora by using a preset first role mark and a preset second role mark to obtain a role sequence;
and splicing the role sequence and the abstract information to obtain a conversation sequence.
Optionally, the extracting the abstract of the effective annotation dialog in the annotation dialog set to obtain abstract information includes:
removing meaningless words in the effective labeling conversation to obtain a screening labeling conversation;
performing word segmentation processing on the screening standard dialogue to obtain a word segmentation dialogue set;
performing part-of-speech tagging on the word segmentation dialogue set, and reserving word segmentation dialogues in the word segmentation dialogue set, wherein the word segmentation dialogue set conforms to a preset part-of-speech;
and connecting the word segmentation conversations conforming to the preset part of speech according to a preset connection method to obtain abstract information.
Optionally, the performing effective information labeling on the multiple rounds of dialog corpuses to obtain a labeled dialog set includes:
carrying out dialogue splitting on the multi-turn dialogue corpus to obtain a split dialogue set;
comparing the split dialogues in the split dialog set with the labeled data in a preset labeled database;
marking the split dialogue which is consistent with any marked data in the marked database as an effective dialogue, and marking the split dialogue which is inconsistent with the marked data in the marked database as an ineffective dialogue;
and summarizing the effective dialogue and the invalid dialogue to obtain a marked dialogue set.
In order to solve the above problem, the present invention further provides a dialog reply generation apparatus, including:
the data processing module is used for acquiring a preset number of multi-turn dialogue corpora, carrying out effective information labeling on the multi-turn dialogue corpora to obtain a labeled dialogue set, carrying out abstract extraction on effective labeled dialogues in the labeled dialogue set to obtain abstract information, carrying out dialogue division on the labeled dialogue set according to a preset first division ratio to obtain a training dialogue set and a verification dialogue set, and carrying out information division on the abstract information according to a preset second division ratio to obtain training abstract information and verification abstract information;
the standard judgment module is used for training and verifying a preset effective information judgment model based on the training dialogue set and the verification dialogue set to obtain a standard judgment model;
the abstract extraction module is used for splicing the abstract information and the effective labeling dialogue corresponding to the abstract information to obtain a training splicing sequence, training a preset abstract extraction model by using the training splicing sequence to obtain an initial abstract extraction model, and verifying the initial abstract extraction model by using the verification abstract information to obtain a standard abstract extraction model;
the dialogue reply module is used for constructing a dialogue sequence based on the abstract information and the multi-turn dialogue linguistic data, utilizing the dialogue sequence to train to obtain a multi-turn dialogue model, obtaining user questions and multi-turn historical dialogue, utilizing the standard judgment model to carry out dialogue judgment on the multi-turn historical dialogue, carrying out splicing processing on the dialogue which is judged to be in accordance with a preset standard to obtain a dialogue splicing sequence, inputting the dialogue splicing sequence into the standard abstract extraction model to obtain a dialogue abstract, carrying out splicing processing on the dialogue abstract and the user questions, and inputting the dialogue abstract and the user questions into the multi-turn dialogue model to obtain user reply.
In order to solve the above problem, the present invention also provides an electronic device, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the dialog reply generation method described above.
In order to solve the above problem, the present invention further provides a computer-readable storage medium, in which at least one computer program is stored, and the at least one computer program is executed by a processor in an electronic device to implement the dialog reply generation method described above.
According to the embodiment of the invention, an effective information judgment model, a standard abstract extraction model and a multi-turn dialogue model are respectively trained, the effective information judgment model is used for judging whether a historical dialogue contains effective information, the standard abstract extraction model is used for extracting abstract information of the historical dialogue judged by the effective information judgment model to obtain abstract information, the abstract information and a user question are spliced to be input into the multi-turn dialogue model, and a proper reply is generated. By judging the effective information and extracting the historical dialogue abstract, the problems of overlong historical dialogue, low effective information density, overlarge input occupied memory, low generation speed and the like are solved, and the efficiency of dialogue reply generation is improved while the accuracy is ensured. Therefore, the dialog reply generation method, the dialog reply generation device, the electronic equipment and the computer readable storage medium provided by the invention can solve the problem of low efficiency of dialog reply generation.
Drawings
Fig. 1 is a schematic flow chart illustrating a dialog reply generation method according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart showing a detailed implementation of one of the steps in FIG. 1;
FIG. 3 is a schematic flow chart showing a detailed implementation of one of the steps in FIG. 1;
FIG. 4 is a schematic flow chart showing a detailed implementation of one of the steps in FIG. 1;
FIG. 5 is a schematic flow chart illustrating another step of FIG. 4;
FIG. 6 is a schematic flow chart showing a detailed implementation of one of the steps in FIG. 1;
FIG. 7 is a schematic flow chart showing a detailed implementation of one of the steps in FIG. 1;
fig. 8 is a functional block diagram of a dialog reply generation apparatus according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of an electronic device implementing the dialog reply generation method according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the application provides a dialog reply generation method. The execution subject of the dialog reply generation method includes, but is not limited to, at least one of electronic devices that can be configured to execute the method provided by the embodiments of the present application, such as a server, a terminal, and the like. In other words, the dialog reply generation method may be executed by software or hardware installed in the terminal device or the server device, and the software may be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like. The server may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like.
Fig. 1 is a schematic flow chart of a dialog reply generation method according to an embodiment of the present invention. In this embodiment, the dialog reply generation method includes the following steps S1-S8:
and S1, acquiring a preset number of multi-turn dialogue corpora, and carrying out effective information labeling on the multi-turn dialogue corpora to obtain a labeled dialogue set.
In the embodiment of the present invention, the preset number may be 10000, so that 10000 groups of multi-turn dialog corpora may be obtained, and the multi-turn dialog corpora may be used as a subsequent data base.
Specifically, referring to fig. 2, the effective information tagging performed on the multiple rounds of dialog corpuses to obtain a tagged dialog set includes the following steps S11-S14:
s11, carrying out dialogue splitting on the multiple rounds of dialogue corpora to obtain a split dialogue set;
s12, comparing the split dialog in the split dialog set with the labeled data in a preset labeled database;
s13, marking the splitting dialogue which is consistent with any marking data in the marking database as an effective marking dialogue, and marking the splitting dialogue which is inconsistent with the marking data in the marking database as an ineffective marking dialogue;
and S14, summarizing the effective annotation dialogues and the ineffective annotation dialogues to obtain an annotation dialog set.
In detail, the annotation database includes a plurality of pieces of dialogue data that need to be effectively annotated in a certain embodiment, the split dialogue in the split dialogue set is compared with any annotated data in the annotation database, the split dialogue that is consistent with any annotated data in the annotation database is annotated as an effective annotation dialogue, and the split dialogue that is inconsistent with the annotated data in the annotation database is annotated as an invalid annotation dialogue.
For example, the dialog corpus of the multiple rounds is "a: is someone online? I need help, I have something to ask. "" B: please say that "" a: how to avoid the gap with others, please give the most detailed scheme! Please refer to the teaching. "" B: how old you are? This problem is too large to be said to be clear in a few words. "" A: "18 was the acquaintance, ask for what to do? That person seems to have gone on pteropteris ": you need to learn, communicate, feel ". And carrying out effective information labeling on the multi-turn dialogue corpus to obtain a labeled dialogue set, wherein the effective information labeling is carried out on the multi-turn dialogue corpus, and the effective information labeling is carried out on the dialogue corpus, namely' A: feeding and feeding, namely feeding and feeding. "" B: is there a? "belongs to a mood word, is not in the annotation database, and is therefore annotated as an invalid annotation session, whereas subsequent sessions belong to valid content, have actual referential meaning, and are therefore annotated as valid annotation sessions.
And S2, carrying out abstract extraction on the effective marked dialogs in the marked dialog set to obtain abstract information.
In the embodiment of the invention, the marked dialogue set comprises effective marked dialogues and ineffective marked dialogues, the effective marked dialogues in the standard dialogue set are screened out, and the ineffective marked dialogues are eliminated.
Specifically, referring to fig. 3, the extracting the summary of the effective annotation dialogs in the annotation dialog set to obtain the summary information includes the following steps S21-S24:
s21, removing meaningless words in the effective annotation dialog to obtain a screening annotation dialog;
s22, performing word segmentation processing on the screening standard conversation to obtain a word segmentation conversation set;
s23, performing part-of-speech tagging on the word segmentation dialogue set, and reserving word segmentation dialogues which accord with preset parts-of-speech in the word segmentation dialogue set;
and S24, connecting the word segmentation conversations conforming to the preset parts of speech according to a preset connection method to obtain abstract information.
In detail, the nonsense word refers to a null word, an exclamation word, a word for linking syllables or representing the action of moods, or the like.
For example, the key information in the active annotation dialog is extracted as summary information, "a: how to avoid getting alienated with others? "B: how big are you? The problem is too great. "" A: 18, acquired the criminal, and the criminal is reluctant to pursue the pterization. "" B: learning, communication, feeling. "
And S3, carrying out dialogue division on the labeling dialogue set according to a preset first division ratio to obtain a training dialogue set and a verification dialogue set, and carrying out information division on the abstract information according to a preset second division ratio to obtain training abstract information and verification abstract information.
In an embodiment of the present invention, the first partition ratio may be 85% of the training session set and 15% of the verification session set, and the second partition ratio may be consistent with the first partition ratio, and the training summary information is 85% and the verification summary information is 15%, or the second partition ratio is not consistent with the second partition ratio, the training summary information is 80% and the verification summary information is 20%. And is not limited herein.
The training dialogue set and the training abstract information are used for training models subsequently, and the verification dialogue set and the verification abstract information are used for verifying the trained models.
And S4, training and verifying a preset effective information judgment model based on the training dialogue set and the verification dialogue set to obtain a standard judgment model.
In the embodiment of the invention, the preset effective information judgment model is a Chinese pre-training model bert-base-chip. Wherein, the BERT-base-chip is a basic model of a Chinese version of a pre-training model BERT and is composed of 12 layers of transform encoders.
Specifically, referring to fig. 4, the training and verifying a preset valid information judgment model based on the training dialog set and the verification dialog set to obtain a standard judgment model includes the following steps S41 to S46:
s41, carrying out sequence conversion on the training dialogs in the training dialog set to obtain an input sequence;
s42, converting the input sequence into a dialogue number by using a Chinese dictionary in the effective information judgment model;
s43, converting the training dialog into a corresponding category number according to whether the training dialog contains effective information or not;
s44, inputting the conversation number and the category number into a cross entropy loss function in the effective information judgment model to obtain a cross entropy loss value;
s45, updating the parameter weight of the effective information judgment model based on the cross entropy loss value and the gradient descending back propagation algorithm to obtain an initial judgment model;
and S46, carrying out verification processing on the initial judgment model by using the verification dialog set, and outputting the initial judgment model as a standard judgment model when the verification processing is passed.
In detail, the training sessions in the training session set are subjected to sequence conversion, and interval labels are inserted into the training sessions, for example, the training session set is "a: is someone online? I need help, I have something to ask. ", is the input sequence [ CLS ] obtained by sequence conversion online? I need help, I have something to ask about (SEP). The input sequence is converted to the dialog number 101330078217625296140880432769744462062376256480242769330067141577522682730951164356382511102 according to the chinese dictionary in the predicate model, i.e., the chinese dictionary in the bert model. And converting the training dialogue into a category number according to whether the training dialogue contains effective information, wherein when the training dialogue does not contain the effective information, the corresponding category number is 0, and when the training dialogue contains the effective information, the corresponding category number is 1.
Further, referring to fig. 5, the performing the verification process on the initial judgment model by using the verification dialog set includes the following steps S461 to S465:
s461, performing dictionary conversion on the verification dialog set to obtain a conversion dialog set;
s462, inputting the conversion dialog set into the initial judgment model to obtain a prediction classification result;
s463, calculating a verification value based on the prediction classification result and a preset real classification result, and judging the size between the verification value and a preset verification threshold value;
s464, when the verification value is smaller than the verification threshold value, judging the verification processing to be failed;
and S465, when the verification value is larger than or equal to the verification threshold value, judging that the verification processing is passed.
In detail, when the verification value is smaller than the verification threshold, the verification processing is determined as processing failed, the initial judgment model is retrained again until the verification value is greater than or equal to the verification threshold, the verification processing is determined as processing passed, and the initial judgment model is output as a standard judgment model.
And S5, splicing the abstract information and the effective labeling dialogue corresponding to the abstract information to obtain a training splicing sequence, training a preset abstract extraction model by using the training splicing sequence to obtain an initial abstract extraction model, and verifying the initial abstract extraction model by using the verification abstract information to obtain a standard abstract extraction model.
In the embodiment of the invention, the abstract extraction model is a Chinese pre-training model GPT 2-Chinese. GPT2-Chinese is a pre-training model GPT-2 is a Chinese universal pre-training model after pre-training by using large-scale Chinese corpora, and is composed of 12 layers of modified Transformer decoders.
Specifically, the summary information and the effective labeling dialogue corresponding to the summary information are spliced, wherein the summary information is extracted from the effective labeling dialogue.
Further, referring to fig. 6, the training a preset digest extraction model by using the training concatenation sequence to obtain an initial digest extraction model includes the following steps S51-S54:
s51, converting the training splicing sequence into a splicing label by using a dictionary in the abstract extraction model;
s52, marking the position corresponding to the summary dialogue in the splicing label as a preset summary label;
s53, inputting the splicing labels and the abstract labels into the abstract extraction model to obtain a cross entropy loss value;
and S54, performing iterative optimization on the abstract extraction model based on the cross entropy loss value to obtain an initial abstract extraction model.
Specifically, the verification summary information is used for verifying the initial summary extraction model to obtain a standard summary extraction model, the verification summary information set is used for verifying the initial summary extraction model, when the verification result meets the preset verification requirement, the verification is finished and the initial summary model is output as the standard summary extraction model, when the verification result does not meet the preset verification requirement, the initial summary model is trained again until the verification result meets the preset verification requirement, and the initial summary model is output as the standard summary model.
And S6, constructing a dialogue sequence based on the abstract information and the multi-turn dialogue corpus, and training by using the dialogue sequence to obtain a multi-turn dialogue model.
In the embodiment of the present invention, referring to fig. 7, the constructing a dialog sequence based on the summary information and the multiple rounds of dialog corpora includes the following steps S61 to S62:
s61, extracting dialogue linguistic data with preset turns in the multi-turn dialogue linguistic data, and segmenting the dialogue linguistic data by utilizing a preset first role mark and a preset second role mark to obtain a role sequence;
and S62, splicing the role sequence and the abstract information to obtain a conversation sequence.
In detail, the dialog corpus of the preset number of turns refers to a corpus of a last turn of dialog in the dialog corpus, the first role mark is [ spaker 1], the second role mark is [ spaker 2], different speaking roles in the dialog corpus are segmented by the first role mark [ spaker 1] and the second role mark [ spaker 2] to obtain a role sequence, and the role sequence and the summary sequence are subjected to head-to-tail splicing to obtain the dialog sequence.
Specifically, a multi-round dialogue model is trained by using the dialogue sequence, and each word in the content is converted into a number in a corresponding digital form as a word number by using a dictionary in the multi-round dialogue model, namely input _ ids; recording all tokens asked for questions in the dialog sequence as [ spaker 1], recording all tokens replied as [ spaker 2], and obtaining token _ type _ ids; all ids of input _ ids except the reply of the last round of dialog are marked as-1, resulting in lm _ labels. Inputting input _ ids, token _ type _ ids and lm _ labels into an initial pair of wheel dialogue model, wherein the initial pair of wheel dialogue model adopts a CDial-GPT model to obtain cross entropy loss; and updating the parameter weight of the model through back propagation based on gradient descent, and obtaining a multi-round dialogue model after multiple iterations. And verifying the multi-turn dialogue model by using a verification set, calculating objective indexes BLEU, Dist, GreedyMatching and Embeddingaverage, manually evaluating three dimensions of dialogue fluency, context correlation and reply diversity, finishing the training if all the evaluations are better than the preset minimum requirement, or increasing the number of multi-turn dialogue corpora and continuing the training if the evaluations are worse than the minimum requirement.
And S7, obtaining user questions and multiple rounds of historical conversations, carrying out conversation judgment on the multiple rounds of historical conversations by using the standard judgment model, and carrying out splicing treatment on the conversations which are judged to be in accordance with the preset standard to obtain a conversation splicing sequence.
In the embodiment of the present invention, when a multi-turn dialog system interacts with a user, a problem posed by the current user is obtained, and at most N rounds of historical dialogs are obtained (for example, N is 5): if the system and the user have finished more than N rounds of conversations, only the most recent N rounds of conversations are reserved; if there are fewer than N rounds, all historical conversations are retained.
Specifically, performing dialogue judgment on the multiple rounds of historical dialogue by using the standard judgment model, and performing splicing processing on the dialogue which is judged to meet a preset standard to obtain a dialogue splicing sequence.
For example, using an effective information judgment model to judge whether each round of historical conversation contains effective information, and if the model judges that the historical conversation contains effective information, keeping the round of historical conversation; if the model judges that the model does not contain valid information, the historical conversation of the round is not reserved. And splicing all the reserved historical conversations according to the original sequence to be used as the input of the next step.
And S8, inputting the dialogue splicing sequence into the standard abstract extraction model to obtain a dialogue abstract, splicing the dialogue abstract and the user question, and inputting the dialogue abstract and the user question into the multi-turn dialogue model to obtain a user reply.
In the embodiment of the invention, the dialogue splicing sequence is input into the standard abstract extraction model to obtain a dialogue abstract, the dialogue abstract and the user question are spliced and input into the multi-turn dialogue model to obtain the user reply.
According to the embodiment of the invention, an effective information judgment model, a standard abstract extraction model and a multi-turn dialogue model are respectively trained, the effective information judgment model is used for judging whether a historical dialogue contains effective information, the standard abstract extraction model is used for extracting abstract information of the historical dialogue judged by the effective information judgment model to obtain abstract information, the abstract information and a user question are spliced to be input into the multi-turn dialogue model, and a proper reply is generated. By judging the effective information and extracting the historical dialogue abstract, the problems of overlong historical dialogue, low effective information density, overlarge input occupied memory, low generation speed and the like are solved, and the efficiency of dialogue reply generation is improved while the accuracy is ensured. Therefore, the dialog reply generation method provided by the invention can solve the problem of low efficiency of dialog reply generation.
Fig. 8 is a functional block diagram of a dialog reply generation apparatus according to an embodiment of the present invention.
The dialog reply generation apparatus 100 according to the present invention may be installed in an electronic device. According to the implemented functions, the dialog reply generation apparatus 100 may include a data processing module 101, a criterion determination module 102, a summary extraction module 103, and a dialog reply module 104. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the data processing module 101 is configured to obtain a preset number of multi-turn dialog corpora, perform effective information tagging on the multi-turn dialog corpora to obtain a tagged dialog set, perform abstract extraction on effective tagged dialogs in the tagged dialog set to obtain abstract information, perform dialog division on the tagged dialog set according to a preset first division ratio to obtain a training dialog set and a verification dialog set, and perform information division on the abstract information according to a preset second division ratio to obtain training abstract information and verification abstract information;
the standard judgment module 102 is configured to train and verify a preset valid information judgment model based on the training session set and the verification session set to obtain a standard judgment model;
the abstract extraction module 103 is configured to splice the abstract information and the effective labeling dialogues corresponding to the abstract information to obtain a training splice sequence, train a preset abstract extraction model by using the training splice sequence to obtain an initial abstract extraction model, and verify the initial abstract extraction model by using the verification abstract information to obtain a standard abstract extraction model;
the dialogue reply module 104 is configured to construct a dialogue sequence based on the summary information and the multiple rounds of dialogue corpora, obtain multiple rounds of dialogue models by using the dialogue sequence training, obtain user questions and multiple rounds of historical dialogue, perform dialogue judgment on the multiple rounds of historical dialogue by using the standard judgment model, perform concatenation processing on the dialogue which meets a preset standard after the dialogue judgment to obtain a dialogue concatenation sequence, input the dialogue concatenation sequence into the standard abstract extraction model to obtain a dialogue summary, perform concatenation processing on the dialogue summary and the user questions, and input the dialogue summary and the user questions into the multiple rounds of dialogue models to obtain user replies.
In detail, the specific implementation of each module of the dialog reply generation apparatus 100 is as follows:
the method comprises the steps of firstly, obtaining a preset number of multi-turn dialogue corpora, and carrying out effective information labeling on the multi-turn dialogue corpora to obtain a labeled dialogue set.
In the embodiment of the present invention, the preset number may be 10000, so that 10000 groups of multi-turn dialog corpora may be obtained, and the multi-turn dialog corpora may be used as a subsequent data base.
Specifically, the effective information labeling is performed on the multiple rounds of dialog corpuses to obtain a labeled dialog set, including:
carrying out dialogue splitting on the multi-turn dialogue corpus to obtain a split dialogue set;
comparing the split dialogues in the split dialog set with the labeled data in a preset labeled database;
marking the splitting dialogue which is consistent with any marked data in the marked database as an effective marked dialogue, and marking the splitting dialogue which is inconsistent with the marked data in the marked database as an ineffective marked dialogue;
and summarizing the effective labeling conversation and the ineffective labeling conversation to obtain a labeling conversation set.
In detail, the annotation database includes a plurality of pieces of dialogue data that need to be effectively annotated in a certain embodiment, the split dialogue in the split dialogue set is compared with any annotated data in the annotation database, the split dialogue that is consistent with any annotated data in the annotation database is annotated as an effective annotation dialogue, and the split dialogue that is inconsistent with the annotated data in the annotation database is annotated as an invalid annotation dialogue.
For example, the dialog corpus of the multiple rounds is "a: is someone online? I need help, I have a little to ask. "" B: please say "" a: how to avoid the gap with others, please give the most detailed scheme! Please refer to the teaching. "" B: how old you are? This problem is too large to be said to be clear in a few words. "" A: "18 was the acquaintance, ask for what to do? That person seems to have gone on pteropteris ": you need to learn, communicate, feel ". And carrying out effective information labeling on the multi-turn dialogue corpus to obtain a labeled dialogue set, wherein the effective information labeling is carried out on the multi-turn dialogue corpus, and the effective information labeling is carried out on the dialogue corpus, namely' A: feeding and feeding, namely feeding and feeding. "" B: is a letter? "belongs to a mood word, is not in the annotation database, and is therefore annotated as an invalid annotation session, whereas subsequent sessions belong to valid content, have actual referential meaning, and are therefore annotated as valid annotation sessions.
And step two, carrying out abstract extraction on the effective marked dialogs in the marked dialog set to obtain abstract information.
In the embodiment of the invention, the marked dialogue set comprises effective marked dialogues and ineffective marked dialogues, the effective marked dialogues in the standard dialogue set are screened out, and the ineffective marked dialogues are eliminated.
Specifically, the extracting the abstract of the effective labeled dialogue in the labeled dialogue set to obtain abstract information includes:
removing meaningless words in the effective labeling conversation to obtain a screening labeling conversation;
performing word segmentation processing on the screening standard dialogue to obtain a word segmentation dialogue set;
performing part-of-speech tagging on the word segmentation conversation set, and reserving word segmentation conversations in the word segmentation conversation set, wherein the word segmentation conversations accord with preset parts-of-speech;
and connecting the word segmentation conversations conforming to the preset part of speech according to a preset connection method to obtain summary information.
In detail, the nonsense word refers to a null word, an exclamation word, a word for linking syllables or representing the action of moods, or the like.
For example, the key information in the active annotation dialog is extracted as summary information, "a: how to avoid getting alienated with others? "B: how big are you? The problem is too great. "" A: 18, acquired the criminal, and the criminal is reluctant to pursue the pterization. "" B: learning, communication, feeling. "
And step three, carrying out dialogue division on the labeling dialogue set according to a preset first division ratio to obtain a training dialogue set and a verification dialogue set, and carrying out information division on the abstract information according to a preset second division ratio to obtain training abstract information and verification abstract information.
In an embodiment of the present invention, the first partition ratio may be 85% of the training session set and 15% of the verification session set, and the second partition ratio may be consistent with the first partition ratio, and the training summary information is 85% and the verification summary information is 15%, or the second partition ratio is not consistent with the second partition ratio, the training summary information is 80% and the verification summary information is 20%. And is not limited herein.
The training dialogue set and the training abstract information are used for training a model subsequently, and the verification dialogue set and the verification abstract information are used for verifying the trained model.
And fourthly, training and verifying a preset effective information judgment model based on the training dialogue set and the verification dialogue set to obtain a standard judgment model.
In the embodiment of the invention, the preset effective information judgment model is a Chinese pre-training model bert-base-chip. Wherein, the BERT-base-chip is a basic model of a Chinese version of a pre-training model BERT and is composed of 12 layers of transform encoders.
Specifically, the training and verifying a preset effective information judgment model based on the training session set and the verification session set to obtain a standard judgment model, including:
performing sequence conversion on the training dialogs in the training dialog set to obtain an input sequence;
converting the input sequence into a dialogue number by utilizing a Chinese dictionary in the effective information judgment model;
converting the training dialogue into a corresponding category number according to whether the training dialogue contains effective information;
inputting the conversation number and the category number into a cross entropy loss function in the effective information judgment model to obtain a cross entropy loss value;
updating the parameter weight of the effective information judgment model based on the cross entropy loss value and the gradient descending back propagation algorithm to obtain an initial judgment model;
and carrying out verification processing on the initial judgment model by using the verification dialogue set, and outputting the initial judgment model as a standard judgment model when the verification processing is passed.
In detail, the training sessions in the training session set are subjected to sequence conversion, and interval labels are inserted into the training sessions, for example, the training session set is "a: is someone online? I need help, I have something to ask. ", is the input sequence [ CLS ] obtained by sequence conversion online? I need help, I have something to ask about (SEP). The input sequence is converted to the dialog number 101330078217625296140880432769744462062376256480242769330067141577522682730951164356382511102 according to the chinese dictionary in the predicate model, i.e., the chinese dictionary in the bert model. And converting the training dialogue into a category number according to whether the training dialogue contains effective information, wherein when the training dialogue does not contain the effective information, the corresponding category number is 0, and when the training dialogue contains the effective information, the corresponding category number is 1.
Further, the verifying the initial judgment model by using the verification dialog set includes:
performing dictionary conversion on the verification dialog set to obtain a conversion dialog set;
inputting the conversion dialog set into the initial judgment model to obtain a prediction classification result;
calculating a verification value based on the prediction classification result and a preset real classification result, and judging the magnitude between the verification value and a preset verification threshold value;
determining the verification process as a process failure when the verification value is less than the verification threshold;
when the verification value is greater than or equal to the verification threshold, the verification process is determined as a process pass.
In detail, when the verification value is smaller than the verification threshold, the verification processing is determined as processing failed, the initial judgment model is retrained again until the verification value is greater than or equal to the verification threshold, the verification processing is determined as processing passed, and the initial judgment model is output as a standard judgment model.
And fifthly, splicing the abstract information and the effective labeling dialogue corresponding to the abstract information to obtain a training splicing sequence, training a preset abstract extraction model by using the training splicing sequence to obtain an initial abstract extraction model, and verifying the initial abstract extraction model by using the verification abstract information to obtain a standard abstract extraction model.
In the embodiment of the invention, the abstract extraction model is a Chinese pre-training model GPT 2-Chinese. GPT2-Chinese is a pre-training model GPT-2 is a Chinese universal pre-training model after pre-training by using large-scale Chinese corpora, and is composed of 12 layers of modified Transformer decoders.
Specifically, the summary information and the effective labeling dialogue corresponding to the summary information are spliced, where the summary information is extracted from the effective labeling dialogue.
Further, the training a preset abstract extraction model by using the training concatenation sequence to obtain an initial abstract extraction model includes:
converting the training splicing sequence into a splicing label by using a dictionary in the abstract extraction model;
marking the position corresponding to the summary dialogue in the splicing label as a preset summary label;
inputting the splicing labels and the abstract labels into the abstract extraction model to obtain a cross entropy loss value;
and carrying out iterative optimization on the abstract extraction model based on the cross entropy loss value to obtain an initial abstract extraction model.
Specifically, the verification summary information is used for verifying the initial summary extraction model to obtain a standard summary extraction model, the verification summary information set is used for verifying the initial summary extraction model, when a verification result meets a preset verification requirement, the verification is finished and the initial summary model is output as the standard summary extraction model, when the verification result does not meet the preset verification requirement, the initial summary model is trained again, and when the verification result meets the preset verification requirement, the initial summary model is output as the standard summary model.
And step six, constructing a dialogue sequence based on the summary information and the multi-turn dialogue corpus, and training by utilizing the dialogue sequence to obtain a multi-turn dialogue model.
In this embodiment of the present invention, the constructing a dialog sequence based on the summary information and the multiple rounds of dialog corpora includes:
extracting dialogue linguistic data with preset turns in the multi-turn dialogue linguistic data, and segmenting the dialogue linguistic data by utilizing a preset first role mark and a preset second role mark to obtain a role sequence;
and splicing the role sequence and the abstract information to obtain a conversation sequence.
In detail, the dialog corpus of the preset number of turns refers to a corpus of a last turn of dialog in the dialog corpus, the first role mark is [ spaker 1], the second role mark is [ spaker 2], different speaking roles in the dialog corpus are segmented by the first role mark [ spaker 1] and the second role mark [ spaker 2] to obtain a role sequence, and the role sequence and the summary sequence are subjected to head-to-tail splicing to obtain the dialog sequence.
Specifically, a multi-round dialogue model is trained by using the dialogue sequence, and each word in the content is converted into a number in a corresponding digital form as a word number by using a dictionary in the multi-round dialogue model, namely input _ ids; recording all tokens asked for questions in the dialog sequence as [ spaker 1], recording all tokens replied as [ spaker 2], and obtaining token _ type _ ids; all ids of input _ ids except the reply of the last round of dialog are marked as-1, resulting in lm _ labels. Inputting input _ ids, token _ type _ ids and lm _ labels into an initial pair of wheel dialogue model, wherein the initial pair of wheel dialogue model adopts a CDial-GPT model to obtain cross entropy loss; and updating the parameter weight of the model through back propagation based on gradient descent, and obtaining a multi-round dialogue model after multiple iterations. And verifying the multi-turn dialogue model by using a verification set, calculating objective indexes BLEU, Dist, GreedyMatching and Embeddingaverage, manually evaluating three dimensions of dialogue fluency, context correlation and reply diversity, finishing the training if all the evaluations are better than the preset minimum requirement, or increasing the number of multi-turn dialogue corpora and continuing the training if the evaluations are worse than the minimum requirement.
And seventhly, user questions and multiple rounds of historical conversations are obtained, conversation judgment is carried out on the multiple rounds of historical conversations by using the standard judgment model, and the conversations which are judged to be in accordance with the preset standards are spliced to obtain a conversation splicing sequence.
In the embodiment of the present invention, when a multi-turn dialog system interacts with a user, a problem posed by the current user is obtained, and at most N rounds of historical dialogs are obtained (for example, N is 5): if the system and the user have finished more than N rounds of conversations, only the most recent N rounds of conversations are reserved; if there are fewer than N rounds, all historical conversations are retained.
Specifically, performing dialogue judgment on the multiple rounds of historical dialogue by using the standard judgment model, and performing splicing processing on the dialogue which is judged to meet a preset standard to obtain a dialogue splicing sequence.
For example, using an effective information judgment model to judge whether each round of historical conversation contains effective information, and if the model judges that the historical conversation contains effective information, keeping the round of historical conversation; if the model judges that the model does not contain valid information, the historical conversation of the round is not reserved. And splicing all the reserved historical dialogs according to the original sequence to be used as the input of the next step.
And step eight, inputting the dialogue splicing sequence into the standard abstract extraction model to obtain a dialogue abstract, splicing the dialogue abstract and the user question, and inputting the dialogue abstract and the user question into the multi-turn dialogue model to obtain a user reply.
In the embodiment of the invention, the dialogue splicing sequence is input into the standard abstract extraction model to obtain a dialogue abstract, the dialogue abstract and the user question are spliced and input into the multi-turn dialogue model to obtain the user reply.
According to the embodiment of the invention, an effective information judgment model, a standard abstract extraction model and a multi-turn dialogue model are respectively trained, the effective information judgment model is used for judging whether a historical dialogue contains effective information, the standard abstract extraction model is used for extracting abstract information of the historical dialogue judged by the effective information judgment model to obtain abstract information, the abstract information and a user question are spliced to be input into the multi-turn dialogue model, and a proper reply is generated. By judging the effective information and extracting the historical dialogue abstract, the problems of overlong historical dialogue, low effective information density, overlarge input occupied memory, low generation speed and the like are solved, and the efficiency of dialogue reply generation is improved while the accuracy is ensured. Therefore, the dialog reply generation device provided by the invention can solve the problem of low efficiency of dialog reply generation.
Fig. 9 is a schematic structural diagram of an electronic device implementing a dialog reply generation method according to an embodiment of the present invention.
The electronic device 1 may comprise a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may further comprise a computer program, such as a dialog reply generating program, stored in the memory 11 and executable on the processor 10.
In some embodiments, the processor 10 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same function or different functions, and includes one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device by running or executing programs or modules (e.g., executing a dialog reply generation program, etc.) stored in the memory 11 and calling data stored in the memory 11.
The memory 11 includes at least one type of readable storage medium including flash memory, removable hard disks, multimedia cards, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disks, optical disks, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device, for example a removable hard disk of the electronic device. The memory 11 may also be an external storage device of the electronic device in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device. The memory 11 may be used not only to store application software installed in the electronic device and various types of data, such as codes of a dialog reply generation program, but also to temporarily store data that has been output or is to be output.
The communication bus 12 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
The communication interface 13 is used for communication between the electronic device and other devices, and includes a network interface and a user interface. Optionally, the network interface may include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), which are typically used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a Display (Display), an input unit such as a Keyboard (Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
Fig. 9 shows only an electronic device with components, and it will be understood by those skilled in the art that the structure shown in fig. 9 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than those shown, or some components may be combined, or a different arrangement of components.
For example, although not shown, the electronic device may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so that functions of charge management, discharge management, power consumption management and the like are realized through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The dialog reply generation program stored in the memory 11 of the electronic device 1 is a combination of a plurality of instructions, which when executed in the processor 10, may implement:
acquiring a preset number of multi-turn dialogue corpora, and carrying out effective information labeling on the multi-turn dialogue corpora to obtain a labeled dialogue set;
extracting the abstract of the effective marked dialogue in the marked dialogue set to obtain abstract information;
carrying out dialogue division on the labeling dialogue set according to a preset first division ratio to obtain a training dialogue set and a verification dialogue set, and carrying out information division on the abstract information according to a preset second division ratio to obtain training abstract information and verification abstract information;
training and verifying a preset effective information judgment model based on the training session set and the verification session set to obtain a standard judgment model;
splicing the abstract information and the effective labeling dialogue corresponding to the abstract information to obtain a training splicing sequence, training a preset abstract extraction model by using the training splicing sequence to obtain an initial abstract extraction model, and verifying the initial abstract extraction model by using the verification abstract information to obtain a standard abstract extraction model;
constructing a dialogue sequence based on the abstract information and the multi-turn dialogue corpus, and training by using the dialogue sequence to obtain a multi-turn dialogue model;
obtaining user questions and multiple rounds of historical conversations, carrying out conversation judgment on the multiple rounds of historical conversations by using the standard judgment model, and carrying out splicing treatment on the conversations which are judged to be in accordance with a preset standard to obtain a conversation splicing sequence;
and inputting the dialogue splicing sequence into the standard abstract extraction model to obtain a dialogue abstract, splicing the dialogue abstract and the user question, and inputting the dialogue abstract and the user question into the multi-turn dialogue model to obtain a user reply.
Specifically, the specific implementation method of the instruction by the processor 10 may refer to the description of the relevant steps in the embodiment corresponding to the drawings, which is not described herein again.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. The computer readable storage medium may be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
The present invention also provides a computer-readable storage medium, storing a computer program which, when executed by a processor of an electronic device, may implement:
acquiring a preset number of multi-turn dialogue corpora, and carrying out effective information labeling on the multi-turn dialogue corpora to obtain a labeled dialogue set;
extracting the abstract of the effective marked dialogue in the marked dialogue set to obtain abstract information;
carrying out dialogue division on the labeling dialogue set according to a preset first division ratio to obtain a training dialogue set and a verification dialogue set, and carrying out information division on the summary information according to a preset second division ratio to obtain training summary information and verification summary information;
training and verifying a preset effective information judgment model based on the training dialogue set and the verification dialogue set to obtain a standard judgment model;
splicing the abstract information and the effective labeling dialogue corresponding to the abstract information to obtain a training splicing sequence, training a preset abstract extraction model by using the training splicing sequence to obtain an initial abstract extraction model, and verifying the initial abstract extraction model by using the verification abstract information to obtain a standard abstract extraction model;
constructing a dialogue sequence based on the abstract information and the multi-turn dialogue corpus, and training by using the dialogue sequence to obtain a multi-turn dialogue model;
obtaining user questions and multiple rounds of historical conversations, carrying out conversation judgment on the multiple rounds of historical conversations by using the standard judgment model, and carrying out splicing treatment on the conversations which are judged to be in accordance with a preset standard to obtain a conversation splicing sequence;
and inputting the dialogue splicing sequence into the standard abstract extraction model to obtain a dialogue abstract, splicing the dialogue abstract and the user question, and inputting the dialogue abstract and the user question into the multi-turn dialogue model to obtain a user reply.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules 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 modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, functional modules in the embodiments of the present invention 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 integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The embodiment of the application can acquire and process related data based on an artificial intelligence technology. Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A dialog reply generation method, the method comprising:
acquiring a preset number of multi-turn dialogue corpora, and carrying out effective information labeling on the multi-turn dialogue corpora to obtain a labeled dialogue set;
extracting the abstract of the effective marked dialogue in the marked dialogue set to obtain abstract information;
carrying out dialogue division on the labeling dialogue set according to a preset first division ratio to obtain a training dialogue set and a verification dialogue set, and carrying out information division on the abstract information according to a preset second division ratio to obtain training abstract information and verification abstract information;
training and verifying a preset effective information judgment model based on the training session set and the verification session set to obtain a standard judgment model;
splicing the abstract information and the effective labeling dialogue corresponding to the abstract information to obtain a training splicing sequence, training a preset abstract extraction model by using the training splicing sequence to obtain an initial abstract extraction model, and verifying the initial abstract extraction model by using the verification abstract information to obtain a standard abstract extraction model;
constructing a dialogue sequence based on the abstract information and the multi-turn dialogue corpus, and training by using the dialogue sequence to obtain a multi-turn dialogue model;
acquiring user questions and multiple rounds of historical conversations, performing conversation judgment on the multiple rounds of historical conversations by using the standard judgment model, and performing splicing processing on the conversations which are judged to meet preset standards to obtain a conversation splicing sequence;
and inputting the dialogue splicing sequence into the standard abstract extraction model to obtain a dialogue abstract, splicing the dialogue abstract and the user question, and inputting the dialogue abstract and the user question into the multi-turn dialogue model to obtain a user reply.
2. The dialog reply generation method according to claim 1, wherein the training and verifying a preset valid information judgment model based on the training dialog set and the verification dialog set to obtain a standard judgment model comprises:
performing sequence conversion on the training dialogs in the training dialog set to obtain an input sequence;
converting the input sequence into a dialogue number by utilizing a Chinese dictionary in the effective information judgment model;
converting the training dialogue into a corresponding category number according to whether the training dialogue contains effective information;
inputting the conversation number and the category number into a cross entropy loss function in the effective information judgment model to obtain a cross entropy loss value;
updating the parameter weight of the effective information judgment model based on the cross entropy loss value and the gradient descending back propagation algorithm to obtain an initial judgment model;
and carrying out verification processing on the initial judgment model by using the verification dialogue set, and outputting the initial judgment model as a standard judgment model when the verification processing is passed.
3. The dialog reply generation method according to claim 2, wherein the verifying the initial judgment model using the verification dialog set includes:
performing dictionary conversion on the verification dialog set to obtain a conversion dialog set;
inputting the conversion dialog set into the initial judgment model to obtain a prediction classification result;
calculating a verification value based on the prediction classification result and a preset real classification result, and judging the magnitude between the verification value and a preset verification threshold value;
determining the verification process as a process failure when the verification value is less than the verification threshold;
when the verification value is greater than or equal to the verification threshold, determining that the verification process passes.
4. The method for generating dialog replies according to claim 1, wherein said training a preset summarization extraction model by using said training concatenation sequence to obtain an initial summarization extraction model comprises:
converting the training splicing sequence into a splicing label by using a dictionary in the abstract extraction model;
marking the position corresponding to the summary dialogue in the splicing label as a preset summary label;
inputting the splicing labels and the abstract labels into the abstract extraction model to obtain a cross entropy loss value;
and carrying out iterative optimization on the abstract extraction model based on the cross entropy loss value to obtain an initial abstract extraction model.
5. The method for generating dialog replies according to claim 1, characterized in that said building of dialog sequences based on said summary information and said plurality of rounds of dialog corpuses comprises:
extracting dialogue linguistic data with preset turns in the multi-turn dialogue linguistic data, and segmenting the dialogue linguistic data by utilizing a preset first role mark and a preset second role mark to obtain a role sequence;
and splicing the role sequence and the abstract information to obtain a conversation sequence.
6. The method for generating a dialog reply according to claim 1, wherein the extracting the abstract of the active markup dialog in the markup dialog set to obtain abstract information comprises:
removing meaningless words in the effective labeling conversation to obtain a screening labeling conversation;
performing word segmentation processing on the screening standard conversation to obtain a word segmentation conversation set;
performing part-of-speech tagging on the word segmentation conversation set, and reserving word segmentation conversations in the word segmentation conversation set, wherein the word segmentation conversations accord with preset parts-of-speech;
and connecting the word segmentation conversations conforming to the preset part of speech according to a preset connection method to obtain abstract information.
7. The method according to any one of claims 1 to 6, wherein the performing effective information tagging on the multiple rounds of dialog corpuses to obtain a tagged dialog set includes:
carrying out dialogue splitting on the multi-turn dialogue corpus to obtain a split dialogue set;
comparing the split dialogues in the split dialog set with the labeled data in a preset labeled database;
marking the split dialogue which is consistent with any marked data in the marked database as an effective dialogue, and marking the split dialogue which is inconsistent with the marked data in the marked database as an ineffective dialogue;
and summarizing the effective dialogue and the invalid dialogue to obtain a marked dialogue set.
8. A dialog reply generation apparatus, the apparatus comprising:
the data processing module is used for acquiring a preset number of multi-turn dialogue corpora, carrying out effective information labeling on the multi-turn dialogue corpora to obtain a labeled dialogue set, carrying out abstract extraction on effective labeled dialogues in the labeled dialogue set to obtain abstract information, carrying out dialogue division on the labeled dialogue set according to a preset first division ratio to obtain a training dialogue set and a verification dialogue set, and carrying out information division on the abstract information according to a preset second division ratio to obtain training abstract information and verification abstract information;
the standard judgment module is used for training and verifying a preset effective information judgment model based on the training dialogue set and the verification dialogue set to obtain a standard judgment model;
the abstract extraction module is used for splicing the abstract information and the effective labeling dialogue corresponding to the abstract information to obtain a training splicing sequence, training a preset abstract extraction model by using the training splicing sequence to obtain an initial abstract extraction model, and verifying the initial abstract extraction model by using the verification abstract information to obtain a standard abstract extraction model;
the dialogue reply module is used for constructing a dialogue sequence based on the abstract information and the multi-turn dialogue linguistic data, utilizing the dialogue sequence to train to obtain a multi-turn dialogue model, obtaining user questions and multi-turn historical dialogue, utilizing the standard judgment model to carry out dialogue judgment on the multi-turn historical dialogue, carrying out splicing processing on the dialogue which is judged to be in accordance with a preset standard to obtain a dialogue splicing sequence, inputting the dialogue splicing sequence into the standard abstract extraction model to obtain a dialogue abstract, carrying out splicing processing on the dialogue abstract and the user questions, and inputting the dialogue abstract and the user questions into the multi-turn dialogue model to obtain user reply.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform a dialog reply generation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, storing a computer program, wherein the computer program, when executed by a processor, implements the dialog reply generation method according to any one of claims 1 to 7.
CN202210255616.8A 2022-03-15 2022-03-15 Dialogue reply generation method and device, electronic equipment and storage medium Active CN114610855B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210255616.8A CN114610855B (en) 2022-03-15 2022-03-15 Dialogue reply generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210255616.8A CN114610855B (en) 2022-03-15 2022-03-15 Dialogue reply generation method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114610855A true CN114610855A (en) 2022-06-10
CN114610855B CN114610855B (en) 2024-06-18

Family

ID=81863182

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210255616.8A Active CN114610855B (en) 2022-03-15 2022-03-15 Dialogue reply generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114610855B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116775850A (en) * 2023-08-24 2023-09-19 北京珊瑚礁科技有限公司 Chat model training method, device, equipment and medium
CN118014039A (en) * 2024-04-08 2024-05-10 亚信科技(中国)有限公司 Model training method and device, storage medium and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112100328A (en) * 2020-08-31 2020-12-18 广州探迹科技有限公司 Intention judgment method based on multi-turn conversation
CN112650768A (en) * 2020-12-22 2021-04-13 网易(杭州)网络有限公司 Dialog information generation method and device and electronic equipment
CN113158665A (en) * 2021-04-02 2021-07-23 西安交通大学 Method for generating text abstract and generating bidirectional corpus-based improved dialog text
WO2021151306A1 (en) * 2020-06-19 2021-08-05 平安科技(深圳)有限公司 Method and apparatus for smart analysis of question and answer linguistic material, electronic device, and readable storage medium
CN113420542A (en) * 2021-06-23 2021-09-21 平安科技(深圳)有限公司 Dialog generation method and device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021151306A1 (en) * 2020-06-19 2021-08-05 平安科技(深圳)有限公司 Method and apparatus for smart analysis of question and answer linguistic material, electronic device, and readable storage medium
CN112100328A (en) * 2020-08-31 2020-12-18 广州探迹科技有限公司 Intention judgment method based on multi-turn conversation
CN112650768A (en) * 2020-12-22 2021-04-13 网易(杭州)网络有限公司 Dialog information generation method and device and electronic equipment
CN113158665A (en) * 2021-04-02 2021-07-23 西安交通大学 Method for generating text abstract and generating bidirectional corpus-based improved dialog text
CN113420542A (en) * 2021-06-23 2021-09-21 平安科技(深圳)有限公司 Dialog generation method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116775850A (en) * 2023-08-24 2023-09-19 北京珊瑚礁科技有限公司 Chat model training method, device, equipment and medium
CN118014039A (en) * 2024-04-08 2024-05-10 亚信科技(中国)有限公司 Model training method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN114610855B (en) 2024-06-18

Similar Documents

Publication Publication Date Title
CN112667800A (en) Keyword generation method and device, electronic equipment and computer storage medium
CN112988963B (en) User intention prediction method, device, equipment and medium based on multi-flow nodes
CN114610855B (en) Dialogue reply generation method and device, electronic equipment and storage medium
CN114822812A (en) Character dialogue simulation method, device, equipment and storage medium
CN111694937A (en) Interviewing method and device based on artificial intelligence, computer equipment and storage medium
CN113722483B (en) Topic classification method, device, equipment and storage medium
CN113704429A (en) Semi-supervised learning-based intention identification method, device, equipment and medium
CN113096242A (en) Virtual anchor generation method and device, electronic equipment and storage medium
CN113064994A (en) Conference quality evaluation method, device, equipment and storage medium
CN112507663A (en) Text-based judgment question generation method and device, electronic equipment and storage medium
CN113807973A (en) Text error correction method and device, electronic equipment and computer readable storage medium
CN113821622A (en) Answer retrieval method and device based on artificial intelligence, electronic equipment and medium
CN112951233A (en) Voice question and answer method and device, electronic equipment and readable storage medium
CN113205814A (en) Voice data labeling method and device, electronic equipment and storage medium
CN114461777A (en) Intelligent question and answer method, device, equipment and storage medium
CN113918704A (en) Question-answering method and device based on machine learning, electronic equipment and medium
CN113360654A (en) Text classification method and device, electronic equipment and readable storage medium
CN113254814A (en) Network course video labeling method and device, electronic equipment and medium
CN115346095A (en) Visual question answering method, device, equipment and storage medium
CN114548114A (en) Text emotion recognition method, device, equipment and storage medium
CN114757154A (en) Job generation method, device and equipment based on deep learning and storage medium
CN114595321A (en) Question marking method and device, electronic equipment and storage medium
CN114401346A (en) Response method, device, equipment and medium based on artificial intelligence
CN114186028A (en) Consult complaint work order processing method, device, equipment and storage medium
CN112749264A (en) Problem distribution method and device based on intelligent robot, electronic equipment and storage 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