Dialogue generation method and device, computer device and storage medium

By filtering and predicting candidate statement types and their sequences in intelligent dialogue, high-quality dialogue statements are generated, thus solving the problem of improving the intelligence of human-computer interaction.

CN117009472BActive Publication Date: 2025-12-12TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211303628.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-24
Publication Date
2025-12-12
Estimated Expiration
2042-10-24

AI Technical Summary

Technical Problem

How to improve the quality of dialogue statements in intelligent dialogue to enhance the level of intelligence in human-computer interaction.

Method used

By filtering candidate statement types from multiple statement types based on historical dialogue statements in the current session, predicting their corresponding type sequences, determining the dialogue quality parameters for each candidate statement type, and selecting statement types that meet the conditions to generate dialogue statements.

Benefits of technology

Ensuring the quality of the current dialogue statements in the current session improves the level of intelligence in human-computer interaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117009472B_ABST
    Figure CN117009472B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a dialogue generation method and device, computer equipment and a storage medium, and belongs to the technical field of computers. The method comprises the following steps: in the process of the current session, at least based on the historical dialogue sentence of the current session, a plurality of candidate sentence types of the current round of dialogue are determined from a plurality of sentence types; based on the historical dialogue sentence, the plurality of sentence types and the plurality of candidate sentence types, a type sequence corresponding to each candidate sentence type is determined; based on each candidate sentence type and the corresponding type sequence, a first parameter of each candidate sentence type is determined, and based on the candidate sentence types in the plurality of candidate sentence types that satisfy a second condition, a dialogue sentence of the current round of dialogue is generated. The method provided in the embodiment of the application guarantees the quality of the dialogue sentence of the current round of dialogue in the current session, and further guarantees the dialogue quality of the current session, and improves the intelligence of human-computer interaction.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of computer technology, and particularly relate to a dialogue generation method and device, computer equipment and a storage medium. BACKGROUND

[0002] With the development of computer technology, the application of intelligent dialogue is becoming more and more widespread. For example, intelligent dialogue is applied in various scenarios such as restaurant recommendation, hotel reservation, weather query or medical diagnosis, and the like, and dialogue is carried out between intelligent robots and users to realize the human-computer interaction process. In the human-computer interaction process, the dialogue sentence output to the user is a key factor affecting the quality of the dialogue, and therefore, how to output a high-quality dialogue sentence to the user to improve the intelligence has become a problem to be solved at present. SUMMARY

[0003] Embodiments of the present application provide a dialogue generation method and device, computer equipment and a storage medium, which can improve the quality of the dialogue sentence, thereby ensuring the quality of the dialogue and improving the intelligence of human-computer interaction. The technical solution is as follows:

[0004] In one aspect, a dialogue generation method is provided, the method comprising:

[0005] During the current session, at least based on a historical dialogue sentence of the current session, a plurality of candidate sentence types of the current round of dialogue are determined from a plurality of sentence types, the candidate sentence type being a sentence type in the plurality of sentence types whose first probability satisfies a first condition, the first probability indicating the possibility of using the sentence type in the current round of dialogue;

[0006] Based on the historical dialogue sentence, the plurality of sentence types and the plurality of candidate sentence types, a type sequence corresponding to each candidate sentence type is determined, the type sequence including a sentence type used in at least one subsequent round of dialogue if the candidate sentence type is used in the current round of dialogue;

[0007] Based on the each candidate sentence type and the corresponding type sequence, a first parameter of the each candidate sentence type is determined, the first parameter indicating the dialogue quality of the current session after dialogue using the candidate sentence type;

[0008] Based on the candidate sentence type in the plurality of candidate sentence types whose first parameter satisfies a second condition, a dialogue sentence of the current round of dialogue is generated.

[0009] In another aspect, a dialogue generation device is provided, the device comprising:

[0010] determine, during a current session, a plurality of candidate sentence types of a current round of dialogue from a plurality of sentence types based on at least historical dialogue sentences of the current session, the candidate sentence types being sentence types of the plurality of sentence types for which a first probability satisfies a first condition, the first probability indicating a possibility that the current round of dialogue adopts the sentence type;

[0011] The determining module is further configured to determine, based on the historical dialogue sentences, the plurality of sentence types, and the plurality of candidate sentence types, a type sequence corresponding to each candidate sentence type, the type sequence including sentence types adopted in at least one subsequent round of dialogue in a case where the current round of dialogue adopts the candidate sentence type;

[0012] The determining module is further configured to determine, based on each candidate sentence type and the corresponding type sequence, a first parameter of the candidate sentence type, the first parameter indicating a dialogue quality of the current session after dialogue in the candidate sentence type is adopted;

[0013] The generating module is further configured to generate a dialogue sentence of the current round of dialogue based on a candidate sentence type of the plurality of candidate sentence types for which a first parameter satisfies a second condition.

[0014] In a possible implementation, the determining module is configured to determine the plurality of candidate sentence types from the plurality of sentence types based on the historical dialogue sentences and object information corresponding to an object participating in the current session, and determine the type sequence corresponding to each candidate sentence type based on the historical dialogue sentences, the object information, the plurality of sentence types, and the plurality of candidate sentence types.

[0015] In another possible implementation, the determining module is configured to determine the first probability of each sentence type of the plurality of sentence types based on the historical dialogue sentences and the object information, the first probability indicating a possibility that the current round of dialogue adopts the sentence type, and determine, as the plurality of candidate sentence types, the sentence types of the plurality of sentence types for which the first probability satisfies the first condition.

[0016] In a possible implementation, the each candidate sentence type corresponds to m type sequences, m is an integer greater than 0; the determining module is configured to predict an (i+1)th sentence type in the ith type sequence based on the historical dialogue sentence, the object information, the candidate sentence type, the plurality of sentence types and the m ith type sequences, to obtain m (i+1)th type sequences, the ith type sequence includes i sentence types, the (i+1)th type sequence includes i+1 sentence types, the i+1 sentence types include the sentence types in one ith type sequence, until m nth type sequences are obtained, n is an integer greater than 1, i is an integer greater than 0 and less than n.

[0017] In a possible implementation, the determining module includes:

[0018] A first determining unit is configured to determine k predicted sentence types corresponding to the each ith type sequence from the plurality of sentence types based on the historical dialogue sentence, the object information and the candidate sentence type, k is an integer greater than 0;

[0019] A constituting unit is configured to constitute each predicted sentence type and the corresponding ith type sequence into a candidate type sequence, to obtain j candidate type sequences, j is a product of k and m;

[0020] The first determining unit is further configured to determine a second probability of each candidate type sequence, the second probability indicates a possibility of adopting the sentence types in the candidate type sequence in the subsequent multi-round dialogue under the condition that the candidate sentence type is adopted in the current round of dialogue;

[0021] A screening unit is configured to screen the m (i+1)th type sequences with the second probability satisfying a third condition from the j candidate type sequences.

[0022] In a possible implementation, the first determining unit is configured to perform feature extraction on the candidate sentence type and the ith type sequence to obtain type features; update a historical feature corresponding to the historical dialogue sentence and an object feature corresponding to the object information based on the type features; and determine the k predicted sentence types corresponding to the ith type sequence from the plurality of sentence types based on the updated historical feature and the updated object feature.

[0023] In a possible implementation, the first determining unit is configured to: perform weighted fusion on the updated historical features and the updated object features to obtain fused features; and perform transformation processing on the fused features to obtain third probabilities of the plurality of sentence types, the third probability indicating a possibility of using the sentence type in a next round of conversation in a case where the candidate sentence type is used in the current round of conversation and sentence types in the i-th type sequence are used in at least one round of conversation thereafter; and determine, as the k predicted sentence types corresponding to the i-th type sequence, sentence types in the plurality of sentence types that satisfy a fourth condition in terms of the third probability.

[0024] In a possible implementation, the determining module includes:

[0025] The obtaining unit is configured to obtain a fourth probability of the candidate sentence type, the fourth probability indicating a possibility of using the candidate sentence type in the current round of conversation.

[0026] The second determining unit is configured to determine a second parameter of the candidate sentence type based on a type sequence corresponding to the candidate sentence type, the second parameter indicating a conversation quality of the current session after a conversation using the candidate sentence type and the corresponding type sequence.

[0027] The fusion unit is configured to perform weighted fusion on the fourth probability and the second parameter to obtain a first parameter of the candidate sentence type.

[0028] In a possible implementation, the candidate sentence type corresponds to m type sequences; the second determining unit is configured to determine a fifth probability of each type sequence corresponding to the candidate sentence type, the fifth probability indicating a possibility of using a sentence type in the type sequence in at least one round of conversation after the current round of conversation in a case where the candidate sentence type is used in the current round of conversation; obtain a third parameter of the each type sequence based on the historical conversation sentence, the third parameter indicating a conversation quality of the current session in a case where the candidate sentence type is used in the current round of conversation and a sentence type in the type sequence is used in at least one round of conversation thereafter; and determine a product of a sixth probability and the third parameter of the same type sequence to obtain m products corresponding to the candidate sentence type; and determine a sum of the m products corresponding to the candidate sentence type as the second parameter of the candidate sentence type.

[0029] In another possible implementation manner, the second determining unit is configured to: acquire historical features corresponding to the historical dialogue sentences, candidate features corresponding to the candidate sentence types, and sequence features corresponding to the type sequence; splice the historical features, the candidate features, and the sequence features to obtain spliced features; encode the spliced features based on a prediction model to obtain encoded features; and perform transformation processing on the encoded features based on the prediction model to obtain third parameters of the type sequence.

[0030] In another aspect, a computer device is provided, which includes a processor and a memory, and the memory stores at least one computer program, which is loaded and executed by the processor to implement operations performed by the dialogue generation method according to the above aspect.

[0031] In another aspect, a computer readable storage medium is provided, which stores at least one computer program, which is loaded and executed by a processor to implement operations performed by the dialogue generation method according to the above aspect.

[0032] In still another aspect, a computer program product is provided, which includes a computer program, and the computer program is executed by a processor to implement operations performed by the dialogue generation method according to the above aspect.

[0033] In the scheme provided by the embodiments of the present application, in the process of human-computer interaction, the influence of the historical dialogue sentences of the current session on the current session is considered, and it is considered that the use of a certain sentence type in the current session will affect the sentence type used in at least one subsequent session, and further affect the dialogue quality of the current session. Therefore, in combination with the historical dialogue sentences of the current session, a plurality of candidate sentence types that can be used in the current session are screened out, and a type sequence corresponding to each candidate sentence type is predicted to determine a first parameter for indicating the dialogue quality of the current session after each candidate sentence type is used in the current session. The candidate sentence type satisfying the second condition is used to generate the dialogue sentence of the current session, so that the quality of the dialogue sentence of the current session is ensured, and the dialogue quality of the current session is further ensured, and the intelligence of human-computer interaction is improved. BRIEF DESCRIPTION OF DRAWINGS

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

[0035] Figure 1 is a structural schematic diagram of an implementation environment provided by an embodiment of the present application;

[0036] Figure 2 is a flowchart of a dialogue generation method provided by an embodiment of the present application;

[0037] Figure 3 is a flowchart of another dialogue generation method provided by an embodiment of the present application;

[0038] Figure 4 is a flowchart of still another dialogue generation method provided by an embodiment of the present application;

[0039] Figure 5 is a flowchart of yet another dialogue generation method provided by an embodiment of the present application;

[0040] Figure 6 is a flowchart of still another dialogue generation method provided by an embodiment of the present application;

[0041] Figure 7 is a flowchart of a first parameter for determining a candidate sentence type provided by an embodiment of the present application;

[0042] Figure 8 is a flowchart of still another dialogue generation method provided by an embodiment of the present application;

[0043] Figure 9 is a schematic diagram of a medical inquiry conversation provided by an embodiment of the present application;

[0044] Figure 10 is a structural schematic diagram of a dialogue generation apparatus provided by an embodiment of the present application;

[0045] Figure 11 is a structural schematic diagram of another dialogue generation apparatus provided by an embodiment of the present application;

