Dialogue generation method, device, electronic device, and storage media

The dialogue generation method enhances response quality and consistency by integrating domain knowledge and context through a generative model with evaluation, addressing the limitations of current systems in understanding user needs and maintaining coherent dialogue.

JP2025094263AActive Publication Date: 2025-06-24BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
JP2025054928
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-09-10
Filing Date
2025-03-28
Publication Date
2025-06-24
Estimated Expiration
2045-03-28

AI Technical Summary

Technical Problem

Current dialogue generation systems struggle with low performance in complex and rapidly changing language environments, failing to adequately understand user needs and maintain consistent, high-quality responses.

Method used

A dialogue generation method that integrates domain knowledge and context information by using a generative model to generate responses, followed by evaluation to ensure accuracy and coherence, including modules for knowledge acquisition, generation, evaluation, and output.

Benefits of technology

Improves the quality and consistency of dialogue responses by integrating domain expertise and evaluating generated text, reducing grammatical errors and logical inconsistencies, thereby enhancing user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2025094263000001_ABST
    Figure 2025094263000001_ABST
Patent Text Reader

Abstract

To provide a dialogue generation method that improves quality of generation of an answer sentence in combination with field knowledge and context information, improves dialogue quality, and optimize user experience, a device, an electronic device, and storage media.SOLUTION: A method includes: a step 101 of obtaining a current first question sentence and historical dialogue information associated with the first question sentence; a step 102 of obtaining, from a knowledge base, a first knowledge item associated with the first question sentence and a second knowledge item whose relation with the first knowledge item is a response relation; a step 103 of inputting the first question sentence, the first knowledge item, and the historical dialogue information into a generative model to obtain a first answer sentence output by the generative model; a step 104 of evaluating the first answer sentence based on the first question sentence, the first knowledge item, and the second knowledge item; and a step 105 of outputting the first answer sentence if the first answer sentence passes evaluation.SELECTED DRAWING: Figure 1
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of artificial intelligence 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 technology, dialogue systems have been widely applied in many fields such as intelligent customer service, smart home, and online education. When facing a complex and rapidly changing language environment and knowledge needs, the performance of current dialogue generation solutions is not high. Therefore, how to improve the depth of understanding of user needs by the dialogue system and improve the quality of the response text and the consistency of the context has become the key to the development of the dialogue system.

Summary of the Invention

Problems to be Solved by the Invention

[0003] The present disclosure aims to at least to some extent solve one of the technical problems in the related art. Therefore, the object of the present disclosure is to propose a dialogue generation method, apparatus, electronic device, and storage medium that improve the quality of response text generation in combination with domain knowledge and context information, improve the dialogue quality, and optimize the user experience.

Means for Solving the Problems

[0004] According to a first aspect of the present disclosure, obtaining a current first question text and historical dialogue information associated with the first question text; obtaining, from a knowledge base, a first knowledge item associated with the first question text and a second knowledge item whose relationship with the first knowledge item is a response relationship; Inputting the first question sentence, the first knowledge item, and the history dialogue information into a generative model, and obtaining a first answer sentence output by the generative model; Evaluating the first answer sentence based on the first question sentence, the first knowledge item, and the second knowledge item; When the first answer sentence passes the evaluation, outputting the first answer sentence. A dialogue generation method is provided.

[0005] According to a second aspect of the present disclosure, A first acquisition module configured to acquire the current first question sentence and the history dialogue information associated with the first question sentence; A second acquisition module configured to acquire, from a knowledge base, a first knowledge item associated with the first question sentence and a second knowledge item whose relationship with the first knowledge item is a response relationship; A generation module configured to input the first question sentence, the first knowledge item, and the history dialogue information into a generative model and obtain a first answer sentence output by the generative model; An evaluation module configured to evaluate the first answer sentence based on the first question sentence, the first knowledge item, and the second knowledge item; An output module configured to output the first answer sentence when the first answer sentence passes the evaluation. A dialogue generation device is provided.

[0006] According to a third aspect of the present disclosure, At least one processor; A memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor can execute the dialogue generation method described in the first aspect. An electronic device is provided.

[0007] According to a fourth aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, the computer instructions causing a computer to execute the dialogue generation method described in the first aspect.

[0008] According to a fifth aspect of the present disclosure, there is provided a computer program including computer instructions, which, when executed by a processor, implement the steps of the dialogue generation method described in the first aspect.

Advantages of the Invention

[0009] The dialogue generation method, apparatus, electronic device, and storage medium provided by the present disclosure have the following beneficial effects. By automatically generating a response text in combination with the field expertise related to the user's question text and the historical dialogue information, the integration of the dialogue response and the field knowledge is realized, the quality of the response text is improved, and the consistency and coherence of the dialogue are ensured. Furthermore, by evaluating the generated response text, the accuracy of the answer is improved, the grammatical errors and logical inconsistencies in the response text are effectively reduced, and the user experience is optimized.

[0010] 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 intended to limit the scope of the present disclosure. Other features of the present disclosure will be easily understood from the following description.

Brief Description of the Drawings

[0011] The above and / or additional aspects and advantages of the present disclosure will become apparent and be easily understood from the following description of the embodiments with reference to the drawings. The drawings are used to better understand the technical solution and do not limit the present disclosure.

[0012]

Figure 1

Figure 2

Figure 3

Figure 4

Figure 5

Figure 6

Figure 7

Embodiments for Carrying Out the Invention

[0013] Hereinafter, exemplary embodiments of the present disclosure will be described with reference to the drawings. For ease of understanding, various details of the embodiments of the present disclosure are included, and they should be regarded as merely illustrative. Therefore, those skilled 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. Also, for clarity and conciseness, descriptions of well-known functions and configurations are omitted in the following description.

[0014] Embodiments of the present disclosure relate to technical fields of artificial intelligence such as natural language processing, large models, and deep learning.

[0015] Artificial Intelligence, abbreviated as AI in English, is a new technical science that researches and develops theories, methods, technologies, and application systems for simulating and expanding human intelligence.

[0016] Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence, and studies various theories and methods that enable effective communication between humans and computers using natural language. Natural language processing is a discipline that analyzes, understands, and processes natural language using computer technology with language as the object, that is, using the computer as a powerful tool for language research, conducting quantitative research on language information with the support of the computer, and providing language descriptions that can be jointly used between humans and computers.

[0017] A large model (also known as a foundation model) refers to a machine learning model with a large number of parameters and a complex structure, capable of processing a large amount of data and completing various complex tasks such as natural language processing, computer vision, and speech recognition. Among them, a large language model is a natural language processing model with large-scale parameters and computing power, and by training with a large amount of data and parameters, it can generate text similar to humans and answer questions in natural language.

[0018] Deep learning is a process of learning the inherent rules and expression levels of sample data, and the information obtained in these learning processes is very useful for the interpretation of data such as text, images, and voices. The ultimate goal of deep learning is to enable machines to have the same analysis and learning capabilities as humans and be able to recognize data such as text, images, and voices.

[0019] In the technical solution of the present disclosure, the processing of collecting, storing, using, processing, transmitting, providing, and disclosing the personal information of such users complies with relevant laws and regulations and does not violate public order and good customs.

