Plan-led response provision
By introducing a plan-based matching model in the chatbot, using dialogue context and plan representation, the problem of inconsistent response of chatbots is solved, and more efficient conversation guidance and response generation is achieved.
Patent Information
- Application Number
- CN201911409242.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-12-31
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2039-12-31
AI Technical Summary
Existing chatbots lack psychological framework guidance when chatting with users, resulting in the possible inconsistency or scattered responses.
Using a plan-based matching model, a matching score for candidate responses is generated by obtaining context and plan representations in the conversation to provide a more consistent and reasonable response.
Improve the consistency and rationality of chatbot responses, ensuring the smoothness and logic of conversations.
Smart Images

Figure CN113127608B_ABST
Abstract
Description
Background Art
[0001] Artificial intelligence (AI) chatbots are becoming more and more popular and are being used in more and more scenarios. Chatbots are designed to simulate human speech and can chat with users through text, voice, images, etc. Generally, chatbots can recognize the language content within a message input by a user or apply natural language processing to the message, and then provide a response to the message to the user. Summary of the invention
[0002] This summary is provided to introduce a set of concepts that will be further described in the following detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
[0003] Embodiments of the present disclosure provide a method and apparatus for plan-guided response provision. A context associated with a previous utterance in a conversation may be obtained, the context including at least the previous utterance. A current plan representation of a plan corresponding to the conversation may be obtained. For each candidate response in a set of candidate responses, a first matching representation may be generated based on the candidate response and the context, a second matching representation may be generated based on the candidate response and the current plan representation, and a matching score corresponding to the candidate response may be calculated based on at least the first matching representation and the second matching representation. The candidate response with the highest matching score in the set of candidate responses may be provided in the conversation.
[0004] It should be noted that one or more of the above aspects include the features specifically pointed out in the following detailed description and claims. The following description and drawings set forth in detail certain illustrative features of the one or more aspects. These features are merely indicative of the various ways in which the principles of various aspects may be implemented, and the present disclosure is intended to include all such aspects and their equivalents. BRIEF DESCRIPTION OF THE DRAWINGS
[0005] The disclosed aspects will be described below in conjunction with the accompanying drawings, which are provided to illustrate rather than limit the disclosed aspects.
[0006] Figure 1 An exemplary process of obtaining a matching score using a plan-based matching model according to an embodiment of the present disclosure is shown.
[0007] Figure 2 An exemplary structure of a representation generating part according to an embodiment of the present disclosure is shown.
[0008] Figure 3 An exemplary process for generating a multi-level self-attention representation according to an embodiment of the present disclosure is shown.
[0009] Figure 4 An exemplary process for generating a multi-level mutual attention representation of utterances and plans in context according to an embodiment of the present disclosure is shown.
[0010] Figure 5 Exemplary structures of a matching portion and a polymerizing portion according to an embodiment of the present disclosure are shown.
[0011] Figure 6 An exemplary process for generating a matching matrix between utterances in context and plans according to an embodiment of the present disclosure is shown.
[0012] Figure 7 An exemplary process for generating a matching cube between a context and a plan and a matching vector between a context and a plan according to an embodiment of the present disclosure is shown.
[0013] Figure 8 Another exemplary process for generating a matching cube between a context and a plan and a matching vector between a context and a plan according to an embodiment of the present disclosure is shown.
[0014] Fig. 9 An exemplary process for generating a matching vector between a candidate response and a plan according to an embodiment of the present disclosure is shown.
[0015] Fig.10 An exemplary process for generating a matching score according to an embodiment of the present disclosure is shown.
[0016] Fig.11 An exemplary process of obtaining a matching score using a matching model based on an update plan according to an embodiment of the present disclosure is shown.
[0017] Fig.12 An exemplary structure of a representation generating part according to an embodiment of the present disclosure is shown.
[0018] Fig.13 An exemplary process of plan updating according to an embodiment of the present disclosure is shown.
[0019] Fig.14 An exemplary process of using an additional matching matrix to generate a matching cube between a context and a plan based on an update mechanism according to an embodiment of the present disclosure is shown.
[0020] Fig.15 An exemplary chat flow according to an embodiment of the present disclosure is shown.
[0021] Fig.16 A specific example of generating a dialog according to an embodiment of the present disclosure is shown.
[0022] Fig.17 is a flow chart of an exemplary method for planning guided response provision according to an embodiment of the present disclosure.
[0023] Fig.18 An exemplary apparatus for planning guided response provision according to an embodiment of the present disclosure is shown.
[0024] Fig.19 An exemplary apparatus for plan-guided response provision according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0025] The present disclosure will now be discussed with reference to various exemplary embodiments. It should be understood that the discussion of these embodiments is only for enabling those skilled in the art to better understand and thereby implement the embodiments of the present disclosure, and does not teach any limitation on the scope of the present disclosure.
[0026] Generally, a chatbot can conduct an automatic chat in a conversation with a user. In this article, a "conversation" may refer to a time-continuous conversation between two chat participants. When conducting an automatic chat, the chatbot may receive an utterance from a user and reply by selecting a candidate response from a set of candidate responses stored in its associated database. When selecting candidate responses, current chatbots usually consider the match between each candidate response and the existing utterances in the conversation, and provide the user with the best matching candidate response. However, when humans conduct a conversation, they not only consider what the other party has said before, but also consider their own psychological framework, and conduct the conversation under the guidance of the psychological framework. This psychological framework may be a goal to be achieved through the conversation, a position or opinion expressed, a decision or judgment made, or the order of matters to be mentioned in the conversation. Current chatbots lack such a psychological framework to guide them in the process of chatting with users, so the responses they provide may be inconsistent or scattered.
[0027] The embodiments of the present disclosure propose to use a plan to simulate such a psychological framework, and further propose a method and apparatus for providing a plan-guided response. In this article, a plan can be used to define the overall plan or plot of a conversation, such as the goals to be achieved through the conversation, the positions or opinions to be expressed, the decisions or judgments to be made, or the order in which the conversation will mention matters, etc. The plan can help to select more consistent and reasonable responses in the conversation, and better control the conversation.
[0028] In one aspect, an embodiment of the present disclosure proposes a plan-based matching model that can obtain context associated with a previous utterance in a conversation and a plan corresponding to the conversation, and provide a response in the conversation based on a match between a candidate response and the context and a match between a candidate response and the plan. In this article, a previous utterance can refer to the most recently received utterance in a conversation, and the context associated with the previous utterance can include all utterances in the conversation, and can include the previous utterance itself. The match between the candidate response and the context can help select a response that is more suitable for the reply context, and the match between the candidate response and the plan can help select a response that is more consistent with the plan.
[0029] In another aspect, the embodiments of the present disclosure propose that when providing candidate responses, not only the match between the candidate response and the context and the match between the candidate response and the plan are considered, but also the match between the context and the plan. The match between the context and the plan can be used to help the matching model "remember" how much information in the plan has been conveyed in the context, which can implicitly promote the selection of candidate responses that are consistent with the plan.
[0030] In another aspect, an embodiment of the present disclosure proposes a plan update mechanism and a corresponding matching model based on an updated plan. The plan update mechanism can update the representation of the plan based on the information that has been conveyed in the context, thereby obtaining the current plan representation of the plan. Accordingly, the matching model based on the updated plan can provide a response in the conversation based on the match between the candidate response and the context and the match between the candidate response and the current plan representation. The matching model based on the updated plan according to an embodiment of the present disclosure can track which information in the plan has been conveyed in the context of the conversation, and the selection of candidate responses will focus on the information that has not been conveyed in the plan. This can enable the selected candidate responses to convey information in the plan that has not yet been conveyed in the context, and can cause the order of information in the conversation to be consistent with the order of information in the plan.
[0031] On the other hand, the method and apparatus for providing a plan-guided response proposed in the embodiment of the present disclosure can be used not only to provide a response in a conversation between a chatbot and a user, that is, to provide only the speech of the chatbot in the conversation, but also to provide the speech of both parties or more parties in the conversation. In other words, the method and apparatus for providing a plan-guided response proposed in the embodiment of the present disclosure can be used to generate a conversation. A conversation can be generated based on a predetermined plan and an initial speech, which can be received from a user, pre-specified, or retrieved from a corpus based on a plan.
[0032] According to an embodiment of the present disclosure, when providing candidate responses in a conversation, a context associated with a previous utterance in the conversation, a plan corresponding to the conversation, and a set of candidate responses can be obtained. For each candidate response in the set of candidate responses, the candidate response can be scored based on a match between the candidate response and the context, a match between the candidate response and the context, and a match between the context and the plan, thereby obtaining a matching score corresponding to the candidate response. Subsequently, the candidate response with the highest matching score in the set of candidate responses can be provided in the conversation.
[0033] Figure 1 An exemplary process 100 for obtaining a matching score using a plan-based matching model according to an embodiment of the present disclosure is shown.
[0034] In process 100, a plan-based matching model 110 can obtain a context 104 associated with previous utterances in a conversation, which may include all utterances in the conversation, such as utterance 1 104-1, utterance 2 104-2, ..., utterance n 104-n, where utterance i 104-i represents the i-th utterance in the context and utterance n 104-n is the previous utterance.
[0035] The plan-based matching model 110 can also obtain a plan 102 corresponding to the conversation. The plan 102 may include, for example, at least one sentence, keyword, or entity, such as the plan "She was very happy to receive the admission letter. But her mother couldn't be happy because she was reluctant to let her daughter leave home", the plan "show off", the plan "Forbidden City", etc. The conversation participants that the plan 102 can target can be determined based on the scenario in which the plan-based matching model 110 is applied. For example, when the plan-based matching model 110 is applied to a scenario in which a chatbot and a user have a conversation, the plan may only target the chatbot; and when the plan-based matching model 110 is applied to a scenario in which a conversation is generated, the plan may target all parties involved in the conversation.
[0036] In some embodiments, the plan 102 may be selected from a set of candidate plans. The set of candidate plans may be manually written for a predefined topic, extracted from a corpus, or generated based on sentences related to the predefined topic retrieved from the corpus. For example, for the topic "failed the exam", a plan such as "don't be sad, the test score is not important, keep working hard" may be manually written. In addition, a plan related to the topic "failed the exam" may be extracted from the corpus. Alternatively, sentences related to the topic "failed the exam" may be retrieved from the corpus, and a plan may be generated by combining these sentences. In some embodiments, in a scenario where a chatbot is having a conversation with a user, a plan may be determined based on the context in the conversation, such as the utterances input by the user. For example, if the user mentions the Forbidden City, a plan related to the Forbidden City may be determined for the chatbot, such as "I have been to the Forbidden City and will go again if I have a chance."
[0037] The plan-based matching model 110 can also obtain a set of candidate responses 106 from a database (not shown) to which it is connected or contained, which may include multiple candidate responses. The following takes the candidate response 108 in the set of candidate responses 106 as an example to illustrate an exemplary process for obtaining the matching score 118 of the candidate response 108.
[0038] The plan-based matching model 110 may include, for example, a representation generation portion 112 , a matching portion 114 , an aggregation portion 116 , and the like.
[0039] Through the representation generation part 112, a multi-level self-attention representation of the plan 102, a multi-level self-attention representation of each utterance i in the context 104, a multi-level self-attention representation of the candidate response 108, etc. can be generated. The representation generation part 112 can further use these multi-level self-attention representations to generate a multi-level mutual attention representation of utterance i-plan, a multi-level mutual attention representation of candidate response-utterance i, a multi-level mutual attention representation of candidate response-plan, etc. Figure 2 The specific structure of the representation generating section 112 will be explained.
[0040] Through the matching part 114, a matching process can be performed based on the multi-level self-attention representation and the multi-level mutual attention representation generated by the representation generation part 112 to generate a matching matrix between each utterance in the context and the plan, a matching matrix between the candidate response and each utterance in the context, and a matching matrix between the candidate response and the plan. The aggregation part 116 can generate a matching score 118 corresponding to the candidate response 108 based on these matching matrices. Figure 5 The specific structures of the matching portion 114 and the aggregation portion 116 are explained.
[0041] Figure 2 FIG. 2 shows an exemplary structure of the representation generation part 200 according to an embodiment of the present disclosure. The representation generation part 200 may correspond to Figure 1 The representation generation part 112 in .
[0042] The plan self-attention representation generation unit 208 may generate a multi-level self-attention representation of the plan 202. The plan 202 may correspond to Figure 1 102 in the plan. Through the utterance i self-attention representation generation unit 210, a multi-level self-attention representation of utterance i 204 can be generated. The utterance i 204 can correspond to Figure 1 The candidate response self-attention representation generating unit 212 may generate a multi-level self-attention representation of the candidate response 206. The candidate response 206 may correspond to Figure 1 The candidate response 108 in Figure 3 To explain the specific process of generating the multi-level self-attention representation of plan 202, the multi-level self-attention representation of utterance i 204, and the multi-level self-attention representation of candidate response 206.
[0043] The multi-level self-attention representation of the plan 202 and the multi-level self-attention representation of the utterance i 204 can be further used to generate the utterance i-plan multi-level mutual attention representation at 214. The multi-level self-attention representation of the utterance i 204 and the multi-level self-attention representation of the candidate response 206 can be further used to generate the candidate response-utterance i multi-level mutual attention representation at 216. The multi-level self-attention representation of the plan 202 and the multi-level self-attention representation of the candidate response 206 can be further used to generate the candidate response-plan multi-level mutual attention representation at 218. Figure 4 To explain the specific process of generating utterance i-plan multi-level mutual attention representation, candidate response-utterance i multi-level mutual attention representation, and candidate response-plan multi-level mutual attention representation.
[0044] Figure 3 Exemplary processes 300 , 310 , and 320 for generating multi-level self-attention representations according to embodiments of the present disclosure are shown.
[0045] In process 300, a multi-level self-attention representation of a plan p may be generated by a plan self-attention representation generation unit 302. The plan self-attention representation generation unit 302 may correspond to Figure 2 The plan self-attention representation generation unit 208 in . Assume that the plan can be represented as in represents the i-th word in the plan, and n pRepresents the number of words in the plan. The pre-trained embedding table 304 can be used to embed each word in the plan Mapped to the corresponding d e Dimensional Embedding This gives us an initial representation of the plan Initial representation P 0 It can be regarded as the self-attention representation at level 0 of the plan. Subsequently, the multi-level attention module 306 can be used to obtain the self-attention representation of the initial representation P 0 To construct the self-attention representation at the planned levels 1 to L Where P l P may represent the self-attention representation at the planned l-th level, and L may represent the total number of levels of attention modules included in the multi-level attention module. P may be obtained by the following formula: l :
[0046] P l =AttentiveBlock(P l-1 ,P l-1 ,P l-1 ) (1)
[0047] Among them, AttentiveBlock represents the output of the multi-level attention module, l∈{1,2,…,L}. can be compared with the initial representation P 0 Multi-level self-attention representations that together form a plan
[0048] In process 310, a multi-level self-attention representation of each utterance in context c may be generated by a utterance i self-attention representation generation unit 312. The utterance i self-attention representation generation unit 312 may correspond to Figure 2 The utterance i in the self-attention representation generation unit 210. Assume that the context can be represented as c = {u1,u2,…,u n}, where u i denotes utterance i in the context, and n denotes the number of utterances in the context. Assume that utterance i can be represented as in represents the i-th word in utterance i, and represents the number of words in utterance i. Figure 3 A multi-level self-attention representation of utterance i can be generated by a similar process 300 for generating a multi-level self-attention representation of a plan in utterance i. For example, a pre-trained embedding table 314 can be used to embed each word in utterance i. Mapped to the corresponding d e Dimensional Embedding So as to obtain the initial representation of utterance i Subsequently, a multi-level attention module 316 can be used to To construct the self-attention representation of utterance i at levels 1 to L in Can represent the self-attention representation at the lth level of utterance i, and L can represent the total number of levels of attention modules included in the multi-level attention module. It can be obtained by the following formula
[0049]
[0050] Among them, AttentiveBlock represents the output of the multi-level attention module, l∈{1,2,…,L}. Can be expressed with the initial Together, we form a multi-level self-attention representation of utterance i
[0051] In process 320, a multi-level self-attention representation of the candidate response r may be generated by a candidate response self-attention representation generation unit 322. The candidate response self-attention representation generation unit 322 may correspond to Figure 2 The candidate response self-attention representation generation unit 212 in . Assume that the candidate response can be represented as in represents the i-th word in the candidate response, and n r Indicates the number of words in the candidate response. Figure 3 A multi-level self-attention representation of a candidate response can be generated by a similar process to the process 300 for generating a multi-level self-attention representation of a plan in FIG. 300. For example, the pre-trained embedding table 324 can be used to embed each word in the candidate response. Mapped to the corresponding d e Dimensional Embedding So as to obtain the initial representation of the candidate response Initial representation R 0 It can be regarded as the self-attention representation at level 0 of the candidate response. Subsequently, a multi-level attention module 326 can be used to obtain the candidate response based on the initial representation R 0 To construct the self-attention representation of the candidate responses at levels 1 to L Where R l R can represent the self-attention representation at the lth level of the candidate response, and L can represent the total number of levels of attention modules included in the multi-level attention module. R can be obtained by the following formula: l :
[0052] R l =AttentiveBlock(R l-1 ,Rl-1 ,R l-1 ) (3)
[0053] Among them, AttentiveBlock represents the output of the multi-level attention module, l∈{1,2,…,L}. can be compared with the initial representation R 0 Multi-level self-attention representations that together form candidate responses
[0054] After generating a multi-level self-attention representation of the plan Multi-level self-attention representation of utterance i in context and multi-level self-attention representation of candidate responses Afterwards, utterance i-plan multi-level mutual attention representation, candidate response-utterance i multi-level mutual attention representation, and candidate response-plan multi-level mutual attention representation can be further generated based on these multi-level self-attention representations.
[0055] Figure 4 An exemplary process 400 for generating a multi-level mutual attention representation of a discourse and a plan in context according to an embodiment of the present disclosure is shown. A multi-level self-attention representation of a plan can be obtained This can be done, for example, by Figure 3 It can also be obtained by the process 300 in the context. The multi-level self-attention representation of the utterance i in the context can also be obtained This can be done, for example, by Figure 3 The multi-level mutual attention representation of the utterance and the plan in the context can be generated by the utterance i-plan mutual attention representation generation unit 402. The utterance i-plan mutual attention representation generation unit 402 can correspond to Figure 2 In one embodiment, the utterance i-plan mutual attention representation generation unit 402 may be a multi-level attention module. The utterance i-plan mutual attention representation generation unit 402 may adopt a multi-level self-attention representation of the plan and the multi-level self-attention representation of utterance i As input, we generate a multi-level mutual attention representation of the utterance i-plan and As shown in the following formula:
[0056]
[0057]
[0058] Among them, AttentiveBlock represents the output of the multi-level attention module, l∈{0,1,…,L}.
[0059] Can be done with Figure 4 A similar process is used to generate a candidate response-discourse i multi-level mutual attention representation. and As shown in the following formula:
[0060]
[0061]
[0062] Among them, AttentiveBlock represents the output of the multi-level attention module, l∈{0,1,…,L}.
[0063] Similarly, you can Figure 4 A similar process is used to generate a multi-level mutual attention representation of a candidate response-plan. and As shown in the following formula:
[0064]
[0065]
[0066] Among them, AttentiveBlock represents the output of the multi-level attention module, l∈{0,1,…,L}.
[0067] By combining Figures 2 to 4 The described process can generate multi-level self-attention representations, such as multi-level self-attention representations of plans, multi-level self-attention representations of individual utterances i in context, and multi-level self-attention representations of candidate responses, as well as multi-level mutual attention representations, such as utterance i-plan multi-level mutual attention representations, candidate response-utterance i multi-level mutual attention representations, and candidate response-plan multi-level mutual attention representations. These representations can be combined into a representation set. The representation set can be provided to the matching part and the aggregation part in the plan-based matching model, such as Figure 1 The matching portion 114 and the aggregation portion 116 in the resultant image are combined to obtain a matching score corresponding to the candidate response.
[0068] Figure 5 FIG. 5 shows an exemplary structure of a matching portion 510 and a polymerizing portion 520 according to an embodiment of the present disclosure. The matching portion 510 and the polymerizing portion 520 may correspond to Figure 1 The matching portion 114 and the aggregation portion 116 in FIG.
[0069] A representation set 502 may be obtained. The representation set 502 may include Figures 2 to 4 The multi-level self-attention representation generated by the described process is shown in Figure 2, such as the planned multi-level self-attention representation Multi-level self-attention representation of each utterance in context and multi-level self-attention representation of candidate responses and multi-level mutual attention representations, such as discourse i-plan multi-level mutual attention representations and Candidate response-utterance i multi-level mutual attention representation and and candidate response-plan multi-level mutual attention representation and
[0070]
[0071] The utterance i-plan matching matrix generating unit 512 can generate a matching matrix between utterance i and the plan. Figure 6 To explain the specific process for generating the matching matrix between utterance i and the plan. Through the candidate response-utterance i matching matrix generating unit 514, the matching matrix between the candidate response and the utterance i can be generated. Through the candidate response-plan matching matrix generating unit 516, the matching matrix between the candidate response and the plan can be generated. The process for generating the matching matrix between the candidate response and the utterance i and the process for generating the matching matrix between the candidate response and the plan can be similar to the process for generating the matching matrix between the utterance i and the plan.
[0072] Through the context-plan matching cube generation unit 522, a matching cube between context and plan can be generated based on the matching matrix between utterance i and plan. Through the context-plan matching cube generation unit 524, a matching vector between context and plan can be generated based on the matching cube between context and plan. Figure 7 to explain the specific process used to generate the matching cube and matching vector between the context and the plan.
[0073] Through the candidate response-context matching cube generation unit 526, a matching cube between the candidate response and the context can be generated based on the matching matrix between the candidate response and the utterance i. Through the candidate response-context matching vector generation unit 528, a matching vector between the candidate response and the context can be generated based on the matching cube between the candidate response and the context. The process for generating the matching cube between the candidate response and the context can be similar to the process for generating the matching cube between the context and the plan, and the process for generating the matching vector between the candidate response and the context can be similar to the process for generating the matching vector between the context and the plan.
[0074] The candidate response-plan matching vector generating unit 530 can generate a matching vector between the candidate response and the plan based on the matching matrix between the candidate response and the plan. Fig. 9 to explain the specific process used to generate the matching vector between the candidate responses and the plan.
[0075] The matching score generating unit 532 can generate a matching score 534 corresponding to the candidate response based on the matching vector between the context and the plan, the matching vector between the candidate response and the context, and the matching vector between the candidate response and the plan. Fig.10 to explain the specific process used to generate the matching score.
[0076] Figure 6 An exemplary process 600 for generating a matching matrix between an utterance in a context and a plan according to an embodiment of the present disclosure is shown. A matching matrix between an utterance in a context and a plan can be generated by using an utterance i-plan matching matrix generating unit 602. The utterance i-plan matching matrix generating unit 602 can correspond to Figure 5 The discourse i-plan matching matrix generation unit 512 in.
[0077] In process 600, a multi-level attention representation of the plan may first be obtained and the multi-level self-attention representation of utterance i For example, you can use Figure 3 The process 300 and 310 in the above embodiment are used to obtain the multi-level self-attention representation of the plan. and the multi-level self-attention representation of utterance i Then, the self-attention matching matrix at each level of the plan can be calculated. For example, the self-attention representation at level 0 of utterance i can be obtained by and the planned self-attention representation P at level 0 0 A correlation operation 604-0 is performed to generate a self-attention matching matrix between utterance i and the plan at level 0 Similarly, we can express the self-attention at level 1 of utterance i by and the planned self-attention representation P at level 1 1 A correlation operation 604-1 is performed to generate a self-attention matching matrix between utterance i and the planned level 1 Similarly, we can express the self-attention at level L of utterance i by and the self-attention representation P at the planned level L L A correlation operation 604-L is performed to generate a self-attention matching matrix at level L between utterance i and the plan In one embodiment, the correlation operations 604-0, 604-1, ..., 604-L may be dot product operations. The self-attention matching matrix of utterance i and the plan at level l may be expressed, for example, by the following formula:
[0078]
[0079] Among them, l∈{0,1,…,L}. Each element in is The jth word in P l The dot product of the k-th word representation in .
[0080] Next, we can match the self-attention matrix at each level of the utterance i with the plan Combining 606, such as cascading, to obtain the self-attention matching matrix of utterance i and the plan As shown in the following formula:
[0081]
[0082] We can also obtain the multi-level mutual attention representation of the discourse i-plan and For example, Figure 4 The process in this paper is used to obtain the multi-level mutual attention representation of the discourse i-plan and Then, the mutual attention matching matrix between utterance i and the plan at each level can be calculated. For example, the mutual attention representation at level 0 of utterance i-plan can be obtained by and A correlation operation 608-0 is performed to generate a mutual attention matching matrix between utterance i and the plan at level 0 Similarly, we can express the mutual attention at level 1 of utterance i-plan by and A correlation operation 608-1 is performed to generate a mutual attention matching matrix between utterance i and the plan at level 1 By analogy, we can express the mutual attention at level L of discourse i-plan by and A correlation operation 608-L is performed to generate a mutual attention matching matrix between utterance i and the plan at level L In one embodiment, the correlation operations 608-0, 608-1, ..., 608-L may be dot product operations. The mutual attention matching matrix between utterance i and the plan at level l may be expressed, for example, by the following formula:
[0083]
[0084] Among them, l∈{0,1,…,L}. Each element in is The jth word in represents The dot product of the k-th word representation in .
[0085] Next, we can calculate the mutual attention matching matrix between discourse i and each level of the plan: Combining 610, such as cascading, to obtain the mutual attention matching matrix between utterance i and the plan As shown in the following formula:
[0086]
[0087] Finally, at 612, the self-attention matching matrix of utterance i and the plan can be and the mutual attention matching matrix Combine, for example, concatenate, to obtain a matching matrix between discourse i and the plan As shown in the following formula:
[0088]
[0089] Through the cascade operation in the above formulas (11), (13) and (14), Each element in may have 2(L+1) channels and contain matching information at different levels.
[0090] The matching matrix between candidate responses and utterance i can be generated by a process similar to that used to generate the matching matrix between utterance i and plan and the matching matrix M between candidate responses and plans r,p . and M r,p Each element in may also have 2(L+1) channels and contain matching information at different levels.
[0091] Figure 7An exemplary process 700 for generating a matching cube between a context and a plan and a matching vector between a context and a plan according to an embodiment of the present disclosure is shown.
[0092] In process 700, each utterance in the context may be first obtained, such as utterance 1u1, utterance 2u2, ..., utterance nu n , and the matching matrix between the plans For example, Figure 6 The process 600 in the context is used to generate a matching matrix between each utterance in the context and the plan
[0093] Then, the context-plan matching cube generation unit 702 can generate a matching cube based on the matching matrix To generate a matching cube Q between context and plan cp . Figure 7 The context-plan matching cube generation unit 702 in may correspond to Figure 5 In one embodiment, the context-plan matching cube generation unit 522 can be generated by matching the matrix Stacking is performed to generate a matching cube Q between context and plan cp .
[0094] Through the context-plan matching vector generation unit 704, the matching cube Q between the context and the plan can be cp To generate the matching vector f(c,p) between the context and the plan. Figure 7 The context-plan matching vector generation unit 704 in may correspond to Figure 5 The context-plan matching vector generation unit 524 in FIG. In one embodiment, the matching cube Q between the context and the plan can be cp Three-dimensional convolution 706 and maximum pooling 708 are performed to generate a matching vector f(c, p) between the context and the plan.
[0095] Can be done with Figure 7 The matching cube between the candidate response and the context and the matching vector between the candidate response and the context can be generated by a process similar to process 700 in FIG. For example, the matching matrix between the candidate response and each utterance in the context can be To generate a matching cube Q between candidate responses and context rc In one embodiment, the matching matrix Stacking is performed to generate a matching cube Q between the candidate response and the context rcSubsequently, the cube Q can be constructed based on the matching between the candidate response and the context. rc To generate a matching vector f(r, c) between the candidate response and the context. In one embodiment, the matching cube Q between the candidate response and the context can be rc Three-dimensional convolution and maximum pooling are performed to generate a matching vector f(r,c) between the candidate response and the context.
[0096] Figure 8 Another exemplary process 800 for generating a matching cube between a context and a plan and a matching vector between a context and a plan according to an embodiment of the present disclosure is shown. During a conversation, the utterances in the context are increased round by round. Therefore, a matching cube, a matching vector, etc. between the context and the plan can be generated by updating in a round-by-round manner. For example, an additional matching matrix can be generated based on the latest utterance in the context, i.e., the previous utterance, and a matching cube between the context and the plan is generated by updating a previous matching cube associated with an utterance in the context that precedes the previous utterance using the additional matching matrix, and the resulting matching cube can be further used to generate a matching vector.
[0097] In process 800, the previous utterance in the context, such as utterance nu, may first be obtained. n , a previous utterance, for example utterance n-1u n-1 , the associated previously matched cube Previously matched cube It can be based on, for example, individual utterances preceding the previous utterance in the context, such as utterance 1u1, utterance 2u1, ..., utterance n-1u n-1 , and the matching matrix between the plans To generate.
[0098] It is also possible to obtain a multi-level self-attention representation of the plan Planned Multi-Level Self-Attention Representation This can be done at the beginning of the conversation, for example by Figure 3 Generated by process 300 in .
[0099] After obtaining the previous utterance in the conversation, such as utterance nu n , we can for example Figure 3 The process 310 in the above example generates a multi-level self-attention representation of utterance n. Then, we can use the multi-level self-attention representation of utterance n as Multi-level self-attention representation of the scheme To generate discourse n-plan multi-level mutual attention representation and For example, Figure 4 The process 400 in the above example generates a multi-level mutual attention representation of the discourse n-plan and
[0100]
[0101] Next, at 802, the multi-level self-attention representation of utterance n may be used. Planned Multi-Level Self-Attention Representation And discourse n-plan multi-level mutual attention representation and To generate an additional matching matrix For example, Figure 6 The process 600 in the embodiment of the present invention is used to generate an additional matching matrix.
[0102] At 804, the previously matched cube may be and additional matching matrix Combine to generate a matching cube Q between context and plan cp .
[0103] At 806, the Figure 7 The context-plan matching vector at 704 is generated in a similar manner, based on the matching cube Q between the context and the plan cp To generate the matching vector f(c,p) between the context and the plan.
[0104] Process 800 may be continuously and iteratively executed as new utterances appear in the conversation, so that the matching cube may be continuously updated and a matching vector may be generated.
[0105] Fig. 9 An exemplary process 900 for generating a matching vector between a candidate response and a plan is shown according to an embodiment of the present disclosure.
[0106] The matching matrix M between candidate responses and plans can be obtained r,p . This can be done by Figure 6 is used to generate the matching matrix between discourse i and the plan A matching matrix M between candidate responses and plans is generated by a similar process to process 600. r,p .
[0107] The candidate response-plan matching vector generating unit 902 can be used to generate a matching matrix M between the candidate response and the plan. r,p To generate a matching vector f(r,p) between the candidate response and the plan. Fig. 9 The candidate response-plan matching vector generation unit 902 in may correspond to Figure 5The candidate response-plan matching vector generation unit 530 in FIG. In one embodiment, the matching matrix M between the candidate response and the plan can be r,p Two-dimensional convolution 904 and max pooling 906 are performed to generate a matching vector f(r, p) between the candidate response and the plan.
[0108] After generating the matching vector f(c, p) between the context and the plan, the matching vector f(r, c) between the candidate response and the context, and the matching vector f(r, p) between the candidate response and the plan, a matching score corresponding to the candidate response can be generated based on these matching vectors. Fig.10 An exemplary process 1000 for generating a matching score according to an embodiment of the disclosure is shown.
[0109] In process 1000 , a matching vector f(c, p) between a context and a plan, a matching vector f(r, c) between a candidate response and a context, and a matching vector f(r, p) between a candidate response and a plan may be first obtained.
[0110] The matching score generating unit 1002 may generate a matching score g(r,c,p) based on the matching vector f(c,p) between the context and the plan, the matching vector f(r,c) between the candidate response and the context, and the matching vector f(r,p) between the candidate response and the plan. The matching score generating unit 1002 may correspond to Figure 5 In the matching score generating unit 532. In one embodiment, the matching vector f(c, p) between the context and the plan, the matching vector f(r, c) between the candidate response and the context, and the matching vector f(r, p) between the candidate response and the plan can be combined 1004, such as cascading, to generate a comprehensive vector f(r, c, p), as shown in the following formula:
[0111] f(r,c,p)=[ f(c,p)⊕f(r,c)⊕f(r,p)] (15)
[0112] The generated comprehensive vector f(r,c,p) may be provided as input to a multi-layer perceptron (MLP) 1006 with a sigmoid activation function to generate a matching score g(r,c,p) corresponding to the candidate response, as shown in the following formula:
[0113] g(r,c,p)=sigmoid(W T ·f(r,c,p)+b) (16)
[0114] Among them, W and b are trainable parameters.
[0115] Can be based on the training data set To train the plan-based matching model according to an embodiment of the present disclosure, for example Figure 1 The plan-based matching model in 110. Training dataset Multiple training samples may be included. Each training sample can be represented as (y, c, p, r), where c = {u1, u2, ..., u n} represents a context with n utterances, p is a plan, r is a candidate response, and y∈{0,1} is a binary label indicating whether the candidate response r is a suitable response for the given context c and given plan p. This can be done by using The associated objective function L(θ) is minimized to train the plan-based matching model. In one embodiment, the objective function L(θ) can be defined as a cross entropy loss, as shown in the following formula:
[0116]
[0117] Where g(r,c,p) is the matching score corresponding to the candidate response r, which can be obtained by combining the above Figures 1 to 10 The described process is obtained.
[0118] Combination of the above Figures 1 to 10 A process for generating a matching score corresponding to a candidate response according to an embodiment of the present disclosure is described. The process may include generating a matching representation between the candidate response and the context, such as a matching matrix between the candidate response and each utterance in the context, a matching cube between the candidate response and the context, and a matching vector between the candidate response and the context. The matching representation between the candidate response and the context can be used to calculate the correlation between the candidate response and the context, thereby facilitating the selection of a response that is more suitable for the reply context.
[0119] The process for generating a matching score corresponding to a candidate response according to an embodiment of the present disclosure may also include generating a matching representation between the candidate response and the plan, such as a matching matrix between the candidate response and the plan and a matching vector between the candidate response and the plan. The matching representation between the candidate response and the plan can be used to calculate the correlation between the candidate response and the plan, thereby facilitating the selection of a response that is more consistent with the plan.
[0120] The process for generating a matching score corresponding to a candidate response according to an embodiment of the present disclosure may also include generating a matching representation between the context and the plan, such as a matching matrix between each utterance in the context and the plan, a matching cube between the context and the plan, and a matching vector between the context and the plan. The matching representation between the context and the plan can be used to help the matching model "remember" how much information in the plan has been conveyed in the context, which will implicitly facilitate the selection of a candidate response that is consistent with the plan.
[0121] It should be understood that the above Figures 1 to 10 The described process for generating a matching score corresponding to a candidate response is merely exemplary. Depending on actual application requirements, the process for generating a matching score may include any other steps, and may include more or fewer steps. For example, although in the above description, the matching score corresponding to the candidate response is generated based on the matching representation between the candidate response and the context, the matching representation between the candidate response and the plan, and the matching representation between the context and the plan, in some embodiments, the matching score corresponding to the candidate response may be generated based only on the matching representation between the candidate response and the context, the matching representation between the context and the plan, and the matching representation between the context and the plan. For example, the matching score corresponding to the candidate response may be generated based only on the matching representation between the candidate response and the context and the matching representation between the candidate response and the plan.
[0122] In order to more effectively track which information in the plan has been communicated in the context of the conversation, so that the selection of candidate responses focuses on the information in the plan that has not yet been communicated in the context, an embodiment of the present disclosure proposes a plan update mechanism and a corresponding matching model based on the updated plan. Fig.11 An exemplary process 1100 for obtaining a matching score using a matching model based on an update plan according to an embodiment of the present disclosure is shown.
[0123] In process 1100, the matching model 1110 based on the update plan can obtain a plan 1102 corresponding to the dialogue. The matching model 1110 based on the update plan can also obtain a context 1104 associated with a previous utterance in the dialogue, which can include all utterances in the conversation in which the previous utterance is located, such as utterance 1 1104-1, utterance 2 1104-2, ..., utterance n 1104-n, where utterance i 1104-i represents the i-th utterance in the context, and utterance n 1104-n can be a previous utterance. In addition, the matching model 1110 based on the update plan can also obtain a set of candidate responses 1106 from a database (not shown) to which it is connected or contained, which can include multiple candidate responses. The following takes the candidate response 1108 in the set of candidate responses 1106 as an example to illustrate an exemplary process for obtaining a matching score 1120 for the candidate response 1108.
[0124] The update plan-based matching model 1110 may include, for example, a representation generation part 1112 , a matching part 1114 , an aggregation part 1116 , and the like.
[0125] Through the representation generation part 1112, a multi-level self-attention representation of each utterance i in the context 1104 and a multi-level self-attention representation of the candidate response 1108 can be generated. The representation generation part 1112 may include a plan updating unit 1118. Through the plan updating unit 1118, a multi-level self-attention representation based on an update mechanism of the plan 1102 can be generated. The representation generation part 1112 can further use these multi-level self-attention representations to generate a multi-level mutual attention representation based on an update mechanism of utterance i-plan, a multi-level mutual attention representation of candidate response-utterance i, and a multi-level mutual attention representation based on an update mechanism of candidate response-plan. This will be combined later. Fig.12 To explain the specific structure of the generation part 1112.
[0126] Through the matching part 1114, a matching process can be performed based on the multi-level self-attention representation and the multi-level mutual attention representation generated by the representation generation part 1112 to generate a matching matrix based on the update mechanism between each utterance in the context and the plan, a matching matrix between the candidate response and each utterance in the context, and a matching matrix based on the update mechanism between the candidate response and the plan. The aggregation part 1116 can generate a matching score 1120 corresponding to the candidate response 1108 based on these matching matrices.
[0127] Fig.12 FIG. 1 shows an exemplary structure of the representation generation part 1200 according to an embodiment of the present disclosure. The representation generation part 1200 may correspond to Fig.11 The representation generation part 1112 in.
[0128] At the beginning of the conversation, the original multi-level self-attention representation of the plan can be generated based on the plan 1202 by the plan self-attention generation unit 1208. Plan 1202 may correspond to Fig.11 Plan 1102 in. Original multi-level self-attention representation of the plan Can be equivalent to the above combination Figures 1 to 10 Multi-level self-attention representation of the described scheme This can be done, for example, by Figure 3 The process 300 is used to generate.
[0129] Through the utterance i self-attention generation unit 1210, a multi-level self-attention representation of utterance i 1204 can be generated Discourse i 1204 may correspond to Fig.11 The utterance i 1104-i in . can be, for example, Figure 3 The process 310 in the above example generates a multi-level self-attention representation of utterance i 1204.
[0130] Through the candidate response self-attention generation unit 1212, a multi-level self-attention representation of the candidate response 1206 can be generated Candidate response 1206 may correspond to Fig.11 Candidate response 1108 in . This can be done, for example, by Figure 3 The process 320 in the above embodiment is used to generate a multi-level self-attention representation of the candidate response 1206.
[0131] The plan updating unit 1214 can update the multi-level self-attention representation of the plan generated by the plan self-attention generating unit 1208 based on the multi-level self-attention of the utterance i generated by the utterance i self-attention generating unit 1210. The plan updating unit 1214 can correspond to Fig.11 The plan update unit 1118 in. Fig.13 An exemplary process 1300 for plan updating according to an embodiment of the disclosure is shown. Fig.13 The process of planning update is explained by taking the self-attention representation at level l as an example.
[0132] At the beginning of the conversation, the context in the conversation may include utterance 1. In addition, the conversation may have a corresponding plan. The self-attention representation of utterance 1 can be obtained and the original self-attention representation of the plan For example, Figure 3 The process 310 in the above example generates the self-attention representation of utterance 1. And through Figure 3 The process 300 in the above example generates the original self-attention representation of the plan. Original self-attention representation of the plan can be thought of as the planned self-attention representation corresponding to utterance 1.
[0133] According to an embodiment of the present disclosure, the planned self-attention representation can be updated round by round based on each utterance in the context of the conversation. For example, the self-attention representation of utterance 1 can be updated round by round based on Original self-attention representation for the plan Update to obtain the planned self-attention representation corresponding to utterance 2 Among them, utterance 2 is the next utterance of utterance 1. Similarly, we can express utterance i based on its self-attention The self-attention representation corresponding to utterance i for the plan Update to obtain the planned self-attention representation corresponding to utterance i+1 Where utterance i+1 is the next utterance after utterance i.
[0134] In one embodiment, based on the self-attention representation of utterance i The self-attention representation corresponding to utterance i for the plan When updating, we can first update the self-attention representation of utterance i and the planned self-attention representation corresponding to utterance i For example, the self-attention representation of utterance i can be calculated and planned self-attention representation The cosine similarity between is shown in the following formula:
[0135]
[0136] where j represents the jth word in utterance i, and k represents the kth word in the plan.
[0137] Afterwards, you can Summing to calculate the vector vector Self-attention representation that reflects planning How much information has been conveyed by utterance i in . The vector can be calculated, for example, by the following formula
[0138]
[0139]
[0140] in, represents the number of words in utterance i, n p represents the number of words in the plan, and γ∈[0,1] is a trainable decay coefficient. The decay coefficient γ can be used to control the self-attention representation of the plan The attenuation degree of the information conveyed by utterance i in . The larger the γ value, the higher the attenuation degree.
[0141] After obtaining the vector Afterwards, the information in utterance i can be reduced in the planned self-attention representation corresponding to utterance i The weights in the self-attention representation of the plan Updated to the planned self-attention representation corresponding to utterance i+1 As shown in the following formula:
[0142]
[0143] It should be understood that each time the self-attention representation of a plan is updated based on an utterance, the weight of the information in the utterance in the previous self-attention representation of the plan will be reduced, resulting in a continuous decay effect. In the case where the context includes n utterances, n update operations can be performed, and each operation can obtain a corresponding representation of the plan. These representations can constitute a multi-level self-attention representation of the plan based on the update mechanism, including, for example in can be a planned multi-level self-attention representation corresponding to utterance i, and It can be a planned multi-level self-attention representation corresponding to the candidate responses. can be thought of as a prior multi-level self-attention representation of the plan, and It can be thought of as a current multi-level self-attention representation of the plan.
[0144] Return to reference Fig.12 It should be understood that plan 1202 is only used in the original multi-level self-attention representation of the generated plan When used, it means It is based on the expression To generate.
[0145] Planned multi-level self-attention representation based on updating mechanism The multi-level self-attention representation of utterance i can be further used to generate a multi-level mutual attention representation of utterance i-plan based on the updating mechanism at 1216 and Can be done with Figure 4 A similar process is used to generate a multi-level mutual attention representation based on the update mechanism of the discourse i-plan. and As shown in the following formula:
[0146]
[0147]
[0148] The multi-level self-attention representation of utterance i generated by the utterance i self-attention generation unit 1210 and the multi-level self-attention representation of the candidate response generated by the candidate response self-attention generation unit 1212 Can be further used to generate candidate responses at 1218 - utterance i multi-level mutual attention representation and The candidate response-utterance i multi-level mutual attention representation can be generated, for example, by formulas (6)-(7) and
[0149] The multi-level self-attention representation of the plan based on the update mechanism generated by the plan self-attention generation unit 1208 and the multi-level self-attention representation of the candidate response generated by the candidate response self-attention generation unit 1212 The multi-level mutual attention representation based on the updating mechanism can be further used to generate a candidate response-plan at 1220 and The multi-level mutual attention representation based on the updating mechanism of the candidate response-plan can be generated, for example, by the following formula and
[0150]
[0151]
[0152] pass Fig.11 The representation generation part 1112 or Fig.12 The representation generation part 1200 in the method can generate multi-level self-attention representations, such as multi-level self-attention representations based on the update mechanism of the plan, multi-level self-attention representations of each utterance in the context, and multi-level self-attention representations of the candidate responses, as well as multi-level mutual attention representations, such as multi-level mutual attention representations based on the update mechanism of utterance i-plan, multi-level mutual attention representations of candidate response-utterance i, and multi-level mutual attention representations based on the update mechanism of candidate response-plan. These representations can be combined into a representation set. The representation set can be provided to the matching part and the aggregation part in the matching model based on the update plan, such as Fig.11 The matching portion 1114 and the aggregation portion 1116 in the flowchart are combined to obtain a matching score corresponding to the candidate response.
[0153] Return to reference Fig.11 , the matching portion 1114 may have Figure 5 For example, the matching part 1114 may include a matching matrix generation unit between utterance i and plan based on an update mechanism, a matching matrix generation unit between candidate responses and utterance i, and a matching matrix generation unit between candidate responses and plan based on an update mechanism.
[0154] The matching matrix generation unit between the candidate response and the utterance i can be used to generate the matching matrix between the candidate response and the utterance i Can be done with Figure 6 A similar process is used to generate a matching matrix between candidate responses and utterance i.
[0155] The matching matrix generation unit between utterance i and plan based on the updating mechanism can be used to generate the matching matrix between utterance i and plan based on the updating mechanism Can be done with Figure 6 The matching matrix between utterance i and the plan based on the updating mechanism is generated by a similar process to the process 600 for generating the matching matrix between utterance i and the plan in FIG. But the matching matrix generated based on the update mechanism The correlation operation involved is performed on the self-attention representation of utterance i and the planned self-attention representation corresponding to utterance i. Assume that the multi-level self-attention representation of utterance i can be expressed as And the planned multi-level self-attention representation corresponding to utterance i can be expressed as The correlation operation performed on the self-attention representation of utterance i and the self-attention representation of the plan can be expressed, for example, by the following formula, such as a dot product operation, which can obtain the self-attention matching matrix based on the update mechanism at level l of utterance i and the plan
[0156]
[0157] Among them, l∈{0,1,…,L}. Each element in is The jth word in represents The dot product of the k-th word representation in .
[0158] The self-attention matching matrix based on the update mechanism at each level of the discourse i and the plan can be Combine, for example, cascade, to obtain the self-attention matching matrix between discourse i and the plan based on the update mechanism As shown in the following formula:
[0159]
[0160] Similarly, the correlation operation, such as the dot product operation, performed on the mutual attention representation of utterance i and the plan can be expressed, for example, by the following formula, which can obtain the mutual attention matching matrix based on the update mechanism at level l of utterance i and the plan
[0161]
[0162] The mutual attention matching matrix based on the updating mechanism at each level of discourse i and plan can be Combine, for example, cascade, to obtain the mutual attention matching matrix between discourse i and the plan based on the update mechanism As shown in the following formula:
[0163]
[0164] Then, the self-attention matching matrix based on the update mechanism of utterance i and the plan can be and the mutual attention matching matrix between discourse i and the plan based on the updating mechanism Combine, for example, cascade, to obtain a matching matrix between discourse i and the plan based on the update mechanism As shown in the following formula:
[0165]
[0166] The matching matrix generation unit based on the updating mechanism between the candidate response and the plan can be used to generate a matching matrix based on the updating mechanism between the candidate response and the plan. In one embodiment, the matching matrix can be generated based on the multi-level self-attention representation of the candidate response. and the planned multi-level self-attention representation corresponding to the candidate responses Through Figure 6 A matching matrix between a candidate response and a plan based on an update mechanism is generated by a similar process to the process 600 for generating a matching matrix between an utterance i and a plan in FIG.
[0167] The matching matrix between discourse i and the plan generated by the above process based on the updating mechanism is The matching matrix between candidate responses and utterance i and the matching matrix between candidate responses and plans based on the updating mechanism can be provided to the aggregation part of the matching model based on the update plan, e.g. Fig.11 The polymerized portion 1116 in.
[0168] Return to reference Fig.11 , the polymeric portion 1116 may have Figure 5 For example, the aggregation part 1116 may include a matching cube generation unit between the context and the plan based on an update mechanism, a matching vector generation unit between the context and the plan based on an update mechanism, a matching cube generation unit between the candidate response and the context, a matching vector generation unit between the candidate response and the context, a matching vector generation unit between the candidate response and the plan based on an update mechanism, and a matching score generation unit based on an update mechanism.
[0169] The matching cube generation unit between the candidate response and the context and the matching vector generation unit between the candidate response and the context can be used to generate a matching cube Q between the candidate response and the contextrc and the matching vector f(r,c). This can be done by Figure 7 A similar process is used to generate a matching cube Q between the candidate response and the context. rc and the matching vector f(r,c) between the candidate response and the context.
[0170] The matching vector generation unit based on the update mechanism between the candidate response and the plan can be used to generate a matching vector f′(r,p) based on the update mechanism between the candidate response and the plan. Through Fig. 9 A matching vector f′(r, p) between the candidate response and the plan is generated by a process similar to process 900 in FIG.
[0171] The matching cube generation unit based on the update mechanism between the context and the plan and the matching vector generation unit based on the update mechanism between the context and the plan can be used to generate a matching cube Q based on the update mechanism between the context and the plan c ′ p and matching vector f′(c,p). The matching matrix based on the updating mechanism between each utterance in the context and the plan can be Through Figure 7 The matching cube Q between context and plan is generated by a similar process in c ′ p and matching vector f′(c,p).
[0172] During the conversation, the utterances in the context are increased round by round. Therefore, the matching cube, matching vector, etc. between the context and the plan can be generated by updating in a round-by-round manner. For example, an additional matching matrix can be generated based on the latest utterance in the context, that is, the previous utterance, and a matching cube based on an update mechanism between the context and the plan can be generated by using the additional matching matrix to update the previous matching cube associated with an utterance in the context that is located before the previous utterance. The obtained matching cube can then be used to generate a matching vector. Fig.14 An exemplary process 1400 of generating a matching cube between a context and a plan based on an update mechanism by using an additional matching matrix according to an embodiment of the present disclosure is shown.
[0173] In process 1400, the previous utterance in the context, such as utterance nu, may first be obtained. n , a previous utterance, for example utterance n-1u n-1 , the associated previously matched cube Previously matched cube It can be based on the utterance n-1u n-1 The associated previous context and the corresponding plan representation are generated. n-1 The associated previous context may include, for example, utterance 1u1, utterance 2u1, ..., utterance n-1u n-1 , these utterances can be expressed separately with the plan Corresponding.
[0174] After obtaining the previous utterance in the conversation, such as utterance nu n , we can for example Figure 3 The process 310 in the above example generates a multi-level self-attention representation of utterance n.
[0175] It is also possible to obtain a multi-level self-attention representation of the plan corresponding to the previous utterance For example, Fig.13 The process 1300 in FIG. 1300 is used to generate a multi-level self-attention representation of the plan corresponding to the previous utterance
[0176] Then, we can use the multi-level self-attention representation of utterance n as and the planned multi-level self-attention representation corresponding to the previous utterance To generate a multi-level mutual attention representation based on the updating mechanism of discourse n-plan and For example, Figure 4 The process 400 in the above embodiment is used to generate a multi-level mutual attention representation based on an updating mechanism for the discourse n-plan. and
[0177] Next, at 1402, the multi-level self-attention representation of utterance n may be used. Planned multi-level self-attention representation corresponding to previous utterances And multi-level mutual attention representation based on update mechanism for discourse n-plan and To generate an additional matching matrix For example, Figure 6 The process 600 in the embodiment of the present invention is used to generate an additional matching matrix.
[0178] At 1404, the previously matched cube may be and additional matching matrix Combine to generate a matching cube Q between context and plan c ′p The matching cube Q c ′ p It can then be used to obtain a matching vector f′(c,p) between the context and the plan based on an update mechanism.
[0179] After obtaining the update mechanism-based matching vector f′(c,p) between the context and the plan, the matching vector f(r,c) between the candidate response and the context, and the update mechanism-based matching vector f′(r,p) between the candidate response and the plan, an update mechanism-based matching score g′(r,c,p) corresponding to the candidate response can be generated based on these matching vectors.
[0180] The process for generating the matching score g′(r,c,p) based on the update mechanism can be similar to Fig.10 The process 1000 for generating a matching score in is similar to that in FIG. For example, the matching vector f′(c, p) based on the update mechanism between the context and the plan, the matching vector f′(r, c) between the candidate response and the context, and the matching vector f′(r, p) based on the update mechanism between the candidate response and the plan can be combined, such as cascaded, to generate a comprehensive vector f′(r, c, p), as shown in the following formula:
[0181] f′(r,c,p)=[ f′(c,p)⊕f(r,c)⊕f′(r,p)] (31)
[0182] The generated comprehensive vector f′(r,c,p) can be provided as input to a multi-layer perceptron (MLP) with a sigmoid activation function to generate a matching score g′(r,c,p) based on an update mechanism corresponding to the candidate response, as shown in the following formula:
[0183] g′(r,c,p)=sigmoid(W ′T ·f′(r,c,p)+b′) (32)
[0184] Among them, W ′T and b′ are trainable parameters.
[0185] The matching model based on the update plan according to the embodiment of the present disclosure can be trained based on the training data set, for example Fig.11 The training data set may be the same training data set as the training data set used to train the matching model based on the plan, that is, the training data set By using the training data set The associated objective function L′(θ) is minimized to train the matching model based on the update plan. In one embodiment, the objective function L′(θ) can be defined as the cross entropy loss, as shown in the following formula:
[0186]
[0187] Where g′(r,c,p) is the matching score based on the update mechanism corresponding to the candidate response r, which can be obtained by combining the above Figures 11 to 14 The described process is obtained.
[0188] Combination of the above Figures 11 to 14 A process for generating matching scores corresponding to candidate responses using a matching model based on an updated plan according to an embodiment of the present disclosure is described. The matching model based on the updated plan can track which information in the plan has been communicated in the context of the conversation, and the selection of candidate responses will focus on information that has not been communicated in the plan. This can enable the selected candidate responses to convey information that has not been communicated in the context of the plan, and can cause the order of information in the conversation to be consistent with the order of the plan.
[0189] It should be understood that the above Figures 11 to 14 The process described for generating a matching score based on the update mechanism corresponding to the candidate response is merely exemplary. Depending on the actual application requirements, the process for generating a matching score based on the update mechanism may include any other steps, and may include more or fewer steps. For example, although in the above, the matching score based on the update mechanism corresponding to the candidate response is generated based on the matching representation between the candidate response and the context, the matching representation based on the update mechanism between the candidate response and the plan, and the matching representation based on the update mechanism between the context and the plan, in some embodiments, the matching score based on the update mechanism corresponding to the candidate response may be generated based on only one or both of the matching representation between the candidate response and the context, the matching representation based on the update mechanism between the candidate response and the plan, and the matching representation based on the update mechanism between the context and the plan. For example, the matching score based on the update mechanism corresponding to the candidate response may be generated based only on the matching representation between the candidate response and the context and the matching representation based on the update mechanism between the candidate response and the plan.
[0190] Fig.15 An exemplary chat flow 1500 according to an embodiment of the present disclosure is shown. Chat flow 1500 may occur between a chatbot and a user. The chatbot may include a matching model based on a plan or a matching model based on an update plan according to an embodiment of the present disclosure.
[0191] At 1502, a plan for the chatbot may be obtained, such as "I don't want to talk, please don't bother me anymore."
[0192] At 1504, the user may enter the initial utterance "Chat with me for a while."
[0193] At 1506, the chatbot may output a response “I want to hear you say that you don’t want to chat with me” through a program-guided response provision process according to an embodiment of the present disclosure.
[0194] At 1508, the user may enter the words "You have no idea how much I want to chat with you."
[0195] At 1510 , the chatbot may output a response “Of course, as long as you feel good about it” through a plan-guided response providing process according to an embodiment of the present disclosure.
[0196] At 1512, the user may enter the words "I am very happy chatting with you."
[0197] At 1514 , the chatbot may output a response “Let’s chat next time” through a plan-guided response provision process according to an embodiment of the present disclosure.
[0198] It can be seen from the chat flow 1500 that although the three rounds of speech input by the user all convey the message that he wants to chat with the chat robot, the three rounds of responses output by the chat robot all convey the message that he does not want to chat, which is consistent with the plan at 1502 "I don't want to talk, please don't bother me anymore".
[0199] According to the embodiment of the present disclosure, the matching model based on the plan or the matching model based on the updated plan can be used not only to provide a response in the conversation between the chatbot and the user, that is, to provide only the speech of the chatbot in the conversation, but also to provide the speech of both parties or more parties in the conversation. That is, according to the embodiment of the present disclosure, the matching model based on the plan or the matching model based on the updated plan can be used to generate a conversation. Fig.16 A specific example 1600 of generating a dialog according to an embodiment of the present disclosure is shown.
[0200] Example 1600 may include a plan “Lucy doesn't like going home. Tom decides to go home late because he is worried about Lucy's safety. Tom is Lucy's best friend.” The plan may include three key information, such as “doesn't like going home,” “goes home late,” and “best friend.”
[0201] Example 1600 may also include an initial utterance "My mother urged me to go back." In one embodiment, the initial utterance may be pre-specified. For example, the initial utterance matching the plan may be manually written. In another embodiment, the initial utterance may be retrieved from a corpus based on the plan. For example, an utterance matching the plan retrieved from a database containing movie dialogues may be used as the initial utterance. When determining the initial utterance, the speaker of the initial utterance, such as Tom, may also be determined at the same time.
[0202] Subsequent utterances in a conversation can be provided based on a plan and initial utterances through a response provision process guided by a plan according to an embodiment of the present disclosure. The first round of utterances may be, for example, "Sit for a while longer" said by Lucy. The information expressed in this round of utterances is consistent with the key information in the plan, "I don't like going home." The second round of utterances may be, for example, "Okay, Lucy, I'll stay." The information expressed in this round of utterances is consistent with the key information in the plan, "Go home late." The third round of utterances may be, for example, "Tom, I'd like to be with you" said by Lucy. The fourth round of utterances may be, for example, "I'm your best friend" said by Tom. The information expressed in the third and fourth rounds of utterances is consistent with the key information in the plan, "best friend."
[0203] It can be seen from example 1600 that the first to fourth rounds of utterances provided according to an embodiment of the present disclosure convey all key information in the plan, and the order of information in the first to fourth rounds of utterances is consistent with the order of information in the plan.
[0204] Fig.17 is a flow chart of an exemplary method 1700 for planning guided response provision according to an embodiment of the disclosure.
[0205] At step 1710, a context associated with a previous utterance in a conversation may be obtained, the context including at least the previous utterance.
[0206] At step 1720, a current plan representation of a plan corresponding to the conversation can be obtained.
[0207] At step 1730, for each candidate response in a set of candidate responses, a first matching representation may be generated based on the candidate response and the context, a second matching representation may be generated based on the candidate response and the current plan representation, and a matching score corresponding to the candidate response may be calculated based on at least the first matching representation and the second matching representation.
[0208] At step 1740, a candidate response having a highest match score from the set of candidate responses may be provided in the dialog.
[0209] In one embodiment, the method 1700 may further include: generating a third matching representation based on the context and the current plan representation. The calculating the matching score may include: calculating the matching score based on the first matching representation, the second matching representation, and the third matching representation.
[0210] The generating of the third matching representation may include: generating an additional matching representation based on the previous utterance and the current plan representation; and obtaining the third matching representation by updating the previous matching representation using the additional matching representation, wherein the previous matching representation is generated based on a previous context associated with an utterance before the previous utterance and the current plan representation.
[0211] In one embodiment, obtaining the current plan representation may include: updating the previous plan representation corresponding to the previous utterance to the current plan representation based on the previous utterance. The updating may include: reducing the weight of information in the previous utterance in the previous plan representation.
[0212] The method 1700 may further include: generating a third matching representation based on the context and the previous plan representation. The calculating the matching score may include: calculating the matching score based on the first matching representation, the second matching representation, and the third matching representation.
[0213] The generating of the third matching representation may include: generating an additional matching representation based on the previous utterance and the previous plan representation; and obtaining the third matching representation by updating the previous matching representation using the additional matching representation, wherein the previous matching representation is generated based on a previous context associated with an utterance before the previous utterance and a corresponding plan representation.
[0214] In one implementation, the initial utterance in the conversation may be received from the user, pre-specified, or retrieved from a corpus based on the plan.
[0215] In one embodiment, the plan may include at least one sentence.
[0216] In one implementation, the plan may be determined based on the context.
[0217] In one embodiment, the plan may be selected from a set of candidate plans. The set of candidate plans may be extracted from a corpus, or generated based on sentences related to a predefined topic retrieved from the corpus.
[0218] It should be understood that method 1700 may also include any steps / processes for planning guided response provision according to the above-mentioned embodiments of the present disclosure.
[0219] Fig.18 An exemplary apparatus 1800 for plan-guided response provision according to an embodiment of the present disclosure is shown. The apparatus 1800 may include: a context acquisition module 1810, for obtaining a context associated with a previous utterance in a conversation, the context including at least the previous utterance; a plan representation acquisition module 1820, for obtaining a current plan representation of a plan corresponding to the conversation; a calculation module 1830, for generating, for each candidate response in a set of candidate responses, a first matching representation based on the candidate response and the context, a second matching representation based on the candidate response and the current plan representation, and a matching score corresponding to the candidate response based at least on the first matching representation and the second matching representation; and a response providing module 1840, for providing, in the conversation, a candidate response with the highest matching score in the set of candidate responses.
[0220] In one embodiment, the apparatus 1800 may further include: a third matching representation generating module, configured to generate a third matching representation based on the context and the current plan representation. The calculating module may also be configured to: calculate the matching score based on the first matching representation, the second matching representation and the third matching representation.
[0221] The third match representation generation module can also be configured to: generate an additional match representation based on the previous utterance and the current plan representation; and obtain the third match representation by updating the previous match representation using the additional match representation, wherein the previous match representation is generated based on a previous context associated with an utterance before the previous utterance and the current plan representation.
[0222] In one embodiment, the plan representation obtaining module 1820 may also be configured to: based on the previous utterance, update the previous plan representation corresponding to the previous utterance to the current plan representation. The updating may include: reducing the weight of the information in the previous utterance in the previous plan representation.
[0223] The apparatus 1800 may further include: a third matching representation generating module, configured to generate a third matching representation based on the context and the previous plan representation. The calculating module may further be configured to: calculate the matching score based on the first matching representation, the second matching representation and the third matching representation.
[0224] The third match representation generation module can also be configured to: generate an additional match representation based on the previous utterance and the previous plan representation; and obtain the third match representation by updating the previous match representation using the additional match representation, wherein the previous match representation is generated based on a previous context associated with an utterance before the previous utterance and a corresponding plan representation.
[0225] It should be understood that the apparatus 1800 may also include any other modules configured for plan-guided response provision according to the above-mentioned embodiments of the present disclosure.
[0226] Fig.19 An exemplary apparatus 1900 for planning guided response provision according to an embodiment of the present disclosure is shown.
[0227] The apparatus 1900 may include at least one processor 1910. The apparatus 1900 may further include a memory 1920 connected to the processor 1910. The memory 1920 may store computer executable instructions, which, when executed, cause the processor 1910 to perform any operation of the method for providing a plan-guided response according to the above-mentioned embodiments of the present disclosure.
[0228] The embodiments of the present disclosure may be implemented in a non-transitory computer-readable medium. The non-transitory computer-readable medium may include instructions, which, when executed, cause one or more processors to perform any operation of the method for providing a plan-guided response according to the embodiments of the present disclosure described above.
[0229] It should be understood that all operations in the method described above are merely exemplary, and the present disclosure is not limited to any operations in the method or the order of these operations, but should cover all other equivalent transformations under the same or similar concept.
[0230] It should also be understood that all modules in the above described device can be implemented in various ways. These modules can be implemented as hardware, software, or a combination thereof. In addition, any module in these modules can be further divided into submodules or combined together functionally.
[0231] Processors have been described in conjunction with various devices and methods. These processors can be implemented using electronic hardware, computer software or any combination thereof. Whether these processors are implemented as hardware or software will depend on specific application and the overall design constraints imposed on the system. As an example, the processor provided in the present disclosure, any part of the processor or any combination of processors can be implemented as a microprocessor, a microcontroller, a digital signal processor (DSP), a field programmable gate array (FPGA), a programmable logic device (PLD), a state machine, a gate logic, a discrete hardware circuit, and other suitable processing components configured to perform the various functions described in the present disclosure. The function of the processor provided in the present disclosure, any part of the processor or any combination of processors can be implemented as software executed by a microprocessor, a microcontroller, a DSP or other suitable platforms.
[0232] Software should be broadly considered to represent instructions, instruction sets, codes, code segments, program codes, programs, subroutines, software modules, applications, software applications, software packages, routines, subroutines, objects, running threads, processes, functions, etc. Software can reside in a computer-readable medium. A computer-readable medium can include, for example, a memory, which can be, for example, a magnetic storage device (e.g., a hard disk, a floppy disk, a magnetic stripe), an optical disk, a smart card, a flash memory device, a random access memory (RAM), a read-only memory (ROM), a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), a register, or a removable disk. Although the memory is shown as being separated from the processor in the various aspects provided in the present disclosure, the memory can also be located inside the processor (e.g., a cache or a register).
[0233] The above description is provided to enable any person skilled in the art to implement the various aspects described herein. Various modifications to these aspects are apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects. Therefore, the claims are not intended to be limited to the aspects shown herein. All structural and functional equivalents of the elements of the various aspects described in this disclosure that are known or to be known to those skilled in the art will be covered by the claims.
Claims
1. A method for planning guided response provision, comprising: Obtaining a context associated with a previous utterance in a conversation, the context comprising at least the previous utterance; obtaining a current plan representation of a plan corresponding to the conversation, the plan defining an overall plan or plot of the conversation; For each candidate response in a set of candidate responses, generating a first matching representation based on the candidate response and the context, generating a second matching representation based on the candidate response and the current plan representation, generating a third matching representation based on the context and the current plan representation, and calculating a matching score corresponding to the candidate response based on at least the first matching representation, the second matching representation, and the third matching representation; as well as A candidate response having a highest match score among the set of candidate responses is provided in the dialog.
2. The method according to claim 1, wherein: Generating the third matching representation comprises: generating an additional matching representation based on the previous utterance and the current plan representation; and The third match representation is obtained by updating a previous match representation with the additional match representation, the previous match representation being generated based on a previous context associated with an utterance preceding the previous utterance and the current plan representation.
3. The method according to claim 1, wherein: The obtaining of the current plan representation includes: Based on the previous utterance, a previous plan representation corresponding to the previous utterance is updated to the current plan representation.
4. The method according to claim 3, wherein: The updates include: The information in the previous utterance is downweighted in the previous plan representation.
5. The method according to claim 3, wherein: Generating the third matching representation comprises: The third matching representation is generated based on the context and the previous plan representation.
6. The method according to claim 5, wherein: Generating the third matching representation comprises: generating an additional matching representation based on the previous utterance and the previous plan representation; and The third match representation is obtained by updating a previous match representation with the additional match representation, the previous match representation being generated based on a previous context associated with an utterance preceding the previous utterance and a corresponding plan representation.
7. The method according to claim 1, wherein: The initial utterance in the conversation is received from the user, pre-specified, or retrieved from a corpus based on the plan.
8. The method according to claim 1, wherein: The plan includes at least one sentence.
9. The method according to claim 1, wherein: The plan is determined based on the context.
10. The method according to claim 1, wherein: The plan is selected from a set of candidate plans.
11. The method according to claim 10, wherein: The set of candidate plans is extracted from a corpus or generated based on sentences related to a predefined topic retrieved from the corpus.
12. An apparatus for plan-guided response provision, comprising: A context obtaining module, configured to obtain a context associated with a previous utterance in a conversation, wherein the context includes at least the previous utterance; a plan representation obtaining module for obtaining a current plan representation of a plan corresponding to the conversation, the plan defining a global plan or plot of the conversation; a calculation module, configured to generate, for each candidate response in a set of candidate responses, a first matching representation based on the candidate response and the context, generate a second matching representation based on the candidate response and the current plan representation, generate a third matching representation based on the context and the current plan representation, and calculate a matching score corresponding to the candidate response based on at least the first matching representation, the second matching representation, and the third matching representation; as well as A response providing module is used to provide a candidate response with a highest matching score among the set of candidate responses in the dialog.
13. The device according to claim 12, wherein: The computing module is further configured to: generating an additional matching representation based on the previous utterance and the current plan representation; and The third match representation is obtained by updating a previous match representation with the additional match representation, the previous match representation being generated based on a previous context associated with an utterance preceding the previous utterance and the current plan representation.
14. The device according to claim 12, wherein: The plan representation obtaining module is further configured to: Based on the previous utterance, a previous plan representation corresponding to the previous utterance is updated to the current plan representation.
15. The device according to claim 14, wherein: The updates include: The information in the previous utterance is downweighted in the previous plan representation.
16. The device according to claim 14, wherein: Generating the third matching representation comprises: The third matching representation is generated based on the context and the previous plan representation.
17. The device according to claim 16, wherein: Generating the third matching representation comprises: generating an additional matching representation based on the previous utterance and the previous plan representation; and The third match representation is obtained by updating a previous match representation with the additional match representation, the previous match representation being generated based on a previous context associated with an utterance preceding the previous utterance and a corresponding plan representation.
18. An apparatus for plan-guided response provision, comprising: at least one processor; as well as a memory storing computer executable instructions that, when executed, cause the at least one processor to: obtaining a context associated with a previous utterance in the conversation, the context comprising at least the previous utterance, obtaining a current plan representation of a plan corresponding to the conversation, the plan defining an overall plan or plot for the conversation, For each candidate response in a set of candidate responses, generating a first matching representation based on the candidate response and the context, generating a second matching representation based on the candidate response and the current plan representation, generating a third matching representation based on the context and the current plan representation, and calculating a matching score corresponding to the candidate response based on at least the first matching representation, the second matching representation, and the third matching representation, and A candidate response having a highest match score among the set of candidate responses is provided in the dialog.
Citation Information
Patent Citations
Method and system for keeping conversation continuity of conversation system
CN106776828A
Dialog method and device based on artificial intelligence and computer readable medium
CN108170749A