[0046] Figure 12 is a structural schematic diagram of a terminal provided by an embodiment of the present application;

[0047] Figure 13 is a structural schematic diagram of a server provided by an embodiment of the present application. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.

[0049] The terms "first", "second", "third", "fourth", "fifth", "sixth" and the like as used herein can be used to describe various concepts, but unless specifically stated otherwise, the concepts are not limited by the terms. These terms are used only to distinguish one concept from another. For example, a first parameter can be referred to as a second parameter, and similarly, a second parameter can be referred to as a first parameter, without departing from the scope of the present application.

[0050] The terms "at least one", "multiple", "each", "any" used herein include one, two or more, multiple includes two or more, and each refers to each of the corresponding multiple, and any refers to any one of the multiple. For example, a plurality of sentence types includes 3 sentence types, and each refers to each of the 3 sentence types, any refers to any one of the 3 sentence types, which can be the first sentence type, or the second sentence type, or the third sentence type.

[0051] It should be noted that the information (including but not limited to object information, dialogue sentences, etc.) involved in the present application, the sentence type, is authorized by the user or fully authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions. For example, the historical dialogue sentences and object information involved in the present application are obtained under sufficient authorization.

[0052] Artificial intelligence (AI) is the use of digital computers or digital computer-controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science, which tries to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making.

[0053] Artificial intelligence technology is a comprehensive discipline, involving a wide range of fields, both hardware and software technologies. Artificial intelligence basic technologies generally include technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, automatic driving, intelligent transportation, etc.

[0054] The key technologies of speech technology include automatic speech recognition technology, speech synthesis technology, and voiceprint recognition technology. Letting computers listen, see, speak, and feel is the future direction of human-computer interaction, and voice is one of the most promising human-computer interaction methods in the future.

[0055] Natural language processing (NLP) is an important direction in the field of computer science and artificial intelligence. It studies various theories and methods that can enable effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, the research in this field will involve natural language, i.e., the language used in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question and answer, knowledge graph, etc.

[0056] Machine learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, etc. It is a field of study that focuses on how computers can simulate or implement human learning behavior to acquire new knowledge or skills, and reorganize existing knowledge structure to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental approach to making computers intelligent. It is applied in various fields of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning.

[0057] The scheme provided by the embodiments of the present application can train a sequence generation model and a prediction model based on machine learning technology of artificial intelligence, and generate a dialogue sentence for the current round of dialogue in the current session by using the trained sequence generation model and prediction model.

[0058] The dialogue generation method provided by the embodiments of the present application is executed by a computer device. Optionally, the computer device is a terminal or a server. Optionally, the server is a physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms. Optionally, the terminal is a smartphone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a smart voice interaction device, a smart home appliance, and a vehicle terminal, but is not limited thereto.

[0059] In some embodiments, the computer program related to the embodiments of the present application can be deployed on one computer device to execute, or on multiple computer devices located in one place to execute, or on multiple computer devices distributed in multiple places and interconnected through a communication network to execute, which can constitute a blockchain system.

[0060] In some embodiments, the computer device is provided as a server. Figure 1 is a schematic diagram of an implementation environment provided by the embodiments of the present application, referring to Figure 1 The implementation environment includes a terminal 101 and a server 102. The terminal 101 and the server 102 are connected through a wireless or wired network.

[0061] The server 102 provides a session service for the terminal 101, and the terminal 101 can input dialogue sentences in the session to realize a multi-round dialogue of human-computer interaction. The server 102 is configured to generate a dialogue sentence of the current round of dialogue based on historical dialogue sentences in the session, send the dialogue sentence of the current round of dialogue to the terminal 101, and display the dialogue sentence of the current round of dialogue in the session by the terminal 101, thereby realizing the human-computer interaction process.

[0062] In some embodiments, the terminal 101 installs a target application provided by the server 102, and the terminal 101 can realize a session function or a message interaction function through the target application. Optionally, the target application is an application in the operating system of the terminal 101, or a target application provided by a third party. For example, the target application is an instant messaging application, and the content sharing application has a session function. Of course, the instant messaging application can also have other functions, such as a review function, a shopping function, a navigation function, a game function, etc. The terminal 101 logs in the target application based on an object identifier, initiates a session in the target application, and interacts with the server 102 through the session in the target application, thereby realizing the human-computer interaction process.

[0063] Figure 2 is a flowchart of a dialogue generation method provided by the embodiments of the present application, which is executed by a computer device, as shown in Figure 2 The method comprises the following steps.

[0064] 201. The computer device determines a plurality of candidate sentence types of the current round of dialogue from a plurality of sentence types based on at least historical dialogue sentences of the current session in the process of the current session, the candidate sentence type being a sentence type in the plurality of sentence types whose first probability satisfies a first condition, and the first probability indicating a possibility of using the sentence type in the current round of dialogue.

[0065] The current session is used to implement human-computer interaction, and the current session is an intelligent session in any scenario, for example, the current session is a session in any scenario such as restaurant recommendation, hotel reservation, weather query, or medical inquiry. The sentence type is used to generate a dialogue sentence matched with the sentence type, and the sentence type is equivalent to a dialogue strategy that can be used in human-computer dialogue. For example, the sentence type is "ask symptoms", and the sentence type is used to generate a dialogue sentence related to "ask symptoms", for example, the dialogue sentence generated based on the sentence type is "What is uncomfortable for you". For another example, the sentence type is "ask age", and the sentence type is used to generate a dialogue sentence related to "ask age", for example, the dialogue sentence generated based on the sentence type is "What is your age" and the like. In the embodiment of the application, the plurality of sentence types are pre-set sentence types, and the plurality of sentence types are sentence types that can be used in the current session. In the process of the current session, a dialogue sentence is generated by selecting a sentence type from the plurality of sentence types in each round of dialogue, thereby enabling multi-round dialogue in the current session.

[0066] In the embodiment of the application, the current session is a human-computer interactive dialogue in which at least one object participates, and the computer device simulates a dialogue between a person and the object in the dialogue to implement a human-computer interaction process. Multi-round dialogue can be performed in the current session, and the current round of dialogue is a round of dialogue being performed in the current session. In the current session, the dialogue sentences in at least one round of dialogue before the current round of dialogue are referred to as historical dialogue sentences for the current round of dialogue. The current session includes at least one historical dialogue sentence, which can include a dialogue sentence generated by the computer device or a dialogue sentence sent by an object participating in the current session. When generating a dialogue sentence in the current round of dialogue, a candidate sentence type suitable for the current round of dialogue is selected from a plurality of pre-set sentence types, so that it can be determined subsequently which candidate sentence type is used to generate a dialogue sentence in the current round of dialogue.

[0067] In the embodiment of the application, the first condition is a condition that a first probability of a sentence type that can be used in the current round of dialogue needs to satisfy. Since the historical dialogue sentence is the historical dialogue content of the current session, the historical dialogue sentence can reflect the dialogue state of the current session, and in combination with the historical dialogue sentence of the current session, it can be determined how to proceed with the dialogue subsequently. The possibility that each sentence type is used in the current round of dialogue is determined from the plurality of sentence types, and based on the first probability used to represent the possibility that the sentence type is used, a plurality of candidate sentence types that can be used in the current round of dialogue are selected, so as to ensure that the plurality of candidate sentence types determined are suitable for the current round of dialogue, that is, the accuracy of the candidate sentence types is ensured.

[0068] 202. The computer device determines the type sequence corresponding to each candidate statement type based on the historical dialogue statement, the multiple statement types, and the multiple candidate statement types. The type sequence includes the statement type to be used in at least one subsequent dialogue if the candidate statement type is used in the current dialogue.

[0069] The type sequence includes at least one statement type, where each statement type corresponds to one round of dialogue. That is, the at least one statement type included in the type sequence is the statement type to be used in at least one round of dialogue following the current round. For example, a type sequence including three statement types indicates the statement type to be used in the subsequent three rounds of dialogue if the candidate statement type is used in the current round. In this embodiment, the statement types in the type sequence are arranged according to their corresponding dialogue rounds.

[0070] In this embodiment, the candidate statement type refers to the statement type that may be used in the current round of dialogue within the current session. The statement types used in the previous rounds of dialogue in the current session will affect at least one subsequent round of dialogue. Therefore, if different candidate statement types are used in the current round, the statement types used in at least one subsequent round may also be different. Thus, a type sequence corresponding to each candidate statement type is predicted to indicate which statement types will be used in at least one subsequent round when each candidate statement type is used in the current round.

[0071] 203. The computer device determines a first parameter for each candidate statement type based on each candidate statement type and its corresponding type sequence. The first parameter indicates the dialogue quality of the current session after the dialogue is conducted using the candidate statement type.

[0072] In the embodiments of this application, when a candidate statement type is used in the current round of dialogue in the current session, it will affect the statement type used in at least one subsequent round of dialogue. By combining the candidate statement type used in the current round of dialogue and the statement type used in at least one subsequent round of dialogue, the dialogue quality of the current session after each candidate statement type is used in the current round of dialogue can be determined, so as to reflect the impact of each candidate statement type on the dialogue quality of the current session. Therefore, by combining each candidate statement type and the corresponding type sequence, a first parameter for indicating the dialogue quality of the current session after each candidate statement type is used in the current round of dialogue can be determined.

[0073] 204. The computer device generates the dialogue statements for this round of dialogue based on the candidate statement types whose first parameter satisfies the second condition among multiple candidate statement types.

[0074] In the embodiment of the present application, the second condition is a condition that the first parameter of the candidate sentence type used in the current round of dialogue needs to meet. After determining the multiple candidate sentence types that the current round of dialogue can use and the first parameter of each candidate sentence type, it is determined whether the first parameter of each candidate sentence type meets the second condition, and the candidate sentence type whose first parameter meets the second condition is used to generate the dialogue sentence of the current round of dialogue, so as to ensure the quality of the dialogue sentence of the current round of dialogue in the current session, and further ensure the dialogue quality of the current session, thereby improving the intelligence of human-computer interaction.

[0075] In the scheme provided by the embodiment of the present application, in the process of human-computer interaction, the influence of the historical dialogue sentence of the current session on the current round of dialogue is considered, and it is considered that the use of a certain sentence type in the current round of dialogue will affect the sentence type used in at least one subsequent round of dialogue, and further affect the dialogue quality of the current session. Therefore, in combination with the historical dialogue sentence of the current session, multiple candidate sentence types that the current round of dialogue can use are screened out, and the type sequence corresponding to each candidate sentence type is also predicted to determine the first parameter for indicating the dialogue quality of the current session after the current round of dialogue uses each candidate sentence type. The candidate sentence type whose first parameter meets the second condition is used to generate the dialogue sentence of the current round of dialogue, so as to ensure the quality of the dialogue sentence of the current round of dialogue in the current session, and further ensure the dialogue quality of the current session, thereby improving the intelligence of human-computer interaction.

[0076] In Figure 2 On the basis of the embodiment shown, the object information corresponding to the object participating in the session can also be combined to predict the candidate sentence type of the current round of dialogue, and the sentence type to be used in the current round of dialogue is screened out in combination with the possibility of each candidate sentence type being taken and the influence of the corresponding type sequence being taken on the dialogue quality of the current session. The specific process is described in detail in the following embodiments.

[0077] Figure 3 is a flowchart of a dialogue generation method provided by an embodiment of the present application. The method is executed by a computer device, as shown in Figure 3 The method comprises the following steps.

[0078] 301. In the process of the current session, the computer device determines multiple candidate sentence types of the current round of dialogue from multiple sentence types based on the historical dialogue sentence of the current session and the object information corresponding to the object participating in the current session. The candidate sentence type is a sentence type whose first probability meets the first condition in the multiple sentence types. The first probability indicates the possibility of the current round of dialogue using the sentence type.