[0020] Hereinafter, a dialogue generation method, apparatus, electronic device, and storage medium according to an embodiment of the present disclosure will be described with reference to the drawings.

[0021] Note that the execution entity of the dialogue generation method according to this embodiment is a dialogue generation device, which can be realized by software and / or hardware and can be configured in an electronic device. The electronic device can include, but is not limited to, a terminal, a server side, etc. In the embodiments of the present disclosure, the case where the dialogue generation device is configured in a dialogue system will be described as an example.

[0022] FIG. 1 is a schematic flowchart of a dialogue generation method proposed according to an embodiment of the present disclosure. As shown in FIG. 1, the dialogue generation method includes the following steps S101 to S105.

[0023] In S101, obtain the current first question sentence and the historical dialogue information associated with the first question sentence. The first question sentence may be a question sentence received by the dialogue interface through which the dialogue system interacts with any user.

[0024] In the embodiments of the present disclosure, in order to ensure the consistency of the dialogue, the context understanding module in the dialogue generation system can further maintain the dialogue history record by storing the dialogue history information between each user and the dialogue system, which is usually realized by a structure such as a memory network or a recurrent neural network (long short-term memory network (LSTM)).

[0025] In the embodiments of the present disclosure, after the dialogue system receives the latest first question sentence input by any user, it can obtain the historical dialogue information associated with the first question sentence from the historical dialogue record of the dialogue interface where the first question sentence is located.

[0026] In S102, obtain from the knowledge base the first knowledge item associated with the first question sentence and the second knowledge item whose relationship with the first knowledge item is a response relationship.

[0027] A knowledge item refers to an individual element or unit that constitutes basic knowledge in a specific field, discipline, or topic, and may be a definition, fact, concept, theory, formula, etc. In a knowledge base, each knowledge item can be stored in the form of a knowledge graph, and there may be relationships such as response relationships, causal relationships, and temporal relationships between different knowledge items.

[0028] In addition, the response relationship refers to a logical correspondence such as "question - answer" or "request - response" between two knowledge items. In a 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.

[0029] In the embodiments of the present disclosure, the similarity between the first question text and each knowledge item in the knowledge base is calculated respectively, and one or more knowledge items with high similarity are determined as the first knowledge items associated with the first question text. Alternatively, the first knowledge item associated with the first question text may be obtained from the knowledge base by other methods such as the distance between word vectors in the question text and the knowledge item, but this is not limited in the present disclosure.

[0030] In the embodiments of the present disclosure, after receiving the first question text currently input by the user, the dialogue system can search for at least one first knowledge item related to the first question text in the knowledge base within the system based on the first question text. Then, based on the relationships between each knowledge item in the knowledge base, the second knowledge items that have a response relationship with each first knowledge item in the knowledge base can be obtained.

[0031] In the present disclosure, the dialogue systems applied to different scenarios may have different information included in their corresponding knowledge bases. For dialogue systems in different application fields such as finance, medical care, and education, relevant field knowledge, such as technical terms, frequently seen question-and-answer pairs, and expert knowledge, etc., can be collected and organized to construct a knowledge base. Then, using natural language processing technology, preprocessing operations such as cleaning, word segmentation, and annotation can be performed on the collected text information and saved in the knowledge base as different knowledge items.

[0032] In S103, input the first question sentence, the first knowledge item, and the historical dialogue information into the generative model, and obtain the first answer sentence output by the generative model.

[0033] The generative model may be any model that can generate new text based on the input text. For example, it may be a pre-trained language model (such as BERT, Bidirectional Encoder Representations from Transformers) based on a multi-layer Transformer encoder or a generative pre-trained model such as GPT (Generative Pre-Trained).

[0034] In the embodiments of the present disclosure, since the generative model has learned rich language knowledge and generative ability through large-scale pre-training, based on the input first question sentence, the first knowledge item, and the historical dialogue information, it can generate a first answer sentence that matches the current dialogue scenario and the user's needs.

[0035] Note that the generative model may be a deep learning model such as BERT or GPT with a Transformer structure. In this case, the first question sentence can be deeply analyzed, and the long-distance dependence relationship and semantic features in the first question sentence can be captured by means of a self-attention mechanism and positional encoding, etc., providing rich semantic information for the subsequent answer sentence generation task and effectively improving the quality of the output sentence.

[0036] Note that in some possible embodiments, there may be a large number of first knowledge items, or the text information included in the first knowledge items may be too much. If all of these first knowledge items are input into the generative model, it may impose a burden on the model and may affect the quality of the answer sentence and the generation efficiency. Therefore, before inputting the first question sentence, the first knowledge items, and the historical dialogue information into the generative model, by first processing the first knowledge items, the generation efficiency of the generative model and the quality of the output answer can be improved. For example, during the generation of the answer, the contribution degree of each first knowledge item can be determined, and then the contribution degrees can be input into the generative model together and the model can be instructed to generate an answer sentence. Or, by deleting the information in the first knowledge items, etc., and inputting only the important information in the first knowledge items into the generative model to generate an answer sentence, the amount of data analyzed by the generative model can also be reduced.

[0037] In S104, based on the first question sentence, the first knowledge item, and the second knowledge item, the first answer sentence is evaluated.

[0038] Note that after obtaining the first answer sentence output by the generative model, in order to improve the accuracy and depth of the dialogue answer, before sending the first answer sentence to the user, the evaluation module in the dialogue system can use the knowledge in the knowledge base to verify and evaluate the first answer sentence to ensure that the information in the first answer sentence is accurate, error-free, and conforms to the norms of the field.

[0039] In embodiments of the present disclosure, the first response sentence can be evaluated in various ways. For example, the first question sentence, the first knowledge item, the second knowledge item, and the first response sentence can be input into any existing evaluation model, and the evaluation result output by the evaluation model can be directly obtained. Or, the similarity between the first question sentence and the first knowledge item, and the similarity between the second knowledge item and the first response sentence can be calculated, and the evaluation result can be determined by the difference value between the two similarities. This is not limited in the present disclosure.

[0040] Optionally, first, the first similarity between the first question sentence and the first knowledge item, and the second similarity between the first response sentence and the second knowledge item can be determined. Then, if the difference value between the first similarity and the second similarity is less than the distance threshold, it is determined that the first response sentence passes the evaluation.

[0041] The distance threshold can be set according to the needs of evaluation accuracy in actual applications, etc. The higher the need for accuracy, the smaller the distance threshold needs to be.

[0042] Note that the first similarity can be determined by calculating the distance between the vector of the first question sentence and the vector of the second knowledge item. Or, the first similarity can be obtained by calculating the semantic similarity between the first question sentence and the second knowledge item, etc. This is not limited in the present disclosure. The calculation method of the second similarity is the same as that of the first similarity.

[0043] In an embodiment of the present disclosure, after obtaining the first similarity and the second similarity, since the first knowledge item is associated with the first question sentence, the value of the first similarity is sufficiently large. Therefore, when the difference value 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 large, that is, the first answer sentence conforms to the normal response knowledge content in the current field and is reliable, and then it can be determined that the first answer sentence passes the evaluation. In this way, by calculating the difference value between the similarities and evaluating the answer sentence, the accuracy and reliability of the generated answer sentence are ensured, and the quality of intelligent dialogue is further improved.

