Dialogue generation method, device, electronic device and storage medium
By combining user problem statements, historical dialogue information and domain knowledge, and generating and evaluating dialogue reply statements, the problem of low dialogue generation performance in the existing technology is solved, and high-quality dialogue generation and optimized user experience is achieved.
Patent Information
- Application Number
- CN202411269987.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2044-09-10
AI Technical Summary
The existing dialogue generation solution is not performing well when facing complex and changing language environments and knowledge needs, making it difficult to improve the depth of understanding of user needs by the dialogue system and the quality of reply statements.
By obtaining the user's question statement and its associated historical dialogue information, obtaining relevant knowledge entries and response relationships from the knowledge base, inputting the generative model with this information, generating replies, and ensuring the accuracy and coherence of replies through evaluation.
It realizes the integration of dialogue replies and domain knowledge, improves the quality of reply statements, ensures the consistency and consistency of dialogues, improves the accuracy of reply, and optimizes the user experience.
Smart Images

Figure CN119226463B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technologies such as natural language processing, large models, and deep learning, and particularly relates to a dialogue generation method, apparatus, electronic device, and storage medium. Background Art
[0002] With the rapid development of artificial intelligence technologies, dialogue systems have been widely applied in multiple fields such as intelligent customer service, smart home, and online education. The current dialogue generation solutions have low performance when facing complex and changeable language environments and knowledge requirements. Therefore, how to improve the depth of understanding of user needs by the dialogue system, improve the quality of response sentences, and the coherence with the context has become the key to the development of intelligent dialogue systems. Summary of the Invention
[0003] The present disclosure aims to at least solve one of the technical problems in the related art to some extent.
[0004] To this end, the purpose of the present disclosure is to provide a dialogue generation method, apparatus, electronic device, and storage medium to combine domain knowledge and context information, improve the generation of response sentences, improve dialogue quality, and optimize the user experience.
[0005] According to a first aspect of the present disclosure, there is provided a dialogue generation method, including:
[0006] Obtain a current first question sentence and historical dialogue information associated with the first question sentence;
[0007] Obtain a first knowledge entry associated with the first question sentence from a knowledge base, and a second knowledge entry whose relationship with the first knowledge entry is a response relationship;
[0008] Input the first question sentence, the first knowledge entry, and the historical dialogue information into a generative model to obtain a first response sentence output by the generative model;
[0009] Evaluate the first response sentence based on the first question sentence, the first knowledge entry, and the second knowledge entry;
[0010] Output the first response sentence when the first response sentence passes the evaluation.
[0011] According to a second aspect of the present disclosure, there is provided a dialogue generation apparatus, including:
[0012] A first acquisition module, configured to obtain a current first question sentence and historical dialogue information associated with the first question sentence;
[0013] A second acquisition module, configured to acquire a first knowledge entry associated with the first question statement from a knowledge base, and a second knowledge entry whose relationship with the first knowledge entry is a response relationship;
[0014] A generation module, configured to input the first question statement, the first knowledge entry, and historical conversation information into a generative model, and obtain a first response statement output by the generative model;
[0015] An evaluation module, configured to evaluate the first response statement based on the first question statement, the first knowledge entry, and the second knowledge entry;
[0016] An output module, configured to output the first response statement when the first response statement passes the evaluation.
[0017] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0018] At least one processor; and
[0019] A memory communicatively connected to the at least one processor; wherein,
[0020] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the dialogue generation method as described in the first aspect.
[0021] According to a fourth aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, and the computer instructions are used to cause a computer to execute the dialogue generation method as described in the first aspect.
[0022] According to a fifth aspect of the present disclosure, there is provided a computer program product, including computer instructions, and the computer instructions implement the steps of the dialogue generation method as described in the first aspect when executed by a processor.
[0023] The dialogue generation method, device, electronic device, and storage medium provided by the present disclosure have the following beneficial effects:
[0024] By combining domain expertise related to the user's question statement and historical conversation information to automatically generate a response statement, the integration of dialogue responses and domain knowledge is achieved, the quality of the response statement is improved, and the coherence and consistency of the dialogue are ensured. Moreover, by evaluating the generated response statement, the accuracy of the reply is enhanced, the situations of grammar errors and illogicality in the response statement are effectively reduced, and the user experience is optimized.
[0025] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood from the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The above and / or additional aspects and advantages of the present disclosure will become apparent and readily understood from the following description of embodiments in conjunction with the drawings, which are used to better understand the solution and do not constitute a limitation to the present disclosure, where:
[0027] Figure 1 is a schematic flowchart of a dialogue generation method according to an embodiment of the present disclosure;
[0028] Figure 2 is a schematic flowchart of a dialogue generation method according to another embodiment of the present disclosure;
[0029] Figure 3 is a schematic flowchart of a dialogue generation method according to another embodiment of the present disclosure;
[0030] Figure 4 is a schematic flowchart of a dialogue generation method according to another embodiment of the present disclosure;
[0031] Figure 5 is a schematic flowchart of a dialogue generation method according to another embodiment of the present disclosure
[0032] Figure 6 is a schematic structural diagram of a dialogue generation device according to an embodiment of the present disclosure;
[0033] Figure 7 shows a block diagram of an exemplary electronic device suitable for implementing the embodiments of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0034] The following describes exemplary embodiments of the present disclosure in conjunction with the drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted below.
[0035] The embodiments of the present disclosure relate to the fields of artificial intelligence technologies such as natural language processing, large models, and deep learning.
[0036] Artificial Intelligence, abbreviated as AI in English, is a new technical science that studies, develops theories, methods, technologies, and application systems for simulating, extending, and expanding human intelligence.
[0037] Natural Language Processing (NLP) is an important direction in the field of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between humans and computers using natural language. It is a discipline that takes language as the object and uses computer technology to analyze, understand, and process natural language, that is, taking the computer as a powerful tool for language research, quantitatively studying language information with the support of the computer, and providing language descriptions that can be commonly used between humans and computers.
[0038] Large Model (also known as the Foundation Model), refers to a machine learning model with a large number of parameters and a complex structure, capable of processing massive amounts of data and completing various complex tasks, such as natural language processing, computer vision, speech recognition, etc. Among them, the large language model is a natural language processing model with large-scale parameters and computing power, which can be trained with a large amount of data and parameters to generate human-like text or answer natural language questions.
[0039] Deep learning is to learn the internal laws and representation levels of sample data, and the information obtained during these learning processes is very helpful for the interpretation of data such as text, images, and sounds. The ultimate goal of deep learning is to enable machines to have the ability to analyze and learn like humans, and be able to recognize data such as text, images, and sounds.
[0040] In the technical solution of the present disclosure, the processing of the collection, storage, use, processing, transmission, provision, and disclosure of the user's personal information complies with the provisions of relevant laws and regulations and does not violate public order and good customs.
[0041] Next, the dialogue generation method, device, electronic device, and storage medium of the embodiments of the present disclosure will be described with reference to the accompanying drawings.
[0042] It should be noted that the execution subject of the dialogue generation method in this embodiment is the dialogue generation device, which can be implemented in software and / or hardware, and the device can be configured in an electronic device. The electronic device can include, but is not limited to, terminals, server sides, etc. In the embodiments of the present disclosure, the case where the dialogue generation device is configured in a dialogue system is taken as an example for illustration.
[0043] Figure 1 It is a schematic flowchart of the dialogue generation method proposed according to an embodiment of the present disclosure.
[0044] As Figure 1 shown, the dialogue generation method includes:
[0045] S101: Obtain the current first question statement and the historical dialogue information associated with the first question statement.
[0046] Among them, the first question statement can be a question statement received by the dialogue system in the dialogue interface for interacting with any user.
[0047] In the embodiments of the present disclosure, in order to ensure the coherence of the dialogue, the context understanding module in the dialogue generation system can also maintain the dialogue history memory by storing the historical dialogue information of each user and the dialogue system, usually implemented through structures such as a memory network or a recurrent neural network (such as a long short-term memory network (LSTM, Long Short-Term Memory)).
[0048] In the embodiments of the present disclosure, after receiving the first question statement newly input by any user, the dialogue system can obtain the historical dialogue information associated with the first question statement from the historical dialogue records in the dialogue interface to which the first question statement belongs.
[0049] S102: Obtain the first knowledge item associated with the first question statement from the knowledge base, and the second knowledge item whose relationship with the first knowledge item is a response relationship.
[0050] Among them, a knowledge item refers to a single element or unit that constitutes the basic knowledge of a certain field, discipline, or topic, and can be a definition, fact, concept, theory, formula, etc. In the knowledge base, each knowledge item can be stored in the form of a knowledge graph, and there may be relationships between different knowledge items, such as response relationships, causal relationships, time relationships, etc.
[0051] In addition, the response relationship means that there is a logical association such as "question - answer" or "request - response" between two knowledge items. In the response relationship, one of the knowledge items represents a question, request, or query, and the other knowledge item is a direct answer or response to the question, request, or query.
[0052] It should be noted that in the embodiments of the present disclosure, the first knowledge item associated with the first question statement can be determined by calculating the similarity between the first question statement and each knowledge item in the knowledge base, and taking one or more knowledge items with higher similarity. Or, the first knowledge item associated with the first question statement can also be obtained from the knowledge base in other ways, such as calculating the distance between the word vectors in the question statement and the knowledge item. The present disclosure does not limit this.
[0053] In an embodiment of the present disclosure, after receiving a first question statement currently input by a user, the dialogue system may retrieve at least one first knowledge entry related to the first question statement in the knowledge base of the system according to the first question statement. Then, according to the relationships between the various knowledge entries in the knowledge base, second knowledge entries that are in a response relationship with each first knowledge entry in the knowledge base can be obtained.
[0054] It should be noted that in the present disclosure, for dialogue systems applied to different scenarios, the information contained in their corresponding knowledge bases may be different. For dialogue systems in different application fields, such as finance, healthcare, and education, relevant domain knowledge, such as professional terms, common question-and-answer pairs, and expert knowledge, can be collected and organized to construct a knowledge base. Then, natural language processing techniques can be used to perform preprocessing tasks such as cleaning, word segmentation, and annotation on the collected text information, and thus store them as different knowledge entries in the knowledge base.
[0055] S103: Input the first question statement, the first knowledge entry, and the historical dialogue information into a generative model to obtain a first response statement output by the generative model.
[0056] Among them, the generative model can be any model that can generate new text according to the input text. For example, it can be a pre-trained language model based on a multi-layer Transformer encoder (BERT, Bidirectional Encoder Representations from Transformers) or a generative pre-trained model GPT (Generative Pre-Trained), etc.
[0057] In an embodiment of the present disclosure, since the generative model has learned rich language knowledge and generation capabilities through large-scale pre-training, it can generate a first response statement that matches the current dialogue scenario and user needs according to the input first question statement, the first knowledge entry, and the historical dialogue information.
[0058] It should be noted that if the generative model is a deep learning model, such as BERT or GPT with a Transformer structure, it can deeply analyze the first question statement. Through self-attention mechanisms and positional encodings, etc., it can capture long-range dependency relationships and semantic features in the first question statement, provide rich semantic information for the subsequent response statement generation task, and effectively improve the quality of the output statement.
[0059] It should be noted that in some possible implementation forms, there may be many first knowledge items, or the text information included in the first knowledge items is excessive. When all these first knowledge items are input into the generative model, it may cause a burden on the model and affect the quality and generation efficiency of the reply statement. Therefore, before inputting the first question statement, the first knowledge items, and the historical conversation information into the generative model, the first knowledge items can be processed first to improve the generation efficiency of the generative model and the quality of the output reply. For example, the contribution degree of each first knowledge item in reply generation can be determined, and then the contribution degrees can be input into the generative model together to instruct the model to generate a reply statement. Or, the information in the first knowledge items can also be deleted, etc., and only the important information in the first knowledge items is input into the generative model for generating a reply statement, reducing the amount of data analyzed by the generative model.
[0060] S104: Evaluate the first reply statement based on the first question statement, the first knowledge item, and the second knowledge item.
[0061] It should be noted that after obtaining the first reply statement output by the generative model, in order to improve the accuracy and depth of the dialogue reply, before sending the first reply statement to the user, the evaluation module in the dialogue system can use the knowledge in the knowledge base to verify and evaluate the first reply statement to ensure that the information in the first reply statement is accurate and conforms to the domain specification.
[0062] In the embodiments of the present disclosure, the first reply statement can be evaluated in multiple ways. For example, the first question statement, the first knowledge item, the second knowledge item, and the first reply statement can be input into any existing evaluation model to directly obtain the evaluation result output by the evaluation model; or, the similarity between the first question statement and the first knowledge item, and the similarity between the second knowledge item and the first reply statement can also be calculated, and then the evaluation result can be determined through the difference between the two similarities, etc. The present disclosure does not limit this.
[0063] Optionally, the first similarity between the first question statement and the first knowledge item, and the second similarity between the first reply statement and the second knowledge item can be determined first. Then, when the difference between the first similarity and the second similarity is less than the distance threshold, it is determined that the first reply statement passes the evaluation.
[0064] Among them, the distance threshold can be set according to the evaluation accuracy requirements in actual applications, etc. The higher the accuracy requirement, the smaller the distance threshold should be.
[0065] It should be noted that the first similarity can be determined by calculating the distance between the vector of the first question statement and the vector of the second knowledge item, or the semantic similarity between the first question statement and the second knowledge item can be calculated to obtain the first similarity, etc. The present disclosure does not limit this. The calculation method of the second similarity is the same as that of the first similarity.
[0066] In the embodiments of the present disclosure, after obtaining the first similarity and the second similarity, since the first knowledge item is associated with the first question statement, the value of the first similarity is large enough. Therefore, when the difference between the first similarity and the second similarity is less than the distance threshold, it can be determined that the value of the second similarity is also relatively large, that is, the first reply statement conforms to the conventional response knowledge content in the current field and is relatively reliable. Then it can be determined that the first reply statement passes the evaluation. Thus, by calculating the difference between the similarities, the reply statement is evaluated, ensuring the accuracy and reliability of the generated reply statement, and further improving the quality of the intelligent dialogue.
[0067] S105: When the first reply statement passes the evaluation, output the first reply statement.
[0068] In the embodiments of the present disclosure. When the first reply statement passes the evaluation, it can be considered that the first reply statement output by the current generative model not only conforms to the user's intention but also conforms to the professional knowledge in the current field. Therefore, the accuracy of the first reply statement is relatively high, and it can be output and sent to the user on the dialogue system interface to answer the first question statement.
[0069] It should be noted that when the first reply statement fails to pass the evaluation, it can be indicated that the current first reply statement does not conform well to the domain knowledge and the accuracy is not high. Then the reply statement output by the generative model needs to be updated until the reply statement passes the evaluation and is output to the user. Among them, the update of the reply statement can be realized by inputting the problems found in the evaluation process or the second knowledge item, etc. into the generative model to obtain the newly output reply statement of the model.
[0070] In this embodiment, first, the current first question statement and its associated historical conversation information are obtained. Then, the first knowledge entry associated with the first question statement is retrieved from the knowledge base, as well as the second knowledge entry whose relationship with the first knowledge entry is a response relationship. Next, the first question statement, the first knowledge entry, and the historical conversation information are input into the generative model to obtain the first response statement output by the generative model. After that, based on the first question statement, the first knowledge entry, and the second knowledge entry, the first response statement is evaluated. If the first response statement passes the evaluation, the first response statement is output. Thus, by combining the domain expertise related to the user's question statement and the historical conversation information, a response statement is automatically generated, realizing the integration of dialogue responses and domain knowledge, improving the quality of the response statement, and ensuring the coherence and consistency of the dialogue. Moreover, by evaluating the generated response statement, the accuracy of the reply is enhanced, effectively reducing the cases of grammar errors and illogicality in the response statement, and optimizing the user experience.
[0071] Figure 2 It is a schematic flowchart of a dialogue generation method proposed in another embodiment of the present disclosure.
[0072] As Figure 2 shown, the dialogue generation method includes:
[0073] S201: Obtain the current first question statement and the historical conversation information associated with the first question statement.
[0074] For the description of S201, specific reference can be made to the above embodiment, and details are not described herein again.
[0075] S202: Determine the first similarity between the first vector corresponding to the first question statement and the second vectors corresponding to each knowledge entry in the knowledge base.
[0076] In the embodiments of the present disclosure, embedding techniques in deep learning (such as word embedding techniques based on neural networks, Word2Vec, BERT, etc.) can be used to encode the first question statement and each knowledge entry respectively, to obtain the first vector corresponding to the first question statement and the second vectors corresponding to each knowledge entry.
[0077] In the embodiments of the present disclosure, the first similarity between the first vector and each second vector can be calculated in any way. For example, it can be the cosine similarity between the first vector and the second vector; or it can also be the Euclidean distance between the first vector and the second vector, where the smaller the distance, the greater the similarity; or, there can also be other feasible similarity calculation methods, etc. The present disclosure does not make any limitations in this regard.
[0078] S203: Determine the knowledge entries corresponding to the first similarity greater than the similarity threshold as the first knowledge entries.
[0079] Among them, the similarity threshold can be defined and set according to factors such as the actual application needs and experience, and the present disclosure does not limit this value.
[0080] In the embodiments of the present disclosure, after determining the first similarity between the first vector and each second vector, each first similarity can be compared with the similarity threshold respectively. When the first similarity is greater than the similarity threshold, it can be determined that the knowledge item corresponding to the first similarity has a strong correlation with the first question statement, and then this knowledge item can be determined as the first knowledge item for generating the response statement.
[0081] It should be noted that since there may be multiple first similarities corresponding to multiple knowledge items that are greater than the similarity threshold, there may also be multiple first knowledge items.
[0082] S204: Determine a second knowledge item whose relationship with the first knowledge item is a response relationship according to the third vector corresponding to the first knowledge item.
[0083] Among them, the third vector is used to represent the association relationship between the first knowledge item and other knowledge items.
[0084] It should be noted that when constructing the knowledge base, knowledge graph embedding techniques (such as TransE (Translating Embeddings for Modeling Multi-relational Data) for multi-relational data modeling, RotatE (Relational Rotation in Complex Space) for knowledge graph embedding in the complex space, etc.) can be used to map the entities and relationships between knowledge items in each knowledge item into a low-dimensional vector space to form a knowledge graph for subsequent calculation and reasoning.
[0085] In the embodiments of the present disclosure, since the relationship between two knowledge items in the knowledge base can be not only a response relationship but also other relationships, after determining the first knowledge item associated with the first question statement, first, according to the knowledge graph in the knowledge base, determine the other knowledge item connected by the third vector corresponding to each first knowledge item, and then screen the relationship represented by the third vector, and determine the knowledge item connected by the third vector representing the response relationship as the second knowledge item.
[0086] In the embodiments of the present disclosure, by calculating the vector similarity between the user input statement and the knowledge entries in the knowledge base, the first knowledge entry associated with the problem statement input by the user is determined, and according to the relationship between the vector representations of the knowledge entries in the knowledge base, the second knowledge entry whose relationship with the first knowledge entry is a response relationship is obtained, which can improve the rationality and reliability of the domain knowledge for generating the response statement and provide a data basis for enhancing the ability of the dialogue system to handle complex problems.
[0087] S205: In the case where there are multiple first knowledge entries, according to the similarity corresponding to each first knowledge entry, determine the first contribution degree of the first knowledge entry.
[0088] In the embodiments of the present disclosure, in the case where there are multiple first knowledge entries, directly input all the first knowledge entries into the generative model for generating the response statement. There is no primary-secondary relationship among the multiple first knowledge entries, and the generative model needs to parse each first knowledge entry to the same extent, which may cause waste of computing resources and affect the quality of the generated statement. Therefore, the similarity between each first knowledge entry and the first problem statement can be determined as the first contribution degree of the first knowledge entry. The higher the similarity, the more the first knowledge entry conforms to the user's intention, and the more important the first knowledge entry is for generating the response statement, that is, the higher the first contribution degree.
[0089] S206: Based on the first problem statement, historical dialogue information, multiple first knowledge entries, and the first contribution degree of each first knowledge entry, generate the first prompt message.
[0090] Among them, the first prompt message is used to instruct the generative model to generate a response statement by combining the contribution degrees of each knowledge entry and other contents.
[0091] In the embodiments of the present disclosure, a template for generating the first prompt message can be preset in the dialogue system. Then, after obtaining the first problem statement, historical dialogue information, multiple first knowledge entries, and the first contribution degree of each first knowledge entry, fill the first problem statement, historical dialogue information, multiple first knowledge entries, and the first contribution degree of each first knowledge entry into the template respectively, and then the first prompt message can be obtained.
[0092] S207: Input the first prompt message into the generative model to obtain the first response statement output by the generative model.
[0093] In the embodiments of the present disclosure, after generating prompt information from the various pieces of information for generating a response statement, the prompt information is input into a generative model to instruct the model to generate a response statement. The generative model can identify the aspects that need to be emphasized more when generating the response statement, perform key analysis and processing on the knowledge item, improve the utilization rate of computing resources, enhance the generative model's understanding ability and processing efficiency for the input information, reduce misunderstandings, and ensure the reliability of the output response statement.
[0094] In the embodiments of the present disclosure, when there are multiple first knowledge items, first, the contribution degree of each first knowledge item to the generation of the response statement is determined. Then, the first question statement, historical dialogue information, multiple first knowledge items, and the contribution degree of each first knowledge item are fused to generate first prompt information. Then, the first prompt information is input into the generative model to obtain the first response statement output by the generative model. Thus, the effective integration of user input and domain knowledge is achieved, which not only enhances the information volume of the model input data but also enables the model to more accurately understand the user's intention, improving the accuracy and reliability of the generated response statement.
[0095] S208: Evaluate the first response statement based on the first question statement, the first knowledge item, and the second knowledge item.
[0096] S209: Output the first response statement when the first response statement passes the evaluation.
[0097] For the descriptions and explanations of S208 and S209, please refer to the above embodiments specifically, and details will not be elaborated here.
[0098] In this embodiment, by calculating the vector similarity between the user input statement and the knowledge items in the knowledge base, the first knowledge item associated with the question statement input by the user is determined, and according to the relationship between the vector representations of the various knowledge items in the knowledge base, the second knowledge item whose relationship with the first knowledge item is a response relationship is obtained, which can improve the rationality and reliability of the domain knowledge for generating the response statement and provide a data basis for enhancing the ability of the dialogue system to handle complex problems. When there are multiple first knowledge items, first, the contribution degree of each first knowledge item to the generation of the response statement is determined. Then, the first question statement, historical dialogue information, multiple first knowledge items, and the contribution degree of each first knowledge item are fused to generate first prompt information. Then, the first prompt information is input into the generative model to obtain the first response statement output by the generative model. Thus, the effective integration of user input and domain knowledge is achieved, which not only enhances the information volume of the model input data but also enables the model to more accurately understand the user's intention, improving the accuracy and reliability of the generated response statement.
[0099] Figure 3It is a schematic flowchart of a dialogue generation method proposed in another embodiment of the present disclosure.
[0100] As Figure 3 shown, the dialogue generation method includes:
[0101] S301: Obtain the current first question statement and the historical dialogue information associated with the first question statement.
[0102] S302: Determine the first similarity between the first vector corresponding to the first question statement and the second vectors corresponding to each knowledge entry in the knowledge base.
[0103] S303: Determine the knowledge entries with the first similarity greater than the similarity threshold as the first knowledge entries.
[0104] S304: Determine the second knowledge entries whose relationship with the first knowledge entries is a response relationship according to the third vector corresponding to the first knowledge entries.
[0105] For the descriptions of S301 to S304 above, specific references can be made to the above embodiments and will not be elaborated here.
[0106] S305: When the first knowledge entry is a preset type entry, determine the second contribution degree of each knowledge fragment in the first knowledge entry to the second vector corresponding to the first knowledge entry.
[0107] Among them, the preset type entry refers to a type with a relatively large amount of information and complexity in the knowledge entries, such as an article or content containing multiple paragraphs of text, etc. Each piece of content or each sentence in the preset type entry can be used as a knowledge fragment in the knowledge entry.
[0108] In the embodiments of the present disclosure, after obtaining the first knowledge entry, it can be determined whether each first knowledge entry is a preset type entry. When any first knowledge entry is a preset type entry, due to the relatively large amount of information in the first knowledge entry, there may be redundant information or noise information, which will affect the quality of the generated response statement. Therefore, through technologies such as the attention mechanism, the second contribution degree of each knowledge fragment in the first knowledge entry to the second vector corresponding to the first knowledge entry is determined to screen out the content that plays a key role in generating the response statement in the first knowledge entry.
[0109] S306: Determine the target knowledge fragment from the first knowledge entry according to the second contribution degree.
[0110] Among them, the target knowledge fragment refers to the content that plays a key role in generating the response statement in the first knowledge entry.
[0111] In the embodiments of the present disclosure, a contribution threshold can be preset in the dialogue system according to actual application requirements, etc. Then, after determining the second contribution corresponding to each knowledge segment in the first knowledge entry, compare the second contribution with the contribution threshold, and determine the knowledge segment corresponding to the second contribution greater than the contribution threshold as the target knowledge segment in the first knowledge entry. Alternatively, the knowledge segment corresponding to the maximum value among all the second contributions can also be determined as the target segment in the first knowledge entry, etc. The present disclosure does not limit this.
[0112] S307: Generate a second prompt message based on the first question statement, historical dialogue information, and target knowledge segment.
[0113] Among them, the second prompt message is used to instruct the generative model to generate a reply statement in combination with content such as the target knowledge segment.
[0114] In the embodiments of the present disclosure, a template for generating the second prompt message can be preset in the dialogue system. Then, after obtaining the first question statement, historical dialogue information, and target knowledge segment, fill the first question statement, historical dialogue information, and target knowledge segment into the template respectively, and the second prompt message can be obtained.
[0115] S308: Input the second prompt message into the generative model to obtain the first reply statement output by the generative model.
[0116] In the embodiments of the present disclosure, by obtaining knowledge segments with higher contributions in the knowledge entries associated with the user input statement and inputting them into the generative model to obtain a reply statement, the segments used to generate the reply statement in each knowledge entry associated with the user input statement can be dynamically adjusted, reducing the resources consumed during the calculation of the generative model, improving the generation efficiency of the reply statement, and further improving the quality of the reply statement.
[0117] S309: Evaluate the first reply statement based on the first question statement, the first knowledge entry, and the second knowledge entry.
[0118] S310: Output the first reply statement when the first reply statement passes the evaluation.
[0119] For the descriptions of S309 and S310, specific reference can be made to the above embodiments, which will not be elaborated here.
[0120] Figure 4 It is a schematic flowchart of a dialogue generation method proposed in another embodiment of the present disclosure.
[0121] As Figure 4 shown, the dialogue generation method includes:
[0122] S401: Obtain the current first question statement and the historical conversation information associated with the first question statement.
[0123] S402: Obtain the first knowledge item associated with the first question statement from the knowledge base, and the second knowledge item whose relationship with the first knowledge item is a response relationship.
[0124] S403: Input the first question statement, the first knowledge item, and the historical conversation information into the generative model to obtain the first response statement output by the generative model.
[0125] For the descriptions of S401 to S403 above, specific references can be made to the above embodiments, which will not be elaborated here.
[0126] S404: Generate the third prompt information based on the first knowledge item, the first question statement, the second knowledge item, and the first response statement.
[0127] Among them, the third prompt information is used to instruct the evaluation model to verify the accuracy and standardization of the response statement.
[0128] In the embodiments of the present disclosure, a template for generating the third prompt information can be preset in the dialogue system. Then, after obtaining the first knowledge item, the first question statement, the second knowledge item, and the first response statement, the first knowledge item, the first question statement, the second knowledge item, and the first response statement are respectively filled into the template, and the third prompt information can be obtained.
[0129] It should be noted that considering that the text generation capabilities of different generative models are different, and the response statements output by them may contain diverse data contents, therefore, only using the second knowledge item whose relationship with the first knowledge item is a response relationship to evaluate the first response statement may not accurately verify the accuracy of all contents in the first response statement. Therefore, in the present disclosure, other knowledge items can also be obtained from the knowledge base to enrich the third prompt information for evaluating the first response statement.
[0130] Optionally, the third knowledge item associated with the first response statement can be obtained from the knowledge base first.
[0131] In the embodiments of the present disclosure, the semantic similarity between the first response statement and each knowledge item in the knowledge base can be calculated, and one or more knowledge items with a semantic similarity higher than a certain threshold are determined as the third knowledge item associated with the first response statement. Or, the third knowledge item associated with the first response statement can also be obtained from the knowledge base by other means, such as calculating the distance between the word vectors in the first response statement and each knowledge item. The present disclosure does not limit this.
[0132] Then, the third knowledge entry can be fused with the second knowledge entry to obtain the fused knowledge entry and the weight of the fused knowledge entry.
[0133] Among them, the fusion method can be to remove duplicates and merge the third knowledge entry with the second knowledge entry.
[0134] Among them, the weight of the fused knowledge entry is used to indicate the degree of emphasis of different knowledge entries when the evaluation model evaluates the reply statement.
[0135] It should be noted that there may be one or more third knowledge entries, and there may also be one or more second knowledge entries, and there may be a situation where the second knowledge entry is the same as the third knowledge entry. Therefore, after performing the operations of removing duplicates and merging each third knowledge entry with the second knowledge entry in turn, the fused knowledge entry may be one, or may be multiple, and may be the same as the second knowledge entry or the third knowledge entry.
[0136] In the embodiments of the present disclosure, after removing the duplicate content in the third knowledge entry from the second knowledge entry and merging all the content in the third knowledge entry with the second knowledge entry to obtain the fused knowledge entry, the fused knowledge entry can be determined in various ways. For example, the similarity between the fused knowledge entry and the first reply statement can be calculated to determine the weight, and the higher the similarity, the higher the weight; or it can also be determined according to the number of occurrences of the fused knowledge entry in the second knowledge entry and the third knowledge entry, etc.
[0137] After that, the third prompt information can be generated based on the first knowledge entry, the first question statement, the first reply statement, the fused knowledge entry, and the weight of the fused knowledge entry.
[0138] In the embodiments of the present disclosure, by fusing the third knowledge entry associated with the first reply statement in the knowledge base with the second knowledge entry, the fused knowledge entry and its corresponding weight are obtained, and then the fused knowledge entry and its corresponding weight are used together with the first knowledge entry, the first question statement, and the first reply statement to generate prompt information to instruct the evaluation model to evaluate the first reply statement. Thus, the content richness of the evaluation prompt information can be improved, and further the reliability and accuracy of the reply statement evaluation result can be improved.
[0139] Optionally, when determining the weight of the fused knowledge entry, the third similarity between the fused knowledge entry and the first reply statement, and the number of occurrences of the fused knowledge entry in the second knowledge entry and the third knowledge entry can be determined first.
[0140] In the embodiments of the present disclosure, the semantic similarity between the fused knowledge entry and the first reply statement may be calculated to obtain the third similarity. Alternatively, the distance between the vector of the fused knowledge entry and the vector of the first reply statement may be calculated. The smaller the distance, the higher the similarity, so as to obtain the third similarity. Alternatively, it may also be other methods for calculating the similarity between texts, etc., and the present disclosure does not limit this.
[0141] It can be understood that in some possible embodiments, there may be a situation where the second knowledge entry is the same as the third knowledge entry, or the third knowledge entry contains the second knowledge entry, etc. In this case, the fused knowledge entry may be the second knowledge entry or the third knowledge entry, or the fused knowledge entry appears in both the second knowledge entry and the third knowledge entry. Therefore, the number of knowledge entries that are the same as the fused knowledge entry in the second knowledge entry and the third knowledge entry can be used to obtain the number of occurrences of the fused knowledge entry.
[0142] It should be noted that when the fused knowledge entry appears in both the second knowledge entry and the third knowledge entry, the number of occurrences is recorded as 2 times. This indicates that the fused knowledge entry is not only in a response relationship with the first knowledge entry, but also associated with the generated first reply statement, and its influence on the evaluation result should be relatively high.
[0143] Then, the weight of the fused knowledge entry may be determined according to the third similarity and / or the number of occurrences.
[0144] In the embodiments of the present disclosure, the weight may be determined only according to the third similarity. The higher the third similarity, the more the corresponding fused knowledge entry conforms to the domain knowledge specification corresponding to the reply statement, and the higher the weight of the fused knowledge entry. The weight may also be determined only according to the number of occurrences. The higher the number of occurrences, the stronger the correlation between the corresponding fused knowledge entry and the reply statement, and the better the evaluation effect on the reply statement, so it can be determined that the weight of the fused knowledge entry is higher. Alternatively, the weight of the fused knowledge entry may also be determined by comprehensively considering the third similarity and the number of occurrences.
[0145] In the embodiments of the present disclosure, by calculating the similarity and the number of occurrences corresponding to the fused knowledge entry to determine its corresponding weight, the reliability of the weight of the fused knowledge entry is improved, and further the accuracy and reliability of the evaluation result obtained based on the weight are improved.
[0146] S405: Input the third prompt information into the evaluation model, and obtain the evaluation result output by the evaluation model.
[0147] Among them, the evaluation model can be any existing model for verifying the accuracy and standardization of text. In the evaluation results generated by the evaluation model, it can include the error types in the first reply statement (such as semantic incoherence, inconsistent with domain knowledge, etc.), the error positions, etc. The present disclosure does not limit this.
[0148] It should be noted that when the evaluation result corresponding to the first reply statement fails, the dialogue system can update the input content of the generative model according to the evaluation result to ensure the smooth progress of the dialogue.
[0149] Optionally, when the first reply statement fails the evaluation, the evaluation result corresponding to the first reply statement can be input into the generative model to obtain the second reply statement output by the generative model. Then, based on the second reply statement, an evaluation operation is returned until a reply statement that passes the evaluation is obtained and output.
[0150] In the embodiments of the present disclosure, the evaluation result corresponding to the first reply statement that fails the evaluation can be input into the generative model to instruct the generative model to re-output the previously generated first reply statement according to the deficiencies included in the evaluation result, and obtain the updated second reply statement. Then, the second reply statement is evaluated again. If the second reply statement passes the evaluation, the second reply statement can be output to the user. If the evaluation result of the second reply statement still fails, the new evaluation result is input into the generative model again to obtain a new reply statement until the generated reply statement can pass the evaluation. Thus, by using the evaluation result of the reply statement that fails the evaluation to instruct the generative model to output the next reply statement, the reliability of the reply statement can be further improved, the quality of the dialogue can be improved, and the coherence of the dialogue can be ensured.
[0151] S406: When the first reply statement passes the evaluation, output the first reply statement.
[0152] For the specific description of the above S406, reference can be specifically made to the above embodiments and will not be elaborated here.
[0153] In this embodiment, by using the first knowledge entry, the first question statement, the second knowledge entry, and the first reply statement to generate the third prompt information, and then instructing the evaluation model to output the evaluation result of the first reply statement, the automatic evaluation and verification of the reply statement can be realized, the evaluation efficiency of the reply statement and the reliability of the evaluation result can be improved, and thus the quality of the dialogue can be improved.
[0154] Figure 5 It is a schematic flowchart of a dialogue generation method proposed in another embodiment of the present disclosure.
[0155] As Figure 5 shown, the dialogue generation method includes:
[0156] S501: Obtain the current first question statement and the historical dialogue information associated with the first question statement.
[0157] S502: Obtain the first knowledge entry associated with the first question statement from the knowledge base, and the second knowledge entry whose relationship with the first knowledge entry is a response relationship.
[0158] S503: Input the first question statement, the first knowledge entry, and the historical dialogue information into the generative model to obtain the first response statement output by the generative model.
[0159] S504: Evaluate the first response statement based on the first question statement, the first knowledge entry, and the second knowledge entry.
[0160] S505: Output the first response statement if the first response statement passes the evaluation.
[0161] For the descriptions of S501 to S505 above, specific references can be made to the above embodiments, which will not be elaborated here.
[0162] S506: Generate and output the third response statement corresponding to the second question statement when receiving the second question statement for the first response statement.
[0163] In the embodiments of the present disclosure, after the dialogue system outputs the first response statement to the user, the user may have doubts about the first response statement, and thus may input a new second question statement in the dialogue interface. Therefore, if the dialogue system can receive the second question statement for the first response statement, it can obtain the third response statement output by the generative model and passing the evaluation according to the method described in the above embodiments, and output it to the current dialogue interface.
[0164] S507: Generate the target response statement corresponding to the first question statement based on the first response statement and the third response statement when not receiving the third question statement for the third response statement.
[0165] In the embodiments of the present disclosure, when the third response statement is output to the dialogue interface and the third question statement for the third response statement is not received, it can be determined that the first response statement and the third response statement can meet the user's needs and solve the user's problem (i.e., the problem corresponding to the first question statement), then the first response statement and the third response statement can be jointly determined as the target response statement corresponding to the first question statement.
[0166] S508: Store the first question statement and the target response statement in a preset database.
[0167] Among them, the data in the preset database is used to update and train the generative model.
[0168] In the embodiments of the present disclosure, the first question statement and its corresponding target reply statement can be stored in pairs in a preset database. When the data in the preset database reaches a certain amount or reaches a preset update time interval, the generative model is updated and trained using the data in the preset database.
[0169] In this embodiment, when a second question statement for the first reply statement is received, a third reply statement corresponding to the second question statement is first generated and output. Then, when a third question statement for the third reply statement is not received, based on the first reply statement and the third reply statement, a target reply statement corresponding to the first question statement is generated. And the first question statement and the target reply statement are stored in the preset database. Thus, by combining user feedback to iteratively optimize the generated reply statements, and based on the question statements and their finally optimized reply contents, the parameters and strategies of the training generative model are adjusted, so that the dialogue system can continuously adapt to new dialogue scenarios and user needs, and improve the overall performance of the dialogue system.
[0170] Figure 6 It is a schematic structural diagram of a dialogue generation device proposed by an embodiment of the present disclosure.
[0171] As Figure 6 shown, the dialogue generation device 600 includes:
[0172] A first acquisition module 601, configured to acquire a current first question statement and historical dialogue information associated with the first question statement;
[0173] A second acquisition module 602, configured to acquire a first knowledge item associated with the first question statement from a knowledge base, and a second knowledge item whose relationship with the first knowledge item is a response relationship;
[0174] A generation module 603, configured to input the first question statement, the first knowledge item, and the historical dialogue information into a generative model, and obtain a first reply statement output by the generative model;
[0175] An evaluation module 604, configured to evaluate the first reply statement based on the first question statement, the first knowledge item, and the second knowledge item;
[0176] An output module 605, configured to output the first reply statement when the first reply statement passes the evaluation.
[0177] Optionally, the second acquisition module 602 may specifically be configured to:
[0178] Determine a first similarity between a first vector corresponding to the first question statement and second vectors corresponding to each knowledge item in the knowledge base;
[0179] Determine the knowledge entries corresponding to the first similarity greater than the similarity threshold as the first knowledge entries;
[0180] Determine the second knowledge entries whose relationship with the first knowledge entries is the response relationship according to the third vector corresponding to the first knowledge entries, where the third vector is used to represent the association relationship between the first knowledge entries and other knowledge entries.
[0181] Optionally, the generation module 603 can specifically be used for:
[0182] In the case where there are multiple first knowledge entries, determine the first contribution degree of each first knowledge entry according to the similarity corresponding to each first knowledge entry;
[0183] Generate the first prompt information based on the first question statement, historical dialogue information, multiple first knowledge entries, and the first contribution degree of each first knowledge entry;
[0184] Input the first prompt information into the generative model to obtain the first response statement output by the generative model.
[0185] Optionally, the generation module 603 can specifically be used for:
[0186] In the case where the first knowledge entries are preset type entries, determine the second contribution degree of each knowledge segment in the first knowledge entries to the second vector corresponding to the first knowledge entries;
[0187] Determine the target knowledge segment from the first knowledge entries according to the second contribution degree;
[0188] Generate the second prompt information based on the first question statement, historical dialogue information, and the target knowledge segment;
[0189] Input the second prompt information into the generative model to obtain the first response statement output by the generative model.
[0190] Optionally, the evaluation module 604 can specifically be used for:
[0191] Determine the first similarity between the first question statement and the first knowledge entries, and the second similarity between the first response statement and the second knowledge entries;
[0192] In the case where the difference between the first similarity and the second similarity is less than the distance threshold, determine that the first response statement passes the evaluation.
[0193] Optionally, the evaluation module 604 can specifically be used for:
[0194] Generate the third prompt information based on the first knowledge entries, the first question statement, the second knowledge entries, and the first response statement;
[0195] Input the third prompt message into the evaluation model to obtain the evaluation result output by the evaluation model.
[0196] Optionally, the evaluation module 604 can specifically be used for:
[0197] Obtain the third knowledge item associated with the first response statement from the knowledge base;
[0198] Fuse the third knowledge item with the second knowledge item to obtain the fused knowledge item and the weight of the fused knowledge item;
[0199] Generate the third prompt message based on the first knowledge item, the first question statement, the first response statement, the fused knowledge item, and the weight of the fused knowledge item.
[0200] Optionally, the evaluation module 604 can specifically be used for:
[0201] Determine the third similarity between the fused knowledge item and the first response statement, and the number of occurrences of the fused knowledge item in the second knowledge item and the third knowledge item;
[0202] Determine the weight of the fused knowledge item according to the third similarity and / or the number of occurrences.
[0203] Optionally, the evaluation module 604 can also be used for:
[0204] In the case where the first response statement fails the evaluation, input the evaluation result corresponding to the first response statement into the generative model to obtain the second response statement output by the generative model;
[0205] Based on the second response statement, return to perform the evaluation operation until a response statement that passes the evaluation is obtained and output.
[0206] Optionally, the output module 605 can also be used for:
[0207] In the case where the second question statement for the first response statement is received, generate and output the third response statement corresponding to the second question statement;
[0208] In the case where the third question statement for the third response statement is not received, generate the target response statement corresponding to the first question statement based on the first response statement and the third response statement;
[0209] Store the first question statement and the target response statement in a preset database, where the data in the preset database is used to update and train the generative model.
[0210] It should be noted that the foregoing explanation of the dialogue generation method also applies to the dialogue generation device in this embodiment, and will not be elaborated here.
[0211] In this embodiment, by combining domain expertise related to the user's question statement and historical conversation information, a response statement is automatically generated, achieving the integration of conversation responses and domain knowledge, improving the quality of the response statement, and ensuring the coherence and consistency of the conversation. Moreover, by evaluating the generated response statement, the accuracy of the reply is enhanced, effectively reducing grammar errors and illogical situations in the response statement, and optimizing the user experience.
[0212] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0213] Figure 7 FIG. shows a schematic block diagram of an exemplary electronic device 700 that can be used to implement embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as, for example, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, for example, a personal digital processor, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely exemplary and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0214] As Figure 7 shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0215] A plurality of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a magnetic disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0216] The computing unit 701 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 executes the various methods and processes described above, such as the dialogue generation method. For example, in some embodiments, the dialogue generation method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the dialogue generation method described above can be executed. Alternatively, in other embodiments, the computing unit 701 can be configured to execute the dialogue generation method in any other suitable manner (e.g., by means of firmware).
[0217] Various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuitry, integrated circuit systems, field-programmable gate arrays (FPGA), application-specific integrated circuits (ASIC), application-specific standard products (ASSP), system-on-a-chip systems (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0218] The program code for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program codes can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0219] In the context of this disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0220] In order to provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0221] The systems and techniques described herein can be implemented in a computing system that includes backend components (such as, for example, a data server), or a computing system that includes middleware components (such as, for example, an application server), or a computing system that includes frontend components (such as, for example, a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (such as, for example, a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and blockchain networks.
[0222] A computer system may include a client and a server. The client and the server are generally far from each other and usually interact via a communication network. The relationship between the client and the server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services ("Virtual Private Server", or simply "VPS" for short). The server may also be a server of a distributed system or a server combined with a blockchain.
[0223] It should be understood that various forms of processes shown above can be used, steps can be reordered, added or deleted. For example, the steps recorded in the present disclosure can be executed in parallel, sequentially or in a different order, as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved, and no limitations are imposed herein.
[0224] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include at least one such feature. In the description of the present disclosure, the meaning of "a plurality" is at least two, such as two, three, etc., unless otherwise specifically defined. In the description of the present disclosure, the words "if" and "when" can be interpreted as "when...", "while...", "in response to determining" or "in the case of...".
[0225] The above specific embodiments do not constitute a limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure shall be included within the protection scope of the present disclosure.
Claims
1. A method for generating a dialogue, comprising: Obtaining a current first question statement and historical conversation information associated with the first question statement; Acquire from a knowledge base a first knowledge item associated with the first question statement, and a second knowledge item having a response relationship with the first knowledge item; Inputting the first question statement, the first knowledge item and the historical dialogue information into a generative model to obtain a first answer statement output by the generative model; Based on the first question statement, the first knowledge item, and the second knowledge item, the first answer statement is evaluated, wherein the evaluation process includes: Determining a first similarity between the first question statement and the first knowledge item, and a second similarity between the first answer statement and the second knowledge item; When the difference between the first similarity and the second similarity is less than a distance threshold, determining that the first reply statement passes the evaluation; In a case where the first reply sentence passes the evaluation, the first reply sentence is output.
2. The method of claim 1, wherein: The step of acquiring from the knowledge base a first knowledge item associated with the first question statement and a second knowledge item having a response relationship with the first knowledge item includes: Determine a first similarity between a first vector corresponding to the first question statement and a second vector corresponding to each knowledge item in the knowledge base; Determine the knowledge item corresponding to the first similarity greater than the similarity threshold as the first knowledge item; According to the third vector corresponding to the first knowledge item, a second knowledge item having a response relationship with the first knowledge item is determined, wherein the third vector is used to represent the association relationship between the first knowledge item and other knowledge items.
3. The method of claim 2, wherein: The step of inputting the first question statement, the first knowledge item, and the historical dialogue information into a generative model to obtain a first answer statement output by the generative model includes: In the case where there are multiple first knowledge items, determining a first contribution of the first knowledge item according to a similarity corresponding to each first knowledge item; Generate first prompt information based on the first question statement, the historical dialogue information, a plurality of the first knowledge items, and a first contribution degree of each of the first knowledge items; The first prompt information is input into the generative model to obtain a first reply sentence output by the generative model.
4. The method of claim 2, wherein: The step of inputting the first question statement, the first knowledge item, and the historical dialogue information into a generative model to obtain a first answer statement output by the generative model includes: In the case where the first knowledge item is an item of a preset type, determining a second contribution of each knowledge fragment in the first knowledge item to a second vector corresponding to the first knowledge item; determining a target knowledge segment from the first knowledge item according to the second contribution; Generate second prompt information based on the first question statement, the historical dialogue information, and the target knowledge fragment; The second prompt information is input into the generative model to obtain a first reply sentence output by the generative model.
5. The method according to any one of claims 1, wherein: The first answer statement is evaluated based on the first question statement, the first knowledge item, and the second knowledge item, wherein the evaluation process further includes: Generate third prompt information based on the first knowledge item, the first question statement, the second knowledge item and the first answer statement; The third prompt information is input into the evaluation model to obtain the evaluation result output by the evaluation model.
6. The method of claim 5, wherein: The generating of the third prompt information based on the first knowledge item, the first question statement, the second knowledge item and the first answer statement includes: Acquire a third knowledge item associated with the first reply statement from the knowledge base; Fusing the third knowledge item with the second knowledge item to obtain a fused knowledge item and a weight of the fused knowledge item; The third prompt information is generated based on the first knowledge item, the first question statement, the first answer statement, the fused knowledge item and the weight of the fused knowledge item.
7. The method of claim 6, wherein: The process of determining the weight of the fused knowledge item includes: Determine a third similarity between the fused knowledge item and the first reply statement, and the number of occurrences of the fused knowledge item in the second knowledge item and the third knowledge item; The weight of the fused knowledge item is determined according to the third similarity and / or the number of occurrences.
8. The method according to any one of claims 1 to 4, wherein: After evaluating the first reply statement, the method further includes: In the case where the first reply sentence fails the evaluation, inputting the evaluation result corresponding to the first reply sentence into the generative model to obtain a second reply sentence output by the generative model; Based on the second reply statement, return to execute the evaluation operation until a reply statement that passes the evaluation is obtained and output.
9. The method according to any one of claims 1 to 4, wherein: After outputting the first reply statement, the method further includes: Upon receiving a second question statement for the first answer statement, generating and outputting a third answer statement corresponding to the second question statement; In the case where a third question statement for the third reply statement is not received, generating a target reply statement corresponding to the first question statement based on the first reply statement and the third reply statement; The first question statement and the target answer statement are stored in a preset database, wherein the data in the preset database is used to update and train the generative model.
10. A dialogue generation device, comprising: A first acquisition module, used to acquire a current first question statement and historical dialogue information associated with the first question statement; A second acquisition module is used to acquire from a knowledge base a first knowledge item associated with the first question statement and a second knowledge item whose relationship with the first knowledge item is an answer relationship; A generation module, configured to input the first question statement, the first knowledge item and the historical dialogue information into a generative model to obtain a first answer statement output by the generative model; An evaluation module is used to evaluate the first answer statement based on the first question statement, the first knowledge item and the second knowledge item, wherein the evaluation process includes: Determining a first similarity between the first question statement and the first knowledge item, and a second similarity between the first answer statement and the second knowledge item; When the difference between the first similarity and the second similarity is less than a distance threshold, determining that the first reply statement passes the evaluation; An output module is used to output the first reply statement if the first reply statement passes the evaluation.
11. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the dialog generation method according to any one of claims 1 to 9.
12. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: in, The computer instructions are used to enable the computer to execute the dialog generation method according to any one of claims 1 to 9.
13. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the steps of the dialog generation method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Processing method and device in question-answering system based on knowledge graph
CN111414465A
Man-machine conversation method and device and storage medium
CN112487173A