Dialogue generation method and device, electronic equipment and storage medium

By obtaining user problem statements and historical dialogue information, combining knowledge entries and generative models in the knowledge base, generating and evaluating replies, the lack of performance of dialogue systems in the existing technology in complex language environments is solved, and the dialogue system is improved depth of understanding and quality of response.

CN119226463AActive Publication Date: 2024-12-31BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411269987.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2024-12-31
Estimated Expiration
2044-09-10

AI Technical Summary

Technical Problem

The existing dialogue generation solutions are not performing well when facing complex and changing locale environments and knowledge needs, making it difficult to improve the depth of understanding of user needs by the dialogue system and the quality of replies, and lack context coherence.

Method used

By obtaining user question statements and their historical dialogue information, relevant knowledge entries and response relationship entries are obtained from the knowledge base, replies are generated in combination with generative models, and evaluation is carried out to improve the accuracy and coherence of replies.

Benefits of technology

The integration of dialogue replies and domain knowledge is achieved, the quality and consistency of replies are improved, the situations of grammatical errors and logical unreasonableness are reduced, and the user experience is optimized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226463A_ABST
    Figure CN119226463A_ABST
Patent Text Reader

Abstract

The invention provides a dialogue generation method and device, electronic equipment and a storage medium, relates to the technical field of artificial intelligence such as natural language processing, large models and deep learning, and can be used for application scenes such as generative search, intelligent assistants and intelligent customer service. According to the specific implementation scheme, the method comprises the steps of obtaining a current first question statement and historical dialogue information associated with the first question statement; obtaining a first knowledge entry associated with the first question statement and a second knowledge entry in response to the first knowledge entry from a knowledge base; inputting the first question statement, the first knowledge entry and the historical dialogue information into a generative model to obtain a first reply statement output by the generative model; based on the first question statement, the first knowledge item and the second knowledge item, evaluating the first reply statement; and outputting the first reply statement under the condition that the first reply statement passes the evaluation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the fields of artificial intelligence technologies such as natural language processing, large models, and deep learning, and specifically to a dialogue generation method, device, electronic device, and storage medium. Background Art

[0002] With the rapid development of artificial intelligence technology, dialogue systems have been widely used in many fields such as intelligent customer service, smart home, online education, etc. The current dialogue generation scheme has low performance when facing complex and changing language environments and knowledge requirements. Therefore, how to improve the depth of understanding of user needs by the dialogue system, improve the quality of reply sentences and 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 solve one of the technical problems in the related art at least to some extent.

[0004] To this end, the purpose of the present disclosure is to propose a dialogue generation method, device, electronic device and storage medium to achieve the combination of domain knowledge and context information, improve the generation of response sentences, improve the quality of dialogue, and optimize the user experience.

[0005] According to a first aspect of the present disclosure, a method for generating a dialogue is provided, comprising:

[0006] Obtaining a current first question statement and historical conversation information associated with the first question statement;

[0007] 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;

[0008] 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;

[0009] Based on the first question statement, the first knowledge item, and the second knowledge item, evaluating the first answer statement;

[0010] In a case where the first reply sentence passes the evaluation, the first reply sentence is output.

[0011] According to a second aspect of the present disclosure, there is provided a dialogue generating device, comprising:

[0012] A first acquisition module, used to acquire a current first question statement and historical dialogue information associated with the first question statement;

[0013] 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;

[0014] 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;

[0015] An evaluation module, configured to evaluate the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item;

[0016] An output module is used to output the first reply statement if the first reply 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 that can be executed 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, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the dialog generation method as described in the first aspect.

[0022] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement the steps of the dialog generation method as described in the first aspect.

[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 user question statements and historical conversation information, we can automatically generate reply statements, integrating dialogue replies with domain knowledge, improving the quality of reply statements, and ensuring the coherence and consistency of the conversation. In addition, by evaluating the generated reply statements, we can improve the accuracy of the replies, effectively reduce grammatical errors and illogical logic in the reply statements, and optimize the user experience.

[0025] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through 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 easily understood from the following description of the embodiments in conjunction with the accompanying drawings, which are used to better understand the present solution and do not constitute a limitation of the present disclosure, wherein:

[0027] Figure 1 is a flowchart of a method for generating a dialogue according to an embodiment of the present disclosure;

[0028] Figure 2 is a flowchart of a method for generating a dialogue according to another embodiment of the present disclosure;

[0029] Figure 3 is a flowchart of a method for generating a dialogue according to another embodiment of the present disclosure;

[0030] Figure 4 is a flowchart of a method for generating a dialogue according to another embodiment of the present disclosure;

[0031] Figure 5 is a flow chart of a method for generating a dialogue according to another embodiment of the present disclosure

[0032] Figure 6 is a structural diagram of a dialogue generation device proposed according to an embodiment of the present disclosure;

[0033] Figure 7 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0034] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may 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 in the following description.