[0044] In S105, if the first answer sentence passes the evaluation, output the first answer sentence.

[0045] In an embodiment of the present disclosure, if the first answer sentence passes the evaluation, it is considered that the current first answer sentence output by the generative model not only conforms to the user's intention but also conforms to the expertise in the current field. Therefore, the accuracy of the first answer sentence is high, and it can be output through the dialogue system interface and sent to the user to answer the first question sentence.

[0046] Note that if the first answer sentence fails the evaluation, it can be shown that the current first answer sentence does not conform well to the field knowledge and its accuracy is not high. Therefore, it is necessary to update the answer sentence output by the generative model until the answer sentence passes the evaluation and is output to the user. Here, the update of the answer sentence can be realized by inputting the problems found during the evaluation or the second knowledge item, etc. into the generative model and obtaining the answer sentence newly output by the model.

[0047] In this embodiment, first, the current first question sentence and the historical dialogue information associated therewith are obtained. Then, from the knowledge base, a first knowledge item associated with the first question sentence and a second knowledge item whose relationship with the first knowledge item is a response relationship are obtained. Then, the first question sentence, the first knowledge item, and the historical dialogue information are input into a generative model to obtain a first answer sentence output by the generative model. Then, based on the first question sentence, the first knowledge item, and the second knowledge item, the first answer sentence is evaluated. If the first answer sentence passes the evaluation, the first answer sentence is output. Thereby, by automatically generating an answer sentence in combination with the domain expertise related to the user's question sentence and the historical dialogue information, the integration of the dialogue answer and the domain knowledge is realized, the quality of the answer sentence is improved, and the consistency and coherence of the dialogue are ensured. Furthermore, by evaluating the generated answer sentence, the accuracy of the answer is improved, the grammatical errors and logical inconsistencies in the answer sentence are effectively reduced, and the user experience is optimized.

[0048] Figure 2 is a schematic flowchart of a dialogue generation method proposed according to another embodiment of the present disclosure. As shown in Figure 2, the dialogue generation method includes the following steps S201 to S209.

[0049] In S201, the current first question sentence and the historical dialogue information associated with the first question sentence are obtained. Since the description of S201 can refer to the above embodiment, the repeated description is omitted here.

[0050] In S202, a first similarity between a first vector corresponding to the first question sentence and second vectors corresponding to each knowledge item in the knowledge base is determined.

[0051] In an embodiment of the present disclosure, embedding techniques in deep learning (for example, word embedding techniques based on neural networks such as Word2Vec and BERT) are used to code the first question sentence and each knowledge item respectively, so as to obtain a first vector corresponding to the first question sentence and a second vector corresponding to each knowledge item.

[0052] In an embodiment of the present disclosure, the first similarity between the first vector and each second vector can be calculated in any manner. For example, it may be a method of calculating the cosine similarity between the first vector and the second vector, or a method of calculating the Euclidean distance between the first vector and the second vector. The smaller the distance, the greater the similarity. Or, it may be other feasible methods for calculating similarity, etc. The present disclosure is not limited thereto.

[0053] In S203, the knowledge item corresponding to the first similarity greater than the similarity threshold is determined as the first knowledge item.

[0054] The similarity threshold can be set by itself based on factors such as actual application needs and experience, and the present disclosure does not limit this value.

[0055] In an embodiment 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 and the first question sentence have a high relevance, and the knowledge item can be determined as the first knowledge item for generating an answer sentence.

[0056] Note that since there may be multiple knowledge items whose corresponding first similarities are greater than the similarity threshold, there may also be multiple first knowledge items.

[0057] In S204, based on the third vector corresponding to the first knowledge item, a second knowledge item whose relationship with the first knowledge item is a response relationship is determined. The third vector indicates the association between the first knowledge item and other knowledge items.

[0058] Note that when constructing the knowledge base, knowledge graph embedding techniques (for example, embedding transformation for modeling multi-relational data (TransE, Translating Embeddings for Modeling Multi-relational Data), knowledge graph embedding method based on complex space (RotatE, Relational Rotation in Complex Space), etc.) are used to map the relationship between entities and knowledge items within each knowledge item to a low-dimensional vector space to form a knowledge graph, which can facilitate subsequent calculations and inferences.

[0059] In the embodiments of the present disclosure, since the relationship between two knowledge items in the knowledge base may be other relationships in addition to the response relationship, after determining the first knowledge item associated with the first question sentence, based on the knowledge graph in the knowledge base, another knowledge item connected to the third vector corresponding to each first knowledge item is determined, and then the relationship indicated by the third vector is screened, and the knowledge item connected to the third vector shown as the response relationship can be determined as the second knowledge item.

[0060] In the embodiments of the present disclosure, by calculating the vector similarity between the sentence input by the user and the knowledge items in the knowledge base, the first knowledge item associated with the question sentence input by the user is determined, and based on the relationship indicated by the vectors between each knowledge item in the knowledge base, by obtaining the second knowledge item whose relationship with the first knowledge item is a response relationship, the rationality and reliability of the domain knowledge for generating the answer sentence can be improved, and a data basis for improving the ability of the dialogue system to process complex questions can be provided.

[0061] In S205, when there are multiple first knowledge items, based on the similarity corresponding to each first knowledge item, determine the first contribution degree of the first knowledge item.

[0062] In the embodiments of the present disclosure, when there are multiple first knowledge items, all the first knowledge items are directly input into the generative model and used to generate the response sentence. There is no primary-secondary relationship among the multiple first knowledge items, and the generative model needs to perform the same degree of analysis on each first knowledge item. Therefore, it will waste computing resources and may affect the quality of the generated text. Therefore, determine the similarity between each first knowledge item and the first question sentence as the first contribution degree of the first knowledge item. The higher the similarity, the more the first knowledge item conforms to the user's intention, so the first knowledge item becomes important for generating the response sentence, that is, the first contribution degree is higher.

[0063] In S206, based on the first question sentence, the historical dialogue information, the multiple first knowledge items, and the first contribution degree of each first knowledge item, generate the first prompt information. The first prompt information is used to instruct the generative model to generate a response sentence based on contents such as the contribution degree of each knowledge item.

[0064] In the embodiments of the present disclosure, a template for generating the first prompt information can be preset in the dialogue system. Then, after obtaining the first question sentence, the historical dialogue information, the multiple first knowledge items, and the first contribution degree of each first knowledge item, when inputting the first question sentence, the historical dialogue information, the multiple first knowledge items, and the first contribution degree of each first knowledge item into the template respectively, the first prompt information can be obtained.

[0065] In S207, input the first prompt information into the generative model and obtain the first response sentence output by the generative model.

[0066] In an embodiment of the present disclosure, after generating each piece of information for generating a response sentence as prompt information, it is input into a generative model to instruct the model to generate a response sentence. The generative model can recognize more notable points when generating a response sentence, and by focusing on and analyzing and processing the knowledge items, it can improve the utilization rate of computing resources, improve the understanding ability and processing efficiency of the generative model for the input information, reduce misunderstandings, and ensure the reliability of the output response sentence.

