Dialogue reply method and device, communication device and readable storage medium

By using a pre-trained few-shot learning model and a transfer learning model to generate response templates for human-computer dialogue systems, the problem of low efficiency in response template generation in existing technologies is solved, achieving efficient and low-cost template generation and adaptive enhancement.

CN116361424BActive Publication Date: 2026-01-20CHINA MOBILE COMM LTD RES INST +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111613286.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-27
Publication Date
2026-01-20
Estimated Expiration
2041-12-27

AI Technical Summary

Technical Problem

Existing technologies are inefficient in the response template generation stage of human-computer dialogue systems, requiring domain experts to spend a lot of time designing response templates.

Method used

A pre-trained few-shot learning model is used to identify the response corpus, generate response templates, and adjust the response statements through the few-shot learning model and transfer learning model, replacing the manual design of response templates.

Benefits of technology

It improves the efficiency of response template generation, reduces generation costs, and can adapt to changes in requirements under business expansion or migration scenarios, thereby enhancing the generalization performance of the dialogue response method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116361424B_ABST
    Figure CN116361424B_ABST
Patent Text Reader

Abstract

The application provides a dialogue reply method and device, communication equipment and a readable storage medium, wherein the method comprises: identifying a reply corpus according to a pre-trained small sample learning model to obtain at least one first reply template; determining a first reply template with the highest matching degree with to-be-replied information as a target reply template in the at least one first reply template; filling the to-be-replied information into the target reply template to generate a first reply sentence; and issuing the first reply sentence to a user end. The small sample learning model is used to construct a reply template, which improves the efficiency of the reply template generation stage, reduces the generation cost of the reply template, and makes the generation process of the reply template scalable to adapt to the demand changes of the human-computer dialogue system in the business expansion or business migration process.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of communication, and in particular to a dialogue reply method and device, a communication device, and a readable storage medium. BACKGROUND

[0002] Due to its wide application, a human-computer dialogue system has high commercial value. One of the most important actions in a human-computer dialogue system is a dialogue reply action, that is, generating a reply sentence in line with human language habits according to expected reply information conveying relevant information to a user, and issuing the reply sentence to the user end.

[0003] At present, the related technology adopts a manual design of a reply template to complete the above-mentioned reply generation action, that is, a number of reply templates for dialogue reply are manually designed by a domain expert, and then the number of reply templates are searched according to the aforementioned reply information to obtain a reply template suitable for the reply information, and then the aforementioned reply information is processed according to the reply template to generate and issue a final reply sentence.

[0004] It is found in application that the related technology has low efficiency in the reply template generation stage, that is, before generating a reply sentence, the related technology needs to arrange a domain expert to repeatedly deliberate on the language to complete the corresponding reply template design work, which is time-consuming. SUMMARY

[0005] Embodiments of the present application provide a dialogue reply method, device, communication device, and readable storage medium to solve the problem of low efficiency of related technology in the reply template generation stage.

[0006] To solve the above-mentioned problem, the present application is implemented as follows:

[0007] In a first aspect, the embodiments of the present application provide a dialogue reply method, which comprises:

[0008] According to a pre-trained small sample learning model, a reply corpus is identified to obtain at least one first reply template;

[0009] In the at least one first reply template, a first reply template with the highest matching degree with the reply information is determined as a target reply template;

[0010] The target reply template is filled with the reply information to generate a first reply sentence;

[0011] The first reply sentence is issued to the user end.

[0012] In some embodiments, the identification of the reply corpus according to the pre-trained small sample learning model to obtain at least one first reply template comprises:

[0013] splitting the reply corpus to obtain at least two word groups;

[0014] identifying an invariant word group and an augmented word group in the at least two word groups;

[0015] augmenting the augmented word group according to a preset vocabulary;

[0016] splicing the invariant word group and the augmented word group after the augmentation to obtain the at least one first reply template.

[0017] In some embodiments, the splicing the invariant word group and the augmented word group after the augmentation to obtain the at least one first reply template comprises:

[0018] splicing the invariant word group and the augmented word group after the augmentation to obtain an initial template set, the initial template set comprising at least one initial template;

[0019] performing clustering processing on the initial template set to obtain the at least one first reply template.

[0020] In some embodiments, the performing clustering processing on the initial template set to obtain the at least one first reply template comprises:

[0021] cyclically judging whether the initial template set is empty, and in the case that the initial template set is not empty, obtaining a centroid template in the initial template set, and determining the centroid template as the first reply template, the centroid template being any one of the initial templates in the initial template set;

[0022] performing clustering processing on the initial template set according to the centroid template to obtain a cluster with the centroid template as a clustering center;

[0023] deleting the initial templates included in the cluster from the initial template set.

[0024] In some embodiments, after the filling the to-be-replied information into the target reply template to generate a first reply sentence, the method further comprises:

[0025] adjusting the first reply sentence according to a transfer learning model to generate a second reply sentence;

[0026] the issuing the first reply sentence to the user end comprises:

[0027] issuing the second reply sentence to the user end.

[0028] In some embodiments, after the reply corpus is identified according to the small sample learning model to obtain at least one first reply template; before the at least one first reply template is retrieved according to the information to be replied to; the method further comprises:

[0029] In the at least one first reply template, the first reply template including the sensitive word is filtered out to obtain at least one second reply template;

[0030] The at least one first reply template is retrieved according to the information to be replied to, and the first reply template with the highest matching degree with the information to be replied to in the at least one first reply template is determined as the target reply template, comprising:

[0031] The at least one second reply template is retrieved according to the information to be replied to, and the second reply template with the highest matching degree with the information to be replied to in the at least one second reply template is determined as the target reply template.

[0032] In some embodiments, before the reply corpus is identified according to the pre-trained small sample learning model, the method further comprises:

[0033] An initial model created according to a small sample learning algorithm is obtained;

[0034] The initial model is trained by a preset training sample, and the training sample includes a word group to be augmented and a word group to be kept unchanged;

[0035] The trained initial model is determined as the small sample learning model.

[0036] In a second aspect, the embodiments of the present application provide a dialogue reply device, comprising:

[0037] A template construction module is configured to identify a reply corpus according to a pre-trained small sample learning model to obtain at least one first reply template;

[0038] A retrieval module is configured to determine a first reply template with the highest matching degree with information to be replied to in the at least one first reply template as a target reply template;

[0039] A sentence generation module is configured to fill the information to be replied to into the target reply template to generate a first reply sentence;

[0040] A reply module is configured to issue the first reply sentence to a user end.

[0041] In a third aspect, the embodiments of the present application further provide a communication device, comprising a transceiver, a memory, a processor, and a program stored in the memory and executable on the processor; and the processor is configured to read the program in the memory to implement the steps in the method according to the first aspect.

[0042] In a fourth aspect, the embodiments of the present application further provide a readable storage medium for storing a program, and the program is executable on a processor to implement the steps in the method according to the first aspect.

[0043] In the embodiments of the present application, a dialogue reply method, device, communication device and readable storage medium are provided, and the method comprises: identifying reply corpus according to a pre-trained small sample learning model to obtain at least one first reply template; determining a first reply template with the highest matching degree with to-be-replied information as a target reply template in the at least one first reply template; filling the to-be-replied information into the target reply template to generate a first reply sentence; and issuing the first reply sentence to a user end. The way of identifying reply corpus by using a small sample learning model is used to replace the way of artificially designing a reply template in the related art, so as to improve the efficiency of the reply template generation stage, reduce the generation cost of the reply template, and at the same time make the generation process of the reply template have scalability to adapt to the demand changes of the human-computer dialogue system in the process of business expansion or business migration. BRIEF DESCRIPTION OF DRAWINGS

[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the description of the embodiments of the present application will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0045] Figure 1 is one of the flowcharts of the dialogue reply method provided by the embodiments of the present application;

[0046] Figure 2 is one of the flowcharts of the dialogue reply method provided by the embodiments of the present application;

[0047] Figure 3 is the second flowchart of the dialogue reply method provided by the embodiments of the present application;

[0048] Figure 4 is the flowchart of the template library construction method provided by the embodiments of the present application;

[0049] Figure 5 is the flowchart of the word group classification method provided by the embodiments of the present application;

[0050] Figure 6 is a flowchart of a reply statement generation process applied to a server end provided by an embodiment of the present application.

[0051] Figure 7 is a structural diagram of a dialogue reply device provided by an embodiment of the present application.

[0052] Figure 8 is a structural diagram of a communication device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0053] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all of the embodiments of the present application. According to the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0054] The terms "first", "second", and the like in the embodiments of the present application are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or device including a series of steps or units does not necessarily have to include only those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to the process, method, product, or device. In addition, "and / or" is used in the present application to represent at least one of the connected objects, for example, A and / or B and / or C represents 7 cases including A alone, B alone, C alone, A and B both exist, B and C both exist, A and C both exist, and A, B and C all exist.

[0055] The dialogue reply method, device, communication device and readable storage medium provided by the embodiments of the present application are described below.

[0056] Referring to Figure 1 , Figure 1 is one of the flowcharts of the dialogue reply method provided by the embodiments of the present application, as shown in Figure 1 , the dialogue reply method can include the following steps:

[0057] Step 101, identifying a reply corpus according to a pre-trained small sample learning model to obtain at least one first reply template.

[0058] Step 102, determining a first reply template with the highest matching degree with the information to be replied in the at least one first reply template as a target reply template.