[0079] The object information is used to represent the object participating in the current session. Optionally, the object participating in the current session is any user. In the embodiments of the present application, during the current session, the object participating in the current session also determines the output of the dialogue sentence, and therefore, in combination with the historical dialogue sentence of the current session and the object information corresponding to the object participating in the current session, the multiple candidate sentence types that can be used in the current round of dialogue are determined, so as to ensure the accuracy of the candidate sentence types that are preliminarily screened.

[0080] In a possible implementation, the object information is attribute information of the object, or is attribute information of the object that is updated based on the historical dialogue sentence of the current session.

[0081] The attribute information of the object is used to represent the object. Optionally, the attribute information of the object is information provided by the object under the authorization of the object. In the embodiments of the present application, when the object participates in a session, the dialogue sentence input by the object in the session can include a sentence or a word related to the object, and the attribute information of the object is updated based on the historical dialogue sentence, and the updated basic attribute information is used as the object information corresponding to the object, so as to enrich the content of the object information and improve the accuracy of the object information.

[0082] For example, the current session is a medical inquiry session, and the historical dialogue sentence of the current session can include a word used to describe the symptoms of the object or the physical characteristics of the object, the word used to describe the symptoms of the object or the physical characteristics of the object is extracted from the historical dialogue sentence of the current session, and the extracted word is added to the attribute information of the object, so as to obtain the updated object information of the object.

[0083] In a possible implementation, the process of determining the multiple candidate sentence types of the current round of dialogue includes: determining a first probability of each sentence type in the multiple sentence types based on the historical dialogue sentence of the current session and the object information corresponding to the object participating in the current session, the first probability indicating the possibility that the sentence type is used in the current round of dialogue; and determining, as the multiple candidate sentence types, the sentence types in the multiple sentence types that satisfy a first condition in the first probability.

[0084] In the embodiments of the present application, the multiple sentence types are pre-set sentence types, when the sentence type used in the current round of dialogue is determined, the possibility that each sentence type is used in the current round of dialogue is determined, the multiple candidate sentences that can be used in the current round of dialogue are selected based on the first probability used to represent the possibility that the sentence type is used, and then the accuracy of the candidate sentence types that are screened is ensured.

[0085] Optionally, the process of screening the candidate sentence types based on the first probabilities and the first condition comprises: determining the sentence types with the first probabilities greater than a first threshold value in the plurality of sentence types as the candidate sentence types; or arranging the plurality of sentence types in a descending order of the first probabilities, and determining the first quantity of sentence types at the front of the arrangement as the candidate sentence types; or arranging the plurality of sentence types in an ascending order of the first probabilities, and determining the first quantity of sentence types at the back of the arrangement as the candidate sentence types.

[0086] The first threshold value is an arbitrary numerical value, for example, the first threshold value is 0.7 or 0.8, etc. The first quantity is an arbitrary quantity, for example, the first quantity is 8 or 7, etc. In the case of arranging the plurality of sentence types in a descending order of the first probabilities, the sentence types at the front of the arrangement have greater first probabilities; in the case of arranging the plurality of sentence types in an ascending order of the first probabilities, the sentence types at the back of the arrangement have greater first probabilities. In the embodiments of the present application, the sentence types with greater first probabilities are screened from the plurality of sentence types based on the first probabilities and the first condition of the plurality of sentence types, as the candidate sentence types of the current round of dialogue, so as to ensure that the possibility of using the screened candidate sentence types in the current round of dialogue is large enough, and further ensure the accuracy of the screened candidate sentence types.

[0087] Optionally, the process of determining the first probability of the sentence type comprises: calling a type determination model, performing feature extraction on the historical dialogue sentence and the object information of the current session respectively to obtain historical features and object features, and calling the type determination model to process the historical features and the object features to obtain the first probability of each sentence type in the plurality of sentence types.

[0088] In the embodiments of the present application, the type determination model is used to determine the probability corresponding to each sentence type, the historical features are used to represent the historical object sentence of the current session, and can also reflect the dialogue state of the current session, that is, reflect the current dialogue situation of the current session. The object features are used to represent the object information corresponding to the object participating in the current session. The type determination model comprises the plurality of sentence types, and the type determination model is used to process the historical dialogue sentence and the object information to determine the first probability of using each sentence type in the current round of dialogue.

[0089] Optionally, the process of calling the type determination model to determine the first probability comprises: calling the type determination model to process the historical features and the object features to obtain a first vector, the first vector comprising a plurality of dimensions of probabilities, each dimension corresponding to a sentence type, that is, obtaining the first probability of each sentence type.

[0090] For example, the historical features and the object features are represented in the form of matrices, a type determination model is called, and the historical features and the object features are subjected to feature transformation to obtain a first vector, which indicates first probabilities of a plurality of sentence types.

[0091] In addition, in training the type determination model, sample historical dialogue sentences of a sample dialogue, sample object information corresponding to a sample object participating in the sample dialogue, and a sentence type label adopted in the current round of dialogue are obtained, the type determination model is called, and based on the sample historical dialogue sentences and the sample object information, prediction probabilities of each sentence type adopted in the current round of dialogue are predicted, and based on the prediction probabilities of the plurality of sentence types and the sentence type label, the type determination model is trained.

[0092] It should be noted that the embodiments of the present application are to determine a plurality of candidate sentence types of the current round of dialogue based on the historical dialogue sentences of the current session and the object information corresponding to the object participating in the current session, while in another embodiment, the above step 301 is not performed, and other ways are adopted to determine the plurality of candidate sentence types of the current round of dialogue based on the historical dialogue sentences of the current session. In a possible implementation manner, the process of determining the plurality of candidate sentence types of the current round of dialogue includes: determining a first probability of each sentence type in the plurality of sentence types based on the historical dialogue sentences of the current session, the first probability indicating a possibility of adopting the sentence type in the current round of dialogue; and determining the sentence types in the plurality of sentence types whose first probabilities satisfy a first condition as the plurality of candidate sentence types.

[0093] Optionally, taking the tth round of dialogue in the current session as an example, t is an integer greater than 1, the historical features and the first probabilities of the sentence types satisfy the following relationship:

[0094] g(s l )=-logP(s l |u t )

[0095] Wherein, s l is used to represent the lth sentence type in the plurality of sentence types, l is an integer greater than 0 and not greater than the number of the plurality of sentence types; g(s l ) is used to represent the first probability of the lth sentence type, u t is used to represent historical features corresponding to historical dialogue sentences of the current session before the tth round of dialogue, that is, the dialogue state of the current session at the tth round of dialogue; P(s l |u t ) is used to represent a probability of adopting the lth sentence type at the tth round of dialogue of the current session based on the historical features u t of the current session, in the embodiments of the present application, the probability P(s l|u t ) the probability obtained after the exponential transformation is the first probability of the lth sentence type.

[0096] 302. The computer device determines, based on the historical dialogue sentences, the object information corresponding to the object participating in the current session, the plurality of sentence types, and the plurality of candidate sentence types, a type sequence corresponding to each candidate sentence type, the type sequence including a sentence type used in at least one subsequent round of dialogue in a case where the candidate sentence type is used in the current round of dialogue.

[0097] In the embodiments of the present application, in the process of the current session, the object participating in the current session will affect what dialogue sentence the computer device outputs, and will also affect what dialogue sentence is output in at least one subsequent round of dialogue in a case where a certain candidate sentence type is used in the current round of dialogue. Therefore, in combination with the historical dialogue sentences of the current session and the object information corresponding to the object participating in the current session, the type sequence corresponding to each candidate sentence type is predicted, so as to ensure the accuracy of the predicted sentence type used in at least one subsequent round of dialogue after the current round of dialogue, that is, to ensure the accuracy of the type sequence corresponding to each candidate sentence type.

[0098] It should be noted that the embodiments of the present application determine the type sequence corresponding to the candidate sentence type of the current round of dialogue on the basis of the object information corresponding to the object participating in the session, and in another embodiment, the step 302 is not performed, but other ways are adopted to determine the type sequence corresponding to each candidate sentence type based on the historical dialogue sentences, the plurality of sentence types, and the plurality of candidate sentence types.

[0099] 303. The computer device obtains a fourth probability of each candidate sentence type, the fourth probability indicating a possibility of using the candidate sentence type in the current round of dialogue.

[0100] In the embodiments of the present application, the process of using the first probability of the sentence type to screen the plurality of candidate sentence types in the step 301, after a certain sentence type is determined as a candidate sentence type, the first probability of the sentence type is the fourth probability of the candidate sentence type. The process of obtaining the fourth probability of the candidate sentence type is the same as the process of obtaining the first probability of the sentence type, and will not be described here.

[0101] 304. The computer device determines a second parameter of each candidate sentence type based on the type sequence corresponding to each candidate sentence type, the second parameter indicating a dialogue quality of the current session after dialogue using the candidate sentence type and the corresponding type sequence.

[0102] The second parameter can reflect satisfaction of an object participating in the current session with the current session after the candidate sentence type is used in the current session and the type sequence corresponding to the candidate sentence type is used in at least one session after the current session, and the larger the second parameter is, the higher the satisfaction of the object participating in the current session with the current session is.

[0103] In the embodiment of the application, different sentence types are used in multiple sessions after the current session, and the conversation quality of the current session can be different. The type sequence corresponding to each candidate sentence type includes the sentence types that can be used in at least one session after the current session when the candidate sentence type is used in the current session. The conversation quality of the current session after the candidate sentence type and the corresponding type sequence are used in the current session and at least one session after the current session can be predicted through the type sequence corresponding to each candidate sentence type, that is, the second parameter of each candidate sentence type is predicted.

[0104] 305, the computer device weights and fuses the fourth probability and the second parameter of each candidate sentence type to obtain a first parameter of each candidate sentence type, and the first parameter indicates the conversation quality of the current session after the candidate sentence type is used for conversation.

[0105] In the embodiment of the application, the fourth probability of the candidate sentence type reflects the possibility that the candidate sentence type is used in the current session, and the fourth probability also reflects the influence of the candidate sentence type on the conversation quality of the current session. The larger the fourth probability of the candidate sentence type is, the more suitable the candidate sentence type is for the current session. When the candidate sentence type is used in the current session, the conversation sentence is more matched with the conversation sentence sent by the object in the current session, and the conversation quality of the current session is higher. The second parameter of the candidate sentence type indicates the conversation quality of the current session after the candidate sentence type and the corresponding type sequence are used for conversation. The conversation quality of the current session when each candidate sentence type is used can be determined by combining the fourth probability and the second parameter of each candidate sentence type, that is, the first parameter of the candidate sentence type is obtained.

[0106] In the embodiment of the application, the fourth probability of each candidate sentence type used in the current session reflects the influence of the candidate sentence type on the conversation quality of the current session. In the process of determining the first parameter of the candidate sentence type, not only the influence of the candidate sentence type on the conversation quality of the current session is considered, but also the influence of the type sequence corresponding to the candidate sentence type on the conversation quality of the current session when the candidate sentence type is used in the current session and the type sequence is used in at least one session after the current session is considered, so as to ensure the accuracy of the determined influence, that is, the accuracy of the determined first parameter is ensured.

[0107] In a possible implementation, taking the tth round of dialogue in the current session as an example, t is an integer greater than 1, the fourth probability of the candidate sentence type, the second parameter, and the first parameter of the candidate sentence type satisfy the following relationship:

[0108] F(s r )=g(s r )+λh(s r )

[0109] wherein s r is used to represent the rth candidate sentence type in the plurality of candidate sentence types of the current round of dialogue; g(s r ) is used to represent the fourth probability of the rth candidate sentence type, h(s r ) is used to represent the second parameter of the candidate sentence type, and λ is used to represent the first weight, and λ is a constant.

[0110] It should be noted that, in another embodiment, the steps 303-305 are not performed, and other manners are adopted to determine the first parameter of each candidate sentence type based on each candidate sentence type and the corresponding type sequence.

[0111] 306. The computer device generates the dialogue sentence of the current round of dialogue based on the candidate sentence type in the plurality of candidate sentence types whose first parameter satisfies the second condition.