[0067] In an embodiment of the present disclosure, when there are multiple first knowledge items, first, determine the contribution degree of each first knowledge item to the generation of the response sentence, and then fuse the first question sentence, historical dialogue information, multiple first knowledge items, and the contribution degree of each first knowledge item to generate first prompt information. Then, input the first prompt information into the generative model to obtain the first response sentence output by the generative model. Thereby, an effective fusion of the user's input and domain knowledge is realized, not only the information volume of the model input data is enhanced, but also the model can understand the user's intention more accurately, and the accuracy and reliability of the generated response sentence are improved.

[0068] In S208, based on the first question sentence, the first knowledge item, and the second knowledge item, evaluate the first response sentence. In S209, when the first response sentence passes the evaluation, output the first response sentence. For the descriptions of S208 and S209, since the above embodiments can be referred to, the repeated description is omitted here.

[0069] In this embodiment, by calculating the vector similarity between the sentence input by the user and the knowledge items in the knowledge base, the first knowledge item associated with the question sentence input by the user is determined, and based on the relationship indicated by the vectors between each knowledge item in the knowledge base, the second knowledge item whose relationship with the first knowledge item is a response relationship is obtained, thereby improving the rationality and reliability of the domain knowledge for generating the answer sentence and providing a data basis for improving the ability of the dialogue system to process complex questions. When there are multiple first knowledge items, first, the contribution degree of each first knowledge item to the generation of the answer sentence is determined. Then, the first question sentence, the historical dialogue information, the multiple first knowledge items, and the contribution degree of each first knowledge item are fused to generate the first prompt information. Then, the first prompt information is input into the generative model to obtain the first answer sentence output by the generative model. Thereby, an effective fusion of the user input and the domain knowledge is realized, not only the information amount of the model input data is enhanced, but also the model can more accurately understand the user's intention, and the accuracy and reliability of the generated answer sentence are improved.

[0070] Figure 3 is a schematic flowchart of a dialogue generation method proposed according to another embodiment of the present disclosure. As shown in Figure 3, the dialogue generation method includes the following steps S301 to S310.

[0071] In S301, the current first question sentence and the historical dialogue information associated with the first question sentence are obtained. In S302, the first similarity between the first vector corresponding to the first question sentence and the second vectors corresponding to each knowledge item in the knowledge base is determined. In S303, the knowledge item corresponding to the first similarity greater than the similarity threshold is determined as the first knowledge item. In S304, based on the third vector corresponding to the first knowledge item, the second knowledge item whose relationship with the first knowledge item is a response relationship is determined. Since the descriptions of S301 to S304 can be referred to the above embodiments, the repeated description is omitted here.

[0072] In S305, when the first knowledge item is an item of a preset type, determine the second contribution degree of each knowledge fragment in the first knowledge item to the second vector corresponding to the first knowledge item.

[0073] The item of the preset type refers to a knowledge item of a type with a large amount of information and complexity. For example, it may be an article or content including characters of multiple paragraphs. The content of each paragraph or each sentence in the item of the preset type can be used as one knowledge fragment within the knowledge item.

[0074] In the embodiments of the present disclosure, after obtaining the first knowledge item, it is possible to determine whether each first knowledge item is an item of a preset type. If any one of the first knowledge items is an item of a preset type, there may be redundant information or noise information with a large amount of information in the first knowledge item, which affects the quality of the generated answer sentence. Therefore, use technologies such as an attention mechanism to determine the second contribution degree of each knowledge fragment in the first knowledge item to the second vector corresponding to the first knowledge item, and screen the content within the first knowledge item that plays an important role in the generation of the answer sentence.

[0075] In S306, based on the second contribution degree, determine the target knowledge fragment from the first knowledge item. The target knowledge fragment refers to the content within the first knowledge item that plays an important role in the generation of the answer sentence.

[0076] In an embodiment of the present disclosure, according to actual application needs and the like, a contribution threshold is preset for the dialogue system. Then, after determining the second contribution degree corresponding to each knowledge fragment in the first knowledge item, the second contribution degree is compared with the contribution threshold, and the knowledge fragment corresponding to the second contribution degree greater than the contribution threshold can be determined as the target knowledge fragment in the first knowledge item. Alternatively, the knowledge fragment corresponding to the maximum value among all the second contribution degrees may be determined as the target fragment in the first knowledge item, etc., and the present disclosure is not limited thereto.

[0077] In S307, based on the first question sentence, the historical dialogue information, and the target knowledge fragment, second prompt information is generated. The second prompt information is used to instruct the generative model to generate an answer sentence in combination with contents such as the target knowledge fragment.

[0078] In an embodiment of the present disclosure, a template for generating the second prompt information can be preset for the dialogue system, and after obtaining the first question sentence, the historical dialogue information, and the target knowledge fragment, the first question sentence, the historical dialogue information, and the target knowledge fragment are respectively input into the template to obtain the second prompt information.

[0079] In S308, the second prompt information is input into the generative model, and the first answer sentence output by the generative model is obtained.

[0080] In an embodiment of the present disclosure, by obtaining the knowledge fragments with high contribution degrees from the knowledge items associated with the sentence input by the user and inputting them into the generative model to obtain the answer sentence, the fragments for generating the answer sentence in each knowledge item associated with the sentence input by the user can be dynamically adjusted, reducing the resources consumed during the calculation of the generative model, improving the efficiency of response sentence generation, and further improving the quality of the response sentence.

[0081] In S309, based on the first question sentence, the first knowledge item, and the second knowledge item, the first answer sentence is evaluated. In S310, if the first answer sentence passes the evaluation, the first answer sentence is output. Since the descriptions of S309 and S310 can refer to the above embodiments, the repeated description is omitted here.

[0082] FIG. 4 is a schematic flowchart of a dialogue generation method proposed according to another embodiment of the present disclosure. As shown in FIG. 4, the dialogue generation method includes the following steps S401 to S406.

[0083] In S401, the current first question sentence and the historical dialogue information associated with the first question sentence are obtained. In S402, from the knowledge base, the first knowledge item associated with the first question sentence and the second knowledge item whose relationship with the first knowledge item is a response relationship are obtained. In S403, the first question sentence, the first knowledge item, and the historical dialogue information are input into a generative model, and the first answer sentence output by the generative model is obtained. Since the descriptions of S401 to S403 above can refer to the above embodiments, the repeated description is omitted here.

[0084] In S404, based on the first knowledge item, the first question sentence, the second knowledge item, and the first answer sentence, third prompt information is generated. The third prompt information is used to instruct an evaluation model to verify the accuracy and normalization of the answer sentence.

[0085] In an embodiment of the present disclosure, a template for generating third prompt information can be preset in the dialogue system. After obtaining the first knowledge item, the first question sentence, the second knowledge item, and the first answer sentence, the first knowledge item, the first question sentence, the second knowledge item, and the first answer sentence can be input into the template respectively to obtain the third prompt information.

