Knowledge-centered reply screening method and system in open domain dialogue field
By adopting the knowledge-centered reply screening method in the open domain dialogue field in the dialogue system, using the three-stage training of the BERT model and the pseudo-data algorithm, the problems of low accuracy of knowledge screening and inconsistent results are solved, and knowledge screening and reply are realized Efficient correlation and accuracy of screening.
Patent Information
- Application Number
- CN202410564432.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-09
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2044-05-09
AI Technical Summary
The existing unstructured knowledge-enhanced dialogue system has low accuracy in knowledge screening and inconsistent knowledge screening results with responses, resulting in cascading errors and redundant knowledge being unable to be effectively removed.
Using a knowledge-centered reply screening method in the open domain dialogue field, the three-stage training of the pseudo-data algorithm and BERT model is constructed to establish the correlation mapping relationship between the knowledge entry and the above-mentioned dialogue and the reply, and jointly model knowledge Screening and reply screening improve the accuracy of knowledge screening and the consistency of results.
The accuracy of knowledge screening is improved by more than 5%, and the consistency between knowledge screening and response screening results is improved by more than 6%, solving the problems of low accuracy of knowledge screening and inconsistent results in existing methods.
Smart Images

Figure CN119322824A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of human-computer dialogue in natural language processing, and in particular relates to a knowledge-centered reply screening method and system in an open domain dialogue field. Background Art
[0002] Dialogue system is an important research branch in natural language processing, and its purpose is to make computers produce meaningful responses in the process of communication with humans. In current dialogue system research, external knowledge is usually used to improve the quality of responses (Emily Dinan, Stephen Roller, Kurt Shuster, Angela Fan, Michael Auli, and Jason Weston. Wizard of wikipedia: Knowledge-powered conversational agents. In 7th International Conference on Learning Representations, ICLR, 2019. and Marjan Ghazvininejad, Chris Brockett, Ming-Wei Chang, Bill Dolan, Jianfeng Gao, Wen-tau Yih, and Michel Galley. A knowledge-grounded neural conversation model. AAAI, 2018.). Knowledge is defined as the results and experience of human exploration of the objective world, which is reusable information, such as legal provisions, dictionaries, Wikipedia, Baidu Encyclopedia, news reports, historical documents, literary works, etc. External knowledge is information that can be used outside the context of the conversation. The dialogue system can use this external information to construct more informative replies and enhance the logic and interestingness of the conversation (Emily Dinan, Stephen Roller, Kurt Shuster, Angela Fan, Michael Auli, and Jason Weston. Wizard of wikipedia: Knowledge-powered conversational agents. In 7th International Conference on Learning Representations, ICLR, 2019.). External knowledge can be divided into unstructured knowledge (unprocessed raw text, such as text on a web page) and structured knowledge (processing unstructured text into knowledge items with a fixed structure, such as a knowledge graph in the form of triples). Compared with structured knowledge that requires special processing to obtain, unstructured knowledge is easier to obtain, more timely, and has a larger amount of data.An example of a Chinese unstructured knowledge-enhanced conversation (Pengjie Ren, Zhongkun Liu, Xiaomeng Song, Hongtao Tian, Zhumin Chen, Zhaochun Ren, and Maartende Rijke. Wizard of Search Engine: Access to Information Through Conversations with Search Engines. In SIGIR 2021.) is shown in Table 1:
[0003] Table 1: Examples of conversations augmented with unstructured knowledge
[0004]
[0005]
[0006] In the example in Table 1, the reply uses the external knowledge in item 3) to construct a reply that meets the requirements of the conversation context. In practical applications, the amount of external knowledge can be determined according to the computing power of the system and is not fixed. The dialogue system enhanced by unstructured knowledge first needs to solve the problem of knowledge screening, that is, to use the conversation context to select the most suitable knowledge items for constructing replies from a large amount of external knowledge (Emily Dinan, Stephen Roller, Kurt Shuster, Angela Fan, Michael Auli, and Jason Weston. Wizard of wikipedia: Knowledge-powered conversational agents. In 7th International Conference on Learning Representations, ICLR, 2019.). After screening the applicable knowledge items, the dialogue system uses the conversation context and the retrieved knowledge items to construct a reply (the reply can be generated directly by the dialogue system or screened from a large number of candidates). For the retrieval system in the dialogue system based on unstructured knowledge enhancement (Longxuan Ma, Mingda Li, Wei-Nan Zhang, et al. Unstructured Text Enhanced Open-Domain Dialogue System: A Systematic Survey [J]. ACM Transactions on Information Systems (TOIS), 2021.), that is, a system that selects the best response from multiple candidate responses given the context of the dialogue. After solving the problem of knowledge screening, this type of system needs to further solve the problem of response screening, that is, use the context of the dialogue and the retrieved external knowledge to select the most appropriate response from a large number of candidate responses. The two current modes of retrieval dialogue systems enhanced by unstructured knowledge are as follows:
[0007] 1) If Figure 1 The conversation-centric retrieval model shown
[0008] This model first uses the conversation context to filter useful external knowledge from external knowledge sources, and then uses the conversation context and the filtered external knowledge to filter replies (Emily Dinan, Stephen Roller, Kurt Shuster, Angela Fan, Michael Auli, and Jason Weston. Wizard of wikipedia: Knowledge-powered conversational agents. In 7th International Conference on Learning Representations, ICLR, 2019. and Chongyang Tao, Changyu Chen, Jiazhan Feng, Ji-Rong Wen, and Rui Yan. A pre-training strategy for zero-resource response selection in knowledge-grounded conversations. ACL / IJCNLP2021.). On the one hand, this method separates the two tasks of knowledge filtering and reply filtering, ignoring the connection between the two subtasks; on the other hand, the output of knowledge filtering is used as the input of reply filtering, which is prone to cascading errors and thus reduces the accuracy of the entire system.
[0009] 2) If Figure 2 The response-centric retrieval model shown
[0010] This model treats external knowledge as a whole, calculates two types of scores (the relevance score of the candidate response to the previous conversation, and the relevance score of the candidate response to the external knowledge), and combines the two types of scores to obtain the final score of the candidate response (Jia-Chen Gu, Zhen-Hua Ling, Xiaodan Zhu, and Quan Liu. Dually interactive matching network for personalized response selection in retrieval-based chatbots. EMNLP-IJCNLP, 2019.). This method does not perform knowledge screening, so it cannot provide the accuracy of knowledge screening. In scenarios where the external knowledge contains a large number of items, it cannot remove redundant knowledge.
[0011] In summary, existing unstructured knowledge augmentation methods model knowledge screening and response screening separately, which breaks the connection between the two and is prone to cascading errors, leading to two problems: 1) low accuracy of knowledge screening; 2) the results of knowledge screening are inconsistent with the screened responses, that is, the responses do not use the retrieved knowledge. Summary of the invention
[0012] The present invention provides a knowledge-centric reply screening method and system in the field of open domain dialogue, which are used to solve the problems of low knowledge screening accuracy and inconsistency between knowledge screening results and screened replies in existing unstructured knowledge enhancement methods.
[0013] The present invention is achieved through the following technical solutions:
[0014] A knowledge-centric reply screening method in an open domain dialogue field, the reply screening method comprising the following steps:
[0015] Step 1: Use the existing conversation data and encyclopedia knowledge data to build the required training data and construct the pseudo data algorithm;
[0016] Step 2: Use the training set constructed in step 1 to perform three-stage training on the BERT model;
[0017] Step 3: During the test, use the sum of the scores of the three stages in Step 2 as the final score.
[0018] Furthermore, the step 1 constructs the required training data specifically as follows:
[0019] According to the dialogue data in the data set ζ, the mapping relationships G1(Q, K), G2(K, R) and G3(K, H, Q, R) are established as follows:
[0020] Dataset {D i , C i , R i ,y i} is the i-th conversation data in the dataset ζ, N represents the total number of conversation data in the dataset ζ, where D i represents the document in the i-th conversation data, Represents the first knowledge entry in the document. Represents the second knowledge entry in the document. Indicates the dth i Knowledge items, d i Representative D i The number of knowledge items in C i Represents the conversation context excluding the reply in the i-th conversation data, Represents C i In the first round of dialogue, Represents C i In the second round of dialogue, Represents C i c i Round dialogue, c i Represents C i The number of rounds in the dialogue, R i For C i Reply, y i =1 represents R i C i The correct answer is y i =0 represents R i Not C i The correct response;
[0021] The dialogue above C i The last round of dialogue Defined as the query Q of the i-th conversation data i , the dialogue above C i The other rounds except the last round of dialogue are defined as the dialogue history of the i-th dialogue data According to the data set ζ, mapping relationships G1(Q, K), G2(K, R) and G3(K, H, Q, R) are established;
[0022] Among them, Q is the query, K is the knowledge item, H is the conversation history, and R is the reply.
[0023] Furthermore, the step 1 also includes constructing a training set according to the established mapping relationship, specifically,
[0024] Step 1.1, the mapping relationship G1(Q, K) represents the relevance between the knowledge item and the query, (Q, K) is used as the input of the training set, and the relevance score G1(Q, K) is used as the corresponding output;
[0025] Step 1.2, the mapping relationship G2(K, R) represents the relevance between the knowledge item and the reply, (K, R) is used as the input of the training set, and the relevance score G2(K, R) is used as the corresponding output;
[0026] Step 1.3, the mapping relationship G3(K, H, Q, R) represents the relevance of knowledge items, conversation history, queries and replies. (K, H, Q, R) is used as the input of the training set, and the relevance score G3(K, H, Q, R) is used as the corresponding output.
[0027] Furthermore, the pseudo data construction algorithm in step 1 is specifically as follows:
[0028] Input: Reddit data DR ,Wikipedia data D w , threshold γ;
[0029] Output: pseudo DGD data Dp;
[0030] 1: Initialize Dp to an empty set;
[0031] 2: For D R For each set of conversations in the data, perform the operations in 3-6.
[0032] 3: Use BM25 algorithm to calculate the reply and Wikipedia data D w The similarity of each knowledge item in ;
[0033] 4: If the similarity score is greater than the threshold γ;
[0034] 5: Then group the found knowledge items with C and R and put them into Dp;
[0035] 6: After traversing D R After the data in is obtained, the pseudo data Dp is obtained.
[0036] Furthermore, the step 2 is specifically to define segment embedding codes for the document D, the conversation data C, and the reply R, respectively, and to denote the last hidden state representation of the special identifier [CLS] at the beginning of the input sequence as E cls , E cls After two nonlinear layers, the output correlation score G(input) is:
[0037] G(input)=σ(W2μ(W1E cls +b1)+b2)
[0038] Among them, W1, W2, b1, b2 are trainable parameters, σ represents the sigmoid activation function, and μ represents the tank activation function. In the three relevance tasks, the same BERT model is used for training, and the relevance scores are calculated using the above formula.
[0039] Furthermore, the loss function L used in step 2 is final for:
[0040] L final =L1+L2+L3
[0041] in:
[0042]
[0043] In the formula, e is the base of the natural logarithm, N1 represents the number of positive examples corresponding to the mapping relationship G1(Q, K), represents the relevance score of the i-th positive example, represents the relevance score of the i-th negative example, and α1 represents the relevance score of each positive example The corresponding number of negative examples, represents the relevance score of the jth negative example, j = 1, 2, ..., α1;
[0044]
[0045] In the formula, N2 represents the number of positive examples corresponding to the mapping relationship G2(K, R), represents the relevance score of the i-th positive example, represents the relevance score of the i-th negative example, and α2 represents the relevance score of each positive example The corresponding number of negative examples, represents the relevance score of the jth negative example, j = 1, 2, ..., α2;
[0046]
[0047] Where N3 represents the number of positive examples corresponding to the mapping relationship G3(K, H, Q, R), represents the relevance score of the i-th positive example, and α3 represents the relevance score of each positive example The corresponding number of negative examples, represents the relevance score of the jth negative example, j = 1, 2, ..., α3: λ represents the different scores assigned to each negative example.
[0048] Furthermore, the step 3 is specifically to screen the knowledge items before constructing the inputs corresponding to the three mapping relationships in step 1, and screen out the knowledge items ranked in the top m positions;
[0049] When the number of knowledge items is large, the knowledge items are combined, that is, when screening knowledge, first screen the knowledge ranked in the topm, and then calculate the three scores; the m value is selected within the allowable error range and varies according to different tasks; the m value remains consistent during training and testing.
[0050] A knowledge-centric reply screening system in the field of open domain dialogue, the reply screening system uses the reply screening method as claimed in claim 1, the reply screening system comprises:
[0051] The construction module uses the existing conversation data and encyclopedia knowledge data to build the required training data and construct the pseudo data algorithm;
[0052] The training module uses the training set constructed by the construction module to perform three-stage training on the BERT model;
[0053] The test module, during testing, uses the sum of the three-stage scores generated by the training module as the final score.
[0054] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the above method is implemented.
[0055] A computer-readable storage medium stores a computer program, and the computer program implements the above method when executed by a processor.
[0056] The beneficial effects of the present invention are:
[0057] The present invention uses knowledge items as a bridge to jointly model the two tasks of knowledge screening and reply screening. The knowledge items need to have a high correlation with both the previous context of the conversation and the candidate replies, which improves the accuracy of knowledge screening. Reply screening and knowledge screening are performed simultaneously, which enhances the correlation between the two tasks and improves the consistency between the knowledge screening results and the reply screening results.
[0058] Using models of the same size on three public standard evaluation data sets, compared with existing methods, the method of the present invention can improve the accuracy of knowledge screening by more than 5% and the consistency of knowledge screening and response screening results by more than 6%. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a schematic diagram of the existing dialogue-centric retrieval model;
[0060] Figure 2 It is a schematic diagram of the existing reply-centric retrieval model;
[0061] Figure 3 It is a schematic diagram of the knowledge-centered retrieval mode of the present invention;
[0062] Figure 4 It is a schematic diagram of the dynamic multi-element matching method of the present invention. DETAILED DESCRIPTION
[0063] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0064] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0065] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, the singular forms "a", "an" and "the" are intended to include plural forms unless the context clearly indicates otherwise.
[0066] The following is a clear and complete description of the technical solutions in the embodiments of the present application in conjunction with the drawings of the present application specification. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0067] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present application. Therefore, the present application is not limited to the specific embodiments disclosed below.
[0068] Embodiment 1
[0069] This embodiment provides a knowledge-centric reply screening method in an open domain dialogue field, characterized in that the reply screening method comprises the following steps:
[0070] Step 1: Use the existing conversation data and encyclopedia knowledge data to build the required training data and construct the pseudo data algorithm. The specific algorithm is shown in Table 2.
[0071] Step 2: Use the training set constructed in step 1 to perform three-stage training on the BERT model. See the attached training diagram. Figure 4 ;
[0072] Step 3: During the test, use the sum of the scores of the three stages in Step 2 as the final score.
[0073] Furthermore, the step 1 of constructing the required training data specifically includes establishing mapping relationships G1(Q, K), G2(K, R) and G3(K, H, Q, R) according to the dialogue data in the data set ζ, and then constructing the training set according to the established mapping relationships;
[0074] The mapping relationships G1(Q, K), G2(K, R) and G3(K, H, Q, R) established according to the dialogue data in the data set ζ are specifically:
[0075] Dataset {D i , C i , R i ,y i} is the i-th conversation data in the dataset ζ, N represents the total number of conversation data in the dataset ζ, where D i represents the document in the i-th conversation data, Represents the first knowledge entry in the document. Represents the second knowledge entry in the document. Indicates the dth i Knowledge items, d i Representative D i The number of knowledge items in C i Represents the conversation context excluding the reply in the i-th conversation data, Represents C i In the first round of dialogue, Represents C i In the second round of dialogue, Represents C i c i Round dialogue, c i Represents C i The number of rounds in the dialogue, R i For C i Reply, y i =1 represents R i C i The correct answer is y i =0 represents R i Not C i The correct response;
[0076] The dialogue above C i The last round of dialogue Defined as the query Q of the i-th conversation data i , the dialogue above C i The other rounds except the last round of dialogue are defined as the dialogue history of the i-th dialogue data According to the data set ζ, mapping relationships G1(Q, K), G2(K, R) and G3(K, H, Q, R) are established;
[0077] Among them, Q is the query, K is the knowledge item, H is the conversation history, and R is the reply.
[0078] Furthermore, the step 1 also includes constructing a training set according to the established mapping relationship, specifically,
[0079] Step 1.1, the mapping relationship G1(Q, K) represents the relevance between the knowledge item and the query, (Q, K) is used as the input of the training set, and the relevance score G1(Q, K) is used as the corresponding output;
[0080] Step 1.2, the mapping relationship G2(K, R) represents the relevance between the knowledge item and the reply, (K, R) is used as the input of the training set, and the relevance score G2(K, R) is used as the corresponding output;
[0081] Step 1.3, the mapping relationship G3(K, H, Q, R) represents the relevance of knowledge items, conversation history, queries and replies. (K, H, Q, R) is used as the input of the training set, and the relevance score G3(K, H, Q, R) is used as the corresponding output.
[0082] Furthermore, in order to solve the problem that manually labeled data is limited and expensive in actual application scenarios, a pseudo data labeling method is designed. Two easily available data resources are used to construct pseudo data, and pseudo data is used to perform knowledge-centered reply retrieval training, thereby verifying the effect of the present invention in actual application scenarios when there is a lack of labeled data. The specific implementation plan is as follows:
[0083] Take the construction of pseudo data in English as an example. First, a large amount of unlabeled conversation data is selected, such as multi-round conversation data on the English forum (Reddit), and the last sentence of the multi-round conversation is used as the reply, and the conversation before the reply is used as the conversation context. Based on the automatic evaluation index BM25, external knowledge is added to each reply, and knowledge items of appropriate length are selected from the English Wikipedia document, and the knowledge items are aligned with the reply. For different practical tasks, knowledge items of different lengths and different thresholds for the BM25 algorithm can be set. In this way, a triple such as the conversation context, external knowledge and reply (C, K, R) is obtained, so that the dynamic multi-element matching method of the present invention can be used to train the model.
[0084] The specific algorithm for constructing pseudo data in step 1 is:
[0085] Input: Reddit data D R ,Wikipedia data D w , threshold γ;
[0086] Output: pseudo DGD data Dp;
[0087] 1: Initialize Dp to an empty set;
[0088] 2: For D RFor each set of conversation context C and response R in the data, perform the following operations (3-6);
[0089] 3: Use BM25 algorithm to calculate the reply and Wikipedia data D w The similarity of each knowledge item in ;
[0090] 4: If the similarity score is greater than the threshold γ;
[0091] 5: Then group the found knowledge items with C and R and put them into Dp;
[0092] 6: After traversing D R After the data in is obtained, the pseudo data Dp is obtained.
[0093] Similarly, for Chinese data, conversation data without knowledge labels can be obtained from Chinese forums, and knowledge entries can be obtained from Chinese encyclopedia documents to obtain pseudo-label data (C, K, R) in Chinese. A large number of experiments have been carried out on public evaluation sets using the method of the present invention, and it has been proven that the method is more effective than existing methods in zero-resource / low-resource / full-data scenarios. Zero resources are defined as not using real labeled training data for training, but only using pseudo-label data for training; low resources are defined as using only a small amount of real labeled data for training; full data is defined as using all available labeled data for training. After the training is completed, the above three cases are tested on the real test set.
[0094] When constructing pseudo data, the selected dialogue data can be replaced by other publicly released dialogue corpus, and the selected external knowledge can be replaced by other knowledge bases containing unstructured knowledge items. The automatic evaluation index (BM25) used to connect the response with external knowledge can be replaced by other automatic evaluation indicators or models that can calculate the similarity of two text sequences.
[0095] Furthermore, the step 2 is specifically to define segment embedding codes for the document D, the conversation data C, and the reply R, respectively, and to denote the last hidden state representation of the special identifier [CLS] at the beginning of the input sequence as E cls , E cls After two nonlinear layers, the output correlation score G(input) is:
[0096] G(input)=σ(W2μ(W1E cls +b1)+b2)
[0097] Among them, W1, W2, b1, b2 are trainable parameters, σ represents the sigmoid activation function, and μ represents the tanh activation function; this implementation adopts BERT with 110M parameters baseIn this version, the input of BERT contains three different vector representations: word vector, position vector and segment vector. Different from the traditional BERT, three different segment embedding codes are defined for D, C, and R to distinguish them as different parts. In the three relevance tasks, the same BERT model is used for training, and the relevance scores are calculated using the above formula.
[0098] In the present invention, BERT is used as the basic model for correlation modeling. Other alternative basic models include RoBERTa (Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. RoBERTa: A Robustly Optimized BERT Pretraining Approach. CoRR abs / 1907.11692 (2019).), ELECTRA (Clark, K.; Luong, M.; Le, QV; and Manning, CDELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators. In ICLR 2020.) and other language models based on mask rule training. This type of model is divided into different scales, such as BERT base The version has about 110M parameters, BERT large The version has about 340M parameters, which can all be trained by the method designed in the present invention to obtain a model with the same reply retrieval function.
[0099] Furthermore, the loss function L used in step 2 is final for:
[0100] L final =L1+L2+L3
[0101] in:
[0102]
[0103] In the formula, e is the base of the natural logarithm, N1 represents the number of positive examples corresponding to the mapping relationship G1(Q, K), represents the relevance score of the i-th positive example, represents the relevance score of the i-th negative example, and α1 represents the relevance score of each positive example The corresponding number of negative examples, represents the relevance score of the jth negative example, j = 1, 2, ..., α1;
[0104]
[0105] In the formula, N2 represents the number of positive examples corresponding to the mapping relationship G2(K, R), represents the relevance score of the i-th positive example, represents the relevance score of the i-th negative example, and α2 represents the relevance score of each positive example The corresponding number of negative examples, represents the relevance score of the jth negative example, j = 1, 2, ..., α2;
[0106]
[0107] Where N3 represents the number of positive examples corresponding to the mapping relationship G3(K, H, Q, R), represents the relevance score of the i-th positive example, and α3 represents the relevance score of each positive example The corresponding number of negative examples, represents the relevance score of the jth negative example, j = 1, 2, ..., α3: λ represents the different scores assigned to each negative example, and the values of different negative examples are as follows Figure 4 As shown in:
[0108] By jointly training the three subtasks, the model can effectively model the relationship between external knowledge and the conversation context and responses: Figure 4 All negative examples in are randomly determined and dynamically constructed during the training process: therefore, the method of the present invention is called a dynamic multi-element matching method.
[0109] Furthermore, the step 3 is specifically to screen the knowledge items before constructing the inputs corresponding to the three mapping relationships in step 1, and screen out the knowledge items ranked in the top m positions;
[0110] When the number of knowledge items is large, the knowledge items are combined, that is, when screening knowledge, first screen the knowledge ranked in the topm, and then calculate the three scores; the m value is selected within the allowable error range and varies according to different tasks; the m value remains consistent during training and testing.
[0111] Specifically, the present invention proposes a dynamic multi-element matching method to train a knowledge-centric reply retrieval model, which uses a unified framework to simultaneously model the connections between the three combinations of conversation context-knowledge, knowledge-reply, and conversation context-knowledge-reply, so that the framework has the ability to perform knowledge screening and reply screening with knowledge as the center. The model learns a mapping relationship G (C, D, R), and for a new example (D, C, R) that does not appear in the data set, the mapping relationship G can predict whether R is the correct reply to C.
[0112] Embodiment 2
[0113] This embodiment uses the method of the first embodiment, which is a further limitation of the first embodiment.
[0114] In step 1, the positive example (Q + , K) has a relevance score of 1, Q + represents the queries that match K;
[0115] Negative example (Q - , K) has a correlation score of 0, Q - represents queries that do not match K.
[0116] Q - Randomly sampled from other dialogue examples in the dataset ζ.
[0117] In step 2, the positive example (K, R + ) has a relevance score of 1, R + is the corresponding original reply R in the conversation data, that is, R + is the response that matches K;
[0118] Negative examples (K, R - ) has a correlation score of 0, R - is a response that does not match K.
[0119] R - Randomly sampled from other conversation data in the dataset ζ.
[0120] In step 3, the original conversation data (K, H) that matches each other as positive examples + , Q + , R + ) has a correlation score of 1, H + Represents the matching of conversation history with knowledge items, queries, and responses;
[0121] Negative examples (K, H - , Q + , R + ) has a correlation score of 0.9, H -Represents conversation history that does not match a knowledge item, query, or response;
[0122] Negative examples (K, H + , Q - , R + ) has a correlation score of 0.1, Q - Represents queries that do not match conversation history, knowledge items, or responses;
[0123] Negative examples (K, H - , Q - , R + ) has a relevance score of 0;
[0124] Negative examples (K, H + , Q + , R - ) has a relevance score of 0, indicating a response that does not match the conversation history, knowledge item, or query;
[0125] Negative example (masked, H + , Q + , R + ) has a correlation score of 0.5, and masked represents the use of special symbols <mask>Replace every word in the knowledge item;
[0126] Negative example (masked, H + , Q + , R - ) has a relevance score of 0.
[0127] When inputting BERT, each word in the external knowledge entry is represented by a special symbol. <mask>Instead, the model is trained to learn the importance of external knowledge for correlation matching.
[0128] Embodiment 3
[0129] This embodiment uses the method described in Embodiments 1 and 2, specifically,
[0130] The present invention can be directly applied to a chat robot system in an open domain and is a core module of a chat robot. The central control module of the chat robot system transmits the conversation context to the module where the present invention is located. The module where the present invention is located uses the conversation context to select the most appropriate entry from a large number of knowledge entries retrieved from a local server or network, and uses the retrieval results to select the most appropriate reply from a large number of candidate replies, and transmits the reply to the central control module to complete an open domain conversation.
[0131] In terms of deployment methods, this technology can be independently used as a computing node and deployed on cloud computing platforms such as Alibaba Cloud or Meituan Cloud. Communication with other modules can be carried out by binding IP addresses and port numbers.
[0132] The specific implementation of this technology uses the deep learning open source framework Pytorch. If necessary, you can switch to other frameworks, such as the equally open source tensorflow or PadlePadle.
[0133] Experimental Section
[0134] As for the test data, the data shown in Table 3 was used. Among them, LIGHT (Jack Urbanek, Angela Fan, Siddharth Karamcheti, Saachi Jain, Samuel Humeau, Emily Dinan, Tim Douwe Kiela, Arthur Szlam, and Jason Weston. 2019. Learning to Speak and Act in a Fantasy Text Adventure Game. EMNLP-IJCNLP 2019.) and CMU_DoG (Kangyan Zhou, Shrimai Prabhumoye, and Alan W. Black. A Dataset for Document Grounded Conversations. EMNLP 2018.) use external knowledge consisting of multiple sentences, without knowledge labels, and manually annotate some test data on LIGHT; WoW (Emily Dinan, Stephen Roller, Kurt Shuster, Angela Fan, Michael Auli, and Jason Weston. Wizard of wikipedia: Knowledge-powered conversational agents. In 7th International Conference on Learning Representations, ICLR, 2019.) and WISE (Pengjie Ren, Zhongkun Liu, Xiaomeng Song, Hongtao Tian, Zhumin Chen, Zhaochun Ren, and Maarten de Rijke. Wizard of SearchEngine: Access to Information Through Conversations with Search Engines. InSIGIR 2021.) External knowledge is knowledge items with knowledge tags. Except for WISE which is in Chinese, the rest of the data are in English.
[0135] Table 3: Statistics of the test dataset
[0136]
[0137]
[0138] On the above public datasets, using a model of the same scale (BERT-base), the accuracy of knowledge screening is compared with existing methods. The experimental results on the LIGHT, WoW, and WISE datasets (the average number of candidate knowledge items on the three datasets is 15, 61, and 245, respectively) are shown in Table 4:
[0139] Table 4: Knowledge screening effect on the test set
[0140]
[0141] Zero-resource, low-resource, and full-data use 0%, 10%, and 100% of the data in the row of the dataset for training respectively. The WoW and WISE datasets have training data annotated with knowledge labels. Since the training data of LIGHT has no knowledge labels, the zero-resource test experiment is only performed on the annotated test set.
[0142] On the above public datasets, using a model of the same scale (BERT-base), the reply screening accuracy is compared with existing methods. The experimental results on the LIGHT, CMU_DoG, WoW, and WISE datasets are shown in Table 5 (the candidate replies on the four datasets are 20, 100, 20, and 20 respectively):
[0143] Table 5: Effect of reply screening on the test set
[0144]
[0145]
[0146] In order to verify whether the present invention can better solve the problem of inconsistency between the selected knowledge and the responses, the proportion of correct knowledge and correct responses selected in the WoW test set is compared, as shown in Table 6:
[0147] Table 6: The percentage of correct knowledge and correct responses selected simultaneously on the WoW test set
[0148]
[0149] The experimental results in Table 4, Table 5 and Table 6 prove that, in a fair comparison, the accuracy of knowledge screening and reply screening of the method proposed in the present invention is significantly improved over the existing methods under the three conditions of zero resources, low resources and full data. In terms of knowledge screening, the average improvement is 5 percentage points; in terms of reply screening, the average improvement is 4 percentage points; in terms of consistency between reply and knowledge screening results, the average improvement is 6 percentage points. This proves the versatility of the method of the present invention and its transferability between different fields.
[0150] Embodiment 4
[0151] This embodiment uses the above method of embodiment 1 to provide a knowledge-centric reply screening system in the open domain dialogue field, and the reply screening system includes a construction module, a training module and a testing module;
[0152] The construction module uses the existing conversation data and encyclopedia knowledge data to construct the required training data and construct the pseudo data algorithm. The specific algorithm is shown in Table 2;
[0153] The training module uses the training set constructed by the construction module to perform three-stage training on the BERT model. The training diagram is attached. Figure 4 ;
[0154] The test module, during testing, uses the sum of the three-stage scores generated by the training module as the final score.
[0155] The construction module is constructed using the method in Example 1;
[0156] The training module is trained using the method in Example 1;
[0157] The test module is tested using the method in Example 1.
[0158] Embodiment 5
[0159] An embodiment of the present invention provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the memory is used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory and the processor are connected via a bus. Specifically, the processor implements any step in the first embodiment above by running the computer program stored in the memory.
[0160] It should be understood that in the embodiments of the present invention, the processor referred to may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0161] The memory may include a read-only memory, a flash memory, and a random access memory, and provides instructions and data to the processor. A part or all of the memory may also include a nonvolatile random access memory.
[0162] As can be seen from the above, the electronic device provided by the embodiment of the present invention can implement the reply screening method as described in Example 1 by running a computer program. The model uses a unified framework to simultaneously model the connection between the three combinations of conversation context-knowledge, knowledge-reply, and conversation context-knowledge-reply, so that the framework has the ability to perform knowledge screening and reply screening with knowledge as the center. The model learns a mapping relationship G (C, D, R). For a new example (D, C, R) that does not appear in the data set, the mapping relationship G can predict whether R is the correct reply to C.
[0163] It should be understood that if the above-mentioned integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The above-mentioned computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the above-mentioned computer program includes computer program code, and the above-mentioned computer program code can be in source code form, object code form, executable file or some intermediate form. The above-mentioned computer-readable medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the above-mentioned computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.
[0164] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0165] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0166] It should be noted that the methods and detailed examples provided in the above embodiments can be combined with the devices and equipment provided in the embodiments, and references can be made to each other, and no further details will be given.
[0167] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0168] In the embodiments provided by the present invention, it should be understood that the disclosed apparatus / terminal equipment and method can be implemented in other ways. For example, the apparatus / equipment embodiments described above are only illustrative, for example, the division of the above modules or units is only a logical function division, and in actual implementation, other division methods can be used, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0169] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.< / mask> < / mask>
Claims
1. A knowledge-centric reply screening method in an open-domain dialogue domain, characterized in that: The reply screening method comprises the following steps: Step 1: Use existing conversation data and encyclopedia knowledge data to build the required training data and construct a pseudo data algorithm; Step 2: Use the training set constructed in step 1 to perform three-stage training on the BERT model; Step 3: During the test, use the sum of the scores of the three stages in Step 2 as the final score.
2. The reply screening method according to claim 1, characterized in that: The step 1 of constructing the required training data is specifically to establish mapping relationships G1(Q, K), G2(K, R) and G3(K, H, Q, R) according to the dialogue data in the data set ζ, specifically, Dataset {D i , C i , R i ,y i } is the i-th conversation data in the dataset ζ, N represents the total number of conversation data in the dataset ζ, where D i represents the document in the i-th conversation data, Represents the first knowledge entry in the document. Represents the second knowledge entry in the document. Indicates the dth i Knowledge items, d i Representative D i The number of knowledge items in C i Represents the conversation context excluding the reply in the i-th conversation data, Represents C i In the first round of dialogue, Represents C i In the second round of dialogue, Represents C i c i Round dialogue, c i Represents C i The number of rounds in the dialogue, R i For C i Reply, y i =1 represents R i C i The correct answer is y i =0 represents R i Not C i The correct response; The dialogue above C i The last round of dialogue Defined as the query Q of the i-th conversation data i , the dialogue above C i The other rounds except the last round of dialogue are defined as the dialogue history of the i-th dialogue data According to the data set ζ, mapping relationships G1(Q, K), G2(K, R) and G3(K, H, Q, R) are established; Among them, Q is the query, K is the knowledge item, H is the conversation history, and R is the reply.
3. The reply screening method according to claim 2, characterized in that: The step 1 also includes constructing a training set according to the established mapping relationship, specifically, Step 1.1, the mapping relationship G1(Q, K) represents the relevance between the knowledge item and the query, (Q, K) is used as the input of the training set, and the relevance score G1(Q, K) is used as the corresponding output; Step 1.2, the mapping relationship G2(K, R) represents the relevance between the knowledge item and the reply, (K, R) is used as the input of the training set, and the relevance score G2(K, R) is used as the corresponding output; Step 1.3, the mapping relationship G3(K, H, Q, R) represents the relevance of knowledge items, conversation history, queries and replies. (K, H, Q, R) is used as the input of the training set, and the relevance score G3(K, H, Q, R) is used as the corresponding output.
4. The reply screening method according to claim 1, characterized in that: The specific algorithm for constructing pseudo data in step 1 is: Input: Reddit data D R ;Wikipedia data D w ;Threshold γ; Output: pseudo DGD data Dp; 1: Initialize Dp to an empty set; 2: For D R For each set of conversations in the data, for context C and response R, perform operations 3-6; 3: Use BM25 algorithm to calculate the reply and Wikipedia data D w The similarity of each knowledge item in 4: If the similarity score is greater than the threshold γ; 5: Then group the found knowledge items with C and R and put them into Dp; 6: After traversing D R After the data in is obtained, the pseudo data Dp is obtained.
5. The reply screening method according to claim 1, characterized in that: Specifically, step 2 is to define segment embedding codes for document D, conversation data C, and reply R, respectively, and denote the last hidden state representation of the special identifier [CLS] at the beginning of the input sequence as E cls , E cls After two nonlinear layers, the output correlation score G(input) is: G(input)=σ(W2μ(W1E cls +b1)+b2) Among them, W1, W2, b1, b2 are trainable parameters, σ represents the sigmoid activation function, and μ represents the tanh activation function. In the three relevance tasks, the same BERT model is used for training, and the relevance scores are calculated using the above formula.
6. The reply screening method according to claim 2, characterized in that: The loss function L used in step 2 is final for: <h2 style=";text-align:left;direction:ltr">L<h2 style=";text-align:left;direction:ltr"> final <h2 style=";text-align:left;direction:ltr"> (L1+L2+L3) in: In the formula, e is the base of the natural logarithm, N1 represents the number of positive examples corresponding to the mapping relationship G1(Q, K), represents the relevance score of the i-th positive example, represents the relevance score of the i-th negative example, and α1 represents the relevance score of each positive example The corresponding number of negative examples, represents the relevance score of the jth negative example, j = 1, 2, ..., α1; In the formula, N2 represents the number of positive examples corresponding to the mapping relationship G2(K, R), represents the relevance score of the i-th positive example, represents the relevance score of the i-th negative example, and α2 represents the relevance score of each positive example The corresponding number of negative examples, represents the relevance score of the jth negative example, j = 1, 2, ..., α2; Where N3 represents the number of positive examples corresponding to the mapping relationship G3(K, H, Q, R), represents the relevance score of the i-th positive example, and α3 represents the relevance score of each positive example The corresponding number of negative examples, represents the relevance score of the jth negative example, j = 1, 2, ..., α3: λ represents the different scores assigned to each negative example.
7. The reply screening method according to claim 2, characterized in that: Specifically, step 3 comprises constructing inputs corresponding to the three mapping relationships in step 1 according to the current dialogue, knowledge items, and candidate responses, respectively, and inputting the constructed inputs into the trained BERT model to obtain three relevance scores output by the BERT model; Sum the three relevance scores, and the sum is the score of the candidate response; After traversing each candidate response, the candidate response with the highest score is taken as the final response.
8. A knowledge-centric response screening system for open-domain dialogue, characterized in that: The reply screening system uses the reply screening method as claimed in claim 1, and the reply screening system includes: The construction module uses the existing conversation data and encyclopedia knowledge data to build the required training data and construct the pseudo-data algorithm; The training module uses the training set constructed by the construction module to perform three-stage training on the BERT model; The test module, during testing, uses the sum of the three-stage scores generated by the training module as the final score.
9. A computer device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Knowledge-driven dialogue method based on pre-training model
CN113254582A
Differential perception reply generation method and system based on remote supervision and knowledge distillation
CN116775840A
Training method and device of dialogue query generation model based on retrieval enhancement model
CN117764140A
Clarification questions selection for conversational search, trained from human-to-human conversations and solution documents
US20230029829A1