[0112] In a possible implementation, the step 306 includes generating the dialogue sentence of the current round of dialogue based on the candidate sentence type in the plurality of candidate sentence types whose first parameter is the largest.

[0113] Optionally, the process of generating the dialogue sentence includes generating the dialogue sentence of the current round of dialogue based on the historical feature corresponding to the historical dialogue sentence of the current session, the object feature corresponding to the object information, and the candidate sentence type in the plurality of candidate sentence types whose first parameter is the largest.

[0114] In the embodiment of the application, the influence of the object information and the historical dialogue sentence on the current round of dialogue is considered, and the dialogue sentence of the current round of dialogue is generated in combination with the historical feature, the object feature, and the candidate sentence type in the plurality of candidate sentence types whose first parameter is the largest, so as to ensure the quality of the generated dialogue sentence.

[0115] The embodiment of the application provides a forward-looking sentence type planning algorithm based on long-term feedback estimation. When determining the sentence type used in the current round of conversation, the long-term influence of the sentence type used in at least one round of conversation after the current round of conversation on the current conversation is considered, that is, the long-term benefits of the use of the sentence type are determined by considering the satisfaction of the object participating in the current conversation with the current conversation after the candidate sentence type is used in the current round of conversation and the type sequence corresponding to the candidate sentence type is used in at least one round of conversation after the current round of conversation, so that the accuracy of determining the sentence type used in the current round of conversation is improved, and the user experience is also improved. Moreover, the application range of the scheme provided in the embodiment of the application is wide, and the scheme can be applied to various conversation tasks.

[0116] In the scheme provided in the embodiment of the application, in the process of human-computer interaction, the influence of the historical conversation sentence of the current conversation on the current round of conversation is considered, and the influence of the use of a certain sentence type in the current round of conversation on the sentence type used in at least one round of conversation after the current round of conversation is considered, and then the conversation quality of the current conversation is influenced. Therefore, while the multiple candidate sentence types that can be used in the current round of conversation are screened out in combination with the historical conversation sentence of the current conversation, the type sequence corresponding to each candidate sentence type is also predicted to determine the first parameter for indicating the conversation quality of the current conversation after each candidate sentence type is used in the current round of conversation. The candidate sentence type whose first parameter satisfies the second condition is used to generate the conversation sentence of the current round of conversation, so that the quality of the conversation sentence of the current round of conversation in the current conversation is ensured, and then the conversation quality of the current conversation is ensured, and the intelligence of human-computer interaction is improved.

[0117] Moreover, the fourth probability of the use of each candidate sentence type in the current round of conversation can reflect the influence of the use of the candidate sentence type in the current round of conversation on the conversation quality of the current conversation. In the process of determining the first parameter of the candidate sentence type, not only the influence of the use of the candidate sentence type in the current round of conversation on the conversation quality of the current conversation is considered, but also the influence of the use of the type sequence corresponding to the candidate sentence type in at least one round of conversation after the current round of conversation on the conversation quality of the current conversation is considered in the case that the candidate sentence type is used in the current round of conversation, so that the accuracy of determining the influence of each candidate sentence type on the conversation quality of the current conversation when the candidate sentence type is used in the current round of conversation is ensured, that is, the accuracy of the determined first parameter is ensured.

[0118] On the basis of the above Figure 3 The embodiment of the application also provides a sequence iteration method for determining the type sequence corresponding to each candidate sentence type. The specific process is shown in the following embodiment.

[0119] Figure 4 is a flowchart of a conversation generation method provided in the embodiment of the application. The method is executed by a computer device, as shown in Figure 4 The method comprises the following steps.

[0120] 401、The computer device determines, from the plurality of sentence types, k predicted sentence types corresponding to each of the m ith-type sequences, k being an integer greater than 0, based on the historical dialogue sentences of the current session, the object information corresponding to the object participating in the current session, and the candidate sentence types of the current round of dialogue.

[0121] In the embodiments of the present application, it is taken as an example that each candidate sentence type corresponds to m type sequences, m being an integer greater than 0, i being an integer greater than 0 and less than n, n being an integer greater than 1. For any candidate sentence type, the m type sequences corresponding to the candidate sentence type are updated in a sequence iteration manner to increase the sentence types in each type sequence until the m type sequences corresponding to the candidate sentence type all contain n sentence types.

[0122] In the embodiments of the present application, any candidate sentence type in the plurality of candidate sentence types of the current round of dialogue is described, the candidate sentence type currently corresponding to m ith-type sequences, each ith-type sequence including i sentence types. For each ith-type sequence, assuming that the candidate sentence type is used in the current round of dialogue and the sentence types in the ith-type sequence are used in the i rounds of dialogue thereafter, from the plurality of sentence types, k sentence types possibly used in the i+1 round of dialogue after the current round of dialogue are predicted, that is, k predicted sentence types corresponding to the ith-type sequence are obtained, and each ith-type sequence can obtain k predicted sentence types in the above manner.

[0123] 402、The computer device forms a candidate type sequence by each predicted sentence type and the corresponding ith-type sequence, to obtain j candidate type sequences, j being the product of k and m.

[0124] In the embodiments of the present application, each ith-type sequence corresponds to k predicted sentence types, and each ith-type sequence and the corresponding one predicted sentence type can form a candidate type sequence, the candidate type sequence including the sentence types in the ith-type sequence and one predicted sentence type, that is, k candidate type sequences corresponding to each ith-type sequence are obtained, that is, j candidate type sequences are obtained. Moreover, in the candidate type sequence formed by any ith-type sequence and the corresponding one predicted sentence type, the candidate type sequence includes i+1 sentence types, and the predicted sentence type is the i+1 sentence type in the candidate type sequence.

[0125] 403、The computer device determines a second probability of each candidate type sequence, the second probability indicating the possibility of using the sentence types in the candidate type sequence in the subsequent rounds of dialogue under the condition that the candidate sentence type is used in the current round of dialogue.

[0126] In the embodiment of the present application, the candidate type sequence includes i+1 sentence types, and the second probability of the candidate type sequence indicates the possibility of adopting the sentence types in the candidate type sequence in the i+1 rounds of conversation after the current round of conversation.

[0127] 404. The computer device screens m (i+1) type sequences from the j candidate type sequences according to the third condition.

[0128] In the embodiment of the present application, the third condition is a condition to be met by the second probability of the m (i+1) type sequences corresponding to the candidate sentence type.

[0129] In the embodiment of the present application, the historical conversation sentences of the current conversation, the object information of the object participating in the current conversation, and the candidate sentence type all affect which sentence type can be selected for the subsequent conversation, and when predicting the sentence type that can be adopted in the next round of conversation, the sentence type adopted in the previous conversation is referred to, and therefore, the (i+1) sentence type in the i type sequence is predicted in combination with the m i type sequences, so as to obtain the m (i+1) type sequences.

[0130] In a possible implementation, the step 404 includes: arranging the j candidate type sequences in descending order of the second probability, and determining the m candidate type sequences at the front of the arrangement as the (i+1) type sequences; or arranging the j candidate type sequences in ascending order of the second probability, and determining the m candidate type sequences at the rear of the arrangement as the (i+1) type sequences.

[0131] In the embodiment of the present application, when the j candidate type sequences are arranged in descending order of the second probability, the second probability of the candidate type sequence at the front of the arrangement is greater; and when the j candidate type sequences are arranged in ascending order of the second probability, the second probability of the candidate type sequence at the rear of the arrangement is greater.

[0132] In the embodiment of the present application, the second probability reflects the probability of the sentence type in the candidate type sequence being adopted, and the candidate type sequence with a greater second probability is screened from the j candidate type sequences as the (i+1) type sequence based on the second probability of the j candidate type sequences and the third condition, so that the probability of the sentence type adopted in the i+1 rounds of conversation after the current round of conversation is maximized, rather than the probability of the sentence type adopted in a certain round of conversation after the current round of conversation, thereby ensuring the accuracy of the determined (i+1) type sequence.

[0133] It should be noted that the embodiments of the present application are only described by taking one sequence iteration as an example. After the m i+1 type sequences corresponding to the candidate sentence type are obtained, the steps 401-404 are repeated to update the m i+1 type sequences corresponding to the candidate sentence type, until the m n type sequences corresponding to the candidate sentence type are obtained, n is an integer greater than 1, and i is an integer greater than 0 and less than n. In the embodiments of the present application, the n type sequence includes n sentence types.

[0134] From i being 1, the first type sequence includes 1 sentence type, that is, the sentence type that is likely to be used in the next round of dialogue under the condition that the candidate sentence type is used in the current round of dialogue. The influence of the candidate sentence type and the sentence type contained in the first type sequence is referred to in predicting the sentence type that is likely to be used in the second round of dialogue after the current round of dialogue, and then the second type sequence is determined, the second type sequence includes 2 sentence types, the first sentence type in any second type sequence is the sentence type in a first type sequence, and so on, until the m n type sequences are obtained. The m n type sequences are determined as the type sequences corresponding to the candidate sentence type.

[0135] In addition, the embodiments of the present application perform sequence iteration on the basis of determining the m first type sequences corresponding to the candidate sentence type to obtain the m n type sequences corresponding to the candidate sentence type. As for the process of obtaining the m first type sequences corresponding to the candidate sentence type: based on the historical dialogue sentences of the current session, the object information corresponding to the object participating in the current session, and the candidate sentence type, m predicted sentence types are determined from a plurality of sentence types, and each predicted sentence type constitutes a first type sequence.

[0136] Optionally, the process of obtaining the m first type sequences corresponding to the candidate sentence type includes: determining a seventh probability of each sentence type based on the historical dialogue sentences of the current session, the object information corresponding to the object participating in the current session, and the candidate sentence type. The seventh probability indicates the possibility of using the sentence type in the next round of dialogue under the condition that the candidate sentence type is used in the current round of dialogue. The sentence types with the seventh probability satisfying the fifth condition in the plurality of sentence types are determined as the m predicted sentence types.

[0137] In the embodiments of the present application, the sentence types that are likely to be used in each round of dialogue after the current round of dialogue are sequentially predicted in the time order of the multiple rounds of dialogue of the current session. When predicting the sentence types that are likely to be used in any round of dialogue after the current round of dialogue, the influence of the type sequence composed of the sentence types that are likely to be used in at least one round of dialogue before the round of dialogue on the round of dialogue is considered, and then a new type sequence is obtained, so as to ensure that the multiple type sequences finally obtained are type sequences composed of the most likely to be used sentence types, and then the accuracy of the determined type sequence is ensured.

[0138] On the basis of the above Figure 4 On the basis of the above

[0139] Figure 5 is a flowchart of a dialogue generation method provided by an embodiment of the present application, and the method is executed by a computer device. As Figure 5 indicated, the method comprises the following steps.

[0140] 501. The computer device extracts features of the candidate sentence type and the i-th type sequence to obtain type features.

[0141] The type features are used to represent the sentence types contained in the candidate sentence type and the i-th type sequence.

[0142] In a possible implementation manner, the step 501 comprises: extracting features of the candidate sentence type to obtain first type features, extracting features of each sentence type in the i-th type sequence to obtain second type features of each sentence type in the i-th type sequence, concatenating the first type features and the second type features of each sentence type in the i-th type sequence to obtain concatenated features, updating the concatenated features by using a multi-head self-attention mechanism, fusing the updated concatenated features and the concatenated features, and performing normalization processing on the fused features to obtain the type features used to represent the sentence types contained in the candidate sentence type and the i-th type sequence.

[0143] The first type features are used to represent the candidate sentence type, and each second type feature is used to represent one sentence type in the i-th type sequence.

[0144] In the embodiment of the present application, the concatenated features contain the type features of the candidate sentence type and each sentence type in the i-th type sequence. The multi-head self-attention mechanism is used to update the concatenated features, so as to update the concatenated features according to the similarities between the features contained in the concatenated features, to enhance the relevance between the candidate sentence type and the sentence types in the i-th type sequence, and to improve the accuracy of the updated concatenated features. Furthermore, the updated concatenated features are fused with the concatenated features and then normalized, so as to reflect the residual of the concatenated features, and to further improve the accuracy of the finally obtained type features.