[0086] In addition, considering that the text generation capabilities of different generative models are different, and the answer sentences output thereby may contain various data contents, when evaluating the first answer sentence using only the second knowledge item that has a response relationship with the first knowledge item, it may not be possible to accurately verify the accuracy of all the contents in the first answer sentence. 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 answer sentence.

[0087] Optionally, first, a third knowledge item associated with the first answer sentence can be obtained from the knowledge base.

[0088] In an embodiment of the present disclosure, by calculating the semantic similarity between the first answer sentence and each knowledge item in the knowledge base respectively, one or more knowledge items whose semantic similarity is higher than a certain threshold can be determined as the third knowledge item associated with the first answer sentence. Alternatively, the third knowledge item associated with the first answer sentence can be obtained from the knowledge base in other ways. For example, the distance between the first answer sentence and the word vectors in each knowledge item can be calculated, etc., which is not limited in the present disclosure.

[0089] Thereafter, the third knowledge item and the second knowledge item can be fused to obtain the fused knowledge item and the weight of the fused knowledge item. As a fusion method, it may be possible to eliminate duplicates and merge the third knowledge item and the second knowledge item. The weights of the fused knowledge items are used to indicate the importance of different knowledge items to the evaluation model when evaluating the answer text.

[0090] Note that there may be one or more third knowledge items, there may also be one or more second knowledge items, and the second knowledge item and the third knowledge item may be the same. Therefore, after sequentially eliminating duplicates and merging each third knowledge item and the second knowledge item, the fused knowledge items may be one, may be multiple, and may also be the same as the second knowledge item or the third knowledge item.

[0091] In the embodiments of the present disclosure, after eliminating the overlapping content between the third knowledge item and the second knowledge item, merging all the content of the third knowledge item and the second knowledge item to obtain the fused knowledge items, the fused knowledge items can be determined in various ways. For example, the weight can be determined by calculating the similarity between the fused knowledge items and the first answer text, and the higher the similarity, the higher the weight. Or, it may also be a method of determining the weight based on the number of occurrences of the fused knowledge items in the second knowledge item and the third knowledge item, etc.

[0092] After that, the third prompt information can be generated based on the first knowledge item, the first question text, the first answer text, the fused knowledge items, and the weights of the fused knowledge items.

[0093] In the embodiments of the present disclosure, the third knowledge item and the second knowledge item associated with the first answer text in the knowledge base are fused to obtain the fused knowledge items and their corresponding weights, and the fused knowledge items and their corresponding weights are used together with the first knowledge item, the first question text, and the first answer text to generate prompt information, and instruct the evaluation model to evaluate the first answer text. Thereby, the richness of the content of the evaluation prompt information can be improved, and the reliability and accuracy of the evaluation result of the answer text can be improved.

[0094] Optionally, when determining the weight of the fused knowledge item, first, a third similarity between the fused knowledge item and the first response sentence, and the number of occurrences of the fused knowledge item in the second knowledge item and the third knowledge item can be determined.

[0095] In an embodiment of the present disclosure, the third similarity can be obtained by calculating the semantic similarity between the fused knowledge item and the first response sentence. Alternatively, the distance between the vector of the fused knowledge item and the vector of the first response sentence can be calculated, and the smaller the distance, the higher the similarity, thereby obtaining the third similarity. Or it may be other methods for calculating the similarity between texts, etc., and the present disclosure is not limited thereto.

[0096] Note that in some possible embodiments, the second knowledge item and the third knowledge item may be the same, or the second knowledge item may be included in the third knowledge item. In this case, the fused knowledge item may be the second knowledge item or the third knowledge item, or the fused knowledge item may appear in both the second knowledge item and the third knowledge item. Therefore, the number of occurrences of the fused knowledge item can be obtained according to the number of knowledge items identical to the fused knowledge item in the second knowledge item and the third knowledge item.

[0097] Note 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 response sentence and should have a significant impact on the evaluation result.

[0098] Thereafter, based on the third similarity and / or the number of occurrences, the weight of the fused knowledge item can be determined.

[0099] In an embodiment of the present disclosure, the weight can be determined based only on the third similarity. The higher the third similarity, the more the corresponding fused knowledge item conforms to the field knowledge norm corresponding to the answer text, indicating that the weight of the fused knowledge item is higher. The weight may also be determined based only on the number of occurrences. The higher the number of occurrences, the greater the relevance of the corresponding fused knowledge item to the answer text, indicating that the evaluation effect of the answer text is good, and it can be determined that the weight of the fused knowledge item is high. Alternatively, the weight of the fused knowledge item may be determined by combining the third similarity and the number of occurrences.

[0100] In an embodiment of the present disclosure, by calculating the similarity and the number of occurrences corresponding to the fused knowledge item, the corresponding weight can be determined. Therefore, the reliability of the weight of the fused knowledge item is improved, and the accuracy and reliability of the evaluation result obtained based on the weight are improved.

[0101] In S405, the third prompt information is input into the evaluation model, and the evaluation result output by the evaluation model is obtained.

[0102] The evaluation model may be any existing model for verifying the accuracy and standardization of text. The evaluation result generated by the evaluation model may include the type of error (such as lack of semantic consistency, inconsistency with field knowledge, etc.) of the first answer text, the position of the error, etc., but this is not limited in the present disclosure.

[0103] If the evaluation result corresponding to the first answer text fails, the dialogue system can ensure smooth dialogue by updating the input content of the generative model based on the evaluation result.

[0104] Optionally, if the first answer text fails the evaluation, the evaluation result corresponding to the first answer text can be input into the generative model, and the second answer text output by the generative model can be obtained. Then, based on the second answer text, the process returns to executing the evaluation operation until an answer text that passes the evaluation is obtained and output.

[0105] In an embodiment of the present disclosure, by inputting an evaluation result corresponding to a first response sentence that fails the evaluation into a generative model, the generative model is instructed to output the previously generated first response sentence again based on the deficiencies included in the evaluation result, and an updated second response sentence can be obtained. Thereafter, the second response sentence is evaluated. If the second response sentence passes the evaluation, the second response sentence can be output to the user. If the evaluation result of the second response sentence still fails, a new evaluation result is input into the generative model to obtain a new response sentence, and the process is repeated until the generated response sentence passes the evaluation. Thereby, by using the evaluation result of the response sentence that fails the evaluation, the generative model is instructed to output the next response sentence, so that the reliability of the response sentence can be further improved, the quality of the dialogue can be improved, and the consistency of the dialogue can be ensured.

[0106] In S406, if the first response sentence passes the evaluation, the first response sentence is output. Since the description of S406 above can refer to the above embodiment, the repeated description is omitted here.

[0107] In this embodiment, the first knowledge item, the first question sentence, the second knowledge item, and the first response sentence are used to generate third prompt information, and the evaluation model is instructed to output the evaluation result of the first response sentence, so as to realize automatic evaluation and verification of the response sentence, improve the evaluation efficiency of the response sentence and the reliability of the evaluation result, and improve the quality of the dialogue.

[0108] FIG. 5 is a schematic flowchart of a dialogue generation method proposed according to another embodiment of the present disclosure. As shown in FIG. 5, the dialogue generation method includes steps S501 to S508.