[0035] The embodiments of the present disclosure relate to artificial intelligence technology fields such as natural language processing, large models, and deep learning.

[0036] Artificial Intelligence (AI) is a new technical science that studies and 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 fields 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 uses computer technology to analyze, understand and process natural language, that is, it uses computers as a powerful tool for language research, conducts quantitative research on language information with the support of computers, and provides language descriptions that can be used by humans and computers.

[0038] Large Model (also called Foundation Model) refers to a machine learning model with a large number of parameters and complex structure, which can process massive data and complete 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 the process of learning the inherent laws and representation levels of sample data. The information obtained in the learning process is of great help in interpreting data such as text, images, and sounds. The ultimate goal of deep learning is to enable machines to have analytical learning capabilities like humans and to be able to recognize data such as text, images, and sounds.

[0040] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0041] The following describes the dialog generation method, device, electronic device, and storage medium according to the embodiments of the present disclosure with reference to the accompanying drawings.

[0042] It should be noted that the execution subject of the dialogue generation method of this embodiment is a dialogue generation device, which can be implemented by software and / or hardware, and can be configured in an electronic device, which can include but is not limited to a terminal, a server, etc. In the disclosed embodiment, the dialogue generation device is configured in a dialogue system as an example for description.

[0043] Figure 1 It is a flowchart of a dialogue generation method proposed according to an embodiment of the present disclosure.

[0044] like Figure 1 As shown, the dialogue generation method includes:

[0045] S101: Obtain the current first question statement and historical dialogue information associated with the first question statement.

[0046] The first question statement may be a question statement received by the dialogue system in a dialogue interface for interacting with any user.

[0047] In the disclosed embodiment, in order to ensure the continuity of the conversation, the context understanding module in the conversation generation system can also maintain the conversation history memory by storing the historical conversation information between each user and the conversation system, which is usually achieved through structures such as memory networks or recurrent neural networks (such as long short-term memory networks (LSTM)).

[0048] In the disclosed embodiment, after receiving the first question sentence most recently input by any user, the dialogue system may obtain historical dialogue information associated with the first question sentence from the historical dialogue record of the dialogue interface to which the first question sentence belongs.

[0049] S102: Acquire from the 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 a response relationship.

[0050] Among them, knowledge items refer to individual elements or units that constitute the basic knowledge of a certain field, discipline or subject, which can be definitions, facts, concepts, theories, formulas, 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, cause-effect relationships, time relationships, etc.

[0051] In addition, the response relationship refers to the existence of a logical association between two knowledge items such as "question-answer" or "request-response". In the response relationship, one knowledge item 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 similarity between the first question statement and each knowledge item in the knowledge base can be calculated, and one or more knowledge items with higher similarity can be determined as the first knowledge item associated with the first question statement. Alternatively, the first knowledge item associated with the first question statement can 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, etc., which is not limited in the present disclosure.

[0053] In the embodiment of the present disclosure, after receiving the first question sentence currently input by the user, the dialogue system can retrieve at least one first knowledge item related to the first question sentence in the knowledge base of the system according to the first question sentence. Then, according to the relationship between the knowledge items in the knowledge base, the second knowledge item in the knowledge base that is in a response relationship with each first knowledge item can be obtained.

[0054] It should be noted that in the present disclosure, the information contained in the corresponding knowledge base of the dialogue system applied to different scenarios may be different. For dialogue systems in different application fields, such as finance, medical care, education, etc., relevant field knowledge, such as professional terms, frequently asked questions and expert knowledge, can be collected and organized to build a knowledge base. Then, natural language processing technology can be used to perform pre-processing work such as cleaning, word segmentation, and annotation on the collected text information, so as to store it as different knowledge items in the knowledge base.

[0055] S103: Input the first question statement, the first knowledge item and the historical dialogue information into the generative model to obtain a first answer statement output by the generative model.

[0056] Among them, the generative model can be any model that can generate new text based on 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).

[0057] In the disclosed embodiment, since the generative model has learned rich language knowledge and generation capabilities through large-scale pre-training, it can generate a first reply sentence that matches the current dialogue scenario and user needs based on the input first question sentence, the first knowledge item and the historical dialogue information.

[0058] It should be noted that the generative model can be a deep learning model, such as BERT and GPT with Transformer structure, which can perform deep analysis on the first question sentence. Through self-attention mechanism and position encoding, it can capture the long-distance dependencies and semantic features in the first question sentence, provide rich semantic information for the subsequent reply sentence generation task, and effectively improve the quality of the output sentence.

