A dialogue reply generation method and device, electronic equipment and storage medium
By filtering and blurring the profile attributes of the target and response objects, a highly relevant and diverse dialogue response is generated, solving the problems of insufficient accuracy and diversity in existing technologies and achieving higher-quality dialogue generation.
Patent Information
- Application Number
- CN202310835160.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-06
- Publication Date
- 2025-12-26
- Estimated Expiration
- 2043-07-06
AI Technical Summary
Existing dialogue response generation methods suffer from issues such as the use of personalized profiles, fusion of multiple encoding modules, and error accumulation, resulting in insufficient accuracy and diversity in dialogue response generation.
By acquiring profiles of the target and responding objects, filtering out attributes that meet preset conditions, and using a fuzzy and blurred dialogue response generation model, response information that is highly relevant to and diverse in nature is generated.
It improves the accuracy and diversity of dialogue-generated responses, ensures the relevance of response information to the initial text information, and enhances the logical consistency and semantic accuracy of responses.
Smart Images

Figure CN116701602B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence, and in particular, to a dialogue reply generation method and device, an electronic device, and a storage medium. BACKGROUND
[0002] Natural Language Processing (NLP) is an important branch in the field of Artificial Intelligence (AI), which mainly studies various theories and methods for effective communication between humans and computers using natural language.
[0003] Among them, text generation (i.e., natural language generation) can automatically generate fluent, smooth, and semantically clear high-quality natural language text using various types of information (such as text, structured information, images, etc.).
[0004] In view of this, as an important research direction in the field of text generation and human-computer interaction, the dialogue system has developed vigorously, and various dialogue reply generation methods have emerged and been applied to various dialogue systems.
[0005] In related technologies, the dialogue system usually uses a deep neural network to realize dialogue reply generation of the dialogue system. Exemplarily, the deep neural network used in the dialogue system includes but is not limited to: a recurrent neural network (RNN) that captures information in a text sequence through a natural sequence structure; reinforcement learning (RL) that learns hidden rules in natural language by imitating human learning methods; and a variational autoencoder (VAE) that introduces variability to the model through hidden variable distribution.
[0006] However, using the above dialogue reply generation method will cause problems such as full personalized portrait use, multi-coding module fusion, and error accumulation caused by multi-model stacking, thereby causing the dialogue system to be unable to generate a dialogue reply with high relevance according to user input during the dialogue process, and thus reducing the accuracy of the dialogue reply.
[0007] Therefore, using the above method, the accuracy of the dialogue reply is low. SUMMARY
[0008] The embodiments of the present application provide a dialogue reply generation method and device, an electronic device, and a storage medium, to improve the accuracy of the dialogue reply and also improve the diversity of the dialogue reply.
[0009] In a first aspect, an embodiment of the present application provides a dialogue generation reply method, the method comprising:
[0010] obtaining initial text information of a target object in a target dialogue scene, and determining a target object portrait and a reply object portrait associated with a scene identifier of the target dialogue scene based on the scene identifier; wherein the target object portrait comprises various target object attributes of the target object, and the reply object portrait comprises various reply object attributes of a reply object in the target dialogue scene;
[0011] selecting, from the target object portrait, a target object attribute that meets a preset attribute similarity condition with the initial text information, and selecting, from the reply object portrait, a reply object attribute that meets a preset attribute relevance condition with the target object attribute;
[0012] performing fuzzy virtualization processing on the target object attribute by using a preset dialogue reply generation model, and generating target reply information that meets a preset dialogue reply relevance condition with the initial text information based on the target object attribute and the reply object attribute after the fuzzy virtualization processing.
[0013] In a second aspect, an embodiment of the present application further provides a dialogue generation reply device, the device comprising:
[0014] an obtaining module configured to obtain initial text information of a target object in a target dialogue scene, and determine a target object portrait and a reply object portrait associated with a scene identifier of the target dialogue scene based on the scene identifier; wherein the target object portrait comprises various target object attributes of the target object, and the reply object portrait comprises various reply object attributes of a reply object in the target dialogue scene;
[0015] a screening module configured to select, from the target object portrait, a target object attribute that meets a preset attribute similarity condition with the initial text information, and select, from the reply object portrait, a reply object attribute that meets a preset attribute relevance condition with the target object attribute;
[0016] a generation module configured to perform fuzzy virtualization processing on the target object attribute by using a preset dialogue reply generation model, and generate target reply information that meets a preset dialogue reply relevance condition with the initial text information based on the target object attribute and the reply object attribute after the fuzzy virtualization processing.
[0017] Optionally, before obtaining the initial text information of the target object in the target dialogue scene, the screening module is further configured to:
[0018] for a plurality of sample dialogue scenes, the following operations are performed respectively:
[0019] obtaining sample dialogue information of each of at least two sample objects involved in a sample dialogue scenario;
[0020] performing attribute feature extraction on the obtained at least two sample dialogue information respectively to obtain a sample object attribute set of each of the at least two sample objects;
[0021] generating a sample object cartoon of each of the at least two sample objects based on the sample object attribute set of each of the at least two sample objects, and associating a scene identifier of the sample dialogue scenario with the sample object cartoon of each of the at least two sample objects.
[0022] Optionally, in the process of obtaining the sample dialogue information of each of the at least two sample objects involved in the sample dialogue scenario, the screening module is further configured to:
[0023] if there is sample dialogue information that does not meet the preset dialogue information specification condition in the obtained at least two sample dialogue information, discarding the sample dialogue scenario;
[0024] and / or,
[0025] if there is sample dialogue information that does not meet the preset dialogue information specification condition in the at least two sample dialogue information, discarding the at least two sample dialogue information.
[0026] Optionally, after associating the scene identifier of the sample dialogue scenario with the sample object cartoon of each of the at least two sample objects, the screening module is further configured to:
[0027] for the sample object attribute contained in each of the at least two sample object cartoons, performing the following operations respectively:
[0028] determining a content prompt label set based on the attribute type of the sample object attribute;
[0029] modifying an initial data format of the sample object attribute to a preset standard data format based on the content prompt label and a preset content filling label.
[0030] Optionally, the dialogue reply generation model is trained in the following manner:
[0031] for the plurality of sample dialogue scenarios, performing the following operations respectively:
[0032] obtaining sample dialogue content of each two sample objects in a first sample dialogue scenario; wherein the first sample dialogue scenario is any one of the plurality of sample dialogue scenarios;
[0033] The dialog reply generation model is iteratively trained based on historical text information and historical reply information contained in sample dialog content and a preset prediction loss function until the dialog reply generation model meets a dialog reply relevance condition.
[0034] Optionally, if the following condition is met, it is determined that the dialog reply generation model meets the dialog reply relevance condition:
[0035] A prediction loss function is used to determine a first loss value between actual reply information obtained based on historical text information corresponding to a sample object attribute and other reply information, and a second loss value between the actual reply information and historical reply information, wherein the historical reply information and the other reply information meet a preset reply information similarity condition.
[0036] Based on the first loss value and the second loss value, a corresponding prediction loss value is obtained, and if the prediction loss value converges to a preset loss value threshold, it is determined that the dialog reply generation model meets the dialog reply relevance condition.
[0037] Optionally, in generating target reply information that meets the preset dialog reply relevance condition based on the target object attribute and the reply object attribute after the fuzzy virtualization processing, the generation module is specifically configured to:
[0038] Based on the target object attribute and the reply object attribute after the fuzzy virtualization processing, an initial reply word of the target reply information is predicted, and the initial reply word is saved to a preset initial reply information.
[0039] The initial reply information is iteratively modified until the target reply information that meets the dialog reply relevance condition is obtained; wherein in the process of one round of iterative modification, the following operations are performed:
[0040] Based on the initial reply information containing a current reply text, the target object attribute after the fuzzy virtualization processing and the reply object attribute, a next reply word of the current reply text is predicted.
[0041] Based on the next reply word of the current reply text, the current reply text is modified to obtain modified initial reply information.
[0042] Optionally, in predicting the next reply word of the current reply text based on the initial reply information containing the current reply text, the target object attribute after the fuzzy virtualization processing and the reply object attribute, the generation module is specifically configured to:
[0043] If the number of reply words contained in the current reply text is not greater than a preset reply word number threshold, a kernel sampling decoding strategy is used to predict the next reply word of the current reply text based on the current reply text, the target object attribute after the fuzzy virtualization processing and the reply object attribute.
[0044] If the number of reply words is greater than the number of reply word threshold, a decoding strategy of beam search is adopted, and the next reply word of the current reply text is predicted based on the current reply text, the target object attribute after the fuzzy virtualization processing, and the reply object attribute.
[0045] In a third aspect, an electronic device is provided, which includes a processor and a memory, wherein the memory stores program code which, when executed by the processor, causes the processor to perform the steps of the dialogue reply generation method of the first aspect.
[0046] In a fourth aspect, a computer-readable storage medium is provided, which includes program code which, when executed on an electronic device, causes the electronic device to perform the steps of the dialogue reply generation method of the first aspect.
[0047] In a fifth aspect, a computer program product is provided, which, when invoked by a computer, causes the computer to perform the steps of the dialogue reply generation method of the first aspect.
[0048] The present application has the following advantages:
[0049] In the dialogue reply generation method provided in the embodiments of the present application, the scene identifier of the target dialogue scene is associated with the target object portrait of the target object involved in the target dialogue scene and the reply object portrait of the reply object. In this way, when replying to the initial text information of the target object in the target dialogue scene, the target object attribute that meets the preset attribute similarity condition with the initial text information can be filtered from the target object portrait, and the reply object attribute that meets the preset attribute relevance condition with the target object attribute can be selected from the reply object portrait. Therefore, the initial text information is replied to according to the obtained target object attribute and reply object attribute, thereby improving the relevance of the target reply information and the initial text information, i.e., the accuracy of the target reply information. In addition, in the embodiments of the present application, the target object attribute is subjected to fuzzy virtualization processing using the preset dialogue reply generation model, and the target object attribute after the fuzzy virtualization processing can be obtained. Therefore, the target reply information generated for the initial text information based on the target object attribute after the fuzzy virtualization processing and the reply object attribute not only ensures the accuracy of the dialogue reply, but also improves the diversity of the dialogue generation reply to a certain extent.
[0050] Additionally, other features and advantages of the present application will be set forth in the description that follows, and in part will be apparent from the description, or can be learned by practice of the application. The objectives and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings. BRIEF DESCRIPTION OF DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without any creative work. In the drawings:
[0052] Figure 1 An optional schematic diagram of a system architecture applicable to the embodiments of the present application;
[0053] Figure 2 A method flow schematic diagram of generating a sample object cartoon and associating with a scene identification provided by the embodiments of the present application;
[0054] Figure 3A A specific application scene schematic diagram of a reply text inconsistency provided by the embodiments of the present application;
[0055] Figure 3B A specific application scene schematic diagram of a reply text inconsistency provided by the embodiments of the present application;
[0056] Figure 4 A specific schematic diagram of a sample object attribute set provided by the embodiments of the present application;
[0057] Figure 5 A specific schematic diagram of a sample object cartoon provided by the embodiments of the present application;
[0058] Figure 6 A specific application scene schematic diagram based on Figure 2 provided by the embodiments of the present application;
[0059] Figure 7 A method flow schematic diagram of generating a dialogue reply provided by the embodiments of the present application;
[0060] Figure 8 A method flow schematic diagram of obtaining a target object attribute and a reply object attribute provided by the embodiments of the present application;
[0061] Figure 9 A logic schematic diagram of processing a target object attribute provided by the embodiments of the present application;
[0062] Figure 10 A method flow diagram for generating target reply information is provided for an embodiment of the present application.
[0063] Figure 11 A logic diagram based on Figure 10 provided for an embodiment of the present application.
[0064] Figure 12 A logic diagram based on Figure 7 provided for an embodiment of the present application.
[0065] Figure 13 A structural diagram of a dialogue reply generation device is provided for an embodiment of the present application.
[0066] Figure 14 A structural diagram of an electronic device is provided for an embodiment of the present application. DETAILED DESCRIPTION
[0067] To make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments described in the present application document, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application technical solutions.
[0068] It should be noted that in the description of the present application, "multiple" is understood as "at least two". The association relationship of the associated objects is described, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone. A and B are connected, which can represent two cases: A and B are directly connected and A and B are connected through C. In addition, in the description of the present application, "first", "second", etc. are used only for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can it be understood as indicating or implying order.
[0069] In order to facilitate those skilled in the art to better understand the technical solutions of the present application, the following briefly describes and explains some concepts or technical terms related to the present application, as follows:
[0070] (1) Natural language processing: a discipline that studies the language problems of human-computer interaction, mainly including several large task categories: speech recognition and generation, text classification, information extraction, entity recognition, dialogue system, machine translation, sentiment analysis, knowledge graph, etc.
[0071] (2) Artificial intelligence: is to use digital computer or digital computer controlled machine simulation, extension and expansion of human intelligence, perception of the environment, knowledge acquisition and use of knowledge to obtain the best results of theory, method, technology and application system. 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.
[0072] Artificial intelligence technology is a comprehensive discipline, involving a wide range of fields, both hardware and software level technology. Artificial intelligence basic technology generally includes such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics and other technologies. 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 and other major directions.
[0073] (3) Open domain dialogue: is to carry out anthropomorphic dialogue in a very open scene, and can carry out arbitrary dialogue; at the same time, the dialogue system requires human setting, personality and emotion.
[0074] (4) Transformer model: is a model that uses attention mechanism to improve model training speed, which mainly consists of two parts: encoder and decoder; for example, when inputting a text, the text data will first pass through the Encoders module to encode the text, and then the encoded data will be transmitted to the Decoders module for decoding, and the decoded text will be obtained after decoding, wherein the Encoders module includes multiple encoders, and the Decoders includes multiple decoders.
[0075] (5) Bi-directional long short-term memory (Bi-LSTM) network: can fully consider the relationship between the context of the time sequence and fully utilize the bidirectional information, in the embodiment of the application, Bi-LSTM network can be used, based on the key frames with time sequence, bidirectional aggregation of the mutual context influence between the key frames.
[0076] (6) Fine-tuning: mainly used in deep learning to continuously train and update the parameters (weights) of the model in the deep network to fit the model that can achieve the expected results.
[0077] (7) Nucleus sampling: also known as top-p sampling, exemplary, at each time step, the probability distribution of the decoded word can have a case of 80 / 20 principle (or long-tail distribution), that is, the appearance probability of a few words in the head has occupied most of the probability space, call these core words nucleus, through the way of nucleus sampling, the core words can be selected.
[0078] (8) Beam search: is an improved algorithm of greedy search, relatively greedy search expands the search space, but far from the exponential search space of exhaustive search, it is a compromise between the two; wherein, when searching, there is a hyperparameter beam_size (beam width), set to k. The first time step, select the k words with the largest conditional probability as the first word of the candidate output sequence; at each subsequent time step, based on the output sequence of the previous step, select the k with the largest conditional probability from all combinations as the candidate output sequence at this time step; always keep k candidates, and finally select the optimal one from the k candidates.
[0079] (9) Bidirectional and Auto-Regressive Transformers (BART): a seq2seq model structure, with a bidirectional encoder (to process noisy text) and an autoregressive decoder.
[0080] (10) Tokenzier: that is, to divide a sentence into small word blocks (tokens), generate a word table, and learn better representation through model.
[0081] (11) Token embedding: is to convert each word into a vector of a certain dimension.
[0082] (12) Position embedding: is to pass the character input order information to the model, add the position information of each word in the sentence to each word, that is, position information coding.
[0083] (13) Word embedding: is the general term of language model and representation learning technology in NLP. In the process of NLP, it is necessary to map words to corresponding vectors, so as to be used for model training. The basic idea of using word embedding is: first, mark the word by one-hot encoding method, and then build a neural network containing embedding layer. The input and output of the model are generally one-hot vectors of words with similar positions in the text. During training, the one-hot vector of the word is input into the embedding, and the output vector of the embedding is the new embedding representation of the word. These vectors are generally much smaller than one-hot vector length, and can be used to measure the similarity and analogy relationship between words.
[0084] Further, based on the above concept or technical language explanation, the design idea of the embodiments of the present application is briefly introduced as follows:
[0085] Natural language processing (NLP) is an important branch in the field of artificial intelligence (AI), which mainly studies various theories and methods of effective communication between man and computer using natural language.
[0086] Among them, the natural language generation of the open domain dialogue model is continuously improved in reply diversity, knowledge depth, and accuracy of generated text in various aspects since the structure of the Transformer model. As a dialogue generation model (i.e. dialogue system) at the bottom of the dialogue robot, although there are many technical solutions to improve dialogue generation replies by combining historical context, most of them are based on full historical dialogue to extract and process relevant information, or through traditional time sequence neural network (such as Bi-LSTM) to extract labels, knowledge and information, and then generate dialogue replies through the decoder structure of the Transformer.
[0087] For example, using the Transformer model, according to the context information, an efficient vector representation of each word in the sequence is obtained, and by learning the sequence dependency relationship between natural languages, the content of the latter can be automatically predicted and generated according to the former, realizing the generation of corresponding reply content according to the dialogue context. At the same time, by adding various optimization algorithms, the generation probability of general replies can be reduced, thereby improving the diversity of generated dialogue content.
[0088] In this process, a deep neural network is usually used to implement the generation of dialogue reply, for example, the deep neural network used includes but is not limited to: RNN and RL, VAE; however, using the above dialogue reply generation method, there are problems such as full personalized image use, multi-encoding module fusion, and error accumulation caused by multi-model stacking, which leads to that in the dialogue process, the dialogue generation reply with high relevance cannot be generated according to the user input, thereby reducing the accuracy of the dialogue generation reply.
[0089] Therefore, in order to improve the relevance or accuracy of the generated reply and the user input, the embodiment of the present application proposes a dialogue reply generation method. Since the scene identifier of the target dialogue scene is associated with the target object image of the target object involved in the target dialogue scene and the reply object image of the reply object. In this way, when replying to the initial text information of the target object in the target dialogue scene, the target object attribute that meets the preset attribute similarity condition with the initial text information can be filtered from the target object image, and the reply object attribute that meets the preset attribute relevance condition with the target object attribute can be selected from the reply object image. Therefore, the initial text information is replied to according to the obtained target object attribute and reply object attribute, thereby improving the relevance of the target reply information and the initial text information, i.e., the accuracy of the target reply information. Moreover, in the embodiment of the present application, the preset dialogue reply generation model is used to perform fuzzy virtualization processing on the target object attribute, so as to obtain the fuzzy virtualization processed target object attribute. Therefore, the target reply information generated for the initial text information based on the fuzzy virtualization processed target object attribute and the reply object attribute not only ensures the accuracy of the dialogue reply, but also improves the diversity of the dialogue generation reply to a certain extent.
[0090] In particular, the preferred embodiments of the present application are described below in conjunction with the accompanying drawings of the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application, and the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0091] Referring to Figure 1 As shown in the figure, it is a system architecture schematic diagram suitable for the embodiment of the present application. The system architecture includes: a target terminal (101a, 101b) and a server 102. The target terminal (101a, 101b) and the server 102 can exchange information through a communication network, wherein the communication mode of the communication network can include: wireless communication mode and wired communication mode.
[0092] Exemplarily, the target terminal (101a, 101b) can access the network and communicate with the server 102 through a cellular mobile communication technology, such as a 5th Generation Mobile Networks (5G) technology.
[0093] Optionally, the target terminal (101a, 101b) can access the network and communicate with the server 102 through a short-range wireless communication method, such as a Wireless Fidelity (Wi-Fi) technology.
[0094] The number of communication devices involved in the system architecture described above is not limited in the embodiments of the present application. For example, there can be more target terminals, or no target terminals, or other network devices, such as Figure 1 As shown, only the target terminal (101a, 101b) and the server 102 are described as examples, and the following briefly introduces each device and its respective function.
[0095] The target terminal (101a, 101b) is a device that can provide voice and / or data connectivity to a user, and can be a device that supports wired and / or wireless connection methods.
[0096] Exemplarily, the target terminal (101a, 101b) includes but is not limited to a mobile phone, a tablet computer, a notebook computer, a palm computer, a Mobile Internet Device (MID), a wearable device, a Virtual Reality (VR) device, an Augmented Reality (AR) device, a wireless terminal device in industrial control, a wireless terminal device in unmanned driving, a wireless terminal device in smart grid, a wireless terminal device in transportation safety, a wireless terminal device in smart city, or a wireless terminal device in smart home, etc.
[0097] In addition, the target terminal (101a, 101b) can be installed with a related client, which can be software, such as an application (APP), a browser, a short video software, etc., or a webpage, an applet, etc. In the embodiments of the present application, the target terminal (101a, 101b) can send a dialogue reply request to the server 102 by making the above-mentioned client related to the object reply generation, wherein the dialogue reply request can carry initial text information of the target object in the target dialogue scene and a scene identifier of the target dialogue scene, so that the server 102 can subsequently perform the method steps of dialogue reply generation according to the initial text information and the scene identifier.
[0098] The server 102 can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms; it should be noted that in the embodiments of the present application, the server 102 can be used to ensure the robot and other devices for interpersonal interaction, and execute the dialogue reply generation method mentioned in the embodiments of the present application; in addition, the server 102 can deploy a dialogue reply generation model to generate a corresponding dialogue reply.
[0099] It is worth mentioning that in the embodiments of the present application, the server 102 is used to obtain initial text information of a target object in a target dialogue scenario, and determine a target object portrait and a reply object portrait associated with the scene identifier based on the scene identifier of the target dialogue scenario; wherein the target object portrait contains various target object attributes of the target object, and the reply object portrait contains various reply object attributes of the reply object in the target dialogue scenario; then, from the target object portrait, the target object attributes that meet the preset attribute similarity condition with the initial text information are filtered out, and from the reply object portrait, the reply object attributes that meet the preset attribute relevance condition with the target object attributes are selected; finally, the dialogue reply generation model is used to perform fuzzy virtualization processing on the target object attributes, and based on the fuzzy virtualization processed target object attributes and the reply object attributes, target reply information that meets the preset dialogue reply relevance condition with the initial text information is generated.
[0100] The dialogue reply generation method provided by the example embodiments of the present application will be described below in combination with the above-mentioned system architecture and in reference to the accompanying drawings. It should be noted that the above-mentioned system architecture is only shown for the purpose of facilitating the understanding of the spirit and principles of the present application, and the embodiments of the present application are not limited in this respect.
[0101] It should be noted that before obtaining the initial text information of the target object in the target dialogue scenario, the respective sample object portraits of each sample object in each sample scene are obtained in advance, and the obtained sample object portraits are associated with the scene identifiers of the respective sample dialogue scenes, so that subsequently the target object portrait and the reply object portrait associated with the scene identifier can be directly determined based on the scene identifier of the target dialogue scenario.
[0102] In an optional implementation, when the sample object portrait is obtained and the obtained sample object portrait is associated with the scene identifier of the corresponding sample dialogue scene, reference is made toFigure 2 As shown, the execution subject takes the server as an example, and performs the following operations on a plurality of sample dialogue scenes, respectively:
[0103] S201: Obtain sample dialogue information of at least two sample objects involved in a sample dialogue scene respectively.
[0104] The sample dialogue scene can be various dialogue situations occurring in daily life, and therefore, the dialogue content of all sample objects involved in the sample dialogue scene is sample dialogue information. For example, the sample dialogue scene can be a dialogue scene between person A and person B after meeting in a park when they are walking in the park on a weekend. The sample dialogue scene can be a dialogue scene between a father and a son when the father is guiding the son to complete homework.
[0105] It should be noted that in the embodiments of the present application, the number of sample objects involved in the sample dialogue scene is not limited in any specific way, but there are at least two sample objects. For example, the number of sample objects involved in the sample dialogue scene can be two or more.
[0106] In an optional implementation, in the process of performing step S201, if there is sample dialogue information that does not meet the preset dialogue information specification condition in the obtained at least two sample dialogue information, the sample dialogue scene is discarded; and / or if there is sample dialogue information that does not meet the preset dialogue information specification condition in the at least two sample dialogue information, the at least two sample dialogue information is discarded, so as to perform script collation cleaning or sampling screening on the obtained sample dialogue information, filter dialogue samples with error symbols or meaningless, incoherent, etc. problems, so as to improve the consistency and logical correctness of the subsequent reply text.
[0107] It should be noted that the above-mentioned preset dialogue information specification condition is used to measure whether the consistency and logical correctness of the reply text are met, for example, referring to Figure 3A As shown, if sample object A asks sample object B: "What did you eat for lunch today?", and sample object B replies: "I ate noodles for lunch today!", and then after a period of time (for example, 10 minutes), sample object A asks sample object B again: "What did you eat for lunch today?", at this time, sample object B replies: "I ate dumplings for lunch today!", it can be seen that the reply text before and after the dialogue sample is inconsistent, which is obviously a problem, that is, it does not meet the consistency of the reply text.
[0108] Referring to Figure 3BAs shown, still taking the above sample dialogue scene Tar.Senc as an example, if sample object A asks sample object B: "What did you eat for lunch today?", and sample object B replies: "Noodles ate me for lunch today!"; it is not difficult to see that the reply text of the sample object does not conform to the logical correctness, therefore, the server can effectively filter out the dialogue samples that do not meet the preset dialogue information specification conditions (consistency and / or logical correctness of the reply text) based on the above method steps of discarding sample dialogue scenes and / or at least two sample dialogue information.
[0109] S202: Attribute feature extraction is performed on the obtained at least two sample dialogue information respectively to obtain a sample object attribute set of each of the at least two sample objects.
[0110] Specifically, when step S202 is performed, after obtaining the sample dialogue information of each of the at least two sample objects in the sample dialogue scene, the server can perform attribute feature extraction on the obtained at least two sample dialogue information, thereby obtaining a sample object attribute set of each of the at least two sample objects.
[0111] Exemplarily, referring to Figure 4 As shown, taking two sample objects (Sam.Obj.1 and Sam.Obj.2) as an example, after obtaining the sample dialogue information Sam.Con.Inf1 of sample object Sam.Obj.1 and the sample dialogue information Sam.Con.Inf2 of sample object Sam.Obj.2, the server can perform attribute feature extraction on the sample dialogue information Sam.Con.Inf1 and the sample dialogue information Sam.Con.Inf2, thereby obtaining a sample object attribute set Sam.Attri.Set1 of sample object Sam.Obj.1 and a sample object attribute set Sam.Attri.Set2 of sample object Sam.Obj.2.
[0112] Among them, as Figure 4 As shown, the sample object attribute set Sam.Attri.Set1 includes but is not limited to: sample object attribute 1.a: "I am an engineer", sample object attribute 1.b: "I have a dog", sample object attribute 1.c: "I like to watch science fiction movies"; the sample object attribute set Sam.Attri.Set2 includes but is not limited to: sample object attribute 2.a: "I study at XX University", sample object attribute 2.b: "I like photography and painting", sample object attribute 2.c: "I have a cold recently".
[0113] S203: generating a sample object portrait of each of the at least two sample objects based on the sample object attribute set of each of the at least two sample objects, and associating the scene identifier of the sample dialogue scene with the sample object portrait of each of the at least two sample objects.
[0114] For example, when performing step S203, still taking the sample object Sam.Obj.1 and the sample object Sam.Obj.2 in the sample dialogue scene in FIG. 2B as an example, the server can generate a sample object portrait of each of the two sample objects based on the sample object attribute set of each of the two sample objects after obtaining the sample object attribute set of each of the two sample objects, as shown in FIG. 2C. Figure 4 Figure 5 For example, when performing step S203, still taking the sample object Sam.Obj.1 and the sample object Sam.Obj.2 in the sample dialogue scene in FIG. 2B as an example, the server can generate a sample object portrait of each of the two sample objects based on the sample object attribute set of each of the two sample objects after obtaining the sample object attribute set of each of the two sample objects, as shown in FIG. 2C.
[0115] In an optional implementation, after the server associates the scene identifier of the sample dialogue scene with the sample object portrait of each of the at least two sample objects, the server can perform the following operations on the sample object attribute included in each of the at least two sample object portraits: determine a content prompt label based on the attribute type of the sample object attribute, and modify the initial data format of the sample object attribute to a preset standard data format based on the content prompt label and a preset content padding label.
[0116] For example, after obtaining the sample object portrait, the server can process the sample object portrait by adding a defined special_token and a corresponding role token of a dialogue role (i.e., a content prompt label) before and after the sample object attribute included in the sample object portrait, so as to strengthen the prompt of the sample object portrait content in the encoding stage, for example, (_persona_user: I have a dog_end_), wherein, “_persona_” and “_end_” are prompt tokens designed according to the fine-tuning task. It should be noted that if the current data format of the sample object attribute does not reach the preset standard data format after adding the content prompt label, a preset content padding label (e.g., pad_token) can also be added to ensure that the initial data format of the sample object attribute is modified to the preset standard data format, so as to reduce the use of system resources such as storage and operation in the fine-tuning task.
[0117] The preset standard data format can be that the data bit number of the modified sample object attribute is a preset data bit threshold, such as 128 bits. Therefore, if the current data format of the sample object attribute after the addition of the content prompt label is 122 bits, it is easy to know that the preset standard data format is not reached, and therefore, a content padding label of 6 bits can be added to modify the initial data format of the sample object attribute to the preset standard data format.
[0118] It should be noted that the server can modify the prompt token according to different personalized labels when designing the prompt token according to the fine-tuning task, and the corresponding prompt token has no actual semantic content. In addition, as described above, the server can also preprocess the dialogue data into a standard {source, target} pair format, where source is an array format dialogue context input, and target is the reply text of the current dialogue, that is, the prediction target.
[0119] Therefore, based on the sample object cartoon generation method of S201-S203, as shown in Figure 6 The server can collect sample dialogue information through an information collection tool (such as the Internet), and rewrite and modify single-sentence character portrait descriptions, where the character portrait descriptions include natural attributes, events, preferences, and other types of information, and are defined as sample object portraits. In the dialogue process, the sample object portraits of the sample objects are used to output dialogue content. Optionally, the information collection tool can also collect sample dialogue information by simulating dialogue between people.
[0120] Further, based on the above method steps, after obtaining the sample object portraits associated with the scene identifier in the plurality of sample dialogue scenes, the server can determine the target object portrait and the reply object portrait associated with the scene identifier based on the scene identifier of the target dialogue scene, as shown in Figure 7 The execution subject is still taken as an example of the server, and the specific implementation process of the method is as follows:
[0121] S701: Obtain initial text information of a target object in a target dialogue scene, and determine a target object portrait and a reply object portrait associated with a scene identifier based on the scene identifier of the target dialogue scene.
[0122] The target object portrait includes various target object attributes of the target object, and the reply object portrait includes various reply object attributes of the reply object in the target dialogue scene.
[0123] In an optional implementation, when performing step S701, the server can obtain the initial text information of the target object in the target dialogue scene from the dialogue information request by receiving the dialogue reply request sent by the target terminal and parsing the received dialogue reply request, and determine the target object portrait and the reply object portrait associated with the scene identifier of the target dialogue scene according to the preset association relationship between the scene identifier and the sample object portrait.
[0124] S702: From the target object portrait, a target object attribute that meets a preset attribute similarity condition with the initial text information is filtered out, and from the reply object portrait, a reply object attribute that meets a preset attribute relevance condition with the target object attribute is selected.
[0125] In an optional implementation, referring to Figure 8 As shown in the figure, when performing step S702, after obtaining the initial text information of the target object in the target dialogue scene, the target object portrait and the reply object portrait, the server can perform semantic analysis on the initial text information to obtain corresponding semantic features, and then filter out a target object attribute that meets a preset attribute similarity condition with the semantic features of the initial text information from the target object portrait, and further select a reply object attribute that meets a preset attribute relevance condition with the target object attribute from the reply object portrait; wherein the target object attribute that meets the preset attribute similarity condition can be understood as the target object attribute with the highest similarity with the semantic features of the initial text information, and the reply object attribute that meets the preset attribute relevance condition can be understood as the reply object attribute with the highest relevance with the target object attribute.
[0126] For example, taking a target object portrait containing three target object attributes as an example, after obtaining the semantic features of the initial text information, the server determines the feature-attribute similarity between each of the three target object attributes contained in the target object portrait and the semantic features of the initial text information according to a preset feature-attribute similarity matching algorithm, wherein the feature-attribute similarity of each of the three target object attributes is shown in Table 1:
[0127] Table 1
[0128] Target Object Properties Tar. Obj. Pro 1 Tar. Obj. Pro 2 Tar. Obj. Pro 3 Feature-Property Similarity 85.2% 98.7% 79.8%
[0129] Based on the feature-property similarity of each target object attribute recorded in the above table, the server can filter the target object attribute that meets the preset attribute similarity condition from the three target object attributes included in the target object portrait and the semantic feature of the initial text information, for example, the target object attribute Tar. Obj. Pro2 with the highest feature-property similarity is taken as the target object attribute that meets the preset attribute similarity condition.
[0130] Further, after filtering the target object attribute Tar. Obj. Pro2, the server can determine the attribute relevance between the target object attribute Tar. Obj. Pro2 and each reply object attribute included in the reply object portrait according to the preset attribute relevance algorithm. Taking the reply object portrait including four reply object attributes as an example, and the attribute relevance including four levels, the attribute relevance is set from high to low as I, II, III and IV, and the attribute relevance between each of the above four reply object attributes and the target object attribute is shown in Table 2.
[0131] Table 2
[0132] Reply Object Properties Rep. Obj. Pro 1 Rep. Obj. Pro 2 Rep. Obj. Pro 3 Rep. Obj. Pro 4 Property Correlation Ⅱ Ⅳ Ⅰ Ⅲ
[0133] Obviously, based on the attribute relevance of each reply object attribute recorded in the above table, the server can filter the reply object attribute that meets the preset attribute relevance condition from the four reply object attributes included in the reply object portrait and the target object attribute Tar. Obj. Pro2, for example, the reply object attribute Rep. Obj. Pro3 with the highest attribute relevance is taken as the reply object attribute that meets the preset attribute relevance condition. It should be noted that the attribute relevance (0-100) can also be used to measure and quantify the attribute relevance in order to filter the reply object attribute.
[0134] S703: The preset dialogue reply generation model is used to perform fuzzy virtualization processing on the target object attribute, and based on the fuzzy virtualization processed target object attribute and the reply object attribute, target reply information that meets the preset dialogue reply relevance condition with the initial text information is generated.
[0135] It should be noted that the above preset dialogue reply generation model can be trained in the following manner: for any one of the plurality of sample dialogue scenarios in S201-S203, i.e., a first sample dialogue scenario, the following operations are performed: obtaining the sample dialogue content of each two sample objects in the first sample dialogue scenario, and based on the historical text information and historical reply information contained in the sample dialogue content, and the preset prediction loss function, the dialogue reply generation model is iteratively trained until the dialogue reply generation model meets the dialogue reply relevance condition; wherein the dialogue reply relevance condition represents that the reply information output by the dialogue reply generation model based on the input text information meets the preset dialogue reply accuracy condition and the preset dialogue reply diversity condition.
[0136] In an optional implementation, referring to Figure 9 As shown, if the following conditions are met, it can be determined that the above dialogue reply generation model meets the dialogue reply relevance condition: using the preset prediction loss function, determining the first loss value between the actual reply information obtained based on the sample object attribute corresponding to the historical text information and other reply information, and the second loss value between the actual reply information and the historical reply information, and then based on the first loss value and the second loss value, obtaining the corresponding prediction loss value, if the prediction loss value converges to the preset loss value threshold, it is determined that the dialogue reply generation model meets the dialogue reply relevance condition; wherein the historical reply information and the other reply information meet the preset reply information similarity condition.
[0137] It should be noted that based on the above preset prediction loss function, the server can reduce the probability that the reply result for the initial text information is the corresponding expected reply information to a certain extent, i.e., the probability that the reply result of the initial text information is the expected reply result input by the model during training is lower, so that the dialogue reply generation model has the prediction generation capability to meet the corresponding dialogue reply requirement, thereby increasing the diversity of dialogue generation reply; and the above historical reply information is the expected reply information.
[0138] It should also be noted that the prediction loss value converging to the preset loss value threshold can be understood as the loss value difference between the prediction loss value and the preset loss value threshold being not greater than a set loss value difference threshold.
[0139] Exemplarily, the preset prediction loss function is based on the standard cross-entropy loss function, and a label smoothing operation is added for token ids outside the special_token. The regularization of the loss function on other labels except special_token is realized, the risk of overconfidence of the model under one-hot loss calculation is reduced, the introduction of noise reduces the kurtosis of the probability distribution, and to some extent, the diversity of token prediction is improved. At the same time, by shielding special_token, the prediction logits (i.e. the output of full connection) of special_token is reduced, avoiding the prediction impact of the high frequency of special_token in the training data. The loss function L corresponding to the label smoothing operation is smooth The specific design is as follows:
[0140]
[0141] Wherein, L smooth is the first loss value, logits nl is the other logits after shielding the index bits of the logits corresponding to the target label, pad_token and special_token, label nl is the total number of logits minus the number of shielded tokens, that is, the target distribution corresponding to other logits outside the shielded tokens is considered as a uniform distribution.
[0142] The standard cross-entropy calculation is not modified, and the formula is as follows:
[0143]
[0144] Wherein, L CE is the second loss value, y i is the predicted label, p i is the predicted probability, and N is the number of other reply information.
[0145] Therefore, the final preset prediction loss function can be defined as:
[0146] L new = ε*L smooth +(1-ε)L CE
[0147] Wherein, ε is a self-defined hyperparameter, and the value is 0.1 according to the standard label smoothing method.
[0148] Optionally, the server can also use a standard Transformer model of the BART type as a base model for fine-tuning tasks. In this process, due to the design of the sample object attributes (data set), the special_token for prompting is added through the same tokenizer for tokenization and tokenization processing. In order to avoid the special_token from appearing too frequently, resulting in an abnormal high probability distribution of the overall context encoding representation for the special_token part during the calculation process, and then affecting the weight distribution of the existing embedding layer during the back propagation process, the weight parameters of the corresponding token embedding and position embedding are frozen during the fine-tuning process, thereby reducing the probability distribution kurtosis in advance.
[0149] Further, after the server performs the fuzzy virtualization processing on the target object attribute and obtains the fuzzy virtualization processed target object attribute, the server can generate target reply information that meets the preset dialogue reply relevance condition based on the fuzzy virtualization processed target object attribute and the reply object attribute and the initial text information.
[0150] In an optional implementation, when performing step S703, after obtaining the fuzzy virtualization processed target object attribute, the server can predict an initial reply word of the target reply information based on the fuzzy virtualization processed target object attribute and the reply object attribute, save the initial reply word to a preset initial reply information, and iteratively modify the initial reply information until the target reply information that meets the dialogue reply relevance condition is obtained. Referring to FIG. 10A, Figure 10 In a round of iterative modification, the following operations are performed:
[0151] S1001: predicting a next reply word of the current reply text based on the current reply text contained in the initial reply information, the fuzzy virtualization processed target object attribute, and the reply object attribute.
[0152] In a preferred implementation, when performing step S1001, if the number of reply words contained in the current reply text is not greater than a preset threshold of the number of reply words, a kernel sampling decoding strategy is used to predict the next reply word of the current reply text based on the current reply text, the fuzzy virtualization processed target object attribute, and the reply object attribute. If the number of reply words is greater than the threshold of the number of reply words, a beam search decoding strategy is used to predict the next reply word of the current reply text based on the current reply text, the fuzzy virtualization processed target object attribute, and the reply object attribute.
[0153] For example, assuming that the preset threshold of the number of reply words is 3, and the current reply text contains 3 reply words, i.e., the number of reply words contained in the current reply text is 3, which is not greater than the preset threshold of the number of reply words 3, then the next reply word of the current reply text can be predicted based on the current reply text, the target object attribute after the fuzzy blurring processing, and the reply object attribute according to the decoding strategy of top-p sampling. For example, if the current reply text is “I ate”, then p (for example, 3) candidate reply words “dumpling”, “noodle”, and “rice” adjacent to the current reply text are predicted. According to the decoding strategy of top-p sampling, one of the three candidate next reply words can be randomly selected as the next reply word, for example, “noodle” is selected as the next reply word of the current reply text.
[0154] It should be noted that the prediction probabilities of the p candidate reply words obtained by the decoding strategy of top-p sampling each satisfy the preset prediction probability arrangement order, and the sum (cumulative probability) of the prediction probabilities of the p candidate reply words satisfies the preset cumulative probability threshold.
[0155] For another example, if the current reply text is “I ate noodles”, it is easy to know that the number of reply words contained in the current text is 4, which is greater than the preset threshold of the number of reply words 3. Therefore, the decoding strategy of beam search can be used to predict the next reply word of the current reply text, so as to obtain beam-size next reply words. Optionally, if this is the last next reply word, the one with the maximum prediction probability can be selected from the obtained beam-size next reply words as the next reply word of the reply text.
[0156] It should be noted that when each round of prediction is performed by using the beam search method, the maximum cumulative prediction probability sum is used as the candidate. Therefore, in each round of prediction, the maximum beam_size is selected from the cumulative sum of the probability of the selected current reply word and the probability of the previous reply word.
[0157] S1002: Modify the current reply text based on the next reply word of the current reply text to obtain modified initial reply information.
[0158] For example, when performing step S1002, the server can add the next reply word to the last word of the current reply text to obtain the modified initial reply information after obtaining the next reply word of the current reply text. For example, still taking the current reply text "I have eaten" as an example, after predicting that the next reply word of the current reply text "I have eaten" is "rice" based on the current reply text, the target object attribute and the reply object attribute after the fuzzy virtualization processing according to the decoding strategy of core sampling, the server can modify "I have eaten" by adding the next reply word "rice" to obtain the modified initial reply information, that is, "I have eaten rice".
[0159] For another example, if the current reply text is "I have eaten rice", the server uses the decoding strategy of beam search to predict that the next reply word of the current reply text can be "strip", "package" or "food". Then, the next reply word can be added to "I have eaten rice" to obtain the modified initial reply information, which can be "I have eaten rice strip", "I have eaten rice package" and "I have eaten rice food". Optionally, if this is the last next reply word, the case with the largest cumulative prediction probability among the three cases of the modified initial reply information can be taken as the modified initial reply information.
[0160] Based on the reply word prediction method steps S1001-S1002, referring to FIG. 10, Figure 11 As shown in FIG. 10, the server adjusts the decoding output strategy by adding core sampling based on beam search to avoid the technical drawbacks of the traditional beam search strategy, that is, the loss of randomness in the actual natural language generation process while ensuring the highest probability. In addition, due to the coherence of the language itself, the starting word in the generation process often determines the generation path of the entire text. Therefore, the randomness of the starting word can be increased by adding core sampling before obtaining the target reply information with the maximum cumulative probability through the beam search output strategy. The specific decoding path is as follows. Figure 11 As shown in FIG. 10, in the first decay decoding process, core sampling is used for batch_size beam_size parallel sampling, and in the (decay+1)th decoding process, batch_size beam_size beam search sampling is used to generate tokens until all beams are generated. Optionally, decay and beam_size are specified hyperparameters, and the values are 2 and 8 respectively.
[0161] Referring to FIG. 10, Figure 12As shown, it is a logic diagram of a dialogue reply generation method provided by the embodiment of the application. The server obtains initial text information of a target object in a target dialogue scenario, and determines a target object portrait and a reply object portrait associated with the scene identifier based on the scene identifier of the target dialogue scenario. Then, target object attributes that meet a preset attribute similarity condition are filtered from the target object portrait based on the initial text information, and reply object attributes that meet a preset attribute relevance condition are selected from the reply object portrait based on the target object attributes. Finally, the target object attributes are blurred using a preset dialogue reply generation model, and target reply information that meets a preset dialogue reply relevance condition based on the initial text information is generated based on the blurred target object attributes and the reply object attributes.
[0162] In summary, in the dialogue reply generation method provided by the embodiment of the application, the scene identifier of the target dialogue scenario is associated with the target object portrait of the target object involved in the target dialogue scenario and the reply object portrait of the reply object. In this way, when replying to the initial text information of the target object in the target dialogue scenario, target object attributes that meet a preset attribute similarity condition can be filtered from the target object portrait based on the initial text information, and reply object attributes that meet a preset attribute relevance condition can be selected from the reply object portrait based on the target object attributes. Thus, the initial text information is replied to according to the obtained target object attributes and reply object attributes, thereby improving the relevance of the target reply information to the initial text information, i.e., the accuracy of the target reply information. In addition, in the embodiment of the application, the target object attributes are blurred using a preset prediction loss function, so that the blurred target object attributes can be obtained. Therefore, the target reply information generated based on the blurred target object attributes and the reply object attributes for the initial text information not only ensures the accuracy of the dialogue reply, but also improves the diversity of the dialogue generation reply to a certain extent.
[0163] Further, based on the same technical concept, the embodiment of the application provides a dialogue reply generation device for implementing the method flow of the embodiment of the application. Referring to Figure 13 As shown, the dialogue reply generation device includes an acquisition module 1301, a screening module 1302, and a generation module 1303, wherein:
[0164] The acquisition module 1301 is configured to acquire initial text information of a target object in a target dialogue scenario, and determine a target object portrait and a reply object portrait associated with the scene identifier based on the scene identifier of the target dialogue scenario. The target object portrait includes various target object attributes of the target object, and the reply object portrait includes various reply object attributes of the reply object in the target dialogue scenario.
[0165] The screening module 1302 is configured to screen a target object attribute that meets a preset attribute similarity condition from the target object image and select a reply object attribute that meets a preset attribute relevance condition from the reply object image.
[0166] The generation module 1303 is configured to perform fuzzy virtualization processing on the target object attribute by using a preset prediction loss function, and generate target reply information that meets a preset dialogue reply relevance condition with the initial text information based on the target object attribute after the fuzzy virtualization processing and the reply object attribute.
[0167] Optionally, before obtaining the initial text information of the target object in the target dialogue scenario, the screening module 1302 is further configured to:
[0168] For a plurality of sample dialogue scenarios, the following operations are respectively performed:
[0169] Obtain sample dialogue information of at least two sample objects involved in a sample dialogue scenario respectively;
[0170] Perform attribute feature extraction on the obtained at least two sample dialogue information respectively to obtain a sample object attribute set of at least two sample objects respectively;
[0171] Generate a sample object cartoon of at least two sample objects respectively based on the sample object attribute set of at least two sample objects respectively, and associate a scene identifier of a sample dialogue scenario with the sample object cartoon of at least two sample objects respectively.
[0172] Optionally, in the process of obtaining sample dialogue information of at least two sample objects involved in a sample dialogue scenario respectively, the screening module 1302 is further configured to:
[0173] If there is sample dialogue information that does not meet a preset dialogue information specification condition in the obtained at least two sample dialogue information, discard the sample dialogue scenario;
[0174] and / or,
[0175] If there is sample dialogue information that does not meet a preset dialogue information specification condition in the at least two sample dialogue information, discard the at least two sample dialogue information.
[0176] Optionally, after associating the scene identifier of a sample dialogue scenario with the sample object cartoon of at least two sample objects respectively, the screening module 1302 is further configured to:
[0177] For sample object attributes respectively contained in at least two sample object cartoons, the following operations are respectively performed:
[0178] determine the content prompt label based on the attribute type setting of the sample object attribute;
[0179] modify the initial data format of the sample object attribute to the preset standard data format based on the content prompt label and the preset content filling label.
[0180] Optionally, the dialogue reply generation model is trained in the following manner:
[0181] For a plurality of sample dialogue scenarios, the following operations are performed respectively:
[0182] Obtain the sample dialogue content of each two sample objects in the first sample dialogue scenario; wherein the first sample dialogue scenario is any one of the plurality of sample dialogue scenarios;
[0183] Based on the historical text information and the historical reply information contained in the sample dialogue content, and the preset prediction loss function, the dialogue reply generation model is iteratively trained until the dialogue reply generation model meets the dialogue reply relevance condition.
[0184] Optionally, if the following conditions are met, it is determined that the dialogue reply generation model meets the dialogue reply relevance condition:
[0185] Using the prediction loss function, determine the first loss value between the actual reply information obtained based on the historical text information corresponding to the sample object attribute and other reply information, and the second loss value between the actual reply information and the historical reply information; wherein the historical reply information and the other reply information meet the preset reply information similarity condition;
[0186] Based on the first loss value and the second loss value, obtain the corresponding prediction loss value, if the prediction loss value converges to the preset loss value threshold, it is determined that the dialogue reply generation model meets the dialogue reply relevance condition.
[0187] Optionally, in generating the target reply information that meets the preset dialogue reply relevance condition based on the target object attribute and the reply object attribute after the fuzzy virtualization processing, the generation module 1303 is specifically configured to:
[0188] Based on the target object attribute and the reply object attribute after the fuzzy virtualization processing, predict the initial reply word of the target reply information, and save the initial reply word to the preset initial reply information;
[0189] Iteratively modify the initial reply information until the target reply information that meets the dialogue reply relevance condition is obtained; wherein in the process of one round of iterative modification, the following operations are performed:
[0190] predict the next reply word of the current reply text based on the current reply text, the target object attribute after the fuzzy virtualization processing, and the reply object attribute contained in the initial reply information.
[0191] modify the current reply text based on the next reply word of the current reply text to obtain modified initial reply information.
[0192] Optionally, when predicting the next reply word of the current reply text based on the current reply text, the target object attribute after the fuzzy virtualization processing, and the reply object attribute contained in the initial reply information, the generation module 1303 is specifically configured to:
[0193] if the number of reply words contained in the current reply text is not greater than the preset threshold of the number of reply words, a decoding strategy of kernel sampling is adopted to predict the next reply word of the current reply text based on the current reply text, the target object attribute after the fuzzy virtualization processing, and the reply object attribute;
[0194] if the number of reply words is greater than the threshold of the number of reply words, a decoding strategy of beam search is adopted to predict the next reply word of the current reply text based on the current reply text, the target object attribute after the fuzzy virtualization processing, and the reply object attribute.
[0195] Based on the same technical concept, the embodiments of the present application also provide an electronic device, which can implement the dialogue reply generation method provided by the above-mentioned embodiments of the present application. In an embodiment, the electronic device can be a server, a terminal device or other electronic device. As shown in Figure 14 the electronic device can include:
[0196] at least one processor 1401 and a memory 1402 connected with the at least one processor 1401, and the specific connection medium between the processor 1401 and the memory 1402 is not limited in the embodiments of the present application, Figure 14 for example, the connection between the processor 1401 and the memory 1402 through the bus 1400. The bus 1400 is represented by a thick line in Figure 14 the connection mode between other components is only schematically illustrated and is not limited. The bus 1400 can be divided into an address bus, a data bus, a control bus, etc. For convenience of representation, Figure 14 only one thick line is used in the embodiment of the present application, but it does not mean that there is only one bus or only one type of bus. Alternatively, the processor 1401 can also be called a controller, and the name is not limited.
[0197] In the embodiments of the present application, the memory 1402 stores instructions executable by the at least one processor 1401, and the at least one processor 1401 can execute the foregoing dialogue reply generation method by executing the instructions stored in the memory 1402. The processor 1401 can implement Figure 13 the functions of various modules of the apparatus shown.
[0198] The processor 1401 is the control center of the apparatus, and can connect all parts of the control device through various interfaces and lines, and monitor the whole apparatus by running or executing the instructions stored in the memory 1402 and calling the data stored in the memory 1402, so as to process data and implement various functions of the apparatus.
[0199] In a possible design, the processor 1401 can include one or more processing units, and the processor 1401 can integrate an application processor and a modem processor, where the application processor mainly processes operating systems, user interfaces, and application programs, and the modem processor mainly processes wireless communication. It can be understood that the foregoing modem processor can also not be integrated into the processor 1401. In some embodiments, the processor 1401 and the memory 1402 can be implemented on the same chip, and in some embodiments, they can also be implemented on separate chips respectively.
[0200] The processor 1401 can be a general-purpose processor, for example, a CPU, a digital signal processor, an application-specific integrated circuit, a field programmable gate array, or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the dialogue reply generation method disclosed in the embodiments of the present application can be directly embodied as execution of the hardware processor, or be executed by a combination of hardware and software modules in the processor.
[0201] The memory 1402, as a non-volatile computer readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 1402 can include at least one type of storage medium, for example, can include flash memory, hard disk, multimedia card, card type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. The memory 1402 is any other medium capable of carrying or storing desired program code in the form of instructions or data structures and capable of being accessed by a computer, but is not limited thereto. The memory 1402 in the embodiments of the present application can also be a circuit or any other device capable of realizing a storage function, used for storing program instructions and / or data.
[0202] By designing and programming the processor 1401, the code corresponding to the dialogue reply generation method introduced in the foregoing embodiments can be fixed into the chip, so that the chip can execute the dialogue reply generation method of the embodiments shown in the running time. Figure 7 The steps of the dialogue reply generation method of the embodiments shown in the foregoing embodiments. How to design and program the processor 1401 is a technology known to those skilled in the art, which will not be described here.
[0203] Based on the same inventive concept, the embodiments of the present application also provide a storage medium storing computer instructions, when the computer instructions run on a computer, the computer instructions make the computer execute the dialogue reply generation method discussed in the foregoing.
[0204] In some possible implementations, the present application also provides various aspects of a dialogue reply generation method, which can also be implemented in the form of a program product, including program code, when the program product runs on a device, the program code is used to make the control device execute the steps of the dialogue reply generation method according to the various exemplary embodiments of the present application described in the foregoing description of the present application.
[0205] It should be noted that, although several units or sub-units of the apparatus are mentioned in the above detailed description, such division is merely exemplary and not mandatory. Indeed, according to an embodiment of the application, the features and functionalities of two or more units described above can be embodied in one unit. Conversely, the features and functionalities of one unit described above can be further divided into units embodied by several units.
[0206] Moreover, although the operations of the method(s) herein can be described in a particular, sequential order, this order is not meant to be a limitation and is not intended to imply that
[0207] Those of skill in the art would understand that embodiments of the present application can be provided as a method, a system, or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, and the like) embodying computer readable program code.
[0208] The present application is described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing system or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 The means for carrying out the functions specified in the flowchart illustrations and / or block diagrams can be embodied in one or more of the following: Figure 1 The means for carrying out the functions specified in the flowchart illustrations and / or block diagrams can be embodied in one or more of the following:
[0209] The program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++, or the like, and conventional procedural programming languages, such as the "C" programming language, or the like. The program code can execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server.
[0210] In situations where the remote computing device is involved, the remote computing device can be connected to the user computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0211] These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.
[0212] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions that are executed on the computer or other programmable apparatus provide steps for implementing the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.
[0213] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the applicable prior art, the application can be practiced otherwise than as specifically described herein.
Claims
1. A method for generating a reply to a dialogue, characterized by, The method comprises the following steps: obtaining initial text information of a target object in a target dialogue scene, and determining a target object portrait and a reply object portrait associated with a scene identifier of the target dialogue scene based on the scene identifier; the target object portrait comprises various target object attributes of the target object, and the reply object portrait comprises various reply object attributes of a reply object in the target dialogue scene; filtering out a target object attribute that meets a preset attribute similarity condition from the target object portrait, and selecting a reply object attribute that meets a preset attribute relevance condition from the reply object portrait; performing fuzzy virtualization processing on the target object attribute by using a preset dialogue reply generation model, and generating target reply information that meets a preset dialogue reply relevance condition with the initial text information based on the target object attribute after the fuzzy virtualization processing and the reply object attribute; the fuzzy virtualization processing is a weakening representation capability of an input representation comprising the target object attribute obtained by introducing noise in a training process of the dialogue reply generation model; the weakening representation capability is used to reduce the dependence of the dialogue reply generation model on the target object attribute when generating the target reply information.
2. The method of claim 1, wherein, Before the step of obtaining the initial text information of the target object in the target dialogue scene, the method further comprises the following steps: for a plurality of sample dialogue scenes, the following operations are respectively performed: obtaining sample dialogue information of at least two sample objects involved in a sample dialogue scene; performing attribute feature extraction on the obtained at least two sample dialogue information to obtain a sample object attribute set of the at least two sample objects respectively; generating a sample object cartoon of the at least two sample objects respectively based on the sample object attribute set of the at least two sample objects respectively, and associating a scene identifier of the sample dialogue scene with the sample object cartoon of the at least two sample objects respectively.
3. The method of claim 2, wherein, In the process of obtaining the sample dialogue information of the at least two sample objects involved in the sample dialogue scene, the method further comprises the following steps: if there is sample dialogue information that does not meet a preset dialogue information specification condition in the obtained at least two sample dialogue information, the sample dialogue scene is discarded; and / or, if there is sample dialogue information that does not meet the preset dialogue information specification condition in the at least two sample dialogue information, the at least two sample dialogue information is discarded.
4. The method of claim 2, wherein, After the step of associating the scene identifier of the sample dialogue scene with the sample object cartoon of the at least two sample objects, the method further comprises the following steps: for the sample object attribute contained in the at least two sample object cartoons respectively, the following operations are respectively performed: determining a content prompt label set based on the attribute type of the sample object attribute; modifying an initial data format of the sample object attribute to a preset standard data format based on the content prompt label and a preset content filling label.
5. The method of any one of claims 2-4, wherein, The dialogue reply generation model is trained in the following manner: for the plurality of sample dialogue scenes, the following operations are respectively performed: obtaining sample dialogue content of each two sample object in a first sample dialogue scene; wherein the first sample dialogue scene is any one of the plurality of sample dialogue scenes; iteratively training the dialogue reply generation model based on historical text information and historical reply information contained in the sample dialogue content, and a preset prediction loss function, until the dialogue reply generation model meets the dialogue reply relevance condition.
6. The method of claim 5, wherein, If the following conditions are met, it is determined that the dialogue reply generation model meets the dialogue reply relevance condition: using the prediction loss function, determining a first loss value between actual reply information obtained based on sample object attributes corresponding to the historical text information and other reply information, and a second loss value between the actual reply information and the historical reply information; wherein the historical reply information and the other reply information meet a preset reply information similarity condition; based on the first loss value and the second loss value, obtaining a corresponding prediction loss value, if the prediction loss value converges to a preset loss value threshold, it is determined that the dialogue reply generation model meets the dialogue reply relevance condition.
7. The method of claim 1, wherein, The target reply information meeting the preset dialogue reply relevance condition is generated based on the target object attribute after the fuzzy virtualization processing and the reply object attribute, including: based on the target object attribute after the fuzzy virtualization processing and the reply object attribute, predicting an initial reply word of the target reply information, and saving the initial reply word to a preset initial reply information; iteratively modifying the initial reply information until the target reply information meeting the dialogue reply relevance condition is obtained; wherein in the process of one round of iterative modification, the following operations are performed: based on the current reply text contained in the initial reply information, the target object attribute after the fuzzy virtualization processing and the reply object attribute, predicting a next reply word of the current reply text; based on the next reply word of the current reply text, modifying the current reply text to obtain modified initial reply information.
8. The method of claim 7, wherein, The next reply word of the current reply text is predicted based on the current reply text contained in the initial reply information, the target object attribute after the fuzzy virtualization processing and the reply object attribute, including: if the number of reply words contained in the current reply text is not greater than a preset reply word number threshold, a kernel sampling decoding strategy is used to predict the next reply word of the current reply text based on the current reply text, the target object attribute after the fuzzy virtualization processing and the reply object attribute; if the number of reply words is greater than the reply word number threshold, a beam search decoding strategy is used to predict the next reply word of the current reply text based on the current reply text, the target object attribute after the fuzzy virtualization processing and the reply object attribute. 9.A dialogue reply generation apparatus, characterized by comprising: including: An acquisition module is configured to acquire initial text information of a target object in a target dialogue scenario, and determine a target object portrait and a reply object portrait associated with a scene identifier of the target dialogue scenario based on the scene identifier; the target object portrait includes various target object attributes of the target object, and the reply object portrait includes various reply object attributes of a reply object in the target dialogue scenario; A screening module is configured to screen a target object attribute that meets a preset attribute similarity condition with the initial text information from the target object portrait, and select a reply object attribute that meets a preset attribute relevance condition with the target object attribute from the reply object portrait; A generation module is configured to perform fuzzy virtualization processing on the target object attribute by using a preset dialogue reply generation model, and generate target reply information that meets a preset dialogue reply relevance condition with the initial text information based on the target object attribute after the fuzzy virtualization processing and the reply object attribute; the fuzzy virtualization processing is a weakening representation capability of an input representation including the target object attribute obtained by introducing noise in a training process of the dialogue reply generation model; and the weakening representation capability is used to reduce a dependence degree of the dialogue reply generation model on the target object attribute when generating the target reply information.
10. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the method of any one of claims 1-8.
11. A computer readable storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement the steps of the method of any one of claims 1-8.
Citation Information
Patent Citations
Human-computer interaction method and device, equipment, storage medium and computer program product
CN114416937A
Voice intent recognition method and device, computer equipment and storage medium
WO2021135548A1