[0109] In S501, the current first question sentence and the historical dialogue information associated with the first question sentence are obtained. In S502, obtain, from the knowledge base, a first knowledge item associated with the first question sentence and a second knowledge item whose relationship with the first knowledge item is a response relationship. In S503, input the first question sentence, the first knowledge item, and the history dialogue information into the generative model, and obtain a first answer sentence output by the generative model.

[0110] In S504, evaluate the first answer sentence based on the first question sentence, the first knowledge item, and the second knowledge item. In S505, if the first answer sentence passes the evaluation, output the first answer sentence. Since the descriptions of S501 to S505 above can refer to the above embodiments, the repeated description is omitted here. In S506, when a second question sentence for the first answer sentence is received, generate and output a third answer sentence corresponding to the second question sentence.

[0111] In the embodiment of the present disclosure, after the dialogue system outputs the first answer sentence to the user, the user may have doubts about the first answer sentence, so there is a possibility of inputting a new second question sentence through the dialogue interface. Therefore, the dialogue system can receive the second question sentence for the first answer sentence, and based on the method described in the above embodiment, obtain a third answer sentence output by the generative model and passing the evaluation, and output it to the current dialogue interface.

[0112] In S507, when a third question sentence for the third answer sentence has not been received, generate a target answer sentence corresponding to the first question sentence based on the first answer sentence and the third answer sentence.

[0113] In an embodiment of the present disclosure, when a third response sentence is output to the dialogue interface and no third question sentence for the third response sentence is received, it can be determined that the first response sentence and the third response sentence satisfy the user's needs and can solve the user's question (i.e., the question corresponding to the first question sentence), and the first response sentence can be determined together with the third response sentence as the target response sentence corresponding to the first question sentence.

[0114] In S508, save the first question sentence and the target response sentence to a preset database. The data in the preset database is used for updating and training the generative model.

[0115] In an embodiment of the present disclosure, save the first question sentence and the corresponding target response sentence in pairs to a preset database, and when the data in the preset database reaches a certain amount or reaches a preset update time interval, the data in the preset database can be used to update and train the generative model.

[0116] In this embodiment, when a second question sentence for the first response sentence is received, first, generate and output a third response sentence corresponding to the second question sentence. Then, when no third question sentence for the third response sentence is received, generate a target response sentence corresponding to the first question sentence based on the first response sentence and the third response sentence. Furthermore, save the first question sentence and the target response sentence to a preset database. Thereby, in accordance with the feedback from the user, the generated response sentences are repeatedly optimized, and based on the question sentence and its finally optimized response content, the parameters and policies of the generative model are adjusted and trained, so that the dialogue system can continuously adapt to new dialogue scenarios and the user's needs, and the performance of the entire dialogue system can be improved.

[0117] FIG. 6 is a schematic configuration diagram of an interaction generation device proposed according to an embodiment of the present disclosure. As shown in FIG. 6, the interaction generation device 600 includes the following first acquisition module 601, second acquisition module 602, generation module 603, evaluation module 604, and output module 605.

[0118] The first acquisition module 601 is configured to acquire the current first question sentence and the historical interaction information associated with the first question sentence. The second acquisition module 602 is configured to acquire, from the knowledge base, a first knowledge item associated with the first question sentence and a second knowledge item whose relationship with the first knowledge item is a response relationship. The generation module 603 is configured to input the first question sentence, the first knowledge item, and the historical interaction information into a generative model and acquire a first answer sentence output by the generative model. The evaluation module 604 is configured to evaluate the first answer sentence based on the first question sentence, the first knowledge item, and the second knowledge item. The output module 605 is configured to output the first answer sentence when the first answer sentence passes the evaluation.

[0119] Optionally, the second acquisition module 602 determines a first similarity between a first vector corresponding to the first question sentence and a second vector corresponding to each knowledge item in the knowledge base, determines, as the first knowledge item, a knowledge item corresponding to a first similarity greater than a similarity threshold, and can be configured to determine a second knowledge item whose relationship with the first knowledge item is a response relationship based on a third vector corresponding to the first knowledge item, where the third vector indicates the association relationship between the first knowledge item and other knowledge items.

[0120] Optionally, the generation module 603 When there are multiple first knowledge items, based on the similarity corresponding to each first knowledge item, determine the first contribution degree of the first knowledge item. Based on the first question sentence, historical dialogue information, multiple first knowledge items, and the first contribution degree of each first knowledge item, generate first prompt information. It can be configured to input the first prompt information into a generative model to obtain the first answer sentence output by the generative model.

[0121] Optionally, the generation module 603 When the first knowledge item is an item of a preset type, determine the second contribution degree of each knowledge fragment in the first knowledge item to the second vector corresponding to the first knowledge item. Based on the second contribution degree, determine a target knowledge fragment from the first knowledge item. Based on the first question sentence, historical dialogue information, and the target knowledge fragment, generate second prompt information. It can be configured to input the second prompt information into a generative model to obtain the first answer sentence output by the generative model.

[0122] Optionally, the evaluation module 604 Determine the first similarity between the first question sentence and the first knowledge item, and the second similarity between the first answer sentence and the second knowledge item. It can be configured to determine that the first answer sentence passes the evaluation when the difference value between the first similarity and the second similarity is less than the distance threshold.

[0123] Optionally, the evaluation module 604 Based on the first knowledge item, the first question sentence, the second knowledge item, and the first answer sentence, generate third prompt information. It can be configured to input the third prompt information into an evaluation model to obtain the evaluation result output by the evaluation model.

[0124] Optionally, the evaluation module 604 Retrieve a third knowledge item associated with the first answer sentence from the knowledge base, Fuse the third knowledge item and the second knowledge item to obtain a fused knowledge item and the weight of the fused knowledge item, Based on the first knowledge item, the first question sentence, the first answer sentence, the fused knowledge item, and the weight of the fused knowledge item, it can be configured to generate third prompt information.

[0125] Optionally, the evaluation module 604 Determine a 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, Based on the third similarity and / or the number of occurrences, it can be configured to determine the weight of the fused knowledge item.

[0126] Optionally, the evaluation module 604 further If the first answer sentence fails the evaluation, input the evaluation result corresponding to the first answer sentence into the generative model to obtain a second answer sentence output by the generative model, Based on the second answer sentence, it can be configured to return to execute the evaluation operation until an answer sentence that passes the evaluation is obtained and output.

[0127] Optionally, the output module 605 further When a second question sentence for the first answer sentence is received, generate and output a third answer sentence corresponding to the second question sentence, When a third question sentence for the third answer sentence is not received, generate a target answer sentence corresponding to the first question sentence based on the first answer sentence and the third answer sentence, The first question sentence and the target answer sentence can be configured to be saved in a preset database, and the data in the preset database is used for updating and training the generative model.

[0128] Note that since the interpretations and explanations regarding the dialogue generation method are also applicable to the dialogue generation device according to this embodiment, the repeated explanations are omitted here.