[0059] Step 103, filling the to-be-replied information into the target reply template to generate a first reply sentence.

[0060] Step 104, issuing the first reply sentence to the user end.

[0061] Exemplarily, the human-computer dialogue system can include a user end and a server end, and the user communicates with the server end through the user end. For example, the foregoing process of obtaining the to-be-replied information can be as follows:

[0062] The user transmits an inquiry sentence (such as querying restaurant information) to the server through the user end. After receiving the inquiry sentence, the server performs semantic recognition on the inquiry sentence through a preset processing model, and outputs a recognition result. The recognition result is the foregoing to-be-replied information. The recognition result can be understood as a plurality of dialogue actions for answering the inquiry sentence. Each dialogue action is composed of a dialogue intent (such as “notification”), a task domain (such as “restaurant”), a slot (such as “price”), and a value (such as “100 yuan”). The foregoing processing model can be a fully convolutional network (FCN), a graph convolutional network (GCN), or other network models with semantic recognition function, which are not limited in the embodiments of the present application.

[0063] As described above, the way of identifying the reply corpus by using the small sample learning model is used to replace the way of artificially designing the reply template in the related art, so as to improve the efficiency of the reply template generation stage and reduce the generation cost of the reply template. Meanwhile, the small sample learning model can quickly generate the first reply template based on a small number of samples (such as the foregoing reply corpus), so as to improve the generalization performance of the dialogue reply method, better adapt to the demand changes of the human-computer dialogue system in the business expansion or business migration, and reduce the generation cost of the first reply template in the complex scene (the business expansion scene or the business migration scene).

[0064] Exemplarily, the foregoing business expansion scene can be understood as the case of additionally adding new businesses such as hotel addressing business, drugstore addressing business, and the like, when the existing business is restaurant addressing business; and the foregoing business migration business scene can be understood as the case of changing the existing business from restaurant addressing business to commodity query business.

[0065] It should be noted that the reply corpus can be understood as a set of artificial reply sentences adapted to the existing business scenario requirements of the human-computer dialogue system, which can come from the network (such as the reply sentences obtained by searching for existing business scenario requirements) or the existing database (such as the historical reply sentences stored in the database before the human-computer dialogue system goes online) and the like, which is not limited by the embodiments of the present application.

[0066] As described above, in the case that the information to be replied exists several dialogue actions, the number of target reply templates also exists several. Exemplarily, the process of determining the first reply template with the highest matching degree with the information to be replied as the target reply template in the at least one first reply template can be:

[0067] traversing the at least one first reply template and several dialogue actions in the information to be replied, and calculating the matching degree between the first reply template and the dialogue action; after the above traversal process ends, the first reply template with the highest matching degree with each dialogue action is determined as the target reply template of the dialogue action.

[0068] Based on the foregoing example, if it is set that the first reply template includes an intent label and the number of word groups to be filled in, the process of calculating the matching degree between the first reply template and the dialogue action can be:

[0069] judging the consistency between the intent label of the first reply template and the dialogue intent of the dialogue action, and generating a first judgment result;

[0070] judging the consistency between the number of word groups to be filled in the first reply template and the actual number of word groups of the dialogue action, and generating a second judgment result;

[0071] based on the first judgment result and the second judgment result, generating the matching value (i.e. the aforementioned matching degree) between the first reply template and the dialogue action.

[0072] wherein the first judgment result includes a first value and a second value, the first value is used to represent that the intent label of the first reply template and the dialogue intent of the dialogue action are the same (such as both are "notification"), and the second value is used to represent that the intent label of the first reply template and the dialogue intent of the dialogue action are different (such as the intent label is "notification" and the dialogue intent is "inform"), for example, the first value can be 1, and the second value can be 0.

[0073] The second judgment result includes a third value and a fourth value. The third value is used to represent that the number of to-be-filled word groups of the first reply template and the actual number of word groups of the dialogue action are the same (for example, both are "4"), and the fourth value is used to represent that the number of to-be-filled word groups of the first reply template and the actual number of word groups of the dialogue action are different (for example, the number of to-be-filled word groups is "3" and the actual number of word groups is "2"). For example, the first value can be 0.2, and the second value can be 0.1. The actual number of word groups can be understood as the number of word groups in the dialogue action that are not empty except for the dialogue intent. For example, if the dialogue intent, task domain, slot and value of a dialogue action are "notification", "restaurant", "empty" and "empty" respectively, the actual number of word groups of the dialogue action is 1.

[0074] On the basis of the above examples, the process of generating the matching value can be understood as a process of calculating the sum of the first judgment result and the second judgment result.

[0075] It should be noted that, in addition to the above examples, the matching degree between the first reply template and the dialogue action can also be calculated by a semantic matching model, which can be a deep structured semantic model (DSSM) or the like. The specific calculation method and specific calculation model of the matching degree between the first reply template and the dialogue action are not limited.

