Robot dialogue method, device, electronic device and storage medium
Through the self-attention coding technology of the dialogue model, the problem of passive answering by the customer service robot is solved, and high-accuracy interaction with the target object is achieved. By identifying relevant information in the dialogue rounds, the current dialogue strategy is determined, and the accuracy of the robot dialogue is improved. effectiveness.
Patent Information
- Application Number
- CN202011279865.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-16
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-11-16
AI Technical Summary
Existing customer service robots are in a passive answering position and cannot effectively interact with target objects.
By obtaining the current input content, including historical dialogue content, current input sentence, intent data and previous dialogue strategy, the trained dialogue model is used for self-attention encoding to determine the current dialogue status and strategy of the robot, and output the corresponding reply sentence.
It achieves high accuracy and effectiveness of the robot's dialogue strategy. It can automatically ignore useless information according to the dialogue status, locate relevant dialogue rounds, and determine the current dialogue strategy, thereby improving the accuracy and interaction effect of the dialogue.
Smart Images

Figure CN112256856B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer programs, and in particular to a robot dialogue method, device, electronic device and storage medium. Background Art
[0002] With the continuous development and maturity of artificial intelligence technology in recent years, intelligent dialogue robots, such as customer service robots, are gradually sharing some simple tasks of traditional manual customer service and solving problems of target objects quickly and efficiently.
[0003] Most of the existing customer service robots return matching answers by searching corpora, knowledge graphs or question-and-answer knowledge bases. They are target-oriented question-and-answer systems.
[0004] The inventors discovered during the process of implementing the present invention that the existing robot dialogue method has at least one problem: the robot in a passive answering position cannot effectively interact with the target object. Summary of the invention
[0005] The embodiments of the present invention provide a robot dialogue method, device, electronic device and storage medium, which solve the problem that a robot in a passive answering position cannot effectively interact with a target object.
[0006] In a first aspect, an embodiment of the present invention provides a robot dialogue method, comprising:
[0007] Obtaining current input content, wherein the current input content includes historical conversation content of this conversation, the current input sentence of the target object, the intention data corresponding to the current input sentence, and the robot's previous conversation strategy, wherein the previous conversation strategy is the conversation strategy adopted by the robot in the previous conversation round of the current conversation round;
[0008] Inputting the current input content into a trained dialogue model to obtain a current dialogue strategy output by the trained dialogue model;
[0009] Determine a current reply sentence corresponding to the current input sentence according to the current dialogue strategy, and output the current reply sentence to the target object;
[0010] Among them, the trained dialogue model is used to encode the historical dialogue content according to the current input sentence, the intention data and the previous dialogue strategy using a self-attention mechanism, determine the representation data of the robot's current dialogue state according to the encoding result, and determine the robot's current dialogue strategy according to the representation data.
[0011] In a second aspect, an embodiment of the present invention further provides a robot dialogue device, comprising:
[0012] An acquisition module is used to acquire current input content, wherein the current input content includes the historical dialogue content of this dialogue, the current input sentence of the target object, the intention data corresponding to the current input sentence, and the robot's previous dialogue strategy, wherein the previous dialogue strategy is the dialogue strategy adopted by the robot in the previous dialogue round of the current dialogue round;
[0013] A dialogue strategy determination module, used for inputting the current input content into a trained dialogue model to obtain a current dialogue strategy output by the trained dialogue model;
[0014] An output module, configured to determine a current reply sentence corresponding to the current input sentence according to the current dialogue strategy, and output the current reply sentence to the target object;
[0015] Among them, the trained dialogue model is used to encode the historical dialogue content according to the current input sentence, the intention data and the previous dialogue strategy using a self-attention mechanism, determine the representation data of the robot's current dialogue state according to the encoding result, and determine the robot's current dialogue strategy according to the representation data.
[0016] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0017] one or more processors;
[0018] A storage device for storing one or more programs;
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the robot dialogue method as described in any embodiment.
[0020] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions are used to execute the robot dialogue method described in any embodiment when executed by a computer processor.
[0021] The technical solution of the robot dialogue method provided in the embodiment of the present invention automatically ignores useless information in multiple rounds of dialogue content through the encoding mechanism of the trained dialogue model, locates the dialogue rounds in the multiple rounds of dialogue content that are related to the current input content, and determines the current dialogue state representation data according to the robot's dialogue strategy in the relevant round. Since the current dialogue state representation data is determined based on the dialogue content of the relevant dialogue round, it has high accuracy. Therefore, the current dialogue strategy of the robot determined according to the current dialogue state has high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 is a flow chart of a robot dialogue method provided by Embodiment 1 of the present invention;
[0024] Figure 2A is a framework diagram of a learning module provided in Embodiment 1 of the present invention;
[0025] Figure 2B is a framework diagram of another learning module provided in the first embodiment of the present invention;
[0026] Figure 3 is a structural block diagram of a robot dialogue device provided in Embodiment 2 of the present invention;
[0027] Figure 4 It is a structural block diagram of an electronic device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described through implementation methods with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0029] Embodiment 1
[0030] Figure 1 : is a flow chart of a robot dialogue method provided in Embodiment 1 of the present invention. The technical solution of this embodiment is applicable to the case of determining the current dialogue strategy of a robot in a multi-round dialogue scenario. The method can be executed by a robot dialogue device provided in an embodiment of the present invention, which can be implemented in software and / or hardware and configured in a robot processor for application. The method specifically includes the following steps:
[0031] S101. Obtain current input content, wherein the current input content includes historical dialogue content of this dialogue, the current input sentence of the target object, the intention data corresponding to the current input sentence, and the robot's previous dialogue strategy, which is the dialogue strategy adopted by the robot in the previous dialogue round of the current dialogue round.
[0032] Among them, the current input sentence is the sentence currently input by the target object, and the historical dialogue content is the dialogue content between the target object and the robot before the current input sentence, for example, target object 1: the shoes you like are out of stock; robot 1, I am very sorry for the inconvenience; robot 2, what price range do you need, I will recommend it to you; target object 2: for a family of three. For robot 3, the current input sentence is "target object 2: for a family of three", and the historical dialogue content is "target object 1: the shoes you like are out of stock", "robot 1, I am very sorry for the inconvenience", "robot 2, what price range do you need, I will recommend it to you", "target object 2: for a family of three". It can be understood that the input sentence received by the robot can be in text form or in voice form. If it is in voice form, it is preferably converted into text form by a voice recognition method.
[0033] In one embodiment, the historical conversation content includes all conversation contents between the target object and the robot within a preset time from the current moment, so as to avoid the situation where the current input content contains more useless information due to more conversation content and longer conversation time.
[0034] In one embodiment, the historical conversation content includes all conversation contents between the target object and the robot in a preset number of conversation rounds closest to the current moment, so as to avoid the situation where the current input content contains more useless information due to more conversation content and longer conversation time.
[0035] The intention data is a conversation intention determined based on the current input sentence or multiple rounds of conversation content including the current input sentence. The intention data can be determined by using an existing intention determination method, and this embodiment does not make any specific limitations here.
[0036] Among them, the robot can be a chat robot, customer service robot or other electronic device used to provide self-service voice services.
[0037] Among them, the robot's previous dialogue strategy is the strategy used by the robot's latest output dialogue content, such as comfort, recommendation, and urging. For example, target object 1: The shoes you like are out of stock; Robot 1, I am very sorry for the inconvenience; Robot 2, What price range do you need? I will recommend one for you; Target object 2: For a family of three. It can be seen that the dialogue strategy used by robot 2, that is, the robot in the second round of dialogue is recommendation. When this dialogue enters the third round, the dialogue strategy used by the robot in the second round is used as the current previous dialogue strategy.
[0038] In one embodiment, when determining the dialogue strategy of the robot in the first round of dialogue, the preset initial dialogue strategy is used as its previous dialogue strategy. The preset initial dialogue strategy can be wait, start, etc.
[0039] In some embodiments, the current input content also includes a current dialogue turn identifier, which is used to identify the turn of the current dialogue in which the current input statement belongs.
[0040] S102: Input the current input content into the trained dialogue model to obtain the current dialogue strategy output by the dialogue model.
[0041] The trained dialogue model is used to encode one or more rounds of dialogue content in the historical dialogue content using a self-attention mechanism according to the target object's current input statement, intent data and the robot's previous dialogue strategy, so as to obtain representation data of the robot's current dialogue state, and determine the robot's current dialogue strategy based on the representation data, wherein the contribution of the one or more rounds of dialogue content to the current input content is greater than the contribution of other rounds of dialogue content to the current input content.
[0042] It can be understood that the trained dialogue model can automatically ignore the dialogue rounds that have no relevance or little relevance to the current input content in multiple rounds of dialogue, and automatically locate and encode the dialogue rounds that contribute highly to the current input content, so that the characterization data of the robot's current dialogue state determined according to the encoding results has higher accuracy, and the current dialogue strategy determined according to the characterization data of the current dialogue state has higher accuracy.
[0043] like Figure 2A As shown, the dialogue model of this embodiment includes a first module and a second module, wherein the first module uses a self-attention mechanism to encode the dialogue content of one or more rounds in the current input content, and determines the representation data of the current dialogue state of the robot according to the encoding result, wherein the contribution of the dialogue content of the one or more rounds to the current input content is greater than the contribution of the dialogue content of other rounds to the current input content. The second module is used to determine the preset dialogue strategy corresponding to the representation data of the current dialogue state according to the encoding result, and use the preset dialogue strategy as the current dialogue strategy.
[0044] In one embodiment, the second module is used to determine the representation data of each preset dialogue strategy in the candidate set to obtain a set of representation strategies; in the set of representation strategies, determine the preset dialogue strategy corresponding to the representation data with the greatest similarity to the representation data of the current dialogue state, and use the preset dialogue strategy as the current dialogue strategy of the robot; wherein the candidate set stores at least two preset dialogue strategies.
[0045] In one embodiment, the second module is used to determine the representation data of each preset dialogue strategy in the candidate set to obtain a representation strategy set; traverse the representation strategy set, and when a representation data whose similarity with the representation data of the current dialogue state exceeds a preset similarity threshold is detected, the preset dialogue strategy corresponding to the representation data is used as the current dialogue strategy, wherein the candidate set stores at least two preset dialogue strategies
[0046] In one embodiment, the representation strategy set is stored in a set location, and the second module directly determines the preset dialogue strategy corresponding to the representation data with the greatest similarity to the representation data of the current dialogue state in the representation strategy set, and uses the preset dialogue strategy as the current dialogue strategy of the robot.
[0047] Among them, the first module is preferably an encoder module in a Transformer model.
[0048] In this embodiment, the cosine similarity algorithm is preferably used to calculate the similarity between the characterization data of the current state and the characterization data of the preset dialogue strategy.
[0049] It is understandable that the preset dialogue strategies included in the candidate set are related to the application scenario of the robot. For an e-commerce platform robot, the corresponding candidate set preferably includes but is not limited to selling point marketing, urging to buy, appeasing, complimenting, proactive questioning, and product recommendation. For a robot that is applicable to multiple scenarios at the same time, it is preferably configured to include multiple candidate sets, and each candidate set corresponds to an application scenario.
[0050] In some embodiments, Figure 2B As shown, the dialogue model also includes a first fully connected layer and a second fully connected layer. The first fully connected layer is used to convert the representation data of the current state to a preset vector space to update the representation data of the current state; the second fully connected layer is used to convert the representation data of each historical dialogue strategy in the historical strategy set to the preset vector space to update the representation data of each historical dialogue strategy. In other words, the dimension of the updated representation data of the current state is the same as the dimension of the updated representation data of the preset dialogue strategy, so that the changing strategy space can be effectively coped with, and the scalability of the system is improved.
[0051] The first fully connected layer and the second fully connected layer may be fully connected layers of the prior art, and this embodiment does not specifically limit this.
[0052] Exemplarily, take the conversation content in Table 1 as an example. Q is the sentence input by the target object, and A is the sentence output by the robot. When "Q3: OK, let me have a look" is detected, it is used as the current input sentence of the target object, and Q1: The shoes I like are out of stock; A1, I am very sorry for the inconvenience; A2, What price range do you need, I will recommend it to you; Q2: For a family of three; A3: How about this one? JDHTTP is used as the historical conversation content of this conversation, and A3's conversation strategy "recommend" is used as the previous conversation strategy, the readiness to accept the recommendation is used as the intent data, and the identifier 3 is used as the current conversation turn. The above historical conversation content, the current input sentence, the intent data of the target object, the previous conversation strategy of the robot, and the current conversation turn are used as the current input content and input into the trained conversation model. The trained dialogue model uses a self-attention mechanism to encode historical dialogue content based on the current input sentence, intent data, previous dialogue strategy, and current dialogue turn, and determines the representation data of the current state based on the encoding result to characterize the current dialogue state of the target object. Then, based on the principle of highest similarity, the preset dialogue strategy corresponding to the representation data is determined in the candidate set, and the preset dialogue strategy is used as the current dialogue strategy.
[0053] In one embodiment, the working process of the trained dialogue model is as follows: for the current input sentence "Q3: OK, let me take a look" in Table 1, the trained dialogue model locates "Q1: The product I like is out of stock" through encoding. Combined with "Q1: The product I like is out of stock", it can be seen that "Q3: OK, let me take a look" indicates that the target object intends to see the recommended items, and the dialogue has proceeded to the fourth round. It is determined that the target object is currently in a state of accepting the recommendation, and the representation data used to represent the accepted state is output. The similarity calculation module finds that the representation data of the accepted recommendation state has the highest matching degree with the representation data of the urging shot, so the urging shot is used as the current dialogue strategy of the robot. It should be noted that this working process is an inference working process, and its actual working process is related to the training samples used in the dialogue model training process.
[0054] Table 1. Human-computer dialogue table
[0055] Dialogue Turns Dialogue sentences Conversation Strategy <![CDATA[Q1]]> The product you are looking for is out of stock <![CDATA[A1]]> We are very sorry for the inconvenience. appease <![CDATA[A2]]> How many people in your family do you need? I'll recommend you a price range. Ask questions proactively <![CDATA[Q2]]> For three people <![CDATA[A3]]> Which one do you like? JDHTTP recommend <![CDATA[Q3]]> OK, let me see <![CDATA[A4]]> This one is currently on sale and is pretty good. If you like it, place an order as soon as possible. Request for bidding
[0056] S103. Determine a current response sentence corresponding to the current input sentence according to the current dialogue strategy, and output the current response sentence to the target object.
[0057] After the current dialogue strategy is determined, the current response statement is determined according to the determined current dialogue strategy, and the current response statement is output to the target object.
[0058] In one embodiment, for a fixed dialogue scenario, each dialogue strategy corresponds to at least two dialogue sentences. After the current dialogue strategy is determined, one of all the dialogue sentences corresponding to it is output as the current reply sentence. It can be understood that the dialogue sentence corresponding to each dialogue strategy can be a complete sentence that can be directly output; or it can be a sentence frame. In this case, the robot fills in the corresponding content according to the dialogue scenario, and then outputs the filled sentence frame as the current reply sentence.
[0059] In one embodiment, for different dialogue scenarios, each dialogue strategy corresponds to at least two dialogue sentences in each dialogue scenario. After the current dialogue strategy is determined, one of all dialogue sentences in the current dialogue scenario is output as the current response sentence.
[0060] In one embodiment, the loss function used by the dialogue model during training is as follows:
[0061] Loss t =max(μ + -sim(a,b + ), 0)+max(u _ +sim(a,b _ ),0)
[0062] Among them, μ + 、u _ are preset constants, b + is the actual dialogue strategy marked in the training sample, b _ is the representation data of the historical dialogue strategy randomly selected from the target candidate set, a is the representation data of the current dialogue state, sim(a, b + ) is used to calculate a and b + Similarity; sim(a, b _ ) is used to calculate a and b _ The target candidate set is the candidate set excluding the actual dialogue strategy; if μ + -sim(a,b + ) is greater than 0, then max(μ + -sim(a,b + ), 0 is equal to μ + -sim(a,b + ), otherwise it is equal to 0; if u _ +sim(a,b _ ) is greater than 0, then max(u _ +sim(a,b _ ), 0) is equal to u_+sim(a, b _), otherwise it is equal to 0. This means that the similarity between the representation data of the current dialogue state and the representation data of the correct dialogue strategy should be as high as possible, and the similarity with the representation data of the wrong dialogue strategy should be as low as possible. It can be understood that in Loss t When it stops decreasing or reaches the preset number of iterations, stop the training of this round.
[0063] Accordingly, the global loss is the sum of all round losses of the entire dialogue, specifically:
[0064] L=∑ t Loss t
[0065] Understandably, in Los t When it no longer decreases or reaches the preset number of iterations, all training of the dialogue model is stopped to obtain the trained dialogue model.
[0066] The technical solution of the robot dialogue method provided in the embodiment of the present invention automatically ignores useless information in multiple rounds of dialogue content through the encoding mechanism of the trained dialogue model, locates the dialogue rounds related to the current input content in the multiple rounds of dialogue content, and determines the current dialogue state representation data according to the robot's dialogue strategy in the relevant rounds. Since the current dialogue state representation data is determined based on the dialogue content of the relevant dialogue round, it has higher accuracy. Therefore, the current dialogue strategy of the robot determined according to the current dialogue state has higher accuracy.
[0067] Embodiment 2
[0068] Figure 3 : is a structural block diagram of a robot dialogue device provided in an embodiment of the present invention. The device is used to execute the robot dialogue method provided in any of the above embodiments, and the device can be implemented in software or hardware. The device includes:
[0069] An acquisition module 11 is used to acquire current input content, wherein the current input content includes the historical dialogue content of this dialogue, the current input sentence of the target object, the intention data corresponding to the current input sentence, and the robot's previous dialogue strategy, where the previous dialogue strategy is the dialogue strategy adopted by the robot in the previous dialogue round of the current dialogue round;
[0070] A dialogue strategy determination module 12, used to input current input content into the trained dialogue model to obtain the current dialogue strategy output by the trained dialogue model;
[0071] An output module 13, configured to determine a current response sentence corresponding to a current input sentence according to a current dialogue strategy, and output the current response sentence to a target object;
[0072] Among them, the trained dialogue model is used to encode the historical dialogue content according to the current input sentence, intent data and the previous dialogue strategy using the self-attention mechanism, determine the representation data of the robot's current dialogue state according to the encoding result, and determine the robot's current dialogue strategy according to the representation data.
[0073] Preferably, the dialogue model includes a first module and a second module, the first module is used to use a self-attention mechanism to encode the dialogue content of one or more rounds in the current input content, and determine the representation data of the robot's current dialogue state based on the encoding results, wherein the contribution of the one or more rounds of dialogue content to the current input content is greater than the contribution of other rounds of dialogue content to the current input content; the second module is used to determine the preset dialogue strategy corresponding to the representation data of the current dialogue state based on the encoding results, and use the preset dialogue strategy as the current dialogue strategy.
[0074] Preferably, the first module is an encoder module in a Transformer model, and the second module is a similarity calculation module.
[0075] Preferably, determining the preset dialogue strategy corresponding to the representation data of the current dialogue state as the current dialogue strategy includes: determining the representation data of each preset dialogue strategy in a candidate set to obtain a representation strategy set, wherein the candidate set stores at least two preset dialogue strategies; in the representation strategy set, determining the preset dialogue strategy corresponding to the representation data having the greatest similarity to the representation data of the current dialogue state, and using the preset dialogue strategy as the current dialogue strategy of the robot; or determining the representation data of each preset dialogue strategy in the candidate set to obtain a representation strategy set, wherein the candidate set stores at least two preset dialogue strategies, traversing the representation strategy set, and upon detecting representation data whose similarity to the representation data of the current dialogue state exceeds a preset similarity threshold, using the preset dialogue strategy corresponding to the representation data as the current dialogue strategy.
[0076] Preferably, the dialogue model also includes a first fully connected layer and a second fully connected layer; the first fully connected layer is used to update the representation data of the current dialogue state output by the first module; the second fully connected layer is used to update the representation data of each preset dialogue strategy in the candidate set; the dimension of the updated representation data of the current dialogue state is the same as the dimension of the updated representation data of each preset dialogue strategy.
[0077] Preferably, the loss function used by the dialogue model during training is as follows:
[0078] Loss t =max(μ + -sim(a,b + ), 0)+max(u _ +sim(a,b_ ),0)
[0079] Among them, μ + 、u _ are preset constants, b + is the representation data of the actual dialogue strategy marked in the training sample, b _ is the representation data of the preset dialogue strategy randomly selected from the target candidate set, a is the representation data of the current dialogue state, sim(a, b + ) is used to calculate a and b + Similarity; sim(a, b _ ) is used to calculate a and b _ The target candidate set is the candidate set without the actual dialogue strategy.
[0080] Preferably, the current input content also includes a current dialogue turn identifier.
[0081] Preferably, the historical conversation content includes all conversation contents between the target object and the robot within a preset time from the current moment; or all conversation contents between the target object and the robot in a preset number of conversation rounds closest to the current moment.
[0082] The technical solution of the robot dialogue method provided in the embodiment of the present invention automatically ignores useless information in multiple rounds of dialogue content through the encoding mechanism of the trained dialogue model, locates the dialogue rounds related to the current input content in the multiple rounds of dialogue content, and determines the current dialogue state representation data according to the robot's dialogue strategy in the relevant rounds. Since the current dialogue state representation data is determined based on the dialogue content of the relevant dialogue round, it has higher accuracy. Therefore, the current dialogue strategy of the robot determined according to the current dialogue state has higher accuracy.
[0083] The robot dialogue device provided in the embodiment of the present invention can execute the robot dialogue method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0084] Embodiment 3
[0085] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 4 As shown, the device includes a processor 201, a memory 202, an input device 203, and an output device 204; the number of processors 201 in the device can be one or more. Figure 4 A processor 201 is taken as an example; the processor 201, the memory 202, the input device 203 and the output device 204 in the device can be connected by a bus or other means. Figure 4 The example of connecting through bus is taken in the following.
[0086] The memory 202 is a computer-readable storage medium that can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the robot dialogue method in the embodiment of the present invention (for example, the acquisition module 11, the dialogue strategy determination module 12 and the output module 13). The processor 201 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 202, that is, realizing the above-mentioned robot dialogue method.
[0087] The memory 202 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 202 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 202 may further include a memory remotely arranged relative to the processor 201, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0088] The input device 203 may be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the device.
[0089] The output device 204 may include a display device such as a display screen, for example, a display screen of a user terminal.
[0090] Embodiment 4
[0091] An embodiment of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to execute a robot dialogue method when executed by a computer processor, the method comprising:
[0092] Obtaining current input content, wherein the current input content includes historical conversation content of this conversation, the current input sentence of the target object, the intention data corresponding to the current input sentence, and the robot's previous conversation strategy, wherein the previous conversation strategy is the conversation strategy adopted by the robot in the previous conversation round of the current conversation round;
[0093] Inputting the current input content into a trained dialogue model to obtain a current dialogue strategy output by the trained dialogue model;
[0094] Determine a current reply sentence corresponding to the current input sentence according to the current dialogue strategy, and output the current reply sentence to the target object;
[0095] Among them, the trained dialogue model is used to encode the historical dialogue content according to the current input sentence, the intention data and the previous dialogue strategy using a self-attention mechanism, determine the representation data of the robot's current dialogue state according to the encoding result, and determine the robot's current dialogue strategy according to the representation data.
[0096] Of course, the computer executable instructions of a storage medium containing computer executable instructions provided by an embodiment of the present invention are not limited to the method operations described above, and can also execute related operations in the robot dialogue method provided by any embodiment of the present invention.
[0097] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the robot dialogue method described in each embodiment of the present invention.
[0098] It is worth noting that in the embodiment of the above-mentioned robot dialogue device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0099] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A robot dialogue method, characterized in that: include: Obtaining the current input content, wherein the current input content includes the historical dialogue content of the current dialogue, the current input sentence of the target object, the intention data corresponding to the current input sentence, and the robot's previous dialogue strategy, wherein the previous dialogue strategy is the dialogue strategy adopted by the robot in the previous dialogue round of the current dialogue round; wherein the intention data is the dialogue intention determined based on the current input sentence or multiple rounds of dialogue content including the current input sentence; Inputting the current input content into a trained dialogue model to obtain a current dialogue strategy output by the trained dialogue model; Determine a current reply sentence corresponding to the current input sentence according to the current dialogue strategy, and output the current reply sentence to the target object; The trained dialogue model is used to encode the historical dialogue content using a self-attention mechanism according to the current input sentence, the intention data and the previous dialogue strategy, determine the representation data of the robot's current dialogue state according to the encoding result, and determine the robot's current dialogue strategy according to the representation data; the representation data of the current dialogue state is used to represent the current dialogue state of the target object; The dialogue model includes: a first module and a second module; The first module is used to encode one or more rounds of dialogue content in the current input content using a self-attention mechanism according to the intention data and the previous dialogue strategy, and determine the representation data of the current dialogue state of the robot according to the encoding result, wherein the contribution of the one or more rounds of dialogue content to the current input content is greater than the contribution of other rounds of dialogue content to the current input content; The second module is used to determine a preset dialogue strategy corresponding to the characterization data of the current dialogue state according to the encoding result, and use the preset dialogue strategy as the current dialogue strategy.
2. The method according to claim 1, characterized in that The first module is the encoder module in the Transformer model.
3. The method according to claim 1, characterized in that: The step of determining a preset dialogue strategy corresponding to the characterization data of the current dialogue state as the current dialogue strategy includes: Determining characterization data of each preset dialogue strategy in a candidate set to obtain a characterization strategy set, wherein the candidate set stores at least two preset dialogue strategies; Determine, from the representation strategy set, a preset dialogue strategy corresponding to the representation data having the greatest similarity to the representation data of the current dialogue state, and use the preset dialogue strategy as the current dialogue strategy of the robot; or The characterization strategy set is traversed, and when characterization data whose similarity with the characterization data of the current dialog state exceeds a preset similarity threshold is detected, the preset dialog strategy corresponding to the characterization data is used as the current dialog strategy.
4. The method according to claim 3, characterized in that The dialogue model also includes a first fully connected layer and a second fully connected layer; The first fully connected layer is used to update the representation data of the current dialogue state output by the first module; The second fully connected layer is used to update the representation data of each preset dialogue strategy in the candidate set; The dimension of the updated representation data of the current dialogue state is the same as the dimension of the updated representation data of each preset dialogue strategy.
5. The method according to claim 1, characterized in that The loss function used in the training process of the dialogue model is as follows: Loss t =max(μ + -sim(a,b + ),0)+max(u - +sim(a,b - ),0) Among them, μ + 、u - are preset constants, b + is the representation data of the actual dialogue strategy marked in the training sample, b - is the representation data of the preset dialogue strategy randomly selected from the target candidate set, a is the representation data of the current dialogue state, sim(a,b + ) is used to calculate a and b - Similarity; sim(a,b - ) is used to calculate a and b - , the target candidate set is the candidate set excluding the actual dialogue strategy.
6. The method according to any one of claims 1 to 5, characterized in that: The current input content also includes a current dialogue turn identifier.
7. The method according to any one of claims 1 to 5, characterized in that: The historical conversation content includes all conversation contents between the target object and the robot within a preset time from the current moment; or all conversation contents between the target object and the robot in a preset number of conversation rounds closest to the current moment.
8. A robot dialogue device, characterized in that: include: An acquisition module, used to acquire current input content, wherein the current input content includes historical dialogue content of this dialogue, the current input sentence of the target object, the intention data corresponding to the current input sentence, and the robot's previous dialogue strategy, wherein the previous dialogue strategy is the dialogue strategy adopted by the robot in the previous dialogue round of the current dialogue round; wherein the intention data is a dialogue intention determined based on the current input sentence or multiple rounds of dialogue content including the current input sentence; A dialogue strategy determination module, used for inputting the current input content into a trained dialogue model to obtain a current dialogue strategy output by the trained dialogue model; An output module, configured to determine a current reply sentence corresponding to the current input sentence according to the current dialogue strategy, and output the current reply sentence to the target object; The trained dialogue model is used to encode the historical dialogue content using a self-attention mechanism according to the current input sentence, the intention data and the previous dialogue strategy, determine the representation data of the robot's current dialogue state according to the encoding result, and determine the robot's current dialogue strategy according to the representation data; the representation data of the current dialogue state is used to represent the current dialogue state of the target object; The dialogue model includes a first module and a second module. The first module is used to encode the dialogue content of one or more rounds in the current input content using a self-attention mechanism, and determine the representation data of the robot's current dialogue state based on the encoding results, wherein the contribution of the one or more rounds of dialogue content to the current input content is greater than the contribution of other rounds of dialogue content to the current input content; the second module is used to determine the preset dialogue strategy corresponding to the representation data of the current dialogue state based on the encoding results, and use the preset dialogue strategy as the current dialogue strategy.
9. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the robot dialogue method as described in any one of claims 1-7.
10. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the robot dialogue method as described in any one of claims 1 to 7 when executed by a computer processor.
Citation Information
Patent Citations
Man-machine hybrid response method, system and device
CN109783704A
Response recommendation system
US20200097544A1