[0145] 502、The computer device updates the historical feature corresponding to the historical dialogue sentence and the object feature corresponding to the object information based on the type feature.

[0146] The historical feature is used to represent the historical dialogue sentence of the current session, and the object feature is used to represent the object information corresponding to the object participating in the current session.

[0147] In the embodiments of the present application, the historical feature and the object feature are updated based on the type feature used to represent the candidate sentence type and the sentence type contained in the i-th type sequence, so that the type feature is fused with the historical feature and the object feature, i.e. the type feature is integrated into the updated historical feature and the updated object feature.

[0148] In a possible implementation manner, the step 502 includes: using a multi-head self-attention mechanism to update the historical feature corresponding to the historical dialogue sentence and the object feature corresponding to the object information.

[0149] In the embodiments of the present application, the multi-head self-attention mechanism is used to update the historical feature and the object feature in combination with the type feature, so that the type feature is fused with the historical feature and the object feature, so as to enrich the information contained in the updated historical feature and the updated object feature.

[0150] Optionally, taking the current session as the t-th round of dialogue in the current session as an example, t is an integer greater than 1, the type feature, the historical feature, the object feature, the updated historical feature and the updated object feature satisfy the following relationship:

[0151]

[0152]

[0153] wherein, P represents the updated historical feature; t H represents the type feature; t U represents the historical feature; t L represents the object feature; L represents the updated object feature; L(·) represents a linear transformation function; and MH(·) represents a transformation operation of multi-head attention.

[0154] 503、The computer device updates the historical feature corresponding to the historical dialogue sentence and the object feature corresponding to the object information based on the type feature.

[0155] In a possible implementation, the step 503 comprises: determining a second weight based on the updated historical feature and the updated object feature, and performing weighted fusion on the updated historical feature and the updated object feature based on the second weight to obtain the fused feature.

[0156] In the embodiments of the present application, the second weight is determined based on the relationship between the updated historical feature and the updated object feature, and the updated historical feature and the updated object feature are weighted fused by using the second weight, so as to ensure the accuracy of the fused feature obtained after fusion.

[0157] Optionally, taking the tth round of dialogue in the current dialogue as an example, t is an integer greater than 1, the updated historical feature, the updated object feature, the second weight and the fused feature satisfy the following relationship:

[0158]

[0159]

[0160] wherein, used to represent the fused feature; μ used to represent the second weight; used to represent the updated historical feature; used to represent the updated object feature; W μ , b μ respectively represent a first adjustment parameter and a second adjustment parameter used for obtaining the second weight μ; W μ , b μ are constants; sigmoid(·) used to represent an activation function, used to map a variable to between 0 and 1; used to represent a feature obtained after the updated historical feature and the updated object feature are spliced.

[0161] 504, the computer device performs transformation processing on the fused feature to obtain a third probability of a plurality of sentence types, the third probability indicating a possibility of using the sentence type in the next round of dialogue in the case that the candidate sentence type is used in the current round of dialogue, and the sentence type in the ith type sequence is used in at least one round of dialogue after the current round of dialogue.

[0162] wherein, the third probability of any sentence type indicates a possibility of using the sentence type in the i+1th round of dialogue after the current round of dialogue in the case that the candidate sentence type is used in the current round of dialogue, and the sentence type in the ith type sequence is used in i rounds of dialogue after the current round of dialogue.

[0163] In the embodiment of the present application, considering that the historical dialogue sentence, the object information and the sentence type used in the current determined multi-round dialogue will have an impact on the next round of dialogue, the fusion feature contains the historical feature, the object feature and the type feature, and based on the fusion feature, the possibility of using each sentence type in the i+1 round of dialogue after the current round of dialogue can be accurately predicted, that is, the third probability of each sentence type is determined.

[0164] In a possible implementation manner, the step 504 comprises: performing transformation processing on the fusion feature to obtain a second vector, the second vector comprising probabilities of multiple dimensions, each dimension corresponding to a sentence type, that is, the third probability of each sentence type is obtained.

[0165] Optionally, the present application takes the current round of dialogue as the tth round of dialogue in the current session, and determines the third probability of the sentence type of the i+1 round of dialogue after the tth round of dialogue as an example, t is an integer greater than 1, the fusion feature and the third probability of each sentence type satisfy the following relationship:

[0166]

[0167] Wherein, P(s t+i+1 |s t : t+i+1 , H t , U t ) is used to represent the third probability of using each sentence type in the i+1 round of dialogue in the case of using the candidate sentence type in the current round of dialogue and using the sentence type in the i-type sequence in the i rounds of dialogue after that; s t+i+1 is used to represent each sentence type in the multiple sentence types; s t : t+i+1 is used to represent the candidate sentence type used in the current round of dialogue and the sequence constituted by the i-type sequence used in the i rounds of dialogue after that, H t is used to represent the historical feature; U t is used to represent the object feature; soft max(·) is used to represent the normalization function; W s , b s are the third adjustment parameter and the fourth adjustment parameter used to obtain the third probability of the sentence type s t+i+1 , W s , b s are both constants. is used to represent the fusion feature.

[0168] 505, the computer device determines the sentence type whose third probability satisfies the fourth condition in the multiple sentence types as the k predicted sentence types corresponding to the i-type sequence.

[0169] In the embodiment of the present application, the fourth condition is that the third probability of the sentence type used in the i+1th round of dialogue after the current round of dialogue needs to meet the condition in the case that the candidate sentence type is used in the current round of dialogue and the sentence type in the i-type sequence is used in the i rounds of dialogue after the current round of dialogue. Based on the fourth condition, the k predicted sentence types that are possibly used in the i+1th round of dialogue after the current round of dialogue are screened from the plurality of sentence types, thereby ensuring the accuracy of the screened k predicted sentence types.

[0170] In a possible implementation manner, the step 505 comprises: determining the sentence types with the third probability greater than the second threshold value in the plurality of sentence types as the candidate sentence types; or arranging the plurality of sentence types in descending order of the third probability, and determining the second number of sentence types at the front of the arrangement as the candidate sentence types; or arranging the plurality of sentence types in ascending order of the first probability, and determining the second number of sentence types at the back of the arrangement as the candidate sentence types.

[0171] The second threshold value is an arbitrary numerical value, for example, the second threshold value is 0.7 or 0.8, etc. The second number is an arbitrary number, for example, the second number is 8 or 7, etc. In the case that the plurality of sentence types are arranged in descending order of the third probability, the sentence types at the front of the arrangement have greater third probability; in the case that the plurality of sentence types are arranged in ascending order of the third probability, the sentence types at the back of the arrangement have greater third probability. In the embodiment of the present application, based on the third probability of the plurality of sentence types and the fourth condition, the sentence types with greater third probability are screened from the plurality of sentence types as the predicted sentence types corresponding to the i-type sequence, so as to ensure that the possibility of using the screened predicted sentence types in the i+1th round of dialogue after the current round of dialogue is large enough in the case that the candidate sentence type is used in the current round of dialogue and the sentence type in the i-type sequence is used in the i rounds of dialogue after the current round of dialogue, thereby ensuring the accuracy of the screened predicted sentence types.

[0172] It should be noted that, in another embodiment, the steps 503-505 are not performed, but other manners are adopted to determine the k predicted sentence types corresponding to the i-type sequence from the plurality of sentence types based on the updated historical features and the updated object features.

[0173] In the embodiment of the present application, it is considered that the historical dialogue sentence, the object information and the sentence type currently determined in the multi-turn dialogue will have an impact on the next turn dialogue. Therefore, the type feature for representing the candidate sentence type and the sentence types contained in the i-th type sequence, the historical feature for representing the historical dialogue sentence and the object feature for representing the object information are combined to obtain the fusion feature, which contains the historical feature, the object feature and the type feature corresponding to the currently determined sentence type. The fusion feature can reflect the dialogue state of the current session under the condition that the candidate sentence type and the sentence types in the i-th type sequence are used in the current turn dialogue and the i-turn dialogue thereafter. Therefore, the possibility of using each sentence type in the next turn dialogue can be determined based on the fusion feature, that is, the possibility of using each sentence type in the i+1-turn dialogue after the current turn dialogue under the condition that the candidate sentence type is used in the current turn dialogue and the sentence types in the i-th type sequence are used in the i-turn dialogue thereafter. Then, the third probability and the fourth condition of each sentence type are combined to select k predicted sentence types that can be used in the i+1-turn dialogue after the current turn dialogue from the plurality of sentence types, thereby ensuring the accuracy of the selected k predicted sentence types.

[0174] In addition, based on the embodiments shown in the above Figure 4 and Figure 5 , the present application further provides a way to determine the second probability of each candidate type sequence, that is, the process of determining the second probability of each candidate type sequence includes: determining the probability of each sentence type in the candidate type sequence being used in the corresponding dialogue turn, and multiplying the probabilities corresponding to the sentence types in the candidate type sequence to determine the second probability of the candidate type sequence.

[0175] In the embodiment of the present application, based on the seventh probability of each sentence type, m first type sequences are determined, and starting from the first type sequence, based on the third probability of the plurality of sentence types, m i+1 type sequences are determined each time on the basis of the i-th type sequence currently determined. Therefore, in the sequence iteration process, the probability of each sentence type in each type sequence being used in the corresponding dialogue turn is determined, so that the second probability of the candidate type sequence can be determined based on the product of the probabilities of the sentence types contained in the candidate type sequence being used in the corresponding dialogue turn.

[0176] In addition, based on the embodiments shown in the above Figure 3 , the present application further provides a way to determine the second parameter of each candidate sentence type, which will be described in detail in the following embodiments.

[0177] Figure 6 is a flowchart of a dialogue generation method provided by an embodiment of the present application. The method is executed by a computer device, such asFigure 6 The method comprises:

[0178] 601. The computer device determines a fifth probability of each type sequence corresponding to the candidate sentence type, the fifth probability indicating a possibility of adopting a sentence type in the type sequence in at least one subsequent round of conversation in the case of adopting the candidate sentence type in the current round of conversation of the current session.

[0179] In the embodiments of the present application, it is assumed that each candidate sentence type corresponds to m type sequences. For any candidate sentence type in the candidate sentence types in the current round of conversation, in the case of adopting the candidate sentence type in the current round of conversation in the current session, a certain type sequence corresponding to the candidate sentence type may be adopted in at least one subsequent round of conversation. The fifth probability of each type sequence corresponding to the candidate sentence type reflects a possibility of adopting the type sequence.

[0180] In a possible implementation, the process of determining the fifth probability of each type sequence comprises: determining a probability of adopting each sentence type contained in any type sequence, and determining a product of the probabilities of the sentence types contained in the type sequence as the fifth probability of the type sequence. It should be noted that the process of determining the fifth probability of each sequence is the same as the process of determining the second probability of the candidate type sequence, which will not be described here.

[0181] 602. The computer device obtains a third parameter of each type sequence corresponding to the candidate sentence type based on historical conversation sentences of the current session, the third parameter indicating a conversation quality of the current session in the case of adopting the candidate sentence type in the current round of conversation and adopting a sentence type in the type sequence in at least one subsequent round of conversation.

[0182] In the embodiments of the present application, the historical conversation sentences of the current session can reflect a conversation state of the current session, and based on the historical conversation sentences, it can be determined how to continue the conversation subsequently. The m type sequences corresponding to the candidate sentence type are different, and adopting sentence types in different type sequences in at least one subsequent round of conversation after the current round of conversation will have different influences on the conversation quality of the current session. Therefore, based on the historical conversation sentences of the current session, it can be determined whether each type sequence corresponding to the candidate sentence type is suitable for the current session, and further, the third parameter of each type sequence corresponding to each candidate sentence type is determined to reflect the conversation quality of the current session in the case of adopting the candidate sentence type in the current round of conversation and adopting a sentence type in the type sequence in at least one subsequent round of conversation.