[0059] It should be noted that in some possible implementation forms, there may be many first knowledge items, or the first knowledge items may contain too much text information. If all these first knowledge items are input into the generative model, it may cause a model burden and affect the quality and generation efficiency of the reply statement. Therefore, before inputting the first question statement, the first knowledge item and the historical dialogue information into the generative model, the first knowledge item may be processed first to improve the generation efficiency of the generative model and the quality of the output reply. For example, the contribution of each first knowledge item in the generation of the reply may be determined, and then the contribution may be input into the generative model together to instruct the model to generate a reply statement. Alternatively, the information in the first knowledge item may be deleted, and only the important information in the first knowledge item may be input into the generative model to generate the reply statement, thereby reducing the amount of data analyzed by the generative model.

[0060] S104: Evaluate the first answer 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 response, 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 meets domain specifications.

[0062] In the embodiments of the present disclosure, the first reply statement can be evaluated in a variety of 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 be calculated, and then the evaluation result can be determined by the difference between the two similarities, etc., which is not limited in the present disclosure.

[0063] Optionally, 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 may be determined first, and then the first answer statement is determined to have passed the evaluation if the difference between the first similarity and the second similarity is less than a distance threshold.

[0064] The distance threshold may be set according to the evaluation accuracy requirements in actual applications. 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., and the present disclosure does not limit this. The calculation method of the second similarity is the same as the calculation method of the first similarity.

[0066] In the disclosed embodiment, 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, so 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 answer knowledge content in the current field and is relatively reliable, and it can be determined that the first reply statement passes the evaluation. Thus, by calculating the difference between the similarities and evaluating the reply statement, the accuracy and reliability of the generated reply statement are ensured, and the quality of the intelligent dialogue is further improved.

[0067] S105: When the first reply sentence passes the evaluation, the first reply sentence is output.

[0068] In the disclosed embodiment, 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 meets the user's intention, but also meets the professional knowledge in the current field. Therefore, the accuracy of the first reply statement is relatively high, and its output can be sent to the user in the dialogue system interface to answer the first question statement.

[0069] It should be noted that if the first reply statement fails to pass the evaluation, it can be explained that the current first reply statement is not consistent with the domain knowledge and is not accurate enough, and 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. The update of the reply statement can be achieved by inputting the problems found in the evaluation process or the second knowledge items into the generative model to obtain the new reply statement output by the model.

[0070] In this embodiment, the current first question statement and its associated historical dialogue information are first obtained. Then, the first knowledge item associated with the first question statement and the second knowledge item whose relationship with the first knowledge item is a response relationship are obtained from the knowledge base. The first question statement, the first knowledge item and the historical dialogue information are input into the generative model to obtain the first reply statement output by the generative model. Afterwards, the first reply statement is evaluated based on the first question statement, the first knowledge item and the second knowledge item, and the first reply statement is output when the first reply statement passes the evaluation. Thus, by combining the domain expertise related to the user's question statement and the historical dialogue information, the reply statement is automatically generated, the integration of the dialogue reply and the domain knowledge is realized, the quality of the reply statement is improved, and the coherence and consistency of the dialogue are guaranteed. In addition, by evaluating the generated reply statement, the accuracy of the reply is improved, the grammatical errors and illogical logic in the reply statement are effectively reduced, and the user experience is optimized.

[0071] Figure 2 It is a flowchart of a conversation generation method proposed in another embodiment of the present disclosure.

[0072] like Figure 2 As shown, the dialogue generation method includes:

[0073] S201: Obtain the current first question statement and historical dialogue information associated with the first question statement.

[0074] The description of S201 can be specifically referred to the above embodiment, which will not be repeated here.

[0075] S202: 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.

[0076] In the disclosed embodiment, embedding technology in deep learning (such as neural network-based word embedding technology Word2Vec, BERT, etc.) can be used to encode the first question statement and each knowledge item respectively to obtain a first vector corresponding to the first question statement and a second vector corresponding to each knowledge item.

[0077] In the embodiments of the present disclosure, the first similarity between the first vector and each second vector may be calculated in any manner. For example, the cosine similarity between the first vector and the second vector may be calculated; or the Euclidean distance between the first vector and the second vector may be calculated, where the smaller the distance, the greater the similarity; or other feasible similarity calculation methods may be used, and the present disclosure does not limit this.

[0078] S203: Determine the knowledge item corresponding to the first similarity greater than the similarity threshold as the first knowledge item.

[0079] The similarity threshold may be customized based on actual application needs and experience, and the present disclosure does not limit this value.

[0080] In the disclosed embodiment, after determining the first similarity between the first vector and each second vector, each first similarity can be compared with a similarity threshold. When the first similarity is greater than the similarity threshold, the knowledge item corresponding to the first similarity can be determined to have a strong correlation with the first question statement. The knowledge item can then be determined as the first knowledge item for generating a reply statement.

[0081] It should be noted that, since there may be multiple knowledge items whose corresponding first similarities are all greater than the similarity threshold, there may also be multiple first knowledge items.

[0082] S204: Determine, based on the third vector corresponding to the first knowledge item, a second knowledge item having a response relationship with the first knowledge item.

