Human-computer interaction method and device and storage medium
By obtaining and analyzing the keywords in the user dialogue text and robot character settings, and generating response texts that meet preferences, the problem of insufficient human-computer dialogue quality in the existing technology is solved, and a higher quality dialogue interaction is achieved.
Patent Information
- Application Number
- CN202311327065.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-12
- Publication Date
- 2025-01-10
AI Technical Summary
The prior art is difficult to improve the quality of human-computer dialogue, especially when considering robot character settings and dialogue preferences, the output response text often does not meet the needs of semantics and language styles.
By obtaining the conversation text generated by the user for the robot and describing the keywords set by the robot, determining the dialogue preference keywords, and generating response texts based on these keywords, thereby improving the quality of human-computer dialogue.
Ensure that the response text not only meets the requirements semantically, but also meets the robot's personality and user preferences, and improves the language style and quality of human-computer dialogue.
Smart Images

Figure CN119294404A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a human-computer interaction method, device and storage medium. Background Art
[0002] With the continuous development of artificial intelligence, users can interact with machines with conversation capabilities in different scenarios, more specifically, human-computer dialogue.
[0003] For example, in a game scenario, the robot can be a virtual robot, which can be a virtual character, such as a non-player character (NPC) in the game. The user as a player can talk to different NPCs in the game to advance the game progress. For another example, in a work scenario, the robot can also include various physical robots, such as sweeping robots, welcoming robots, guiding robots, etc. Users can talk to physical robots to control them to complete tasks.
[0004] Based on the above description, how to improve the quality of dialogue between humans and machines becomes an urgent problem to be solved. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a human-computer interaction method, device and storage medium to improve the quality of human-computer dialogue.
[0006] In a first aspect, an embodiment of the present invention provides a human-computer interaction method, comprising:
[0007] Obtaining a dialogue text generated by a user to a robot and a first keyword describing a character setting of the robot;
[0008] Identify the second keyword that describes the conversational preferences;
[0009] A response text of the dialogue text is determined according to the first keyword and the second keyword.
[0010] In a second aspect, an embodiment of the present invention provides a human-computer interaction method, including:
[0011] In response to the dialogue initiation operation, obtaining dialogue data generated by the user to the robot;
[0012] Outputting response data corresponding to the dialogue data, wherein the response data is obtained according to a first keyword describing the robot character setting and a second keyword describing the dialogue preference.
[0013] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the human-computer interaction method in the first aspect or the second aspect. The electronic device may also include a communication interface for communicating with other devices or a communication network.
[0014] In a fourth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the human-computer interaction method as described in the first aspect or the second aspect.
[0015] In the human-computer interaction method provided by the embodiment of the present invention, the robot can obtain the dialogue text generated by the user to itself and the first keyword describing the robot character setting, and can also determine the second keyword describing the dialogue preference, and determine the response text corresponding to the dialogue text according to the above two parts of keywords, thereby completing the human-computer dialogue. When determining the response text, the above scheme takes into account the robot's character setting and the dialogue preference during the human-computer dialogue process, so that the output response text not only meets the requirements in terms of semantics, but also the language style conforms to the preferences of the two parties in the dialogue, and also conforms to the robot's character setting, effectively improving the quality of human-computer dialogue. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 paying creative work.
[0017] Figure 1 A schematic diagram of a flow chart of a human-computer interaction method provided by an embodiment of the present invention;
[0018] Figure 2 A schematic diagram of a flow chart of another human-computer interaction method provided by an embodiment of the present invention;
[0019] Figure 3 A flowchart of a model training method provided by an embodiment of the present invention;
[0020] Figure 4 A schematic diagram of a human-computer interaction operation provided by an embodiment of the present invention;
[0021] Figure 5 Another working schematic diagram of human-computer interaction provided by an embodiment of the present invention;
[0022] Figure 6 A flowchart of another human-computer interaction method provided by an embodiment of the present invention;
[0023] Figure 7 A schematic diagram of the structure of a human-computer interaction device provided by an embodiment of the present invention;
[0024] Figure 8 For Figure 7 A schematic diagram of the structure of an electronic device corresponding to the human-computer interaction device provided in the illustrated embodiment;
[0025] Fig. 9 A schematic diagram of the structure of another human-computer interaction device provided by an embodiment of the present invention;
[0026] Fig.10 For Fig. 9 A schematic structural diagram of an electronic device corresponding to the human-computer interaction device provided in the illustrated embodiment. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with 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.
[0028] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two, but does not exclude the inclusion of at least one.
[0029] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0030] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to identifying", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is identified" may be interpreted as "when determining" or "in response to determining" or "when identifying (stated condition or event)" or "in response to identifying (stated condition or event)", depending on the context.
[0031] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a product or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such a product or system. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the product or system including the elements.
[0032] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In addition, the following embodiments and features in the embodiments can be combined with each other if there is no conflict between the embodiments. In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.
[0033] Figure 1 The flowchart of a human-computer interaction method provided by an embodiment of the present invention is shown in FIG. The human-computer interaction method provided by an embodiment of the present invention can be performed by a robot. It is understandable that the robot can be implemented as a virtual robot as a virtual character, or a physical robot with dialogue capability. Figure 1 As shown, the method comprises the following steps:
[0034] S101, obtaining the dialogue text generated by the user to the robot and the first keyword describing the robot character setting.
[0035] As described in the background technology, the robot may include a virtual robot or a physical robot. Optionally, the virtual robot may play multiple roles, such as an NPC in a game scenario, a customer service representative in an online shopping scenario, a teacher in an online education scenario, a doctor in a medical scenario, etc. Optionally, the physical robot may provide different services to the user, such as a cleaning robot providing cleaning services to the user, a welcoming robot providing welcoming services to the user, a shopping guide robot providing navigation to the user, etc.
[0036] When the virtual robot is role-playing or the physical robot is performing tasks, the user can have a conversation with it, and the robot can obtain the conversation text generated by the user, which is the latest sentence generated by the user that has not yet been answered. At the same time, the robot can also obtain the first keyword that describes its own character setting. The first keyword can be used to describe the basic information of the robot, such as name, age, gender, and occupation. The first keyword can be set in advance. And in the subsequent process of determining the response sentence, regardless of the content of the conversation, the first keyword needs to be used in each round of conversation.
[0037] Taking the game scenario as an example, the player Xiao Ming can have at least one of the following rounds of dialogue with the NPC Zhang San played by the virtual robot:
[0038] Xiao Ming: Hello,
[0039] Zhang San: Hello, we meet again.
[0040] Xiao Ming: Yes.
[0041] Zhang San: What would you like to drink today?
[0042] Xiao Ming: Give me some wine, please.
[0043] Continuing with the above example, in step S101, the dialogue text obtained by the robot is "Give me some wine", and the first keywords obtained include: name Zhang San, gender male, age 35 years old, occupation bartender.
[0044] S102, determining a second keyword describing the conversation preference.
[0045] Next, the robot may further determine a second keyword describing the conversation preference. The second keyword may include a keyword describing the robot preference and / or a keyword describing the user preference.
[0046] Optionally, the second keyword may generally include a keyword describing the user's preference. Depending on the content of the human-machine dialogue, the second keyword may or may not include a keyword describing the robot's preference. For example, when the dialogue content is about sports, a keyword describing the robot's preference for what to eat may not be used as the second keyword. It can be seen that, unlike the fixed first keyword, the second keyword can change dynamically according to the dialogue content, that is, the second keyword describes the robot's preference related to the dialogue content.
[0047] In an optional manner, the second keyword can be directly generated by the robot based on the dialogue text. In order to further improve the accuracy of the second keyword, optionally, the second keyword can also be directly generated by the robot based on the dialogue text and the semantics of the context of the dialogue text. The dialogue text and the context of the dialogue text correspond to a dialogue initiation operation of the user. The dialogue text and its context can include at least one round of dialogue between the user and the robot after a dialogue initiation operation is generated.
[0048] Following the example in step S101, the second keyword determined by the robot may include: "Xiao Ming likes to drink", which is used to describe the user's preference. The second keyword may also include: "Zhang San likes white wine", which is used to describe the robot's preference.
[0049] Alternatively, the second keyword can also be obtained by the robot from the candidate keywords. The process of obtaining the candidate keywords and selecting the second keyword can be referred to as follows: Figure 2 Related description in the illustrated embodiment.
[0050] S103: Determine a response text of the dialogue text according to the first keyword and the second keyword.
[0051] Finally, the robot can determine the response text of the dialogue text based on the first keyword describing the robot's personality and the second keyword describing the dialogue preference, combined with the semantics of the dialogue text.
[0052] Optionally, the robot can determine the response text based on preset rules. For example, the robot can perform semantic matching on the dialogue text in step S101 based on the knowledge graph, question-answer database, etc. deployed within itself. If a matching sentence with the same semantics as the dialogue text is matched, the first keyword and the second keyword can be used to fine-tune the matching sentence without changing the semantics of the matching sentence to obtain the response text corresponding to the dialogue text.
[0053] Following the example in step S101, the robot may finally give a response text: "OK. The liquor has arrived today. Would you like to try it?" This response text is consistent with the robot's personality (the robot likes liquor) and satisfies the user's preference (the user likes liquor).
[0054] In this embodiment, the robot can obtain the dialogue text generated by the user to itself and the first keyword describing the robot's character setting. It can also determine the second keyword describing the dialogue preference, and determine the response text corresponding to the dialogue text based on the above two parts of keywords, thereby completing the human-computer dialogue.
[0055] In the above method, when determining the response text, the character setting of the robot and the dialogue preferences during the human-computer dialogue are taken into consideration at the same time, so that the output response text not only meets the requirements in terms of semantics, but also has a language style that conforms to the preferences of the two parties in the dialogue and the character setting of the robot, thereby improving the quality of human-computer dialogue.
[0056] Figure 1 In the illustrated embodiment, it has been mentioned that the second keyword may include a keyword describing the robot's preference and / or a keyword describing the dialogue preference, and the robot may select the second keyword from the candidate keywords. The following is a detailed description of the selection process of the second keyword.
[0057] Figure 2 FIG. 1 is a flow chart of another human-computer interaction method provided by an embodiment of the present invention. Figure 2 As shown, the method may include the following steps:
[0058] S201, obtaining the dialogue text generated by the user to the robot and the first keyword describing the robot character setting.
[0059] The execution process of step 201 is similar to the corresponding steps of the above-mentioned embodiment, and can be seen in FIG. Figure 1 The relevant description in the illustrated embodiment will not be repeated here.
[0060] S202, determining a second keyword among candidate keywords, where the candidate keywords include a third keyword describing robot preference and a fourth keyword describing user preference.
[0061] The robot can select the second keyword from the candidate keywords. The third keyword can be considered as the robot's own preference, and the fourth keyword can be considered as the robot's preference when facing the user.
[0062] Optionally, the robot may screen the second keywords according to the semantics of the conversation text, and the screened second keywords may include at least one of the third keywords and / or at least one of the fourth keywords.
[0063] Optionally, the above screening process can be implemented with the help of a model. Specifically, the encoding model can encode the dialogue text and any keyword in the candidate keywords to obtain the sentence vector of the dialogue text and the word vector of any keyword. Then determine the correlation coefficient between the sentence vector and the word vector. If the correlation coefficient is not less than a preset threshold, it indicates that the semantic correlation between the keyword corresponding to the word vector and the dialogue text corresponding to the sentence vector meets the requirement, then any keyword is determined as the second keyword. Then, by calculating the above correlation coefficient for each keyword in the candidate set, the second keyword required for the application dialogue text can be obtained.
[0064] Optionally, the correlation coefficient can be a Pearson correlation coefficient, or it can be obtained by calculating the cosine similarity. Optionally, the coding model can specifically be a bidirectional transform coding (Bidirectional Encoder Representation from Transformers, referred to as BERT) model, or any one of baichuan-7B, QWEN, and Jiang Ziya general model (Ziya-LLaMA-13B). Among them, baichuan-7B and Jiang Ziya general model can be models based on LLaMA (Large LanguageModel Meta AI, referred to as LLaMA). The coding model can also be any one of a convolutional neural network (Convolutional Neural Networks, referred to as CNN) model and a recurrent neural network (Recurrent Neural Network, referred to as RNN) model.
[0065] Optionally, the encoding model may extract and store word vectors for each keyword in the candidate keywords in advance. Then, when the robot obtains the conversation text, the encoding model may extract word vectors for the conversation text.
[0066] Optionally, when the encoding model is a BERT model with a dual-tower structure, the conversation text and any keyword in the alternative keywords can be encoded together to obtain the sentence vector of the conversation text and the word vector of any keyword, without the need to perform the above-mentioned process of extracting word vectors for the alternative keywords in advance.
[0067] According to the above description, the preset threshold is an important basis for screening the second keyword. In practice, the larger the preset threshold, the higher the accuracy of the screened second keywords, and the fewer the number of second keywords; on the contrary, the larger the preset threshold, the higher the accuracy of the screened second keywords, and the fewer the number of second keywords. You can set a reasonable preset threshold according to the dialogue scenario. For example, in a question-and-answer scenario, you can set a higher preset threshold to ensure the accuracy of the answer; in a chat scenario, you can set a lower preset threshold to ensure the flexibility and diversity of the answer.
[0068] S203: Determine a response text of the dialogue text according to the first keyword and the second keyword.
[0069] The execution process of step 203 is similar to the corresponding steps of the above-mentioned embodiment, and can be seen in FIG. Figure 1 The relevant description in the illustrated embodiment will not be repeated here.
[0070] In this embodiment, the robot can filter out the second keyword describing the dialogue preference from the candidate keywords by calculating the correlation, and the filtered second keyword is related to the dialogue text generated by the user. Then the response text determined according to the first keyword and the second keyword describing the robot's personality not only meets the requirements in terms of semantics, but also conforms to the preferences of the two parties in the dialogue and the personality of the robot, effectively improving the quality of human-computer dialogue. In addition, the contents not described in detail in this embodiment and the technical effects that can be achieved can all be referred to the relevant descriptions in the above embodiments, and will not be repeated here.
[0071] Optionally, in order to ensure the continuity of human-computer dialogue, after determining the second keyword corresponding to the dialogue text most recently generated by the user (i.e., the dialogue text generated in this round of dialogue), the robot can also generate a response text for the dialogue text of this round of dialogue based on the second keyword corresponding to the dialogue text of the previous round of dialogue, the second keyword of the dialogue text of this round of dialogue, and the robot's first keyword.
[0072] In this embodiment, the second keyword used in the previous round of dialogue can continue to be retained and used in the next round of dialogue, thereby ensuring the consistency of the dialogue context.
[0073] Regarding the determination of the candidate keywords, optionally, similar to the first keyword, the third keyword in the candidate keywords can also be preset to reflect the robot's own preference. The robot can determine the fourth keyword in the candidate keywords based on the preference information. The robot can obtain the user's preference information based on the dialogue and / or behavior generated during the human-computer interaction process.
[0074] As for obtaining the user's preference information, an optional way is that during the human-computer dialogue, the robot can prompt the user to evaluate the satisfaction of the robot's reply. The robot can also determine the user's preference information based on the user's evaluation behavior on the historical text. In practice, this evaluation behavior can occur in customer service scenarios.
[0075] Alternatively, the robot can extract the user's preference information from historical texts, which correspond to at least one conversation initiation operation before the user's current conversation initiation operation. That is, the robot can perform semantic analysis on the historical texts to analyze the user's preference information. For example, a historical text generated by user Xiao Ming may be: "I like to listen to light music", and the robot can extract Xiao Ming's preference information from it as: "I like light music", and the fourth keyword may be: "Xiao Ming likes light music".
[0076] In practice, the user's preference is changing, so in order to ensure the accuracy of the response text, the fourth keyword can also be updated in real time. Optionally, the robot can update the fourth keyword according to the conversation content generated by at least one conversation process after the user ends the conversation with the robot at least once.
[0077] In another embodiment, in order to further shorten the update cycle, optionally, the robot can update the fourth keyword in real time according to the conversation content generated by the conversation each time the user ends the conversation with the robot; optionally, during a conversation, the robot can also analyze the semantics of each text generated during the human-computer dialogue in real time, and after ending the conversation on a topic, use at least one round of conversation with the same topic to update the fourth keyword; optionally, during a conversation, the fourth keyword can also be updated in real time after each round of human-computer dialogue.
[0078] In this embodiment, the third keyword describing the robot's own preferences can be preset, and the robot can also dynamically update the fourth keyword describing the user's preferences based on the user's historical behavior, so that the fourth keyword can describe the user's latest preferences. Then the robot can determine the second keyword from the fourth keyword describing the user's latest preferences, and finally make the response text also meet the user's latest preferences, thereby improving the quality of human-computer dialogue.
[0079] In practice, when using the above-mentioned method of filtering keywords, the robot may encounter a conflict between the second keyword filtered out from the fourth keyword and the third keyword, that is, the keywords filtered out from different keywords describe opposite preferences. In this case, the robot will give priority to the second keyword filtered out from the fourth keyword.
[0080] For example, the keywords filtered out by the robot from the third keyword based on the correlation coefficient may include: "The robot likes star A", and the keywords filtered out by the robot from the fourth keyword may include: "The user does not like star A". At this time, the robot can use the keywords filtered out from the fourth keyword as the second keyword and ignore the keywords filtered out from the third keyword.
[0081] In this embodiment, when conflicts occur among the selected keywords, the keywords selected from the fourth keywords are used preferentially, so that the basic personality of the robot and the user preferences are involved in the generation of the response text, while the robot's own preferences are not involved in the generation of the response text, so that the generated response text conforms to the basic personality of the robot and also conforms to the user preferences.
[0082] In addition, it is easy to understand that a robot can have human-computer dialogues with different users, and different users can have different preferences, so different users can have their own exclusive fourth keyword.
[0083] In the process of human-computer dialogue, the robot can select the second keyword for the user from the third keyword and the fourth keyword specific to the user according to the user identifier, so that the final response text meets the user's preference. The generation process of the fourth keyword specific to each user can refer to the relevant description in the above embodiment, which will not be repeated here.
[0084] In this embodiment, when the first keyword and the third keyword are fixed, the robot can use the fourth keyword exclusive to each user to form a personality exclusive to the user when facing different users, and use the exclusive personality to respond to the dialogue text generated by the user.
[0085] for Figure 2 The training process of the encoding model in the embodiment shown can be combined with Figure 3 The model training method provided in the embodiment of the present invention can be executed by a training device. The training device can be either the robot mentioned in each embodiment of the invention or another device independent of the robot. Figure 3 A flow chart of a model training method provided by an embodiment of the present invention. Figure 3 As shown, the method may include the following steps:
[0086] S301: Obtain a first training text, a first training keyword corresponding to the first training text, and a reference correlation coefficient between the first training keyword and the first training text.
[0087] S302: Input the first training text and the first training keyword into the first pre-training model, so that the first pre-training model outputs the sentence vector of the first training text and the word vector of the first training keyword.
[0088] S303: Determine a prediction correlation coefficient between the sentence vector and the word vector output by the first pre-training model.
[0089] S304, fine-tuning the first pre-trained model according to the loss calculation result between the prediction correlation system and the reference correlation coefficient to obtain the encoding model.
[0090] The training device can obtain a first training text, a first training keyword corresponding to the first training text, and a reference correlation coefficient between the first training keyword and the first training text. The first training text can include the first training keyword. The reference correlation coefficient can be used as supervision information.
[0091] Then, the first training text and the first training keyword are input into the first pre-training model, so that the pre-training model outputs the sentence vector of the first training text and the word vector of the first training keyword. The training device can further calculate the prediction correlation coefficient between the vectors output by the first pre-training model, and fine-tune the first pre-training model with the loss calculation result between the prediction correlation coefficient and the reference correlation coefficient to obtain the encoding model.
[0092] Optionally, the loss value between two correlation coefficients may be calculated using a mean square error (MSE) function or a cross entropy error function.
[0093] Optionally, when the first pre-training model is specifically a BERT model with a dual-tower structure, the word vectors of the first training text and the first training keyword can be output from the output layers of the dual-towers respectively.
[0094] In this embodiment, the first pre-trained model can be fine-tuned by using the correlation task to obtain the encoding model, and the fine-tuning of the model is implemented in a supervised manner. The first pre-trained model after fine-tuning, that is, the encoding model, has the ability to calculate the correlation of word vectors.
[0095] Figure 1 In step S103 of the illustrated embodiment, the robot can determine the response text of the dialogue text by means of rules. In addition, in another optional way, the robot can also use deep learning technology to obtain a generative model to generate a response text corresponding to the dialogue text. Compared with the response text of the dialogue text determined based on rules, the response text output by the generative model is more flexible and has a more everyday language style, thereby making the human-computer dialogue smoother.
[0096] Before describing the working process of the generative model in detail, we can first explain the concepts related to the generative model:
[0097] A generative model is a model with data generation capabilities. Optionally, the generative model may include a Chat Generative Pre-trained Transformer (ChatGPT), baichuan-7B, MOSS, etc. Among them, baichuan-7B is a large-scale pre-trained language model similar to LLaMA; MOSS is a Transformer-based dialogue model.
[0098] Prompt: used to guide the data generation direction of the generative model. Prompt information can be input into the generative model so that the generative model generates data under the guidance of the prompt information.
[0099] Based on the above concept introduction, for the working process of the generative model: Optionally, prompt information can be generated based on the dialogue text, the first keyword and the second keyword generated by the user, and then the prompt information can be input into the generative model deployed in the robot so that the model can output a response text.
[0100] For the generation of prompt information, the robot can optionally mark the source of the dialogue text, the first keyword, and the second keyword, that is, mark the dialogue text as coming from the user and the keyword as coming from the robot. Optionally, the robot can automatically mark the source through a marking program configured by itself. Specifically, the marking of the dialogue text and the keyword can be done by adding a prefix indicating the source to the dialogue text and the keyword. For example, the prefix "coming from the robot" can be used. <bot>Indicates that it comes from the user, for example, you can use the prefix <user>express.
[0101] Undertake Figure 1 In the example of the illustrated embodiment, the dialogue text generated by the player Xiao Ming is: "Give me some wine"; the first keyword includes: Zhang San, male, 35 years old, occupation is bartender; the second keyword includes: Zhang San likes white wine, Xiao Ming likes drinking.
[0102] The marked prompt information is:
[0103] <bot>:Zhang San, male, 35 years old, bartender, [SEP]Zhang San likes liquor, has been to the Great Wall in Beijing, and met a lovely girl, Wang Mei, who likes wine. [SEP]Xiao Ming likes drinking. [SEP]
[0104] <user>: Give me some wine.
[0105] Among them, [SEP] is used to indicate the interval between sentences.
[0106] In the above case, the specific process of using the encoding model and the generative model for human-computer dialogue can be combined Figure 4 The workflow diagram shown is understood.
[0107] In order to further improve the accuracy of the response text, optionally, prompt information can be generated based on the dialogue text generated by the user, the context of the dialogue text, the first keyword and the second keyword, and then the prompt information is input into the generative model so that the model outputs the response text. The context of the dialogue text and the dialogue text also correspond to a dialogue operation generated by the user. The generation process of the prompt information can refer to the above description, which will not be repeated here.
[0108] Continue to undertake Figure 1 In the embodiment shown, for example, the generated and marked prompt information in this case may be:
[0109] <bot>:Zhang San, male, 35 years old, bartender, [SEP]Zhang San likes liquor, has been to the Great Wall in Beijing, and met a lovely girl, Wang Mei, who likes wine. [SEP]Xiao Ming likes drinking. [SEP]
[0110] <user>:hello,
[0111] <bot>: Hello, we meet again
[0112] <user>:yes.
[0113] <bot>: What would you like to drink today?
[0114] <user>: Give me some wine.
[0115] In the above case, the specific process of using the encoding model and the generative model for human-computer dialogue can be combined Figure 5 The workflow diagram shown is understood.
[0116] Alternatively, the generative model can be trained in an unsupervised manner. Similar to the training of the encoding model, the training process can also be performed by a robot or an independent device.
[0117] Specifically, the second training text and the second training keywords corresponding to the second training text can be obtained, and the second training text and the second training keywords are source-marked in the above manner to obtain prompt information, and then the prompt information is input into the second pre-training model to train the second pre-training model to obtain a generative model.
[0118] The second training text may be a conversation text generated between the user and the robot in a historical period of time, or a conversation text collected from the Internet. The second training keywords may include keywords describing the character settings of the robot and keywords describing the conversation preferences of the second training text. The extraction of keywords may be performed manually.
[0119] Optionally, the second pre-trained model may be a pre-trained model that already has basic text processing capabilities, so the training process of the second pre-trained model is also a fine-tuning process of the model. And the number of second training texts and second training keywords used in this fine-tuning process may be relatively small.
[0120] The above embodiments have described in detail the working process of the robot in the process of human-machine dialogue. On this basis, it can also be described from the perspective of human-machine interaction.
[0121] Figure 6 A flowchart of another human-computer interaction method provided by an embodiment of the present invention. The human-computer interaction method provided by an embodiment of the present invention can be performed by a robot. It is understandable that the robot can be implemented as a virtual robot as a virtual character, or a physical robot with dialogue ability. Figure 6 As shown, the method may include the following steps:
[0122] S401, in response to a dialogue initiation operation, obtaining dialogue data generated by the user to the robot.
[0123] S402, outputting response data corresponding to the dialogue data, wherein the response data is obtained according to a first keyword describing the robot character setting and a second keyword describing the dialogue preference.
[0124] The user can trigger a dialogue initiation operation on the robot. When the robot is a physical robot, the dialogue initiation operation generated by the user can be specifically the user generating activation data or generating an activation action on the physical robot. The activation data can be, for example, activation text or activation voice, and the activation action can be, for example, the user waving to the robot to say hello, or the user blocking the robot from moving, etc.
[0125] When the robot is a virtual robot as a virtual character, optionally, the dialogue initiation operation generated by the user may specifically be an activation action generated by the user on the virtual character, wherein the activation action may be, for example, the user clicking a dialogue button in the human-computer interaction interface.
[0126] In response to the dialogue initiation operation triggered by the user, the robot may obtain the dialogue data generated by the user. Optionally, the dialogue data, the activation data, and the response data obtained by the robot may have the same data type, such as voice or text. Optionally, the dialogue data, the activation data, and the response data may also have different data types.
[0127] Among them, the specific generation process of the response text can refer to the description in the above-mentioned related embodiments, and will not be repeated here.
[0128] In this embodiment, the robot can obtain the dialogue text generated by the user to itself and the first keyword describing the robot character setting, and can also determine the second keyword describing the dialogue preference, and determine the response text corresponding to the dialogue text according to the above two parts of keywords, so as to complete the human-computer dialogue. In the above method, when determining the response text, the robot's character setting and the dialogue preference in the human-computer dialogue process are considered at the same time, so that the output response text not only meets the requirements in terms of semantics, but also the language style conforms to the preferences of the two parties in the dialogue, and also conforms to the robot's character setting, thereby improving the quality of human-computer dialogue.
[0129] In addition, the contents not described in detail in this embodiment and the technical effects that can be achieved can all be found in the relevant descriptions in the above embodiments, and will not be repeated here.
[0130] The human-computer interaction method provided in the above embodiments of the present invention can be described below by taking a game scene as an example.
[0131] Player Xiao Ming can trigger a conversation with NPC Li Si in the game interface, which can generate at least one of the following rounds of dialogue:
[0132] Xiao Ming: How old are you?
[0133] Li Si: I’m almost 60 years old.
[0134] Xiao Ming: What do you do every day?
[0135] Li Si: I concentrate on my work and go to the garden every day.
[0136] Xiao Ming: I like flowers, too.
[0137] At this time, the dialogue text that the robot needs to generate a response sentence is "I like flowers too", and the text before the dialogue text is the previous context of the dialogue text. The robot can also obtain the first keyword: name Li Si, age 55, professional gardener. By calculating the similarity coefficient, the robot can also determine the second keyword from the candidate keywords: have a child, like flowers. Then, using the dialogue text, the previous context of the dialogue text, the first keyword, and the second keyword, the robot finally outputs the response sentence "You like flowers just like my child." At this time, the response text output by Li Si not only meets the requirements in terms of semantics, but also meets the preferences of Li Si and Xiao Ming, thereby ensuring the quality of human-computer dialogue.
[0138] Among them, the third keyword in the candidate keywords may include: having a child, divorced for 20 years, dull personality, focusing on work, liking flowers, and going to the garden every day. The fourth keyword in the candidate keywords may include: liking flowers.
[0139] In addition, the processes not described in detail in this embodiment and the technical effects that can be achieved can be found in Figures 1 to 6 Related description in the illustrated embodiment.
[0140] The following will describe in detail one or more embodiments of the human-computer interaction device of the present invention. Those skilled in the art will appreciate that these human-computer interaction devices can be configured using commercially available hardware components through the steps taught in this solution.
[0141] Figure 7 A schematic diagram of a human-computer interaction device provided by an embodiment of the present invention is shown in FIG. Figure 7 As shown, the device comprises:
[0142] The first acquisition module 11 is used to acquire the dialogue text generated by the user to the robot and the first keyword describing the character setting of the robot.
[0143] The first keyword determination module 12 is used to determine a second keyword that describes the conversation preference.
[0144] The text determination module 13 is used to determine the response text of the dialogue text according to the first keyword and the second keyword.
[0145] The robot includes a physical robot or a virtual robot serving as a virtual character.
[0146] Optionally, the first keyword determination module 12 is used to generate the second keyword according to the dialogue text and / or the context of the dialogue text, and the context and the dialogue text correspond to a dialogue initiation operation of the user.
[0147] Optionally, the device further comprises: a second keyword determination module 14, configured to determine candidate keywords, wherein the candidate keywords include a third keyword describing the robot preference and a fourth keyword describing the user preference.
[0148] The first keyword determination module 12 is used to determine the second keyword from the candidate keywords.
[0149] Optionally, the second keyword determination module 14 is used to obtain the preset third keyword; and determine the fourth keyword according to the user's preference information.
[0150] Optionally, the second keyword determination module 14 is used to extract the user's preference information from a historical text, where the historical text corresponds to at least one conversation initiation operation of the user before the conversation text is generated;
[0151] And / or, determining the user's preference information based on the user's evaluation behavior on the historical text.
[0152] Optionally, the first keyword determination module 12 is used to input the dialogue text and any keyword among the alternative keywords into the encoding model to obtain the sentence vector of the dialogue text and the word vector of any keyword; determine the correlation coefficient between the sentence vector and the word vector; if the correlation coefficient is not less than a preset threshold, determine any keyword as the second keyword.
[0153] Optionally, the device further comprises: a training module 15, configured to obtain a first training text, a first training keyword corresponding to the first training text, and a reference correlation coefficient between the first training keyword and the first training text;
[0154] Inputting the first training text and the first training keyword into a first pre-training model, so that the first pre-training model outputs a sentence vector of the first training text and a word vector of the first training keyword;
[0155] Determine a prediction correlation coefficient between the sentence vector and the word vector output by the first pre-training model;
[0156] According to the loss calculation result between the prediction correlation system and the reference correlation coefficient, the first pre-training model is fine-tuned to obtain the encoding model.
[0157] Optionally, the text determination module 13 is used to obtain the previous context of the conversation text, where the previous context and the conversation text correspond to a conversation initiation operation of the user;
[0158] The prompt information generated according to the dialogue text, the previous context, the first keyword and the second keyword is input into a generative model so that the generative model outputs the response text.
[0159] Optionally, the text determination module 13 is used to mark the source of each text in the above text, the dialogue text, the first keyword and the second keyword;
[0160] The dialogue text including the source tag, the context of the dialogue text, the first keyword, and the second keyword are determined as the prompt information.
[0161] Optionally, the training module 15 is used to input prompt information generated according to the second training text and the second training keywords corresponding to the second training text into the second pre-trained model to fine-tune the second pre-trained model to obtain the generative model, and the second training keywords include keywords describing the robot character settings and keywords describing the dialogue preferences of the second training text.
[0162] Figure 7 The device shown can perform Figures 1 to 5 For the method of the embodiment shown in the figure, the part not described in detail in this embodiment can be referred to Figures 1 to 5 The implementation process and technical effects of this technical solution refer to Figures 1 to 5 The description in the illustrated embodiment will not be repeated here.
[0163] The above describes the internal functions and structure of the human-computer interaction device. In a possible design, the structure of the human-computer interaction device can be implemented as an electronic device, such as Figure 8 As shown, the electronic device may include: a first processor 21 and a first memory 22. The first memory 22 is used to store data that supports the electronic device to execute the above Figures 1 to 5 The program of the human-computer interaction method provided in the illustrated embodiment, the first processor 21 is configured to execute the program stored in the first memory 22 .
[0164] The program includes one or more computer instructions, wherein the one or more computer instructions can implement the following steps when executed by the first processor 21:
[0165] Obtaining a dialogue text generated by a user to a robot and a first keyword describing a character setting of the robot;
[0166] Identify the second keyword that describes the conversational preferences;
[0167] A response text of the dialogue text is determined according to the first keyword and the second keyword.
[0168] Optionally, the first processor 21 is further configured to execute the aforementioned Figures 1 to 5 All or part of the steps in the illustrated embodiments.
[0169] The structure of the electronic device may further include a first communication interface 23 for the electronic device to communicate with other devices or a communication network.
[0170] Fig. 9 A schematic diagram of the structure of another human-computer interaction device provided by an embodiment of the present invention is shown in FIG. Fig. 9 As shown, the device comprises:
[0171] A second acquisition module 31 is used to acquire the dialogue data generated by the user to the robot in response to the dialogue initiation operation;
[0172] The output module 32 is used to output response data corresponding to the dialogue data, wherein the response data is obtained according to a first keyword describing the robot character setting and a second keyword describing the dialogue preference.
[0173] The conversation data and the response data have the same data type, which includes text or voice.
[0174] Fig. 9 The device shown can perform Figure 6 For the method of the embodiment shown in the figure, the part not described in detail in this embodiment can be referred to Figure 6 The implementation process and technical effects of this technical solution refer to Figure 6 The description in the illustrated embodiment will not be repeated here.
[0175] The above describes the internal functions and structure of the human-computer interaction device. In a possible design, the structure of the human-computer interaction device can be implemented as another electronic device, such as Fig.10 As shown, the electronic device may include: a second processor 41 and a second memory 42. The second memory 42 is used to store the information that supports the electronic device to execute the above Figure 6 The program of the human-computer interaction method provided in the illustrated embodiment, the second processor 41 is configured to execute the program stored in the second memory 42 .
[0176] The program includes one or more computer instructions, wherein the one or more computer instructions can implement the following steps when executed by the second processor 41:
[0177] In response to the dialogue initiation operation, obtaining dialogue data generated by the user to the robot;
[0178] Outputting response data corresponding to the dialogue data, wherein the response data is obtained according to a first keyword describing the robot character setting and a second keyword describing the dialogue preference.
[0179] Optionally, the second processor 41 is further configured to execute the aforementioned Figure 6 All or part of the steps in the illustrated embodiments.
[0180] The structure of the electronic device may further include a second communication interface 43 for the electronic device to communicate with other devices or a communication network.
[0181] In addition, an embodiment of the present invention provides a computer storage medium for storing computer software instructions used by the above electronic device, which includes instructions for executing the above Figures 1 to 6 The program involved in the human-computer interaction method in the method embodiment shown.
[0182] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.< / user> < / bot> < / user> < / bot> < / user> < / bot> < / user> < / bot> < / user> < / bot>
Claims
1. A human-computer interaction method, characterized in that: include: Obtaining a dialogue text generated by a user to a robot and a first keyword describing a character setting of the robot; Identify the second keyword that describes the conversational preferences; A response text of the dialogue text is determined according to the first keyword and the second keyword.
2. The method according to claim 1, characterized in that The determining of the second keyword describing the conversation preference includes: The second keyword is generated according to the conversation text and / or the context of the conversation text, wherein the context and the conversation text correspond to a conversation initiation operation of the user.
3. The method according to claim 1, characterized in that: The method further comprises: Determining candidate keywords, the candidate keywords including a third keyword describing the robot preference and a fourth keyword describing the user preference; The determining of the second keyword describing the conversation preference includes: Among the candidate keywords, the second keyword is determined.
4. The method according to claim 3, characterized in that The determining of candidate keywords includes: Acquire the third keyword which is preset in advance; The fourth keyword is determined according to the preference information of the user.
5. The method according to claim 4, characterized in that The method further comprises: extracting preference information of the user from a history text, where the history text corresponds to at least one conversation initiation operation of the user before the conversation text is generated; and / or, The user's preference information is determined according to the user's evaluation behavior on the historical text.
6. The method according to claim 3, characterized in that Determining the second keyword from among the candidate keywords includes: Inputting the conversation text and any keyword among the candidate keywords into an encoding model to obtain a sentence vector of the conversation text and a word vector of any keyword; Determine a correlation coefficient between the sentence vector and the word vector; If the correlation coefficient is not less than a preset threshold, any one of the keywords is determined as the second keyword.
7. The method according to claim 6, characterized in that The method further comprises: Acquire a first training text, a first training keyword corresponding to the first training text, and a reference correlation coefficient between the first training keyword and the first training text; Inputting the first training text and the first training keyword into a first pre-training model, so that the first pre-training model outputs a sentence vector of the first training text and a word vector of the first training keyword; Determine a prediction correlation coefficient between the sentence vector and the word vector output by the first pre-training model; According to the loss calculation result between the prediction correlation system and the reference correlation coefficient, the first pre-training model is fine-tuned to obtain the encoding model.
8. The method according to claim 1, characterized in that The step of determining a response text of the conversation text according to the first keyword and the second keyword includes: Acquire the context of the conversation text, where the context and the conversation text correspond to a conversation initiation operation of the user; The prompt information generated according to the dialogue text, the previous context, the first keyword and the second keyword is input into a generative model so that the generative model outputs the response text.
9. The method according to claim 8, characterized in that The method further comprises: Marking the source of each of the above texts, the dialogue text, the first keyword, and the second keyword; The dialogue text including the source tag, the context of the dialogue text, the first keyword, and the second keyword are determined as the prompt information.
10. The method according to claim 8, characterized in that The method further comprises: The prompt information generated according to the second training text and the second training keywords corresponding to the second training text is input into the second pre-trained model to fine-tune the second pre-trained model to obtain the generative model, wherein the second training keywords include keywords describing the robot character settings and keywords describing the dialogue preferences of the second training text.
11. An electronic device, characterized in that: include: A memory and a processor; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the human-computer interaction method as described in any one of claims 1 to 10.
12. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the human-computer interaction method according to any one of claims 1 to 10.