[0183] In a possible implementation, the process of obtaining the third parameter of any type sequence corresponding to the candidate sentence type comprises: obtaining historical features corresponding to historical dialogue sentences, candidate features corresponding to the candidate sentence type, and sequence features corresponding to the type sequence; concatenating the historical features, the candidate features, and the sequence features to obtain concatenated features; encoding the concatenated features based on a prediction model to obtain encoded features; and performing transformation processing on the encoded features based on the prediction model to obtain the third parameter of the type sequence.

[0184] The prediction model is used to predict the third parameter of the type sequence. In the embodiments of the present application, the historical features are used to represent the historical dialogue sentences of the current session, the candidate features are used to represent the candidate sentence type, and the sequence features are used to represent the sentence types in the type sequence. By concatenating the historical features, the candidate features, and the sequence features, and processing the concatenated features by using the prediction model, the dialogue quality of the current session after the current session adopts the candidate sentence type and the type sequence for dialogue can be predicted.

[0185] Optionally, the prediction model comprises an encoding layer and a feedforward neural layer, the encoding layer in the prediction model is invoked to encode the concatenated features to obtain encoded features, and the feedforward neural layer is invoked to perform transformation processing on the encoded features to obtain the third parameter of the type sequence. The encoding layer is a Bi-RNN (Bidirectional Recurrent Neural Networks), a Transformer, or the like.

[0186] Optionally, the concatenated features are obtained by concatenating a start character, historical features, a separator, candidate features, and sequence features, and the process of invoking the feedforward neural layer to obtain the third parameter comprises: after the encoding layer is invoked to obtain the encoded features, a target sub-feature in the encoded features is extracted, the position of the target sub-feature in the encoded features is the same as the position of the start character in the concatenated features, the feedforward neural layer is invoked to perform transformation processing on the target sub-feature to obtain the third parameter of the type sequence.

[0187] In the embodiments of the present application, in the case where the concatenated features are obtained by concatenating a start character, historical features, a separator, candidate features, and sequence features, after the concatenated features are encoded, the target sub-feature in the encoded features can represent the encoded features, and only the target sub-feature is subsequently subjected to transformation processing, so as to reduce the amount of calculation and improve the efficiency of obtaining the third parameter.

[0188] Optionally, taking the t th round of dialogue in the current session as an example, t is an integer greater than 1, and the third parameter of any type sequence corresponding to the candidate sentence type satisfies the following relationship:

[0189] f(u t , s t:t+n ) = W f q f + b f

[0190] B = TRS Enc ([Emb([CLS];H t ;[SEP];s ≥t )])

[0191] wherein f(u t , s t:t+n ) is used to represent the third parameter of the type sequence; u t is used to represent the historical feature corresponding to the historical dialogue sentence of the current session before the tth round of dialogue, that is, the dialogue state at the tth round of dialogue of the current session; s t : t+n is used to represent the sequence formed by the candidate sentence type and the type sequence, the type sequence including n sentence types; W f , b f are the fifth adjustment parameter and the sixth adjustment parameter respectively, W f , b f are both constants; B is used to represent the encoding feature; q f is used to represent the target sub-feature in the encoding feature; TRS Enc [·] is used to represent the encoding layer; Emb(·) is used to represent the embedded encoding; [CLS] is used to represent the starting character; [SEP] is used to represent the separator; H t is used to represent the historical feature; s ≥t is used to represent the feature after splicing the candidate feature and the sequence feature.

[0192] 603. The computer device determines the product of the sixth probability and the third parameter of the same type sequence to obtain m products corresponding to the candidate sentence type.

[0193] In the embodiments of the present application, the candidate sentence type corresponds to m type sequences, each type sequence corresponds to a sixth probability and a third parameter, and the product of the sixth probability and the third parameter corresponding to the same type sequence is determined, that is, one product corresponding to each type sequence is obtained, that is, m products are obtained.

[0194] 604. The computer device determines the sum of the m products corresponding to the candidate sentence type as the second parameter of the candidate sentence type.

[0195] In a possible implementation manner, taking the tth round of dialogue in the current session as an example, t is an integer greater than 1, the sixth probability and the third parameter of each type sequence corresponding to the candidate sentence type, and the second parameter of the candidate sentence type satisfy the following relationship:

[0196]

[0197] wherein, s r is used to represent the rth candidate sentence type in the plurality of candidate sentence types in the current round of dialogue; h(s r ) is used to represent the second parameter of the rth candidate sentence type, E[f(u t , s r , s >t ) | s r , u t ] is used to represent the expectation between the sixth probability of the m type sequences corresponding to the rth candidate sentence type and the third parameter when the rth candidate sentence type is adopted in the current round of dialogue, f(u t , s r , s > t) is used to represent the third parameter of the type sequence corresponding to the rth candidate sentence type, u t is used to represent the historical features corresponding to the historical dialogue sentences of the current session before the tth round of dialogue, i.e., the dialogue state of the current session at the tth round of dialogue; P(s >t | s r , u t ) is used to represent the sixth probability of the type sequence corresponding to the rth candidate sentence type, s >t is used to represent the type sequence corresponding to the rth candidate sentence type, and Q is used to represent the set of all possible type sequences composed of the plurality of sentence types.

[0198] Optionally, taking the tth round of dialogue in the current session as an example, t is an integer greater than 1, and the m type sequences corresponding to the candidate sentence type each include n sentence types, the second parameter of the candidate sentence type satisfies the following relationship:

[0199]

[0200]

[0201] wherein, s r is used to represent the rth candidate sentence type in the plurality of candidate sentence types in the current round of dialogue; h(s r ) is used to represent the second parameter of the rth candidate sentence type in the plurality of candidate sentence types in the current round of dialogue, f(u t , s r , s >t ) is used to represent the third parameter of the type sequence corresponding to the rth candidate sentence type, P(s >t | s r , u t) for representing the sixth probability of any type sequence corresponding to the rth candidate sentence type, u t for representing the historical features corresponding to the historical dialogue sentences of the current session before the tth round of dialogue, that is, the dialogue state of the current session at the tth round of dialogue; s >t for representing any type sequence corresponding to the rth candidate sentence type, in the embodiments of the present application, the type sequence s >t of the rth candidate sentence type includes n sentence types, Q n for representing a type sequence set including all type sequences composed of n sentence types, for representing the type sequence set composed of m type sequences corresponding to the rth candidate sentence type, argtop m(·) is used for representing selecting the m type sequences with the highest ranking, in the embodiments of the present application, the m type sequences with the highest probability of being used in at least one round of dialogue after the current round of dialogue are determined under the condition that the rth candidate sentence type is used in the current round of dialogue, and the type sequence set Q n is constructed from the m type sequences selected from the type sequence set Q n in which the m type sequences with the highest probability of being used in at least one round of dialogue after the current round of dialogue are selected under the condition that the rth candidate sentence type is used in the current round of dialogue.

[0202] In the embodiments of the present application, the candidate sentence type corresponds to m type sequences, any type sequence of the m type sequences can be used in at least one round of dialogue after the current round of dialogue under the condition that the candidate sentence type is used in the current round of dialogue, the dialogue quality of the current session can be different after different type sequences are used in at least one round of dialogue after the current round of dialogue, and the influence of using each type sequence on the dialogue quality of the current session is comprehensively considered to determine the second parameter of the candidate sentence type, so that the second parameter can indicate the dialogue quality of the current session after the candidate sentence type is used in the current round of dialogue, and the accuracy of the determined second parameter is ensured.

[0203] In the embodiments shown in the above Figures 2 to 6 , the present application further provides a sequence generation model, based on the sequence generation model and the prediction model, the first parameter of each candidate sentence type of the current round of dialogue can be determined, as shown in Figure 7As shown, the sequence generation model includes n+1 sub-models and a probability prediction sub-model, each sub-model includes a multi-head self-attention layer, a first residual & normalization layer, a first interaction attention layer, a second interaction attention layer, an information fusion layer, a feedforward neural layer, a second residual & normalization layer, wherein the linear & normalization layer is used for linear processing and then normalization processing of the feature, the first residual & normalization layer is used for residual operation and then normalization processing of the feature, and the second residual & normalization layer is used for residual operation and then normalization processing of the feature, and the probability prediction sub-model includes a linear layer and a normalization layer. The prediction model includes an encoding layer and a feedforward neural layer. Then the process of determining the first parameter of each candidate sentence type of the current round of dialogue includes:

[0204] Step 1. When determining the candidate sentence type of the current round of dialogue, the multi-head self-attention layer and the first residual & normalization layer in the first sub-model output an empty vector; the first interaction attention layer in the first sub-model is called to update the historical feature based on the empty vector, the second interaction attention layer in the first sub-model is called to update the object feature based on the empty vector; the information fusion layer in the first sub-model is called to weight and fuse the updated historical feature and the updated object feature to obtain a fused feature, the feedforward neural layer and the second residual & normalization layer in the first sub-model are called to transform the fused feature; the probability prediction sub-model is called to process the transformed feature to obtain the first probability of multiple sentence types; the sentence type in the multiple sentence types that satisfies the first condition is determined as the multiple candidate sentence types of the current round of dialogue.

[0205] Wherein, the empty vector is used to represent that the current determined sentence type is empty. The embodiments of the present application are described by taking the empty vector as an example, and in another embodiment, the process of generating the empty vector and updating the historical feature and the object feature using the empty vector is not required to be performed, and the first interaction attention layer in the first sub-model is called to update the historical feature, and the second interaction attention layer in the first sub-model is called to update the object feature.

[0206] Step 2, call the multi-head self-attention layer, the first residual & normalization layer in the second sub-model, process any candidate sentence type to obtain the first type feature; call the first interaction attention layer in the second sub-model, update the historical feature based on the first type feature, call the second interaction attention layer in the second sub-model, update the object feature based on the first type feature; call the information fusion layer in the second sub-model, weight the updated historical feature and the updated object feature to obtain the fusion feature, call the feedforward neural layer and the second residual & normalization layer in the second sub-model, transform the fusion feature; call the probability prediction sub-model to process the transformed feature to obtain the seventh probability of multiple sentence types; determine the sentence type of which the seventh probability meets the fifth condition in the multiple sentence types as the m predicted sentence types, and form a first type sequence corresponding to the candidate sentence type for each predicted sentence type.

[0207] Step 3, call the multi-head self-attention layer, the first residual & normalization layer in the i+2th sub-model, process the candidate sentence type and any i type sequence to obtain the i+1th type feature; call the first interaction attention layer in the i+2th sub-model, update the historical feature based on the i+1th type feature, call the second interaction attention layer in the i+2th sub-model, update the object feature based on the i+1th type feature; call the information fusion layer in the i+2th sub-model, weight the updated historical feature and the updated object feature to obtain the fusion feature, call the feedforward neural layer and the second residual & normalization layer in the i+2th sub-model, transform the fusion feature; call the probability prediction sub-model to process the transformed feature to obtain the third probability of multiple sentence types; determine the sentence type of which the third probability meets the fourth condition in the multiple sentence types as the k predicted sentence types corresponding to the i type sequence, form a candidate type sequence for each predicted sentence type and the corresponding i type sequence to obtain j candidate type sequences, determine the second probability of each candidate type sequence, and select the m i+1th type sequences of which the second probability meets the third condition from the j candidate type sequences, until the m n type sequences corresponding to the candidate sentence type are obtained, and the n type sequence includes n sentence types.

[0208] Step 4, determine the product of the seventh probability of the first sentence type and the second probability of the remaining sentence types in each n type sequence as the sixth probability of each n type sequence.

[0209] In the embodiments of the present application, according to the above steps 2-3, the multiple m n type sequences corresponding to each candidate sentence type of the current round of dialogue and the sixth probability of each n type sequence can be obtained.

[0210] Step 5, concatenating the start character, the history feature, the separator, the candidate feature and any nth type sequence to obtain a concatenated feature; calling an encoding layer in the prediction model to encode the concatenated feature to obtain an encoded feature; calling a feedforward neural layer in the prediction model to transform the encoded feature to obtain a third parameter of the nth type sequence, and in the above manner, the third parameter of each nth type sequence can be obtained.