[0129] In this embodiment, by automatically generating a response sentence by combining the domain expertise related to the user's question sentence and the historical dialogue information, the integration of the dialogue response and the domain knowledge is realized, the quality of the response sentence is improved, and the consistency and coherence of the dialogue are ensured. Furthermore, by evaluating the generated response sentence, the accuracy of the response is improved, the grammatical errors and logical inconsistencies in the response sentence are effectively reduced, and the user experience is optimized.

[0130] According to an embodiment of the present disclosure, the present disclosure further provides an electronic device, a readable storage medium, and a computer program.

[0131] FIG. 7 shows a schematic block diagram of an exemplary electronic device according to an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers such as laptop computers, desktop computers, workstations, portable information terminals, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices such as portable information terminals, mobile phones, smart phones, wearable devices, and other similar computing devices. The components, their connections and relationships, and their functions shown in this specification are merely examples and are not intended to limit the description of this specification and / or the implementation of the present disclosure required.

[0132] As shown in FIG. 7, the device 700 includes a computing unit 701, which can execute various appropriate operations and processes based on a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 707 into a random access memory (RAM) 703. The RAM 703 can also store various programs and data necessary for the operation of the device 700. The computing unit 701, ROM 702, and 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.

[0133] 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 and a mouse, an output unit 707 such as various displays and speakers, a storage unit 708 such as a magnetic disk and an optical disk, and a communication unit 709 such as a network card, a modem, and a wireless communication transceiver. The communication unit 709 enables the device 700 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0134] The computing unit 701 may be various general-purpose and / or dedicated processing components having 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 that execute machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 executes various methods and processes described above, such as the dialogue generation method. For example, in some embodiments, the dialogue generation method can be realized as a computer software program tangibly included in a machine-readable medium such as the storage unit 707. In some embodiments, part or all of the computer program can 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 above dialogue generation method can be executed. Optionally, in other embodiments, the computing unit 701 may be configured to execute the dialogue generation method in any other suitable manner (e.g., by firmware).

[0135] The various embodiments of the systems and techniques described in this specification 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), system on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can be implemented by one or more computer programs, which can be executed and / or interpreted in a programmable system including at least one programmable processor, which can be a dedicated or general-purpose programmable processor, and which receives data and instructions from a storage system, at least one input device, and at least one output device, and can transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.

[0136] The program code for implementing the methods of the present disclosure can be written using any combination of one or more programming languages. These program codes can be provided to the processor or controller of a general-purpose computer, a dedicated computer, or other programmable data processing device, and when the program code is executed by the processor or controller, the functions / operations defined in the flowchart and / or block diagram will be executed. The program code can be fully executed on a machine, partially executed on a machine, partially executed on a machine as a stand-alone software package and partially executed on a remote machine, or fully executed on a remote machine or server.

[0137] In the context of the present disclosure, a machine-readable medium may be a tangible medium that includes or can store a program used by or in combination with an instruction execution system, apparatus, or device. A machine-readable medium may be either a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium include electrical connections based on one or more lines, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0138] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer, which includes 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 trackball), by which the user can provide input to the computer. Other types of devices can also be used to provide for interaction with a user, for example, 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, and tactile input).

[0139] The systems and techniques described herein can be implemented in a computing system that includes backend components (such as a data server), or a computing system that includes middleware components (such as an application server), or a computing system that includes frontend components (such as a user computer having a graphical user interface or a web browser, and the user interacts with embodiments of the systems and techniques described herein through the graphical user interface or the web browser), or a computing system that includes any combination of such backend components, middleware components, and frontend components. The components of the system can be interconnected with each other via digital data communication in any form or medium (such as a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), the Internet, and blockchain networks.

[0140] A computer system can include clients and servers. Clients and servers are generally separated from each other and typically interact via a communication network. The relationship between a client and a server is created by computer programs that are executed on corresponding computers and have a client-server relationship with each other. The server can be a cloud server, also called a cloud computing server or a cloud host, which is a host product of a cloud computing service system and solves the drawbacks of difficult management and weak business scalability in conventional physical hosts and VPS (Virtual Private Server) services. The server can also be a server of a distributed system or a server combined with a blockchain.

[0141] Using the various forms of flow shown above, steps can be rearranged, added, or deleted. For example, each step described in this disclosure may be executed in parallel, sequentially, or in a different order, but is not limited herein as long as the technical solutions disclosed in this disclosure can achieve the desired results.

[0142] Also, the terms "first" and "second" are used only for the purpose of explanation and should not be understood as indicating relative importance, implying it, or implicitly indicating the number of the technical features shown. Therefore, the features defined by "first" and "second" may implicitly include at least one of these features. In the description of this disclosure, "a plurality" means at least two, such as two, three, etc., unless specifically and clearly limited. In the description of this disclosure, the word "when... is used" may be interpreted as "when...", "at the time of...", "depending on the determination", or "in the case of...".

[0143] The above specific embodiments do not limit the protection scope of this disclosure. Those skilled in the art can make various modifications, combinations, sub - combinations, and substitutions based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should all be included within the protection scope of this disclosure.

Claims

1. A dialogue generation method, comprising: obtaining a current first question sentence and historical dialogue information associated with the first question sentence; obtaining, from a knowledge base, a first knowledge item associated with the first question sentence and a second knowledge item having a response relationship with the first knowledge item; inputting the first question sentence, the first knowledge item, and historical dialogue information into a generative model to obtain a first answer sentence output by the generative model; evaluating the first answer sentence based on the first question sentence, the first knowledge item, and the second knowledge item; and if the first answer sentence passes evaluation, outputting the first answer sentence.

2. The step of acquiring, from the knowledge base, a first knowledge item associated with the first question sentence and a second knowledge item having a response relationship with the first knowledge item, comprises: determining a first similarity between a first vector corresponding to the first question sentence and a second vector corresponding to each knowledge item in the knowledge base; determining a knowledge item corresponding to a first similarity greater than a similarity threshold as the first knowledge item; 2. The dialogue generation method according to claim 1, further comprising: a step of determining a second knowledge item having a response relationship with the first knowledge item based on a third vector corresponding to the first knowledge item, the third vector indicating an association relationship between the first knowledge item and another knowledge item.

3. The step of inputting the first question sentence, the first knowledge item, and historical dialogue information into a generative model and acquiring a first answer sentence output by the generative model includes: determining a first contribution degree of each of the first knowledge items based on a similarity degree corresponding to each of the first knowledge items when the number of the first knowledge items is multiple; generating first prompt information based on the first question sentence, the historical dialogue information, a plurality of the first knowledge items, and a first contribution degree of each of the first knowledge items; The dialogue generation method according to claim 2 , further comprising: inputting the first prompt information into the generative formula model to obtain a first answer sentence output by the generative formula model.

4. The step of inputting the first question sentence, the first knowledge item, and historical dialogue information into a generative model and acquiring a first answer sentence output by the generative model includes: if the first knowledge item is of a predefined 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 fragment from the first knowledge item based on the second contribution; generating second prompt information based on the first question sentence, the historical dialogue information, and the target knowledge fragment; The dialogue generation method according to claim 2 , further comprising: inputting the second prompt information into the generative formula model to obtain a first answer sentence output by the generative formula model.