[0083] 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 building a knowledge base, knowledge graph embedding technology (such as Translating Embeddings for Modeling Multi-relationalData (TransE), Relational Rotation in ComplexSpace (RotatE), etc.) can be used to map the entities in each knowledge item and the relationships between knowledge items into a low-dimensional vector space to form a knowledge graph, which is convenient for subsequent calculations and reasoning.

[0085] In the disclosed embodiment, since the relationship between two knowledge items in the knowledge base can be not only an answer relationship but also other relationships, after determining the first knowledge item associated with the first question statement, it is possible to first determine another knowledge item connected to the third vector corresponding to each first knowledge item based on the knowledge graph in the knowledge base, and then screen the relationship represented by the third vector, and determine the knowledge item connected by the third vector represented as an answer relationship as the second knowledge item.

[0086] In the disclosed embodiment, the first knowledge item associated with the question statement input by the user is determined by calculating the vector similarity between the user input statement and the knowledge items in the knowledge base, and the second knowledge item whose relationship with the first knowledge item is a response relationship is obtained based on the relationship represented by the vectors between the knowledge items in the knowledge base. This can improve the rationality and reliability of the domain knowledge used to generate the reply statement, and provide a data basis for improving the ability of the dialogue system to handle complex problems.

[0087] S205: When there are multiple first knowledge items, determine the first contribution of each first knowledge item according to the similarity corresponding to each first knowledge item.

[0088] In the disclosed embodiment, when there are multiple first knowledge items, all the first knowledge items are directly input into the generative model for generating a reply statement. There is no primary-secondary relationship between the multiple first knowledge items. The generative model needs to parse each first knowledge item to the same degree, which may cause a waste of computing resources and affect the quality of the generated statement. Therefore, the similarity between each first knowledge item and the first question statement can be determined as the first contribution of the first knowledge item. The higher the similarity, the more the first knowledge item conforms to the user's intention, and the more important the first knowledge item is for generating a reply statement, that is, the higher the first contribution.

[0089] S206: Generate first prompt information based on the first question statement, historical dialogue information, multiple first knowledge items, and the first contribution of each first knowledge item.

[0090] Among them, the first prompt information is used to instruct the generative model to generate a reply sentence based on the contribution of each knowledge item and other content.

[0091] In the disclosed embodiment, a template for generating the first prompt information can be pre-set in the dialogue system. Then, after obtaining the first question statement, historical dialogue information, multiple first knowledge items and the first contribution of each first knowledge item, the first question statement, historical dialogue information, multiple first knowledge items and the first contribution of each first knowledge item are respectively filled into the template to obtain the first prompt information.

[0092] S207: Input the first prompt information into the generative model to obtain a first reply sentence output by the generative model.

[0093] In the disclosed embodiment, after generating prompt information for each piece of information used to generate a reply statement, it is input into the generative model to instruct the model to generate a reply statement. The generative model can identify the angle that needs to be emphasized more when generating a reply statement, and perform focused analysis on the knowledge item, which can improve the utilization rate of computing resources, improve the generative model's ability to understand input information and processing efficiency, reduce misunderstandings, and ensure the reliability of the output reply statement.

[0094] In the disclosed embodiment, when there are multiple first knowledge items, the contribution of each first knowledge item to the generation of the reply statement is first determined. Then, the first question statement, historical dialogue information, multiple first knowledge items, and the contribution of each first knowledge item are integrated to generate the first prompt information. The first prompt information is then input into the generative model to obtain the first reply statement output by the generative model. Thus, the effective integration of user input and domain knowledge is achieved, which not only enhances the amount of information in the model input data, but also enables the model to more accurately understand the user's intentions, thereby improving the accuracy and reliability of the generated reply statements.

[0095] S208: Evaluate the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item.

[0096] S209: When the first reply sentence passes the evaluation, the first reply sentence is output.

[0097] The description of S208 and S209 can be specifically referred to the above embodiment, which will not be repeated 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 used to generate the reply statement, and provide a data basis for improving the ability of the dialogue system to handle complex problems. When there are multiple first knowledge items, the contribution of each first knowledge item to the generation of the reply statement is first determined. Then, the first question statement, historical dialogue information, multiple first knowledge items and the contribution of each first knowledge item are fused to generate the first prompt information. The first prompt information is then input into the generative model to obtain the first reply statement output by the generative model. Thus, the effective fusion of user input and domain knowledge is achieved, which not only enhances the amount of information in the model input data, but also enables the model to understand the user's intention more accurately, and improves the accuracy and reliability of the generated reply statement.

[0099] Figure 3It is a flowchart of a conversation generation method proposed in another embodiment of the present disclosure.

[0100] like Figure 3 As shown, the dialogue generation method includes:

[0101] S301: Obtain the current first question statement and historical dialogue information associated with the first question statement.