[0076] Optionally, the reply corpus is identified according to the pre-trained small sample learning model to obtain at least one first reply template, including:

[0077] The reply corpus is split to obtain at least two word groups;

[0078] The invariable word groups and the augmented word groups are identified in the at least two word groups;

[0079] The augmented word groups are augmented according to a preset vocabulary table;

[0080] The invariable word groups and the augmented word groups after the augmentation processing are spliced to obtain the at least one first reply template.

[0081] The above reply corpus includes a plurality of reply sentences. The reply corpus is split to obtain at least two word groups, specifically, the plurality of reply sentences included in the reply corpus are split one by one to obtain at least two word groups included in each reply sentence.

[0082] The at least two word groups in each reply sentence are identified, augmented and spliced to generate a first reply template corresponding to the reply sentence, that is, the number of reply sentences in the reply corpus is the same as the number of first reply templates, and they are one-to-one corresponding.

[0083] Preferably, the at least two word groups can also be identified to delete word groups, wherein the delete word group can be understood as a word group to be deleted in the reply sentence, the unchanged word group can be understood as a word group to be kept unchanged in the reply sentence, and the augmented word group can be understood as a word group to be augmented in the reply sentence.

[0084] For example, if the augmented word group is set to "of", the word groups in the vocabulary are "but for you" and "you require", respectively, as described above, the obtained association result is "you require-of", wherein "-" is an association mark, and the augmented word group after the augmentation processing based on the association result is "you require of".

[0085] The association operation can be understood as traversing all word groups in the vocabulary and calculating the semantic similarity between the traversed word groups and the augmented word group, and finally associating the word group with the highest semantic similarity with the augmented word group through the association mark to generate the association result.

[0086] As described above, the functions of the small sample learning model include: corpus splitting function (such as splitting the reply corpus or reply sentence into several word groups), word group identification function (such as identifying unchanged word groups and augmented word groups in several word groups), word group augmentation function (such as augmenting the augmented word group based on the vocabulary), and word group splicing function (such as splicing the augmented word group after the augmentation processing and the unchanged word group to form a first reply template).

[0087] For example, if the reply corpus is "no restaurant found", wherein "no" (order 1) "found" (order 2) are unchanged word groups, and "restaurant" (order 3) is an augmented word group, the word group in the vocabulary that fits "restaurant" is "you require of", the first reply template formed based on the small sample learning model processing the reply corpus and based on the order is "no restaurant found you require of".

[0088] For example, the vocabulary can be constructed based on a manually designed manner.

[0089] Optionally, an initial model created according to a small sample learning algorithm is acquired;

[0090] The initial model is trained by preset training samples, the training samples including word groups to be augmented and word groups to be kept unchanged;

[0091] The trained initial model is determined as the small sample learning model.

[0092] The training samples include an original sample set and a supervised template set, the original sample set including a plurality of sample sentences, the supervised template set including a plurality of first templates, the number of sample sentences in the original sample set being consistent with and one-to-one corresponding to the number of first templates in the supervised sample set, the sample sentences including word groups to be augmented and word groups to be kept unchanged, and the first templates including augmented word groups and unchanged word groups (i.e., the word groups to be augmented in the sample sentences are determined as the augmented word groups by artificial recognition, and the word groups to be kept unchanged are determined as the unchanged word groups; then the augmented word groups are augmented based on human language habits, and the augmented word groups after the augmentation and the unchanged word groups are spliced to generate the first templates).

[0093] The process of training the initial model by the training samples is as follows:

[0094] In step S1, the original sample set is input into the initial model, a second template output by the initial model is obtained, and a difference degree between the first template and the second template is calculated.

[0095] In step S2, it is determined whether the difference degree is less than a preset difference threshold, if yes, the training is ended, and if no, the parameters of the initial model are adjusted based on the difference degree, and the process returns to step S1.

[0096] Preferably, the aforementioned vocabulary table can also be constructed based on the difference between the first template and the second template, i.e., the vocabulary table can be understood as a word group set obtained by removing the intersection word groups between the first template and the second template from the first template. For example, if the first template is "This is your best choice", and the second template is "This is your choice", the intersection word groups between the first template and the second template are "This", "you" and "choice", and at this time, the word group to be supplemented in the vocabulary table is "best".

[0097] Optionally, the splicing of the unchanged word groups and the augmented word groups after the augmentation to obtain the at least one first reply template includes:

[0098] The unchanged word groups and the augmented word groups after the augmentation are spliced to obtain an initial template set, the initial template set including at least one initial template;

[0099] perform clustering processing on the initial template set to obtain the at least one first reply template.