5. The step of evaluating the first answer sentence based on the first question sentence, the first knowledge item, and the second knowledge item includes: determining a first similarity between the first question sentence and the first knowledge item and a second similarity between the first answer sentence and the second knowledge item; The dialogue generation method according to claim 1 , further comprising: determining that the first answer sentence passes evaluation if a difference value between the first similarity and the second similarity is less than a distance threshold.

6. The step of evaluating the first answer sentence based on the first question sentence, the first knowledge item, and the second knowledge item includes: generating third prompt information based on the first knowledge item, the first question sentence, the second knowledge item, and the first answer sentence; The dialogue generating method according to claim 1 , further comprising: inputting the third prompt information into an evaluation model to obtain an evaluation result output by the evaluation model.

7. The step of generating third prompt information based on the first knowledge item, the first question sentence, the second knowledge item, and the first answer sentence includes: obtaining a third knowledge item associated with the first answer sentence 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 dialogue generation method according to claim 6, further comprising: generating third prompt information based on the first knowledge item, the first question sentence, the first answer sentence, the fused knowledge item, and a weight of the fused knowledge item.

8. The step of determining weights of the fused knowledge items comprises: determining a third similarity between the merged knowledge item and the first answer sentence and a number of occurrences of the merged knowledge item in the second knowledge item and the third knowledge item; and determining a weight of the fused knowledge item based on the third similarity and / or the number of occurrences.

9. After the step of evaluating the first response sentence, If the first answer sentence does not pass the evaluation, inputting an evaluation result corresponding to the first answer sentence into the generation formula model to obtain a second answer sentence output by the generation formula model; The dialogue generating method according to claim 1 , further comprising the step of returning to execute the evaluation operation until an answer sentence that passes evaluation is obtained and output based on the second answer sentence.

10. After outputting the first reply sentence, when a second question sentence in response to the first answer sentence is received, generating and outputting a third answer sentence corresponding to the second question sentence; generating a target answer sentence corresponding to the first question sentence based on the first answer sentence and the third answer sentence when a third question sentence for the third answer sentence has not been received; The method further includes a step of storing the first question sentence and the target answer sentence in a preset database; The method of claim 1 , wherein the data in the pre-defined database is used to update and train the generative model.

11. A dialogue generation device, comprising: a first acquisition module configured to acquire a current first question sentence and historical dialogue information associated with the first question sentence; a second acquisition module configured to acquire from a knowledge base a first knowledge item associated with the first question sentence and a second knowledge item having a response relationship with the first knowledge item; a generation module configured to input the first question sentence, the first knowledge item, and historical dialogue information into a generative model to obtain a first answer sentence output by the generative model; an evaluation module configured to evaluate the first answer sentence based on the first question sentence, the first knowledge item, and the second knowledge item; an output module configured to output the first answer sentence if the first answer sentence passes evaluation.

12. The second acquisition module includes: determining a first similarity between a first vector corresponding to the first question sentence and a second vector corresponding to each knowledge item in the knowledge base; determining a knowledge item corresponding to a first similarity greater than a similarity threshold as the first knowledge item; determining a second knowledge item having a response relationship with the first knowledge item based on a third vector corresponding to the first knowledge item; The dialogue generating device according to claim 11 , wherein the third vector indicates an association relationship between the first knowledge item and another knowledge item.

13. The generating module, When the number of the first knowledge items is multiple, determining a first contribution degree of each of the first knowledge items based on a similarity degree corresponding to each of the first knowledge items; generating first prompt information based on the first question sentence, the historical dialogue information, the first knowledge items, and a first contribution degree of each of the first knowledge items; The dialogue generation device according to claim 12 , configured to input the first prompt information to the generative formula model to obtain a first answer sentence output by the generative formula model.

14. The generating module includes: determining a second contribution of each knowledge fragment in the first knowledge item to a second vector corresponding to the first knowledge item if the first knowledge item is a predetermined type of item; determining a target knowledge fragment from the first knowledge item based on the second contribution; generating second prompt information based on the first question sentence, the historical dialogue information, and the target knowledge fragment; The dialogue generation device according to claim 12 , configured to input the second prompt information to the generative formula model to obtain a first answer sentence output by the generative formula model.

15. The evaluation module includes: determining a first similarity between the first question sentence and the first knowledge item and a second similarity between the first answer sentence and the second knowledge item; The dialogue generation device according to claim 11 , configured to determine that the first answer sentence passes evaluation if a difference value between the first similarity and the second similarity is less than a distance threshold.

16. The evaluation module includes: generating third prompt information based on the first knowledge item, the first question sentence, the second knowledge item, and the first answer sentence; The dialogue generating device according to claim 11 , configured to input the third prompt information into an evaluation model to obtain an evaluation result output by the evaluation model.

17. The evaluation module includes: obtaining a third knowledge item associated with the first answer sentence 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 dialogue generation device according to claim 16, configured to generate third prompt information based on the first knowledge item, the first question sentence, the first answer sentence, the fused knowledge item, and a weight of the fused knowledge item.

18. The evaluation module includes: determining a third similarity between the merged knowledge item and the first answer sentence and a number of occurrences of the merged knowledge item in the second knowledge item and the third knowledge item; The dialogue generating apparatus according to claim 17 , configured to determine a weight of the fused knowledge item based on the third similarity and / or the number of occurrences.

19. The evaluation module further comprises: If the first answer sentence does not pass the evaluation, inputting an evaluation result corresponding to the first answer sentence into the generative formula model to obtain a second answer sentence output by the generative formula model; The dialogue generation device according to claim 11 , configured to return to executing the evaluation operation until an answer sentence that passes evaluation is obtained and output based on the second answer sentence.

20. The output module further comprises: when a second question sentence in response to the first answer sentence is received, generating and outputting a third answer sentence corresponding to the second question sentence; If a third question sentence for the third answer sentence has not been received, generating a target answer sentence corresponding to the first question sentence based on the first answer sentence and the third answer sentence; The first question sentence and the target answer sentence are stored in a preset database; 15. The dialogue generating device according to claim 11, wherein the data in the pre-defined database is used for updating and training the generative model.

21. 1. An electronic device comprising: At least one processor; a memory communicatively coupled to the at least one processor; An electronic device, wherein the memory stores instructions executable by the at least one processor, and the instructions, when executed by the at least one processor, enable the at least one processor to perform the interaction generation method described in any one of claims 1 to 10.

22. A non-transitory computer-readable storage medium having computer instructions stored thereon, comprising: A non-transitory computer readable storage medium, the computer instructions causing the computer to perform a dialogue generation method according to any one of claims 1 to 10.

23. A computer program comprising: A computer program product, which, when executed by a processor, causes the steps of the dialogue generation method according to any one of claims 1 to 10 to be realized.

Citation Information

Patent Citations

  • Intelligent question and answer method and system combining retrieval and generation

    CN112364150A

  • Question answering method, related device, electronic equipment and storage medium

    CN114547273A

  • Man-machine collaborative office method and terminal equipment

    CN115545044A

  • Text coding model training method and device, equipment and storage medium

    CN117272937A

  • Control method, control program and information processor

    JP2020060894A