[0102] S302: 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.

[0103] S303: Determine the knowledge item corresponding to the first similarity greater than the similarity threshold as the first knowledge item.

[0104] S304: Determine, based on the third vector corresponding to the first knowledge item, a second knowledge item having a response relationship with the first knowledge item.

[0105] The description of S301 to S304 can be specifically referred to the above embodiment, which will not be repeated here.

[0106] S305: When the first knowledge item is an item of a preset type, determine a second contribution of each knowledge segment in the first knowledge item to a second vector corresponding to the first knowledge item.

[0107] The preset type entry refers to a knowledge entry that contains a large amount of information and is relatively complex, such as an article or content containing multiple paragraphs. Each paragraph or sentence in the preset type entry can be used as a knowledge fragment in the knowledge entry.

[0108] In the disclosed embodiment, after obtaining the first knowledge item, it is possible to judge whether each first knowledge item is a preset type item. In the case where any first knowledge item is a preset type item, due to the large amount of information in the first knowledge item, there may be redundant information or noise information, which will affect the quality of the generated reply statement. Therefore, through the attention mechanism and other technologies, the second contribution of each knowledge fragment in the first knowledge item to the second vector corresponding to the first knowledge item is determined to screen the content in the first knowledge item that plays a key role in generating the reply statement.

[0109] S306: Determine a target knowledge segment from the first knowledge item according to the second contribution degree.

[0110] The target knowledge fragment refers to the content in the first knowledge item that plays a key role in generating the reply sentence.

[0111] In the embodiment of the present disclosure, a contribution threshold can be pre-set in the dialogue system according to actual application needs, and then after determining the second contribution corresponding to each knowledge fragment in the first knowledge item, the second contribution is compared with the contribution threshold, and the knowledge fragment corresponding to the second contribution greater than the contribution threshold is determined as the target knowledge fragment in the first knowledge item. Alternatively, the knowledge fragment corresponding to the maximum value of all second contributions can be determined as the target fragment in the first knowledge item, etc., and the present disclosure does not limit this.

[0112] S307: Generate second prompt information based on the first question statement, historical dialogue information, and target knowledge fragment.

[0113] Among them, the second prompt information is used to instruct the generative model to generate a reply sentence based on the target knowledge fragment and other content.

[0114] In the disclosed embodiment, a template for generating the second prompt information can be pre-set in the dialogue system. Then, after obtaining the first question statement, historical dialogue information, and target knowledge fragment, the first question statement, historical dialogue information, and target knowledge fragment are respectively filled into the template to obtain the second prompt information.

[0115] S308: Input the second prompt information into the generative model to obtain a first reply sentence output by the generative model.

[0116] In the disclosed embodiment, by obtaining knowledge fragments with higher contribution from the knowledge items associated with the user input sentences and inputting them into the generative model to obtain reply sentences, the fragments used to generate reply sentences in each knowledge item associated with the user input sentences can be dynamically adjusted, thereby reducing the resources consumed in the calculation of the generative model, improving the generation efficiency of the reply sentences, and further improving the quality of the reply sentences.

[0117] S309: Evaluate the first answer statement based on the first question statement, the first knowledge item and the second knowledge item.

[0118] S310: When the first reply sentence passes the evaluation, output the first reply sentence.

[0119] The description of S309 and S310 can be specifically referred to the above embodiment, which will not be repeated here.

[0120] Figure 4 It is a flowchart of a conversation generation method proposed in another embodiment of the present disclosure.

[0121] like Figure 4 As shown, the dialogue generation method includes:

[0122] S401: Obtain the current first question statement and historical dialogue information associated with the first question statement.

[0123] S402: Acquire from the 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 a response relationship.

[0124] S403: Input the first question statement, the first knowledge item and the historical dialogue information into the generative model to obtain a first answer statement output by the generative model.

[0125] The description of S401 to S403 above can be specifically referred to the above embodiment, which will not be repeated here.

[0126] S404: Generate third prompt information based on the first knowledge item, the first question statement, the second knowledge item and the first answer 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 disclosed embodiment, a template for generating the third prompt information can be pre-set in the dialogue system, and then after obtaining the first knowledge item, the first question statement, the second knowledge item and the first reply statement, the first knowledge item, the first question statement, the second knowledge item and the first reply statement are respectively filled into the template to obtain the third prompt information.

[0129] It should be noted that, considering that different generative models have different text generation capabilities, the reply statements they output may contain diverse data content. Therefore, only using the second knowledge item that is in a response relationship with the first knowledge item to evaluate the first reply statement may not accurately verify the accuracy of all the content in the first reply statement. Therefore, in the present disclosure, other knowledge items can also be obtained in the knowledge base to enrich the third prompt information for the evaluation of the first reply statement.

[0130] Optionally, a third knowledge item associated with the first reply statement may be first obtained from the knowledge base.