[0211] Step 6, determining the product of the sixth probability and the third parameter of the same nth type sequence to obtain m products corresponding to the candidate sentence type, and determining the sum of the m products corresponding to the candidate sentence type as the second parameter of the candidate sentence type.

[0212] Step 7, weighting and fusing the fourth probability and the second parameter of each candidate sentence type to obtain a first parameter of each candidate sentence type; selecting a candidate sentence type whose first parameter satisfies a second condition from a plurality of candidate sentence types, and the selected candidate sentence type is used to generate a dialogue sentence of the current round of conversation.

[0213] Based on the above Figures 2 to 6 The embodiment shown, the present application further provides a flow chart of a dialogue generation method, as Figure 8 shown, the method comprises: calling an information encoder to encode object information corresponding to an object participating in a current session to obtain an encoded feature; calling a history encoder to encode a historical dialogue sentence of the current session to obtain a history feature; calling a sentence type planner to process the object feature and the history feature to obtain a sentence type used to generate a dialogue sentence of the current round of conversation; calling a dialogue generator to process the object feature, the history feature and the sentence type used to generate the dialogue sentence of the current round of conversation to obtain the dialogue sentence of the current round of conversation.

[0214] Among them, the dialogue generator is any network model, for example, the dialogue generator is a Seq2seq (Sequence to sequence, sequence to sequence) model.

[0215] In the embodiment of the present application, the sentence type planner is used to perform steps 1-7 in the embodiment shown in Figure 7 .

[0216] On the basis of the above Figures 2 to 8 The embodiment shown, the dialogue sentence generation method provided by the embodiment of the present application can be applied to various scenes. Taking the application in the medical inquiry scene as an example, the current session is a medical inquiry session, and the medical inquiry session is as Figure 9As shown in FIG. 1, when the user initiates the medical consultation session, the computer device outputs the preset dialogue sentence corresponding to at least one sentence type in the medical consultation session, that is, when the medical consultation session is initiated, the fixed two dialogue sentences "Hello, I am your doctor's assistant, and I need to understand your condition so that the doctor can better diagnose" and "Please describe your condition in detail, such as where you are uncomfortable and what symptoms (5-100 words) you have" are output. After the user replies, based on the historical dialogue sentences in the medical consultation session, a dialogue sentence "Please confirm your age and gender" is generated by using the method provided in the embodiments of the present application, and the control related to the dialogue sentence is displayed in the interface for the user to select, such as Figure 9 As shown in FIG. 1, the age control and the gender control are displayed for the user to select the age and the gender, and when the user clicks the "next step" control, the input of the user is completed, and a user-replied dialogue sentence is generated, which includes the age and the gender.

[0217] Figure 10 FIG. 2 is a structural schematic diagram of a dialogue generation device provided in the embodiments of the present application, as shown in FIG. 2, the device includes: Figure 10

[0218] The determining module 1001 is configured to determine, during the current session process, a plurality of candidate sentence types of the current dialogue from a plurality of sentence types based on at least the historical dialogue sentences of the current session, the candidate sentence type being a sentence type in the plurality of sentence types whose first probability satisfies a first condition, and the first probability indicating the possibility of using the sentence type in the current dialogue.

[0219] The determining module 1001 is further configured to determine, based on the historical dialogue sentences, the plurality of sentence types and the plurality of candidate sentence types, a type sequence corresponding to each candidate sentence type, the type sequence including the sentence types used in at least one subsequent dialogue in the case of using the candidate sentence type in the current dialogue.

[0220] The determining module 1001 is further configured to determine, based on each candidate sentence type and the corresponding type sequence, a first parameter of each candidate sentence type, the first parameter indicating the dialogue quality of the current session after using the candidate sentence type for dialogue.

[0221] The generating module 1002 is further configured to generate the dialogue sentence of the current dialogue based on the candidate sentence type in the plurality of candidate sentence types whose first parameter satisfies a second condition.

[0222] In a possible implementation, the determining module 1001 is configured to determine, based on the historical dialogue sentences and object information corresponding to the object participating in the current session, the plurality of candidate sentence types from the plurality of sentence types; and determine, based on the historical dialogue sentences, the object information, the plurality of sentence types and the plurality of candidate sentence types, the type sequence corresponding to each candidate sentence type.​

[0223] In a possible implementation, the determining module 1001 is configured to determine, based on the historical dialogue sentences and the object information, a first probability of each of a plurality of sentence types, the first probability indicating a possibility of adopting the sentence type in the current round of dialogue; and determine, as the plurality of candidate sentence types, the sentence types in the plurality of sentence types that satisfy a first condition in terms of the first probability.

[0224] In a possible implementation, each candidate sentence type corresponds to m type sequences, m being an integer greater than 0; and the determining module 1001 is configured to predict, based on the historical dialogue sentences, the object information, the candidate sentence type, the plurality of sentence types, and an ith type sequence of the m type sequences, an (i+1)th sentence type in the ith type sequence to obtain an (i+1)th type sequence of the m type sequences, the ith type sequence including i sentence types, the (i+1)th type sequence including i+1 sentence types, the i+1 sentence types including the sentence types in one ith type sequence, until an nth type sequence of the m type sequences is obtained, n being an integer greater than 1 and i being an integer greater than 0 and less than n.

[0225] In a possible implementation, as shown in FIG. 10, the determining module 1001 includes: Figure 11

[0226] The first determining unit 1011 is configured to determine, based on the historical dialogue sentences, the object information, and the candidate sentence type, k predicted sentence types corresponding to each ith type sequence from the plurality of sentence types, k being an integer greater than 0.

[0227] The constituting unit 1012 is configured to constitute each predicted sentence type and the corresponding ith type sequence into a candidate type sequence to obtain j candidate type sequences, j being a product of k and m.

[0228] The first determining unit 1011 is further configured to determine a second probability of each candidate type sequence, the second probability indicating a possibility of adopting the sentence types in the candidate type sequence in the subsequent rounds of dialogue in the case where the candidate sentence type is adopted in the current round of dialogue.

[0229] The screening unit 1013 is configured to screen, from the j candidate type sequences, m (i+1)th type sequences that satisfy a third condition in terms of the second probability.

[0230] In a possible implementation, the first determining unit 1011 is configured to perform feature extraction on the candidate sentence type and the ith type sequence to obtain type features; update historical features corresponding to the historical dialogue sentences and object features corresponding to the object information based on the type features; and determine, based on the updated historical features and the updated object features, the k predicted sentence types corresponding to the ith type sequence from the plurality of sentence types. ​

[0231] In another possible implementation, the first determining unit 1011 is configured to: perform weighted fusion on the updated historical feature and the updated object feature to obtain a fusion feature; perform transformation processing on the fusion feature to obtain third probabilities of a plurality of sentence types, the third probability indicating a possibility of using a sentence type in a next round of dialogue in a case where the candidate sentence type is used in the current round of dialogue and sentence types in an i-th type sequence are used in at least one round of dialogue after the current round of dialogue; and determine, as the k predicted sentence types corresponding to the i-th type sequence, sentence types of the plurality of sentence types that satisfy a fourth condition in terms of the third probability.

[0232] In another possible implementation, as shown in Figure 11 The determining module 1001 includes:

[0233] The obtaining unit 1014 is configured to obtain a fourth probability of the candidate sentence type, the fourth probability indicating a possibility of using the candidate sentence type in the current round of dialogue.

[0234] The second determining unit 1015 is configured to determine a second parameter of the candidate sentence type based on the type sequence corresponding to the candidate sentence type, the second parameter indicating a dialogue quality of the current session after dialogue using the candidate sentence type and the corresponding type sequence.

[0235] The fusion unit 1016 is configured to perform weighted fusion on the fourth probability and the second parameter to obtain a first parameter of the candidate sentence type.

[0236] In another possible implementation, the candidate sentence type corresponds to m type sequences; the second determining unit 1015 is configured to determine a fifth probability of each type sequence corresponding to the candidate sentence type, the fifth probability indicating a possibility of using a sentence type in the type sequence in at least one round of dialogue after the current round of dialogue in a case where the candidate sentence type is used in the current round of dialogue; obtain a third parameter of each type sequence based on the historical dialogue sentence, the third parameter indicating a dialogue quality of the current session in a case where the candidate sentence type is used in the current round of dialogue and a sentence type in the type sequence is used in at least one round of dialogue after the current round of dialogue; and determine a product of a sixth probability and the third parameter of the same type sequence to obtain m products corresponding to the candidate sentence type; and determine a sum of the m products corresponding to the candidate sentence type as the second parameter of the candidate sentence type.

[0237] In another possible implementation, the second determining unit 1015 is configured to obtain a historical feature corresponding to the historical dialogue sentence, a candidate feature corresponding to the candidate sentence type, and a sequence feature corresponding to the type sequence; perform splicing on the historical feature, the candidate feature, and the sequence feature to obtain a spliced feature; perform encoding on the spliced feature based on a prediction model to obtain an encoded feature; and perform transformation processing on the encoded feature based on the prediction model to obtain the third parameter of the type sequence.

[0238] It should be noted that the dialogue generation apparatus provided in the above embodiments is only exemplified by the division of the above functional modules. In actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above. In addition, the dialogue generation apparatus and the dialogue generation method provided in the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be described here.

[0239] The embodiments of the present application further provide a computer device, which comprises a processor and a memory. The memory stores at least one computer program. The at least one computer program is loaded and executed by the processor to implement the operations performed by the dialogue generation method of the above embodiments.

[0240] Optionally, the computer device is provided as a terminal. Figure 12 A structural block diagram of a terminal 1200 provided by an example embodiment of the present application is shown. The terminal 1200 can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, etc. The terminal 1200 can also be referred to as a user equipment, a portable terminal, a laptop terminal, a desktop terminal, or other names.

[0241] The terminal 1200 comprises a processor 1201 and a memory 1202.

[0242] The processor 1201 can include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 1201 can be implemented in at least one of a hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), a PLA (Programmable Logic Array). The processor 1201 can also include a main processor and a coprocessor, the main processor being a processor for processing data in an awake state, also known as a CPU (Central Processing Unit), and the coprocessor being a low-power processor for processing data in a standby state. In some embodiments, the processor 1201 can be integrated with a GPU (Graphics Processing Unit) for rendering and drawing content required to be displayed by the display screen. In some embodiments, the processor 1201 can further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.

[0243] The memory 1202 can include one or more computer-readable storage media that can be non-transitory. The memory 1202 can also include a high-speed random access memory, and a nonvolatile memory such as one or more disk storage devices, flash storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1202 is used to store at least one computer program for being executed by the processor 1201 to implement the dialogue generation method provided by the method embodiments in the present application.

[0244] In some embodiments, the terminal 1200 can also optionally include a peripheral device interface 1203 and at least one peripheral device. The processor 1201, the memory 1202, and the peripheral device interface 1203 can be connected through a bus or a signal line. Each peripheral device can be connected to the peripheral device interface 1203 through a bus, a signal line, or a circuit board. Specifically, the peripheral device includes at least one of a radio frequency circuit 1204, a display screen 1205, a camera assembly 1206, an audio circuit 1207, and a power supply 1208.

[0245] The peripheral interface 1203 can be used to connect at least one I / O (Input / Output) related peripheral device to the processor 1201 and the memory 1202. In some embodiments, the processor 1201, the memory 1202 and the peripheral interface 1203 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1201, the memory 1202 and the peripheral interface 1203 can be implemented on a separate chip or circuit board, and the present embodiments are not limited in this regard.

[0246] The radio frequency circuit 1204 is used to receive and send RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1204 communicates with a communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1204 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 1204 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and the like. The radio frequency circuit 1204 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1204 can also include NFC (Near Field Communication) related circuitry, and the present application is not limited in this regard.