[0100] As described above, in the case of obtaining the initial template set, at least one initial template in the initial template set is summarized by using the clustering processing mode to reduce the number of initial templates in the initial template set.

[0101] For example, the clustering processing can be performed on at least one initial template in the initial template set by using a K-means algorithm to obtain a plurality of first template clusters and a centroid of each first template cluster, and the initial template most similar to the centroid in the first template cluster is determined as the first reply template. The K-means algorithm can be replaced by other algorithms with clustering function (such as K-means++ algorithm, hierarchical clustering algorithm, etc.), which is not limited in the embodiments of the present application.

[0102] Optionally, the clustering processing on the initial template set to obtain the at least one first reply template comprises:

[0103] cyclically judging whether the initial template set is empty, and in the case that the initial template set is not empty, obtaining a centroid template in the initial template set, and determining the centroid template as the first reply template, the centroid template being any one of the initial templates in the initial template set;

[0104] performing clustering processing on the initial template set according to the centroid template to obtain a cluster with the centroid template as the clustering center;

[0105] deleting the initial templates included in the cluster from the initial template set.

[0106] As described above, whether the initial template set is empty is judged, and in the case that the initial template set is not empty, the centroid template (any one of the initial templates) in the initial template set is obtained by random sampling, and the sampled centroid template is determined as the first reply template. Then, the clustering processing is performed on the initial template set with the centroid template as the centroid (i.e. the similarity values between the centroid template and other initial templates in the initial template set are calculated, and other initial templates with the similarity values higher than a threshold value and the centroid template are gathered into the same cluster). The cluster including the centroid template is obtained, and then all the initial templates included in the cluster are deleted from the initial template set, and the above-mentioned empty set judgment, random sampling and clustering process are continued until the initial template set is empty, and the cycle is ended to obtain the at least one first reply template. This can reduce the calculation complexity of the above-mentioned clustering process and improve the clustering efficiency.

[0107] The similarity degree calculation process can be:

[0108] calculating a formal similarity between the other initial templates and the centroid template;

[0109] calculating a semantic similarity between the other initial templates and the centroid template;

[0110] weighting the formal similarity and the semantic similarity to obtain the similarity value.

[0111] The formal similarity is used to represent the structural similarity trend between the other initial templates and the centroid template (such as the difference in the number of words), and the semantic similarity is used to represent the semantic similarity trend between the other initial templates and the centroid template. The weight of the foregoing weighting calculation can be artificially set or obtained through model fitting (that is, in the case of pre-setting the weight, the pre-set weight is adjusted and optimized through model training to obtain the final weight).

[0112] Optionally, after the target reply template is filled with the information to be replied to and the first reply sentence is generated, the method further comprises:

[0113] adjusting the first reply sentence according to a transfer learning model to generate a second reply sentence;

[0114] The first reply sentence is sent to the user end, comprising:

[0115] The second reply sentence is sent to the user end.

[0116] As described above, the first reply sentence is re-expressed by using the transfer learning model to generate a second reply sentence with complex human language habits, and the second reply sentence is sent to the user end to improve user satisfaction.

[0117] For example, the transfer learning model can be a T5 (Text-to-Text Transfer Transformer) model, and other types of transfer learning models can also be applied in actual applications, and the embodiments of the present application are not limited thereto.

[0118] Optionally, after the reply corpus is identified according to the small sample learning model to obtain at least one first reply template; before the at least one first reply template is searched according to the information to be replied to; the method further comprises:

[0119] filtering out the first reply template including the sensitive word from the at least one first reply template to obtain at least one second reply template;

[0120] The at least one first reply template is retrieved according to the to-be-replied information, and a first reply template with the highest matching degree with the to-be-replied information is determined as a target reply template in the at least one first reply template.

[0121] The at least one second reply template is retrieved according to the to-be-replied information, and a second reply template with the highest matching degree with the to-be-replied information is determined as a target reply template in the at least one second reply template.

[0122] As described above, the first reply template is screened by using the sensitive word filtering manner to obtain the second reply template with a more optimal reply effect, so as to avoid generating a dialogue reply with a meaning of discrimination, abuse, etc., and further improve user experience.

[0123] For example, the sensitive word filtering can be realized by manual supervision, or can be realized by setting a supervision function or a supervision model with a sensitive word filtering function, and the embodiments of the present application are not limited in this regard.

[0124] The various optional embodiments introduced in the embodiments of the present application can be combined with each other for implementation in the case of no conflict with each other, or can be implemented alone, and the embodiments of the present application are not limited in this regard.

[0125] For convenience of understanding, an example is illustrated as follows:

[0126] As shown in Figure 2 and Figure 3 , the server end in the man-machine dialogue system is mainly used for mining of dialogue reply corpus and template extraction to form a template library, then searching in the template library based on a dialogue action list to determine a candidate template adapted to the dialogue action list, and forming a first reply sentence according to the candidate template and the dialogue action list, then rewriting and fine-tuning the first reply sentence by a rewriting model to generate a second reply sentence conforming to human language habits, and finally rendering the second reply sentence on a user interface to realize dialogue reply for the user. Wherein, manual supervision is mainly used for filtering out templates including sensitive words in the template library, and the filtering can be completed before a template library entry action is executed, or can be completed before a template library searching action is executed, and the embodiments of the present application are not limited in this regard.

[0127] Further, for any given system reply turn (i.e. robot reply turn) in the dialogue, define A as the dialogue action set of the turn, and A is a dialogue action sequence with a length of N A , wherein each dialogue action A i is composed of a dialogue intent a i (e.g. “notification”), a task domain d i (e.g. “restaurant”), and a slot si (e.g. "price") and value v i (e.g. "100 yuan"). The dialogue response generation, i.e. the result of converting the dialogue action sequence A into the natural language response S, can be expressed as follows:

[0128]

[0129] wherein denotes the i-th word in the response sentence S.

[0130] The above formula is implemented as follows:

[0131]

[0132] wherein, is the candidate template set corresponding to the dialogue action A, used to fill A j to generate the dialogue response.

[0133] As can be seen from the above formula, the dialogue response task is decomposed into two tasks:

[0134] 1) response generation p(S|A, C);

[0135] 2) template learning p(C|A).

[0136] Among them, task 2) template learning aims to mine from unsupervised corpus to get high-quality template library, and is suitable for template mining in the premise of small sample learning. As Figure 4 shown, overall, template learning includes three parts: a preliminary template extraction method based on word group label text editing, template induction based on K- centroid unsupervised clustering, and online template retrieval. It should be noted that, Figure 4 the parameter T in the formula is used to represent the word group.

[0137] Specifically, for a native dialogue response corpus set the learning framework uses a transformer encoder to convert the dialogue responses R i in the set into initial templates P i , then the initial template set will be inducted into a final template library L.

[0138] When performing model inference, each dialogue intent a i of the dialogue action A i will obtain some candidate set by querying the template library L, then select a template C i as the final result. The above process can be formally expressed as:

[0139]

[0140] As Figure 5 shown, template extraction is taken as a text editing problem to ensure the controllability of template generation and its performance under small sample learning. Generally, text editing is regarded as a multi-classification problem at the word group level. Through the transformer encoder, each word group in the dialogue reply is judged to predict what operation will be performed on the word group. Three word group operations are defined: deleting a word group, keeping a word group unchanged (which can be understood as the aforementioned invariant word group), and adding a word group in front of the word group (which can be understood as the aforementioned augmented word group).

[0141] Based on the above operations, for all word groups i in the reply R Two classification tasks are designed:

[0142] (1) 0-1 classification to determine whether to save the current word group, that is, to determine T j i whether to keep it unchanged or to be deleted;

[0143] (2) a multi-classification facing the vocabulary to determine which word combination should be added in front of T .

[0144] In particular, if no word group needs to be added, the predicted result will be an empty combination. The vocabulary can be constructed by comparing the differences between the replies and the templates in the training set. The above two classification tasks are combined to form the final classification label space , that is, the Cartesian product of the labels of the above two classification tasks . In this way, the final classification task obtained has a label number of 2xN V , where N V is the length of the vocabulary.

[0145] To complete the above classification task, a 12-layer small transformer encoder is used as f e (·), and a fully connected layer f l (·) is spliced after it for classification. The above process can be described as a whole:

[0146]

[0147] wherein, is the word combination that should be added obtained by prediction.

[0148] Based on the cross-entropy loss, let c be the index of the class, be the probability that the word group will be predicted as c, and N be the maximum length of the sequence, Nc For the number of categories, the loss function can be written as:

[0149]

[0150] In order to map the preliminary template set P to the template library L, the template induction is defined as a K-centroid clustering problem. The main execution process is: first, according to the form similarity and semantic similarity of the templates, the initial template set P is clustered; then the representative templates are selected from each cluster, and the template library L is formed based on these templates. Considering that the whole process is in the range of and the number of elements in the template set N R may be in the range of 10 2 to 10 5 , therefore the above process is simplified as: each time a preliminary template P r is randomly selected from the template set P, and the initial template library is traversed according to the form similarity and semantic similarity to construct its neighborhood set P n , P r is added to L and {P r}∪P n is deleted, and so on until P is empty. As shown in Figure 6 , the generation of p(S|A,C) refers to converting the dialog action A and the candidate template into a dialog reply S based on the candidate template C. Generally speaking, a simple but relatively effective method is to manually design a rule engine. Considering that the method based on manual design of rules is difficult to cover all template generation spaces, and there is a problem that the generated reply is not smooth enough, a paraphrasing module is added on the basis of the rule-based template generation. The paraphrasing module is implemented based on T5 (Text-to-Text Transfer Transformer), which aims to re-express the rule-based sentence (which can be understood as the first reply sentence) to generate a reply (which can be understood as the second reply sentence) that truly conforms to the habits of human language.