[0131] In the embodiment of the present disclosure, the semantic similarity between the first reply 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 can be determined as the third knowledge item associated with the first reply statement. Alternatively, the third knowledge item associated with the first reply statement can be obtained from the knowledge base in other ways, such as calculating the distance between the word vectors in the first reply statement and each knowledge item, etc., which is not limited in the present disclosure.

[0132] Then, the third knowledge item may be fused with the second knowledge item to obtain a fused knowledge item and a weight of the fused knowledge item.

[0133] The fusion method may be to deduplicate and merge the third knowledge item with the second knowledge item.

[0134] The weights of the fused knowledge items are used to indicate the emphasis that the evaluation model places on different knowledge items when evaluating the response statements.

[0135] It should be noted that there may be one or more third knowledge items, and there may be one or more second knowledge items, and there may be a situation where the second knowledge item is the same as the third knowledge item. Therefore, after deduplication and merging of each third knowledge item with the second knowledge item in turn, the merged knowledge item may be one or more, and may be the same as the second knowledge item or the third knowledge item.

[0136] In the embodiment of the present disclosure, after removing the duplicate content in the third knowledge item and the second knowledge item, and merging the third knowledge item with all the content in the second knowledge item to obtain a fused knowledge item, the fused knowledge item can be determined in a variety of ways. For example, the weight can be determined by calculating the similarity between the fused knowledge item and the first reply statement, the higher the similarity, the higher the weight; or the weight can be determined based on the number of times the fused knowledge item appears in the second knowledge item and the third knowledge item, etc.

[0137] Afterwards, the third prompt information may be 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.

[0138] In the disclosed embodiment, the third knowledge item associated with the first reply statement in the knowledge base is fused with the second knowledge item to obtain the fused knowledge item and its corresponding weight, and then the fused knowledge item and its corresponding weight are used together with the first knowledge item, 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, thereby improving the reliability and accuracy of the reply statement evaluation result.

[0139] Optionally, when determining the weight of the fused knowledge item, the 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 may be determined first.

[0140] In the embodiment of the present disclosure, the semantic similarity between the fused knowledge item and the first reply statement can be calculated to obtain the third similarity. Alternatively, the distance between the vector of the fused knowledge item and the vector of the first reply statement can be calculated, and the smaller the distance, the higher the similarity, to obtain the third similarity. Alternatively, other methods for calculating the similarity between texts can be used, and the present disclosure does not limit this.

[0141] It is understandable that in some possible embodiments, there is a situation where the second knowledge item is the same as the third knowledge item, or the third knowledge item contains the second knowledge item, etc. In this case, the fused knowledge item may be the second knowledge item or the third knowledge item, or the fused knowledge item may have appeared in both the second knowledge item and the third knowledge item. Therefore, the number of occurrences of the fused knowledge item can be obtained by the number of knowledge items in the second knowledge item and the third knowledge item that are the same as the fused knowledge item.

[0142] It should be noted that when the fused knowledge item appears in both the second knowledge item and the third knowledge item, the number of occurrences is recorded as 2. This indicates that the fused knowledge item is not only in a response relationship with the first knowledge item, 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 item may be determined according to the third similarity and / or the number of occurrences.

[0144] In the disclosed embodiment, the weight can be determined only based on the third similarity. The higher the third similarity, the more the corresponding fused knowledge item conforms to the domain knowledge specification corresponding to the reply statement, and the higher the weight of the fused knowledge item. The weight can also be determined only based on the number of occurrences. The higher the number of occurrences, the stronger the correlation between the corresponding fused knowledge item and the reply statement, the better the evaluation effect of the reply statement, and the higher the weight of the fused knowledge item. Alternatively, the weight of the fused knowledge item can be determined by combining the third similarity and the number of occurrences.

[0145] In the disclosed embodiment, the corresponding weights are determined by calculating the similarities and occurrence counts of the fused knowledge items, thereby improving the reliability of the weights of the fused knowledge items and further improving the accuracy and reliability of the evaluation results based on the weights.

[0146] S405: Input the third prompt information into the evaluation model to obtain the evaluation result output by the evaluation model.

[0147] The evaluation model may be any existing model for verifying text accuracy and standardization. The evaluation results generated by the evaluation model may include the error type (such as semantic incoherence, inconsistency with domain knowledge, etc.), error location, etc. in the first reply sentence, which is not limited in the present disclosure.

[0148] It should be noted that, when the evaluation result corresponding to the first reply statement is failed, 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, if 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 a second reply statement output by the generative model. Then, based on the second reply statement, the evaluation operation is returned to be performed until a reply statement that passes the evaluation is obtained and output.