[0247] The display screen 1205 is configured to display a UI (User Interface). The UI can include graphics, text, icons, video, and any combination thereof. When the display screen 1205 is a touch display screen, the display screen 1205 is further configured to capture touch signals on or above the surface of the display screen 1205. The touch signals can be input to the processor 1201 as control signals for processing. In this case, the display screen 1205 can also be configured to provide virtual buttons and / or virtual keyboard, also known as soft buttons and / or soft keyboard. In some embodiments, the display screen 1205 can be one, disposed on the front panel of the terminal 1200; in other embodiments, the display screen 1205 can be at least two, respectively disposed on different surfaces of the terminal 1200 or in a folding design; in other embodiments, the display screen 1205 can be a flexible display screen, disposed on a curved surface or a folding surface of the terminal 1200. Even, the display screen 1205 can also be disposed in an irregular shape, i.e., a special-shaped screen. The display screen 1205 can be made of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), etc.

[0248] The camera assembly 1206 is configured to capture images or videos. Optionally, the camera assembly 1206 includes a front camera and a rear camera. The front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, the rear camera is at least two, which is any one of a main camera, a depth-of-field camera, a wide-angle camera, and a telephoto camera, to realize the background blur function of the main camera and the depth-of-field camera, the panoramic shooting and VR (Virtual Reality) shooting function of the main camera and the wide-angle camera, or other fusion shooting functions. In some embodiments, the camera assembly 1206 can further include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. The dual-color temperature flash refers to the combination of a warm light flash and a cold light flash, which can be used for light compensation under different color temperatures.

[0249] The audio circuit 1207 can include a microphone and a speaker. The microphone is used to collect sound waves of a user and an environment, and convert the sound waves into an electrical signal input to the processor 1201 for processing, or input to the radio frequency circuit 1204 to realize voice communication. For the purpose of stereo sound collection or noise reduction, the microphone can be multiple, respectively arranged at different parts of the terminal 1200. The microphone can also be an array microphone or an omnidirectional collection type microphone. The speaker is used to convert the electrical signal from the processor 1201 or the radio frequency circuit 1204 into sound waves. The speaker can be a traditional diaphragm speaker, or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, not only can the electrical signal be converted into a sound wave audible to humans, but also can be converted into a sound wave inaudible to humans for ranging purposes. In some embodiments, the audio circuit 1207 can also include a headphone jack.

[0250] The power supply 1208 is used to supply power to each component in the terminal 1200. The power supply 1208 can be alternating current, direct current, disposable battery or rechargeable battery. When the power supply 1208 includes a rechargeable battery, the rechargeable battery can be a wired charging battery or a wireless charging battery. The wired charging battery is a battery charged through a wired line, and the wireless charging battery is a battery charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.

[0251] Those skilled in the art can understand that the structure shown in the figure does not constitute a limitation on the terminal 1200, and can include more or fewer components than the figure, or combine certain components, or use different component arrangements. Figure 12 The structure shown in the figure does not constitute a limitation on the terminal 1200, and can include more or fewer components than the figure, or combine certain components, or use different component arrangements.

[0252] Optionally, the computer device is provided as a server. Figure 13 The server 1300 can have a large difference due to different configurations or performances, and can include one or more processors (Central Processing Units, CPUs) 1301 and one or more memories 1302, wherein the memory 1302 stores at least one computer program, and the at least one computer program is loaded and executed by the processor 1301 to realize the method provided by each method embodiment. Of course, the server can also have a wired or wireless network interface, a keyboard and an input / output interface, etc., so as to perform input / output, and the server can also include other components for realizing the function of the device, which will not be described here.

[0253] The computer readable storage medium stores at least one computer program, and the at least one computer program is loaded and executed by the processor to realize the operations performed by the dialogue generation method of the above embodiments.

[0254] The embodiment of the present application further provides a computer program product comprising a computer program which, when executed by a processor, implements the operations performed by the dialogue generation method of the above-mentioned embodiment.

[0255] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or can be instructed by a program to instruct related hardware to complete, and the program can be stored in a computer readable storage medium. The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.

[0256] The above-mentioned is only an optional embodiment of the present application, and does not limit the present application, and any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims

1. A dialogue generation method, characterized in that, The method includes: During the current session, based at least on the historical dialogue statements of the current session, multiple candidate statement types for the current dialogue are determined from multiple statement types. The candidate statement type is a statement type among the multiple statement types that satisfies a first condition with a first probability. The first probability indicates the likelihood that the current dialogue will use the statement type. Based on the historical dialogue statements, the multiple statement types, and the multiple candidate statement types, a type sequence corresponding to each candidate statement type is determined. The type sequence includes the statement type to be used in at least one subsequent dialogue if the candidate statement type is used in the current dialogue. For each candidate statement type, a fourth probability of the candidate statement type is obtained, the fourth probability indicating the likelihood of using the candidate statement type in the current round of dialogue; based on the type sequence corresponding to the candidate statement type, a second parameter of the candidate statement type is determined; the fourth probability and the second parameter of the candidate statement type are weighted and fused to obtain a first parameter of the candidate statement type, the first parameter indicating the dialogue quality of the current session after using the candidate statement type, and the second parameter indicating the dialogue quality of the current session after using the candidate statement type and the corresponding type sequence. Based on the candidate statement types among the multiple candidate statement types whose first parameter satisfies the second condition, the dialogue statement for this round of dialogue is generated.

2. The method according to claim 1, characterized in that, The step of determining multiple candidate statement types for the current round of dialogue from multiple statement types, based at least on the historical dialogue statements of the current session, includes: Based on the historical dialogue statements and the object information corresponding to the objects participating in the current session, the multiple candidate statement types are determined from the multiple statement types; The step of determining the type sequence corresponding to each candidate statement type based on the historical dialogue statements, the multiple statement types, and the multiple candidate statement types includes: Based on the historical dialogue statements, the object information, the multiple statement types, and the multiple candidate statement types, a type sequence corresponding to each candidate statement type is determined.

3. The method according to claim 2, characterized in that, The process of determining the multiple candidate statement types from the multiple statement types based on the historical dialogue statements and the object information corresponding to the objects participating in the current session includes: Based on the historical dialogue statements and the object information, a first probability is determined for each of the plurality of statement types, wherein the first probability indicates the likelihood that the current round of dialogue will use the statement type. The statement type that satisfies the first condition with a first probability among the plurality of statement types is determined as the plurality of candidate statement types.

4. The method according to claim 2, characterized in that, Each candidate statement type corresponds to m type sequences, where m is an integer greater than 0; determining the type sequence corresponding to each candidate statement type based on the historical dialogue statements, the object information, the multiple statement types, and the multiple candidate statement types includes: Based on the historical dialogue statements, the object information, the candidate statement types, the multiple statement types, and m i-th type sequences, predict the (i+1)-th statement type in the i-th type sequence to obtain m (i+1)-th type sequences. The i-th type sequence includes i statement types, the (i+1)-th type sequence includes i+1 statement types, and the (i+1)-th statement type includes a statement type from the i-th type sequence, until m n-th type sequences are obtained, where n is an integer greater than 1 and i is an integer greater than 0 and less than n.

5. The method according to claim 4, characterized in that, The step of predicting the (i+1)th statement type in the i-th type sequence based on the historical dialogue statements, the object information, the candidate statement types, the multiple statement types, and m i-th type sequences to obtain m (i+1)th type sequences includes: Based on the historical dialogue statements, the object information, and the candidate statement types, k predicted statement types corresponding to each i-th type sequence are determined from the multiple statement types, where k is an integer greater than 0; Each predicted statement type is combined with its corresponding i-th type sequence to form a candidate type sequence, resulting in j candidate type sequences, where j is the product of k and m. Determine a second probability for each candidate type sequence, the second probability indicating the likelihood that a statement type in the candidate type sequence will be used in subsequent rounds of dialogue if the candidate statement type is used in the current round of dialogue; From the j candidate type sequences, select the m (i+1)th type sequences with a second probability that satisfy the third condition.

6. The method according to claim 5, characterized in that, The step of determining the k predicted statement types corresponding to each i-th type sequence from the plurality of statement types based on the historical dialogue statements, the object information, and the candidate statement types includes: Feature extraction is performed on the candidate statement types and the i-th type sequence to obtain type features; Based on the type features, the historical features corresponding to the historical dialogue statements and the object features corresponding to the object information are updated respectively; Based on the updated historical features and updated object features, k predicted statement types corresponding to the i-th type sequence are determined from the multiple statement types.

7. The method according to claim 6, characterized in that, The step of determining the k predicted statement types corresponding to the i-th type sequence from the multiple statement types based on the updated historical features and updated object features includes: The updated historical features and the updated object features are weighted and fused to obtain fused features; The fusion features are transformed to obtain a third probability of the plurality of statement types. The third probability indicates the probability of using the statement type in the next round of dialogue if the candidate statement type is used in the current round of dialogue and the statement type in the i-th type sequence is used in at least one subsequent round of dialogue. The statement type whose third probability satisfies the fourth condition among the multiple statement types is determined as the k predicted statement types corresponding to the i-th type sequence.

8. The method according to claim 1, characterized in that, The candidate statement type corresponds to m type sequences; determining the second parameter of the candidate statement type based on the type sequences corresponding to the candidate statement type includes: Determine a fifth probability for each type sequence corresponding to the candidate statement type, the fifth probability indicating the likelihood that, given that the candidate statement type is used in the current round of dialogue, a statement type from the type sequence will be used in at least one subsequent round of dialogue; Based on the historical dialogue statements, a third parameter is obtained for each type sequence, the third parameter indicating the dialogue quality of the current session if the candidate statement type is used in the current round of dialogue and the statement type in the type sequence is used in at least one subsequent round of dialogue. Determine the product of the sixth probability and the third parameter for sequences of the same type to obtain m products corresponding to the candidate statement type; The sum of the m products corresponding to the candidate statement type is determined as the second parameter of the candidate statement type.

9. The method according to claim 8, characterized in that, The step of obtaining the third parameter for each type sequence based on the historical dialogue statements includes: Obtain the historical features corresponding to the historical dialogue statements, the candidate features corresponding to the candidate statement types, and the sequence features corresponding to the type sequences; The historical features, the candidate features, and the sequence features are concatenated to obtain the concatenated features; Based on the prediction model, the spliced ​​features are encoded to obtain the encoded features; Based on the prediction model, the encoded features are transformed to obtain the third parameter of the type sequence.

10. A dialogue generation device, characterized in that, The device includes: The determining module is configured to, during the current session, at least based on the historical dialogue statements of the current session, determine multiple candidate statement types from multiple statement types for the current round of dialogue, wherein the candidate statement type is a statement type among the multiple statement types that satisfies a first condition with a first probability, and the first probability indicates the likelihood that the current round of dialogue will use the statement type. The determining module is further configured to determine a type sequence corresponding to each candidate statement type based on the historical dialogue statements, the multiple statement types, and the multiple candidate statement types. The type sequence includes the statement type to be used in at least one subsequent dialogue if the candidate statement type is used in the current dialogue. The determining module is further configured to: obtain a fourth probability for each candidate statement type, the fourth probability indicating the likelihood of using the candidate statement type in the current round of dialogue; determine a second parameter for the candidate statement type based on the type sequence corresponding to the candidate statement type; and perform weighted fusion of the fourth probability and the second parameter of the candidate statement type to obtain a first parameter of the candidate statement type, the first parameter indicating the dialogue quality of the current session after using the candidate statement type, and the second parameter indicating the dialogue quality of the current session after using the candidate statement type and the corresponding type sequence. The generation module is also used to generate the dialogue statement for the current round of dialogue based on the candidate statement type whose first parameter satisfies the second condition among the multiple candidate statement types.

11. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one computer program, which is loaded and executed by the processor to perform the operations of the dialogue generation method as described in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to perform the operations of the dialogue generation method as described in any one of claims 1 to 9.

13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it performs the operations of the dialogue generation method as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Multi-round dialogue task processing method and device, and electronic equipment

    CN113821620A