[0151] The various optional embodiments introduced in the embodiments of the present application can be combined with each other to implement, or can be implemented alone, and the embodiments of the present application do not limit this.

[0152] Referring to Figure 7 , Figure 7 is a structural schematic diagram of a dialog reply device provided by the embodiments of the present application. As shown in Figure 7 , the dialog reply device 200 comprises:

[0153] The template construction module 201 is configured to identify the reply corpus according to a pre-trained small sample learning model to obtain at least one first reply template.

[0154] The retrieval module 202 is configured to determine, in the at least one first reply template, a first reply template with the highest matching degree with the information to be replied as a target reply template.

[0155] The sentence generation module 203 is configured to fill the information to be replied into the target reply template to generate a first reply sentence.

[0156] The reply module 204 is configured to issue the first reply sentence to a user end.

[0157] Optionally, the template construction module 201 comprises:

[0158] The splitting sub-module is configured to perform splitting processing on the reply corpus to obtain at least two word groups.

[0159] The identification sub-module is configured to identify, in the at least two word groups, an invariant word group and an augmented word group.

[0160] The augmentation sub-module is configured to perform augmentation processing on the augmented word group according to a preset vocabulary table.

[0161] The concatenation sub-module is configured to concatenate the invariant word group and the augmented word group after the augmentation processing to obtain the at least one first reply template.

[0162] Optionally, the concatenation sub-module comprises:

[0163] The concatenation unit is configured to concatenate the invariant word group and the augmented word group after the augmentation processing to obtain an initial template set, and the initial template set comprises at least one initial template.

[0164] The clustering unit is configured to perform clustering processing on the initial template set to obtain the at least one first reply template.

[0165] Optionally, the clustering unit comprises:

[0166] The clustering unit is configured to perform clustering processing on the initial template set to obtain the at least one first reply template.

[0167] The clustering unit is configured to perform clustering processing on the initial template set to obtain the at least one first reply template.

[0168] delete the initial template included in the class cluster in the initial template set.

[0169] Optionally, the dialogue reply device 200 further comprises a re-release module, and the re-release module is configured to:

[0170] adjust the first reply sentence according to the transfer learning model to generate a second reply sentence.

[0171] The reply module 204 is further configured to issue the second reply sentence to the user terminal.

[0172] Optionally, the dialogue reply device 200 further comprises a supervision module, and the supervision module is configured to:

[0173] filter the first reply template including the sensitive word in the at least one first reply template to obtain at least one second reply template;

[0174] The retrieval module 202 is further configured to retrieve the at least one second reply template according to the information to be replied, and determine the second reply template with the highest matching degree with the information to be replied as a target reply template in the at least one second reply template.

[0175] Optionally, the dialogue reply device 200 further comprises a training module, and the training module is configured to:

[0176] obtain an initial model created according to a small sample learning algorithm;

[0177] train the initial model through a preset training sample, and the training sample includes a word group to be augmented and a word group to be kept unchanged;

[0178] determine the trained initial model as the small sample learning model.

[0179] The dialogue reply device provided in the embodiments of the present application uses the way of identifying reply corpus by a small sample learning model to replace the way of artificially designing reply templates adopted in related technologies, so as to improve the efficiency of the reply template generation stage, reduce the generation cost of the reply template, and at the same time make the generation process of the reply template have scalability to adapt to the demand changes of the human-computer dialogue system in the process of business augmentation or business migration.

[0180] The dialogue reply device 200 can implement each process of the method embodiments in the embodiments of the present application and achieve the same beneficial effects. To avoid repetition, details are not repeated here. Figure 1

[0181] The embodiments of the present application further provide a communication device. Please refer to Figure 8 ​The communication device can include a processor 301, a memory 302, and a program 3021 stored in the memory 302 and executable on the processor 301.

[0182] The program 3021, when executed by the processor 301, can implement the Figure 1 Any step in the corresponding method embodiment and the same beneficial effects can be achieved, and details are not repeated here.

[0183] Those skilled in the art can understand that all or part of the steps of the method of the above embodiments can be completed by program instructions related to hardware, and the program can be stored in a readable medium.

[0184] The embodiments of the present application also provide a readable storage medium, the readable storage medium stores a computer program, and the computer program is executable by a processor to implement the above Figure 1 Any step in the corresponding method embodiment and the same technical effects can be achieved, to avoid repetition, which will not be repeated here.