[0150] In the disclosed embodiment, the evaluation result corresponding to the first reply statement that failed the evaluation can be input into the generative model to instruct the generative model to re-output the first reply statement generated previously according to the deficiencies contained in the evaluation result, and obtain an updated second reply statement. The second reply statement is then evaluated again, and 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 passes the evaluation. Therefore, by using the evaluation result of the reply statement that failed the evaluation to instruct the generative model to output the reply statement of the next year, the reliability of the reply statement can be further improved, the quality of the conversation can be improved, and the coherence of the conversation can be ensured.

[0151] S406: When the first reply sentence passes the evaluation, output the first reply sentence.

[0152] The description of S406 can be specifically referred to the above embodiment, which will not be repeated here.

[0153] In this embodiment, by utilizing the first knowledge item, the first question statement, the second knowledge item and the first reply statement to generate a third prompt message, and then instructing the evaluation model to output the evaluation result of the first reply statement, automatic evaluation and verification of the reply statement can be achieved, thereby improving the evaluation efficiency of the reply statement and the reliability of the evaluation results, thereby improving the quality of the conversation.

[0154] Figure 5 It is a flowchart of a conversation generation method proposed in another embodiment of the present disclosure.

[0155] like Figure 5 As shown, the dialogue generation method includes:

[0156] S501: Obtain the current first question statement and historical dialogue information associated with the first question statement.

[0157] S502: Acquire from the 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 a response relationship.

[0158] S503: Input the first question statement, the first knowledge item and the historical dialogue information into the generative model to obtain a first answer statement output by the generative model.

[0159] S504: Evaluate the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item.

[0160] S505: When the first reply sentence passes the evaluation, output the first reply sentence.

[0161] The description of S501 to S505 can be specifically referred to the above embodiment, which will not be repeated here.

[0162] S506: When a second question statement is received in response to the first reply statement, a third reply statement corresponding to the second question statement is generated and output.

[0163] In the disclosed embodiment, after the dialogue system outputs the first reply statement to the user, the user may have questions about the first reply statement, and may enter a new second question statement in the dialogue interface. Therefore, the dialogue system can receive the second question statement for the first reply statement, and then, according to the method described in the above embodiment, obtain the third reply statement output by the generative model and passed the evaluation, and output it to the current dialogue interface.

[0164] S507: When the third question statement for the third reply statement is not received, a target reply statement corresponding to the first question statement is generated based on the first reply statement and the third reply statement.

[0165] In the disclosed embodiment, when the third reply statement is output to the dialogue interface and no third question statement is received for the third reply statement, it can be determined that the first reply statement and the third reply 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 reply statement and the third reply statement can be determined together as the target reply statements corresponding to the first question statement.

[0166] S508: Storing the first question statement and the target answer 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 an embodiment of the present disclosure, the first question sentence and its corresponding target answer sentence 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 can be updated and trained using the data in the preset database.

[0169] In this embodiment, when a second question statement is received for a first reply statement, 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, a target reply statement corresponding to the first question statement is generated based on the first reply statement and the third reply statement. The first question statement and the target reply statement are stored in a preset database. Thus, the generated reply statement is iteratively optimized by combining user feedback, and the parameters and strategies of the training generative model are adjusted based on the question statement and its final optimized reply content, so that the dialogue system can continuously adapt to new dialogue scenarios and user needs, thereby improving the overall performance of the dialogue system.

[0170] Figure 6 It is a structural diagram of a dialogue generation device proposed in an embodiment of the present disclosure.

[0171] like Figure 6 As shown, the dialogue generating device 600 includes:

[0172] A first acquisition module 601 is used to acquire the current first question statement and historical dialogue information associated with the first question statement;

[0173] A second acquisition module 602 is used to acquire, from the 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 a response relationship;

[0174] A generation module 603 is used to input the first question statement, the first knowledge item and the historical dialogue information into the generative model to obtain a first answer statement output by the generative model;

[0175] An evaluation module 604, configured to evaluate the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item;

[0176] The output module 605 is used to output the first reply statement if the first reply statement passes the evaluation.

[0177] Optionally, the second acquisition module 602 may be specifically configured to:

[0178] 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;

[0179] Determine the knowledge item corresponding to the first similarity greater than the similarity threshold as the first knowledge item;

[0180] 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.

[0181] Optionally, the generating module 603 may be specifically used for:

[0182] 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;

[0183] Generate first prompt information based on the first question statement, the historical dialogue information, the plurality of first knowledge items, and the first contribution of each first knowledge item;

[0184] The first prompt information is input into the generative model to obtain a first reply sentence output by the generative model.

[0185] Optionally, the generating module 603 may be specifically used for:

[0186] In the case where the first knowledge item is an item of a preset type, determining a second contribution of each knowledge segment in the first knowledge item to a second vector corresponding to the first knowledge item;

[0187] According to the second contribution, a target knowledge segment is determined from the first knowledge item;

[0188] Generate second prompt information based on the first question statement, historical dialogue information, and target knowledge fragment;

[0189] The second prompt information is input into the generative model to obtain a first reply sentence output by the generative model.

[0190] Optionally, the evaluation module 604 may be specifically configured to:

[0191] 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;

[0192] In a case where the difference between the first similarity and the second similarity is smaller than the distance threshold, it is determined that the first reply sentence passes the evaluation.

[0193] Optionally, the evaluation module 604 may be specifically configured to:

[0194] Generate third prompt information based on the first knowledge item, the first question statement, the second knowledge item and the first answer statement;

[0195] The third prompt information is input into the evaluation model to obtain the evaluation result output by the evaluation model.

[0196] Optionally, the evaluation module 604 may be specifically configured to:

[0197] Acquire a third knowledge item associated with the first reply statement from the knowledge base;

[0198] Fusing the third knowledge item with the second knowledge item to obtain a fused knowledge item and a weight of the fused knowledge item;

[0199] 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.

[0200] Optionally, the evaluation module 604 may be specifically configured to:

[0201] Determine the third similarity between the fused knowledge item and the first answer sentence, and the number of occurrences of the fused knowledge item in the second knowledge item and the third knowledge item;

[0202] The weight of the fused knowledge item is determined according to the third similarity and / or the number of occurrences.

[0203] Optionally, the evaluation module 604 may also be used to:

[0204] In the case where the first reply sentence fails the evaluation, the evaluation result corresponding to the first reply sentence is input into the generative model to obtain a second reply sentence output by the generative model;

[0205] Based on the second reply statement, return to perform the evaluation operation until a reply statement that passes the evaluation is obtained and output.

[0206] Optionally, the output module 605 may also be used to:

[0207] Upon receiving a second question statement in response to the first answer statement, generating and outputting a third answer statement corresponding to the second question statement;

[0208] In the case where the third question statement for the third answer statement is not received, generating a target answer statement corresponding to the first question statement based on the first answer statement and the third answer statement;

[0209] 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.

[0210] It should be noted that the above explanation of the dialogue generation method is also applicable to the dialogue generation device of this embodiment and will not be repeated here.

[0211] In this embodiment, by combining domain expertise related to the user's question statement and historical conversation information, the reply statement is automatically generated, which realizes the integration of dialogue reply and domain knowledge, improves the quality of reply statements, and ensures the coherence and consistency of the dialogue. In addition, by evaluating the generated reply statements, the accuracy of the reply is improved, the grammatical errors and illogical logic in the reply statements are effectively reduced, and the user experience is optimized.

[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 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0214] like Figure 7 As 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 number 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 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 through a computer network such as the Internet and / or various telecommunication networks.

[0216] The computing unit 701 may be a variety of general and / or special 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, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as the dialogue generation method. For example, in some embodiments, the dialogue generation method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on 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 may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the dialogue generation method in any other appropriate manner (e.g., by means of firmware).

[0217] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being 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 can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit 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 method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0219] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0220] 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 pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types 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 (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations 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 (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.

[0222] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding 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 cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "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 the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0224] In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In the description of the present disclosure, the words "if" and "if" used can be interpreted as "at the time of" or "when" or "in response to determination" or "under the circumstances of".

[0225] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in 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, evaluating the first answer statement; 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 to 4, wherein: The step of evaluating the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item 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 smaller than a distance threshold, it is determined that the first reply statement passes the evaluation.

6. The method according to any one of claims 1 to 4, wherein: The step of evaluating the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item 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.

7. The method of claim 6, 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.

8. The method of claim 7, 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.

9. 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.

10. 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.

11. A dialogue generating 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, configured to evaluate the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item; An output module is used to output the first reply statement if the first reply statement passes the evaluation.

12. The device of claim 11, wherein: The second acquisition module is specifically used for: 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.

13. The device of claim 12, wherein: The generation module is specifically used for: 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.

14. The device of claim 12, wherein: The generation module is specifically used for: 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.

15. The device according to any one of claims 11 to 14, wherein: The evaluation module is specifically used for: 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 smaller than a distance threshold, it is determined that the first reply statement passes the evaluation.

16. The device according to any one of claims 11 to 14, wherein: The evaluation module is specifically used for: 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.

17. The device of claim 16, wherein: The evaluation module is specifically used for: 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.

18. The device of claim 17, wherein: The evaluation module is specifically used for: 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.

19. The device according to any one of claims 11 to 14, wherein: The evaluation module is also used to: 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.

20. The device according to any one of claims 11 to 14, wherein: The output module is further used for: 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.

21. 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 10.

22. 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 10.

23. 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 10.

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

  • Target answer acquisition method and device, electronic equipment and storage medium

    CN115238031A

  • Knowledge question-answering method and device, equipment and storage medium

    CN116737908A

  • Question answering method and device based on artificial intelligence, electronic equipment and storage medium

    CN117725188A