[0185] The computer readable storage medium of the embodiments of the present application can adopt any combination of one or more computer readable media. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium may, for example, be but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples (non-exhaustive list) of the computer readable storage medium include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus.

[0186] The computer readable signal medium can include a data signal propagated in a baseband or as a part of a carrier wave, in which a computer readable program code is carried. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer readable signal medium can also be any computer readable medium other than the computer readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or apparatus.

[0187] Program code embodied on a storage medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0188] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0189] The preferred embodiments of the present application have been described above with the purpose of enabling not a limited number of embodiments of the present application to be made and utilized, but of providing the best modes contemplated of carrying out the application. As will be realized by those skilled in the art, the application is capable of modifications in various obvious aspects, all without departing from the application. The applications also include any other suggested modifications that are within the scope of the application. The applications also include the combinations of the embodiments described herein to the maximum extent allowed by the priority date of the present application.

Claims

1. A dialogue response method, characterized in that, The method includes: The response corpus is identified using a pre-trained few-shot learning model to obtain at least one first response template; Among the at least one first reply template, the first reply template that matches the information to be replied to the most is determined as the target reply template; Fill the information to be replied to into the target reply template to generate the first reply statement; Send the first response statement to the user's client; The step of identifying the response corpus based on a pre-trained few-shot learning model to obtain at least one first response template includes: The response corpus is split to obtain at least two character groups; Identify invariant and augmented character groups among the at least two character groups; The augmented character group is augmented according to a preset vocabulary list; The invariant character group and the augmented character group after augmentation are concatenated to obtain the at least one first response template.

2. The method according to claim 1, characterized in that, The step of concatenating the invariant character group and the augmented character group after augmentation to obtain the at least one first response template includes: The invariant character group and the augmented character group after augmentation are concatenated to obtain an initial template set, which includes at least one initial template. The initial template set is clustered to obtain at least one first response template.

3. The method according to claim 2, characterized in that, The step of clustering the initial template set to obtain the at least one first response template includes: The process iteratively checks whether the initial template set is empty. If the initial template set is not empty, the centroid template in the initial template set is obtained and the centroid template is determined as the first response template. The centroid template is any one of the initial templates in the initial template set. Clustering is performed on the initial template set based on the centroid template to obtain clusters with the centroid template as the cluster center; Remove the initial templates included in the cluster from the initial template set.

4. The method according to claim 1, characterized in that, After filling the information to be replied to into the target reply template and generating the first reply statement, the method further includes: The first response statement is adjusted based on the transfer learning model to generate the second response statement; Sending the first reply statement to the user terminal includes: The second response statement is sent to the user's client.

5. The method according to claim 1, characterized in that, After identifying the response corpus using a few-shot learning model and obtaining at least one first response template; Before retrieving the at least one first reply template based on the information to be replied to; the method further includes: Filter out first response templates containing sensitive words from the at least one first response template to obtain at least one second response template; The step of retrieving at least one first reply template based on the information to be replied to, and determining the first reply template with the highest degree of matching with the information to be replied to as the target reply template, includes: Retrieve at least one second reply template based on the information to be replied to, and determine the second reply template with the highest degree of matching with the information to be replied to as the target reply template.

6. The method according to claim 1, characterized in that, Before identifying the response corpus based on the pre-trained few-shot learning model, the method further includes: Obtain the initial model created using the few-shot learning algorithm; The initial model is trained using preset training samples, which include word groups to be augmented and word groups to be kept unchanged. The trained initial model is determined as the few-shot learning model.

7. A dialogue response device, characterized in that, include: The template building module is used to identify the response corpus based on a pre-trained few-shot learning model and obtain at least one first response template. The retrieval module is used to determine the first reply template with the highest degree of matching with the information to be replied to from the at least one first reply template as the target reply template; The statement generation module is used to fill the information to be replied into the target reply template and generate the first reply statement; The reply module is used to send the first reply statement to the user terminal; The template construction module includes: The splitting submodule is used to split the response corpus to obtain at least two character groups; A recognition submodule is used to identify invariant character groups and augmented character groups in the at least two character groups; The augmentation submodule performs augmentation processing on the augmented character groups according to a preset vocabulary list; The splicing submodule is used to splice the invariant character group and the augmented character group after augmentation to obtain the at least one first reply template.

8. A communication device, comprising: A transceiver, a memory, a processor, and a program stored in the memory and executable on the processor; characterized in that the processor is configured to read the program in the memory to implement the steps of the dialogue response method as described in any one of claims 1 to 6.

9. A readable storage medium for storing a program, characterized in that, When the program is executed by the processor, it implements the steps in the dialogue response method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Question and answer method, device and equipment and storage medium

    CN109815321A

  • Man-machine question and answer method, device and equipment based on semantic parsing and storage medium

    CN109885810A