Dialogue generation method, apparatus, electronic device, and storage medium
By integrating domain knowledge and context information through a generative model with an evaluation step, the method enhances dialogue response quality and coherence, addressing the challenges of inconsistent responses in complex environments.
Patent Information
- Application Number
- JP2025054928
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2024-09-10
- Filing Date
- 2025-03-28
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2045-03-28
AI Technical Summary
Current dialogue generation solutions struggle to handle complex and rapidly changing language environments, leading to inconsistent and low-quality responses.
A method that integrates domain knowledge and context information using a generative model to generate responses, followed by an evaluation step to ensure accuracy and coherence.
Improves the quality and consistency of dialogue responses by integrating domain knowledge and evaluating generated responses, reducing grammatical errors and logical inconsistencies.
Smart Images

Figure 0007911104000001 
Figure 0007911104000002 
Figure 0007911104000003
Abstract
Description
Technical Field
[0001] This 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. Current dialogue generation solutions do not perform well when facing complex and rapidly changing language environments and knowledge needs. Therefore, how to improve the depth of understanding of user needs by the dialogue system and improve the quality of response texts and context consistency has become the key to dialogue system development.
Summary of the Invention
Problems to be Solved by the Invention
[0003] This disclosure aims to at least somewhat solve one of the technical problems in the related art. Therefore, the objective of this disclosure is to propose a dialogue generation method, apparatus, electronic device, and storage medium that combine domain knowledge and context information to improve the quality of response text generation, improve dialogue quality, and optimize the user experience.
Means for Solving the Problems
[0004] According to a first aspect of this disclosure, obtaining the current first question text and the 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; The steps include inputting the first question, the first knowledge item, and the history dialogue information into a generative model to obtain the first answer output by the generative model, A step of evaluating the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item; A dialogue generation method is provided, which includes the step of outputting the first response if the first response passes the evaluation.
[0005] According to a second aspect of this disclosure, A first acquisition module configured to acquire the current first question and the history dialogue information associated with the first question, A second retrieval module is configured to retrieve from a knowledge base a first knowledge item associated with the first question statement and a second knowledge item whose relationship to 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 generation formula model and obtain a first answer sentence output by the generation formula 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, A dialogue generation device is provided, which includes an output module configured to output the first response if the first response passes the evaluation.
[0006] According to a third aspect of this disclosure, At least one processor, Includes memory communicated to at least one processor, An electronic device is provided in which the memory stores instructions that can be executed 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 embodiment.
[0007] A fourth aspect of this disclosure provides a non-temporary computer-readable storage medium in which computer instructions are stored, the computer instructions causing a computer to execute the dialogue generation method described in the first aspect.
[0008] A fifth aspect of this disclosure provides a computer program including a computer instruction, wherein when the computer instruction is executed by a processor, the steps of the dialogue generation method described in the first aspect are realized. [Effects of the Invention]
[0009] The dialogue generation methods, apparatus, electronic devices, and storage media provided by this disclosure have the following beneficial effects: By automatically generating responses by combining the user's question with relevant domain expertise and historical dialogue information, the integration of dialogue responses with domain knowledge is achieved, improving the quality of responses and ensuring dialogue consistency and coherence. Furthermore, by evaluating the generated responses, the accuracy of the responses is improved, grammatical errors and logical inconsistencies in responses are effectively reduced, and the user experience is optimized.
[0010] It should be understood that the information described in this section is not intended to identify any essential or important features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will be readily apparent from the following description. [Brief explanation of the drawing]
[0011] The above and / or additional aspects and advantages of this disclosure will become apparent and readily apparent from the following description of the embodiments with reference to the drawings. The drawings are used for a better understanding of the present invention and do not limit this disclosure.
[0012] [Figure 1]Schematic flowchart of the dialogue generation method proposed by an embodiment of the present disclosure. [Figure 2] Schematic flowchart of the dialogue generation method proposed by another embodiment of the present disclosure. [Figure 3] Schematic flowchart of the dialogue generation method proposed by another embodiment of the present disclosure. [Figure 4] Schematic flowchart of the dialogue generation method proposed by another embodiment of the present disclosure. [Figure 5] Schematic flowchart of the dialogue generation method proposed by another embodiment of the present disclosure. [Figure 6] Schematic configuration diagram of the dialogue generation device proposed by an embodiment of the present disclosure. [Figure 7] Block diagram of an exemplary electronic device suitable for realizing the embodiments of the present disclosure is shown.
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 brevity, descriptions of well-known functions and configurations are omitted in the following description.
[0014] Embodiments of the present disclosure relate to the 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, it uses the computer as a powerful tool for language research, conducts quantitative research on language information with the support of the computer, and provides 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, which can process a large amount of data and complete 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, which can generate text similar to humans and answer questions in natural language by training with a large amount of data and parameters.
[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 characters, 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 this 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, device, electronic device, and storage medium according to an embodiment of this disclosure will be described with reference to the drawings.
[0021] The entity executing the dialogue generation method according to this embodiment is a dialogue generation device, which can be implemented by software and / or hardware and can be configured within an electronic device. The electronic device may include, but is not limited to, a terminal or a server. In the embodiments of this disclosure, the case in which the dialogue generation device is configured in a dialogue system will be described as an example.
[0022] Figure 1 is a schematic flowchart of the dialogue generation method proposed by one embodiment of the present disclosure. As shown in Figure 1, the dialogue generation method includes the following steps S101 to S105.
[0023] In S101, the current first question and the history dialogue information associated with the first question are obtained. The first question may be a question received by the dialogue interface in which the dialogue system interacts with any user.
[0024] In the embodiments of this disclosure, in order to ensure the consistency of the dialogue, the context understanding module in the dialogue generation system can further maintain a dialogue history record by storing dialogue history information between each user and the dialogue system, which is typically implemented by a memory network or a recurrent neural network (Long Short-Term Memory (LSTM)).
[0025] In embodiments of the present disclosure, after receiving the most recent first question sentence entered by any user, the dialogue system can obtain historical dialogue information associated with the first question sentence from the historical dialogue record of the dialogue interface in which the first question sentence is located.
[0026] In S102, the first knowledge item associated with the first question and the second knowledge item whose relationship to the first knowledge item is a response relationship are retrieved from the knowledge base.
[0027] Knowledge items refer to individual elements or units that constitute foundational knowledge in a particular field, discipline, or topic, and may include definitions, facts, concepts, theories, and formulas. In a knowledge base, each knowledge item can be stored in the form of a knowledge graph, and relationships such as response relationships, causal relationships, and temporal relationships may exist between different knowledge items.
[0028] Furthermore, a response relationship refers to a logical correspondence between two knowledge items, such as a "question-answer" or "request-response" relationship. In a response relationship, one knowledge item represents a question, request, or query, and the other knowledge item is the direct answer or response to that question, request, or query.
[0029] In the embodiments of this disclosure, the similarity between the first question and each knowledge item in the knowledge base is calculated, and one or more knowledge items with high similarity are determined to be the first knowledge item associated with the first question. Alternatively, the first knowledge item associated with the first question may be obtained from the knowledge base by other methods, such as the distance between the word vectors in the question and the knowledge item, but this disclosure is not limited to these methods.
[0030] In embodiments of the present disclosure, after receiving a first question sentence currently entered by a user, the dialogue system can retrieve at least one first knowledge item related to the first question sentence from a knowledge base within the system based on the first question sentence. Subsequently, based on the relationships between each knowledge item in the knowledge base, the system can retrieve a second knowledge item that is in a response relationship with each first knowledge item in the knowledge base.
[0031] Furthermore, in this disclosure, dialogue systems applied to different linarios may contain different information in their corresponding knowledge bases. Dialogue systems in different application areas such as finance, healthcare, and education can build knowledge bases by collecting and organizing relevant domain knowledge, such as terminology, frequently occurring question-and-answer pairs, and expert knowledge. Then, using natural language processing techniques, preprocessing tasks such as cleaning, word segmentation, and annotation can be performed on the collected text information, and it can be stored in the knowledge base as different knowledge items.
[0032] In S103, the first question, the first knowledge item, and the history dialogue information are input into the generative model, and the first answer is obtained from the generative model.
[0033] The generative model may be any model capable of generating new text based on input text, such as 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).
[0034] In the embodiments of this disclosure, the generative model has learned extensive linguistic knowledge and generative capabilities through extensive pre-training, so that it can generate a first response sentence that matches the current dialogue linario and user needs based on an input first question sentence, a first knowledge item, and historical dialogue information.
[0035] Furthermore, 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 analyzed in depth, and long-range dependencies and semantic features in the first question sentence can be captured through self-attention mechanisms and position coding, providing rich semantic information to the subsequent answer sentence generation task and effectively improving the quality of the output sentence.
[0036] In some possible embodiments, there may be a large number of first knowledge items, or the text information contained in the first knowledge items may be excessive. If all of these first knowledge items are input into the generative model, it may burden the model and affect the quality and efficiency of the response. Therefore, processing the first knowledge items before inputting the first question, first knowledge items, and historical dialogue information into the generative model can improve the efficiency of the generative model and the quality of the output response. For example, the contribution of each first knowledge item can be determined during response generation, and then the contributions can be input into the generative model together to instruct the model to generate the response. Alternatively, the amount of data analyzed by the generative model can be reduced by inputting only the essential information within the first knowledge items into the generative model to generate the response, such as by deleting information within the first knowledge items.
[0037] In S104, the first answer is evaluated based on the first question, the first knowledge item, and the second knowledge item.
[0038] Furthermore, after obtaining the first response sentence output by the generative model, in order to improve the accuracy and depth of the dialogue response, the evaluation module in the dialogue system can verify and evaluate the first response sentence using knowledge in the knowledge base before sending it to the user, thereby ensuring that the information in the first response sentence is accurate, error-free, and conforms to domain standards.
[0039] In the embodiments of this disclosure, the first answer can be evaluated in various ways. For example, the first question, the first knowledge item, the second knowledge item, and the first answer can be input into any existing evaluation model, and the evaluation result output by the evaluation model can be directly obtained. Alternatively, the similarity between the first question and the first knowledge item, and the similarity between the second knowledge item and the first answer can be calculated, and the evaluation result can be determined by the difference between the two similarity values. This disclosure is not limited to these methods.
[0040] Selectively, the first similarity between the first question and the first knowledge item, and the second similarity between the first answer and the second knowledge item can be determined. Then, if the difference between the first and second similarities is less than the distance threshold, it is determined that the first answer passes the evaluation.
[0041] The distance threshold can be set according to the evaluation accuracy needs in actual applications; the higher the accuracy requirement, the smaller the distance threshold needs to be.
[0042] The first similarity can be determined by calculating the distance between the vector of the first question and the vector of the second knowledge item. Alternatively, the first similarity can be obtained by calculating the semantic similarity between the first question and the second knowledge item. This disclosure is not limited to these methods. The method for calculating the second similarity is the same as the method for calculating the first similarity.
[0043] In the embodiments of this disclosure, after obtaining the first and second similarity scores, the value of the first similarity score is sufficiently large because the first knowledge item is associated with the first question sentence. Therefore, if the difference between the first and second similarity scores is less than the distance threshold, it can be determined that the value of the second similarity score is also large, that is, the first answer sentence is consistent with typical response knowledge content in the current domain and is reliable, and thus the first answer sentence passes the evaluation. In this way, by calculating the difference between similarity scores and evaluating the answer sentence, the accuracy and reliability of the generated answer sentence are ensured, and the quality of the intelligent dialogue is further improved.
[0044] In S105, if the first response passes the evaluation, the first response is output.
[0045] In the embodiments of this disclosure, if the first response passes the evaluation, it is considered that the current first response output by the generative model not only conforms to the user's intent but also to the expertise of the current field. Therefore, the accuracy of the first response is high, and it can be output to the user via the dialogue system interface and sent to answer the first question.
[0046] If the first answer fails the evaluation, it indicates that the current first answer does not fit the domain knowledge well and is not very accurate. Therefore, the answer generated by the generative model needs to be updated until the answer passes the evaluation and is output to the user. This update can be achieved by inputting the problem discovered during the evaluation or the second knowledge item into the generative model and obtaining the newly generated answer from the model.
[0047] In this embodiment, first, the current first question and its associated historical dialogue information are obtained. Then, from the knowledge base, the first knowledge item associated with the first question and the second knowledge item whose relationship to the first knowledge item is a response relationship are obtained. Next, the first question, the first knowledge item, and the historical dialogue information are input into the generative model to obtain the first answer output by the generative model. Then, the first answer is evaluated based on the first question, the first knowledge item, and the second knowledge item, and if the first answer passes the evaluation, the first answer is output. This realizes the fusion of dialogue answers and domain knowledge by automatically generating answer sentences in combination with domain expertise and historical dialogue information related to the user's question, improving the quality of the answer sentences and ensuring the consistency and coherence of the dialogue. Furthermore, by evaluating the generated answer sentences, the accuracy of the answers is improved, grammatical errors and logically illogical situations in the answer sentences are effectively reduced, and the user experience is optimized.
[0048] Figure 2 is a schematic flowchart of a dialogue generation method proposed by 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 and the history dialogue information associated with the first question are retrieved. Since the explanation of S201 can be found in the above embodiment, a further explanation will be omitted here.
[0050] In S202, the first similarity between the first vector corresponding to the first question and the second vector corresponding to each knowledge item in the knowledge base is determined.
[0051] In the embodiments of this disclosure, embedding techniques in deep learning (e.g., neural network-based word embedding techniques such as Word2Vec and BERT) can be used to code the first question and each knowledge item, respectively, to obtain a first vector corresponding to the first question and a second vector corresponding to each knowledge item.
[0052] In embodiments of this disclosure, the first similarity between the first vector and each of the second vectors can be calculated in any manner. For example, the method may be to calculate the cosine similarity between the first vector and the second vector, or to calculate the Euclidean distance between the first vector and the second vector, where a smaller distance indicates a greater similarity. Alternatively, other feasible methods for calculating similarity may be used, but are not limited to these.
[0053] In S203, the knowledge item corresponding to the first similarity that is greater than the similarity threshold is determined as the first knowledge item.
[0054] The similarity threshold can be set by the user based on factors such as actual application needs and experience, and this disclosure does not limit such value.
[0055] In the embodiments of this disclosure, after determining a first similarity between a first vector and each second vector, each first similarity can be compared with a similarity threshold. If the first similarity is greater than the similarity threshold, it can be determined that the knowledge item corresponding to the first similarity has a strong relationship with the first question, and that knowledge item can be determined as the first knowledge item for generating the answer.
[0056] Furthermore, since there may be multiple knowledge items for which the corresponding first similarity is greater than the similarity threshold, there may also be multiple first knowledge items.
[0057] In S204, a second knowledge item whose relationship to the first knowledge item is a response relationship is determined based on a third vector corresponding to the first knowledge item. The third vector shows the relationship between the first knowledge item and the other knowledge items.
[0058] Furthermore, when constructing a knowledge base, knowledge graph embedding techniques (for example, Translating Embeddings for Modeling Multi-relational Data (TransE), a knowledge graph embedding method based on complex number spaces (RotatE, Relational Rotation in Complex Space), etc.) can be used to map the relationships between entities within each knowledge item and other knowledge items into a low-dimensional vector space to form a knowledge graph, thereby facilitating subsequent computations and inferences.
[0059] In embodiments of this disclosure, since the relationship between two knowledge items in a knowledge base may be a response relationship or other relationship, after determining the first knowledge item associated with the first question, another knowledge item connected to a third vector corresponding to each first knowledge item can be determined based on the knowledge graph in the knowledge base, and then the relationships indicated by the third vector can be screened to determine the knowledge item connected to the third vector that indicates a response relationship as the second knowledge item.
[0060] In embodiments of this disclosure, a first knowledge item associated with a user-inputted question is determined by calculating the vector similarity between the user-inputted sentence and a knowledge item in the knowledge base, and a second knowledge item whose relationship to the first knowledge item is a response relationship is obtained based on the relationships shown by the vectors between each knowledge item in the knowledge base. This improves the rationality and reliability of domain knowledge for generating response sentences and provides a data base for improving the ability of a dialogue system to process complex questions.
[0061] In S205, if there are multiple first knowledge items, the first contribution of each first knowledge item is determined based on the similarity corresponding to each first knowledge item.
[0062] In the embodiments of this disclosure, if there are multiple first knowledge items, all first knowledge items are directly input into the generative model and used to generate the answer sentence. Since there are no major secondary relationships between the multiple first knowledge items, the generative model needs to perform the same level of analysis on each first knowledge item, which can be a waste of computing resources and affect the quality of the generated sentence. Therefore, the similarity between each first knowledge item and the first question sentence is determined as the first contribution of that first knowledge item. The higher the similarity, the better the first knowledge item fits the user's intent, making that first knowledge item more important for generating the answer sentence, i.e., its first contribution is higher.
[0063] In S206, first prompt information is generated based on the first question, history dialogue information, multiple first knowledge items, and the first contribution of each first knowledge item. The first prompt information is used to instruct the generative model to generate response sentences based on content such as the contribution of each knowledge item.
[0064] In the embodiments of this disclosure, a template for generating first prompt information can be pre-configured in the dialogue system. Subsequently, after obtaining a first question, history dialogue information, multiple first knowledge items, and the first contribution of each first knowledge item, the first prompt information can be obtained by inputting the first question, history dialogue information, multiple first knowledge items, and the first contribution of each first knowledge item into the template.
[0065] In S207, the first prompt information is input to the generative model, and the first response sentence output by the generative model is obtained.
[0066] In the embodiments of this disclosure, after generating each piece of information for generating a response as prompt information, it is input into a generative model to instruct the model to generate a response. The generative model can recognize points that require more attention when generating a response and, by focusing its analysis and processing on those knowledge items, can improve the utilization of computing resources, enhance the generative model's ability to understand and process the input information, reduce misunderstandings, and ensure the reliability of the output response.
[0067] In the embodiments of this disclosure, if there are multiple first knowledge items, first, the contribution of each first knowledge item to the generation of the answer sentence is determined. Then, the first question sentence, history dialogue information, multiple first knowledge items, and the contribution of each first knowledge item are merged to generate first prompt information. Subsequently, the first prompt information is input into a generation formula model to obtain the first answer sentence output by the generation formula model. This enables effective fusion of user input and domain knowledge, not only enhancing the amount of information in the model input data but also allowing the model to understand the user's intent more accurately and improving the accuracy and reliability of the generated answer sentence.
[0068] In S208, the first answer is evaluated based on the first question, the first knowledge item, and the second knowledge item. In S209, if the first response passes the evaluation, the first response is output. The explanations for S208 and S209 can be found in the above embodiment, so a further explanation is omitted here.
[0069] In this embodiment, by calculating the vector similarity between the sentence entered by the user and the knowledge items in the knowledge base, a first knowledge item associated with the question entered by the user is determined. Based on the relationships shown by the vectors between each knowledge item in the knowledge base, a second knowledge item whose relationship to the first knowledge item is a response relationship is obtained. This improves the rationality and reliability of domain knowledge for generating response sentences and provides a data base for improving the ability of the dialogue system to handle complex questions. If there are multiple first knowledge items, first, the contribution of each first knowledge item to the generation of the response sentence is determined. Then, the first question sentence, historical dialogue information, multiple first knowledge items, and the contribution of each first knowledge item are fused to generate first prompt information. Subsequently, the first prompt information is input into a generative model to obtain the first response sentence output by the generative model. This achieves effective fusion of user input and domain knowledge, not only enhancing the information content of the model input data but also allowing the model to understand the user's intent more accurately and improving the accuracy and reliability of the generated response sentences.
[0070] Figure 3 is a schematic flowchart of a dialogue generation method proposed by 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 and the history dialogue information associated with the first question are retrieved. In S302, the first similarity between the first vector corresponding to the first question and the second vector corresponding to each knowledge item in the knowledge base is determined. In S303, the knowledge item corresponding to the first similarity that is greater than the similarity threshold is determined as the first knowledge item. In S304, a second knowledge item whose relationship to the first knowledge item is a response relationship is determined based on a third vector corresponding to the first knowledge item. The explanations for S301 to S304 above can be found in the above embodiment, so we will omit further explanation here.
[0072] In S305, if the first knowledge item is of a predefined type, the second contribution of each knowledge fragment within the first knowledge item to the second vector corresponding to that first knowledge item is determined.
[0073] A predefined type of item refers to a knowledge item that contains a large amount of information and is complex. For example, it may be content containing the text of a single article or multiple paragraphs. The content of each paragraph or sentence in a predefined type of item can be used as a single knowledge fragment within that knowledge item.
[0074] In embodiments of this disclosure, after acquiring a first knowledge item, it is possible to determine whether each first knowledge item is of a predefined type. If any one of the first knowledge items is of a predefined type, the first knowledge item may contain information that is too informational and redundant or noisy, thus affecting the quality of the generated response. Therefore, techniques such as an attention mechanism are used to determine the second contribution of each knowledge fragment within the first knowledge item to a second vector corresponding to the first knowledge item, thereby screening the content within the first knowledge item for which it plays a crucial role in generating the response.
[0075] In S306, the target knowledge fragment is determined from the first knowledge item based on the second contribution. A target knowledge fragment refers to the content within the first knowledge item that plays a crucial role in generating the answer statement.
[0076] In embodiments of this disclosure, a contribution threshold can be pre-set in the dialogue system according to actual application needs, and then a second contribution corresponding to each knowledge fragment in the first knowledge item can be determined. After that, the second contribution can be compared with the contribution threshold, and the knowledge fragment corresponding to the second contribution 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 second contributions can be determined as the target fragment in the first knowledge item, and this disclosure is not limited thereto.
[0077] In S307, second prompt information is generated based on the first question, history dialogue information, and target knowledge fragment. The second prompt information is used to instruct the generative model to generate a response sentence in combination with content such as a target knowledge fragment.
[0078] In the embodiments of this disclosure, a template for generating second prompt information can be pre-configured in the dialogue system, and after obtaining the first question, history dialogue information, and target knowledge fragment, the first question, history dialogue information, and target knowledge fragment can be input into the template, respectively, to obtain the second prompt information.
[0079] In S308, the second prompt information is input to the generative model, and the first response sentence output by the generative model is obtained.
[0080] In the embodiments of this disclosure, knowledge fragments with high contribution are obtained from knowledge items associated with a sentence entered by the user and input into a generative model to obtain a response sentence. This allows for the dynamic adjustment of the fragments used to generate the response sentence for each knowledge item associated with the sentence entered by the user, thereby reducing the resources consumed during the computation of the generative model, improving the efficiency of response sentence generation, and further improving the quality of the response sentence.
[0081] In S309, the first answer is evaluated based on the first question, the first knowledge item, and the second knowledge item. In S310, if the first response passes the evaluation, the first response is output. The explanations for S309 and S310 can be found in the above embodiment, so a further explanation is omitted here.
[0082] Figure 4 is a schematic flowchart of a dialogue generation method proposed by another embodiment of the present disclosure. As shown in Figure 4, the dialogue generation method includes the following steps S401 to S406.
[0083] In S401, the current first question and the history dialogue information associated with the first question are retrieved. In S402, the first knowledge item associated with the first question and the second knowledge item whose relationship to the first knowledge item is a response relationship are retrieved from the knowledge base. In S403, the first question, the first knowledge item, and the history dialogue information are input into the generative model, and the first answer is obtained from the generative model. The explanations for S401 to S403 above can be found in the above embodiment, so we will omit further explanation here.
[0084] In S404, third prompt information is generated based on the first knowledge item, the first question, the second knowledge item, and the first answer. The third prompt information is used to instruct the evaluation model to verify the accuracy and standardization of the response.
[0085] In the embodiments of this disclosure, a template for generating third prompt information can be pre-configured in the dialogue system, and after obtaining a first knowledge item, a first question, a second knowledge item, and a first answer, the first knowledge item, the first question, the second knowledge item, and the first answer can be entered into the template, respectively, to obtain the third prompt information.
[0086] Furthermore, considering that different generative formula models have different text generation capabilities, the resulting response sentences may contain various data content. Therefore, if the first response sentence is evaluated using only the second knowledge item, which is the response relationship between the first knowledge item and the second knowledge item, it may not be possible to accurately verify the accuracy of all content in the first response sentence. Accordingly, this disclosure allows for the acquisition of other knowledge items from the knowledge base to enrich the third prompt information for evaluating the first response sentence.
[0087] Selectively, a third knowledge item associated with the first answer can be retrieved from the knowledge base.
[0088] In the embodiments of this disclosure, by calculating the semantic similarity between the first response sentence and each knowledge item in the knowledge base, one or more knowledge items whose semantic similarity is higher than a certain threshold can be determined as third knowledge items associated with the first response sentence. Alternatively, the third knowledge items associated with the first response sentence may be obtained from the knowledge base in other ways, such as calculating the distance between the first response sentence and the word vectors in each knowledge item, but this disclosure is not limited to such methods.
[0089] Subsequently, the third knowledge item and the second knowledge item can be merged to obtain the merged knowledge item and its weight. The merging method may involve merging the third knowledge item with the second knowledge item after eliminating duplicates. The weights of the merged knowledge items are used to instruct the evaluation model on the importance of different knowledge items when evaluating the response text.
[0090] Furthermore, there may be one or more third knowledge items, and there may also be one or more second knowledge items, and the second and third knowledge items may be the same. Therefore, after sequentially removing duplicates from each third and second knowledge item and merging them, there may be one or more fused knowledge items, and they may be the same as either the second or third knowledge item.
[0091] In the embodiments of this disclosure, overlapping content between the third and second knowledge items is removed, and all content from both the third and second knowledge items is merged to obtain a fused knowledge item. The fused knowledge item can then be determined in various ways. For example, its weight can be determined by calculating the similarity between the fused knowledge item and the first answer sentence, with higher similarity resulting in a higher weight. Alternatively, the weight may be determined based on the number of occurrences of the fused knowledge item in the second and third knowledge items.
[0092] Subsequently, third prompt information can be generated based on the first knowledge item, the first question, the first answer, the fused knowledge item, and the weights of the fused knowledge item.
[0093] In the embodiments of this disclosure, a third knowledge item and a second knowledge item associated with a first answer sentence in a knowledge base are merged to obtain a merged knowledge item and its corresponding weight. The merged knowledge item and its corresponding weight are then used together with the first knowledge item, the first question sentence, and the first answer sentence to generate prompt information, which is then used to instruct the evaluation model to evaluate the first answer sentence. This improves the richness of the content of the evaluation prompt information and enhances the reliability and accuracy of the evaluation results of the answer sentence.
[0094] When selectively determining the weight of a merged knowledge item, it is possible to first determine the third similarity between the merged knowledge item and the first answer statement, and the number of times the merged knowledge item appears in the second and third knowledge items.
[0095] In the embodiments of this disclosure, a third similarity can be obtained by calculating the semantic similarity between the merged knowledge item and the first answer sentence. Alternatively, the distance between the vector of the merged knowledge item and the vector of the first answer sentence may be calculated, with a smaller distance indicating a higher similarity, thereby obtaining a third similarity. Alternatively, other methods for calculating similarity between texts may be used, but are not limited to these.
[0096] In some possible embodiments, the second and third knowledge items may be the same, or the third knowledge item may contain the second knowledge item. In this case, the fused knowledge item may be the second or third knowledge item, or it may appear in both the second and third knowledge items. Therefore, the number of occurrences of the fused knowledge item can be obtained by the number of identical knowledge items in the second and third knowledge items.
[0097] Furthermore, if a fused knowledge item appears in both the second and third knowledge items, its appearance count will be recorded as 2. This indicates that the fused knowledge item is not only in a response relationship with the first knowledge item, but is also associated with the first response sentence that was generated, and should therefore have a significant impact on the evaluation result.
[0098] Subsequently, the weights of the merged knowledge items can be determined based on a third similarity and / or frequency of occurrence.
[0099] In the embodiments of this disclosure, weights can be determined based solely on a third similarity metric, where a higher third similarity metric indicates that the corresponding fused knowledge item better fits the domain knowledge norms corresponding to the answer, resulting in a higher weight for the fused knowledge item. Weights can also be determined based solely on frequency of occurrence, where a higher frequency indicates that the corresponding fused knowledge item has a greater relevance to the answer, resulting in a better evaluation effect on the answer, and thus a higher weight for the fused knowledge item. Alternatively, the weights of fused knowledge items can be determined by combining the third similarity metric and frequency of occurrence.
[0100] In the embodiments of this disclosure, the weights can be determined by calculating the similarity and frequency of occurrence for the merged knowledge items, thereby improving the reliability of the weights for the merged knowledge items and improving the accuracy and reliability of the evaluation results obtained based on the weights.
[0101] In S405, the third prompt information is input to 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 results generated by the evaluation model may include, but are not limited to, the type of error in the first response sentence (e.g., semantic inconsistency, mismatch with domain knowledge), the location of the error, etc.
[0103] Furthermore, if the evaluation result corresponding to the first response does not pass, the dialogue system can ensure smooth dialogue by updating the input content of the generative model based on the evaluation result.
[0104] Selectively, if the first response statement fails the evaluation, the evaluation result corresponding to the first response statement can be input into the generative model, and the second response statement output by the generative model can be obtained. Then, based on the second response statement, the evaluation process returns to obtaining and outputting a response statement that passes the evaluation.
[0105] In the embodiments of this disclosure, by inputting the evaluation result corresponding to the first response that fails the evaluation into the generative model, the generative model can be instructed to output the previously generated first response again based on the shortcomings included in the evaluation result, and an updated second response can be obtained. Subsequently, the second response is evaluated, and if the second response passes the evaluation, the second response can be output to the user. If the evaluation result of the second response still fails, a new evaluation result is input into the generative model to obtain a new response, and this process is repeated until the generated response passes the evaluation. In this way, the evaluation result of the response that failed the evaluation can be used to instruct the generative model to output the next response, further improving the reliability of the response, improving the quality of the dialogue, and ensuring the consistency of the dialogue.
[0106] In S406, if the first response passes the evaluation, the first response is output. The explanation of S406 above can be found in the above embodiment, so a further explanation is omitted here.
[0107] In this embodiment, by generating third prompt information using the first knowledge item, the first question, the second knowledge item, and the first answer, and instructing the evaluation model to output the evaluation result of the first answer, automatic evaluation and verification of the answer can be achieved, improving the evaluation efficiency and reliability of the evaluation result of the answer, and thereby improving the quality of the dialogue.
[0108] Figure 5 is a schematic flowchart of a dialogue generation method proposed by another embodiment of the present disclosure. As shown in Figure 5, the dialogue generation method includes steps S501 to S508.
[0109] In S501, the current first question and the history dialogue information associated with the first question are retrieved. In S502, the first knowledge item associated with the first question and the second knowledge item whose relationship to the first knowledge item is a response relationship are retrieved from the knowledge base. In S503, the first question, the first knowledge item, and the history dialogue information are input into the generative model, and the first answer is obtained from the generative model.
[0110] In S504, the first answer is evaluated based on the first question, the first knowledge item, and the second knowledge item. In S505, if the first response passes the evaluation, the first response is output. The explanations for S501 to S505 above can be found in the above embodiment, so we will omit further explanation here. In S506, if a second question is received in response to the first answer, a third answer corresponding to the second question is generated and output.
[0111] In the embodiments of this disclosure, after the dialogue system outputs a first response to the user, the user may have questions about the first response and may input a new second question in the dialogue interface. Therefore, the dialogue system can receive the second question regarding the first response and, based on the method described in the above embodiments, can obtain a third response output by the generative model that has passed evaluation and output it to the current dialogue interface.
[0112] In S507, if a third question for the third answer has not been received, a target answer corresponding to the first question is generated based on the first and third answers.
[0113] In the embodiments of this disclosure, if a third response is output to the dialogue interface and no third question is received in response to the third response, it can be determined that the first and third responses satisfy the user's needs and resolve the user's question (i.e., the question corresponding to the first question), and the first response, together with the third response, can be determined as the target response corresponding to the first question.
[0114] In S508, the first question and target answer are saved in a pre-configured database. The data in the pre-configured database is used to update and train the generative model.
[0115] In the embodiments of this disclosure, a first question and its corresponding target answer are stored as pairs in a pre-configured database. When the data in the pre-configured database reaches a certain amount or a pre-configured update time interval is reached, the generative model can be updated and trained using the data in the pre-configured database.
[0116] In this embodiment, when a second question is received in response to a first answer, a third answer corresponding to the second question is first generated and output. Subsequently, if a third question is not received in response to the third answer, a target answer corresponding to the first question is generated based on the first and third answer. Furthermore, the first question and target answer are saved in a pre-configured database. This allows the dialogue system to continuously adapt to new dialogue scenarios and user needs by iteratively optimizing the generated answer in accordance with user feedback, and by adjusting and training the parameters and policies of the generative model based on the question and its ultimately optimized answer content, thereby improving the overall performance of the dialogue system.
[0117] Figure 6 is a schematic diagram of a dialogue generation device proposed by one embodiment of the present disclosure. As shown in Figure 6, the dialogue generation device 600 includes the following: a first acquisition module 601, a second acquisition module 602, a generation module 603, an evaluation module 604, and an output module 605.
[0118] The first acquisition module 601 is configured to acquire the current first question and the history dialogue information associated with the first question. The second acquisition module 602 is configured to acquire from the knowledge base a first knowledge item associated with the first question and a second knowledge item whose relationship to the first knowledge item is a response relationship. The generation module 603 is configured to input a first question, a first knowledge item, and historical dialogue information into a generation model and to obtain a first answer output by the generation model. The evaluation module 604 is configured to evaluate the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item. The output module 605 is configured to output the first answer if the first answer passes the evaluation.
[0119] Selectively, the second acquisition module 602, Determine the first similarity between the first vector corresponding to the first question and the second vector corresponding to each knowledge item in the knowledge base. A knowledge item corresponding to a first similarity greater than the similarity threshold is determined as the first knowledge item. Based on a third vector corresponding to a first knowledge item, it is possible to configure the system to determine a second knowledge item whose relationship to the first knowledge item is a response relationship, where the third vector indicates the relationship between the first knowledge item and other knowledge items.
[0120] Selectively, the generating module 603 is If there are multiple first knowledge items, the first contribution of each first knowledge item is determined based on the similarity corresponding to each first knowledge item. Based on the first question, historical dialogue information, multiple first knowledge items, and the first contribution of each first knowledge item, first prompt information is generated. The system can be configured to input first prompt information into a generative model and obtain a first response sentence output by the generative model.
[0121] Selectively, the generating module 603 is If the first knowledge item is of a predefined type, determine the second contribution of each knowledge fragment within the first knowledge item to the second vector corresponding to that first knowledge item. Based on the second contribution, the target knowledge fragment is determined from the first knowledge item. Based on the first question, history dialogue information, and target knowledge fragment, second prompt information is generated. By inputting the second prompt information into the generative model, the first response sentence output by the generative model can be obtained.
[0122] Selectively, evaluation module 604, Determine the first similarity between the first question and the first knowledge item, and the second similarity between the first answer and the second knowledge item. The system can be configured to determine that the first response passes the evaluation if the difference between the first similarity score and the second similarity score is less than a distance threshold.
[0123] Selectively, evaluation module 604, Based on the first knowledge item, the first question, the second knowledge item, and the first answer, a third prompt information is generated. The system can be configured to input a third prompt into the evaluation model and obtain the evaluation results output by the evaluation model.
[0124] Selectively, evaluation module 604, Retrieve the third knowledge item associated with the first answer statement from the knowledge base. The third knowledge item and the second knowledge item are merged to obtain the merged knowledge item and the weight of the merged knowledge item. It can be configured to generate third prompt information based on a first knowledge item, a first question, a first answer, a fused knowledge item, and the weights of the fused knowledge item.
[0125] Selectively, evaluation module 604, The third similarity between the merged knowledge item and the first answer statement, and the number of occurrences of the merged knowledge item in the second and third knowledge items are determined. The system can be configured to determine the weights of the merged knowledge items based on a third similarity and / or frequency of occurrence.
[0126] Selectively, evaluation module 604 further, If the first response fails the evaluation, the evaluation result corresponding to the first response is input into the generative model, and the second response output by the generative model is obtained. Based on the second answer, the system can be configured to return to executing the evaluation process until it retrieves and outputs an answer that has passed the evaluation.
[0127] Selectively, output module 605 further, When a second question is received in response to the first answer, a third answer corresponding to the second question is generated and output. If a third question is not received for the third answer, a target answer corresponding to the first question is generated based on the first and third answers. The system can be configured to save the first question and target answer to a pre-configured database, and the data in the pre-configured database is used to update and train the generative model.
[0128] Furthermore, since the interpretation and explanation of the dialogue generation method also apply to the dialogue generation device according to this embodiment, a further explanation will be omitted here.
[0129] In this embodiment, by automatically generating response text by combining domain expertise related to the user's question text and historical dialogue information, the integration of dialogue responses with domain knowledge is achieved, improving the quality of response text and ensuring the consistency and coherence of the dialogue. Furthermore, by evaluating the generated response text, the accuracy of the response is improved, grammatical errors and logical inconsistencies in the response text are effectively reduced, and the user experience is optimized.
[0130] According to embodiments of the present disclosure, the present disclosure further provides an electronic device, a readable storage medium, and a computer program.
[0131] Figure 7 shows a schematic block diagram of an exemplary electronic device relating 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, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, mobile phones, smartphones, wearable devices, and other similar computing devices. The components, their connections and relationships, and their functions shown herein are merely examples and are not intended to limit the description herein and / or the implementation of the present disclosure as required.
[0132] As shown in Figure 7, device 700 includes a computing unit 701, which can perform various appropriate operations and processes based on computer programs stored in read-only memory (ROM) 702 or computer programs loaded from storage unit 707 into random access memory (RAM) 703. RAM 703 can also store various programs and data necessary for the operation of device 700. The computing unit 701, ROM 702, and RAM 703 are connected to each other via bus 704. An input / output (I / O) interface 705 is also connected to bus 704.
[0133] Multiple components in device 700 are connected to an I / O interface 705, which includes an input unit 706 such as a keyboard and 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, modem, and wireless communication transceiver. The communication unit 709 enables device 700 to exchange information / data with other devices via computer networks such as the Internet and / or various telecommunication networks.
[0134] The computing unit 701 may be a variety of 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), a variety of dedicated artificial intelligence (AI) computing chips, a variety of computing units that execute machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, 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 tangibly contained in a machine-readable medium such as a memory unit 707. In some embodiments, part or all of the computer program may be loaded and / or installed into the device 700 via the ROM 702 and / or the communication unit 709. Once 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 can be performed. Optionally, in other embodiments, the computing unit 701 may be configured to perform the dialogue generation method by any other suitable method (e.g., by firmware).
[0135] Various embodiments of the systems and technologies described herein can be implemented as digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-chip (SOCs), load-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments are implemented by one or more computer programs, which can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, which 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, at least one input device, and at least one output device.
[0136] Program code for carrying out the methods of this disclosure can be written using any combination of one or more programming languages. This program code can be provided to a 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 flowcharts and / or block diagrams will be performed. The program code may run entirely on a machine, partially on a machine, partially on a machine and partially on a remote machine as a standalone software package, or fully on a remote machine or server.
[0137] In the context of this disclosure, a machine-readable medium may be a tangible medium that contains or stores a program used by or in combination with an instruction execution system, apparatus, or device. 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, apparatus, or device, or any suitable combination thereof. More specific examples of machine-readable storage media include one or more line-based electrical connections, 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 thereof.
[0138] To provide user interaction, the systems and techniques described herein can be implemented on a computer, which has a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) and a keyboard and pointing device (e.g., a mouse or trackball), and the user can provide input to the computer using the keyboard and pointing device. Other types of devices can also provide user interaction, for example, the feedback provided to the user may be any form of sensing feedback (e.g., visual feedback, auditory feedback, or haptic feedback), and input from the user may be received in any form (including acoustic input, voice input, and haptic input).
[0139] The systems and technologies described herein can be implemented in a computing system including backend components (e.g., as a data server), a computing system including middleware components (e.g., an application server), a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser, through which the user interacts with embodiments of the systems and technologies described herein), or in a computing system including any combination of such backend components, middleware components, and frontend components. The components of the system can be interconnected via digital data communication in any form or medium (e.g., 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 geographically separated and typically interact via a communication network. The client-server relationship is created by computer programs running on corresponding computers that have a client-server relationship with each other. A server may be a cloud server, also called a cloud computing server or cloud host, and is a host product of a cloud computing service system, solving the shortcomings of traditional physical hosts and VPS (Virtual Private Server) services, which are difficult to manage and have limited scalability. A server may be a server in a distributed system, or a server combined with blockchain technology.
[0141] The steps can be rearranged, added, or deleted using the various forms of flows shown above. For example, each step described in this disclosure may be performed in parallel, sequentially, or in a different order, as long as the proposed techniques disclosed herein achieve the desired results.
[0142] Furthermore, the terms “first” and “second” are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features described. Accordingly, features limited by “first” and “second” may explicitly or implicitly include at least one of these features. In the descriptions of this disclosure, “plural” means at least two, such as two, three, etc., unless explicitly and specifically limited. In the descriptions of this disclosure, the word “when” may be interpreted as “when” or “at the time” or “depending on the decision” or “in the case.”
[0143] The specific implementation methods described above do not limit the scope of protection of this disclosure. Those skilled in the art can make various modifications, combinations, subcombinations, 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 be included within the scope of protection of this disclosure.
Claims
1. A dialogue generation method performed by a dialogue generation device, The steps include obtaining the current first question and the historical dialogue information associated with the first question, The steps include obtaining from a knowledge base a first knowledge item associated with the first question sentence and a second knowledge item whose relationship to the first knowledge item is a response relationship, The steps include inputting the first question, the first knowledge item, and the history dialogue information into a generative model to obtain the first answer output by the generative model, A step of evaluating the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item, The process includes the step of outputting the first response if the first response passes the evaluation, The step of evaluating the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item is: A step of determining a first similarity between the first question and the first knowledge item, and a second similarity between the first answer and the second knowledge item, A dialogue generation method comprising the step of determining that the first response sentence passes the evaluation if the difference between the first similarity and the second similarity is less than a distance threshold.
2. The step of obtaining from the knowledge base a first knowledge item associated with the first question and a second knowledge item whose relationship to the first knowledge item is a response relationship is: A step of determining 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, A step of determining a knowledge item corresponding to a first similarity greater than a similarity threshold as the first knowledge item, A dialogue generation method according to claim 1, comprising the step of determining 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, wherein the third vector indicates the relationship between the first knowledge item and other knowledge items.
3. The step of inputting the first question, the first knowledge item, and the history dialogue information into a generative formula model and obtaining the first answer output by the generative formula model is: If there are multiple first knowledge items, the first contribution of each first knowledge item is determined based on the similarity corresponding to each first knowledge item. A step of generating first prompt information based on the first question statement, the history dialogue information, a plurality of first knowledge items, and the first contribution of each of the first knowledge items, The dialogue generation method according to claim 2, comprising the steps of inputting the first prompt information into the generation formula model and obtaining a first response sentence output by the generation formula model.
4. The step of inputting the first question, the first knowledge item, and the history dialogue information into a generative formula model and obtaining the first answer output by the generative formula model is: If the first knowledge item is of a predetermined type, the steps include determining the second contribution of each knowledge fragment within the first knowledge item to the second vector corresponding to the first knowledge item, The steps include determining a target knowledge fragment from the first knowledge item based on the second contribution, A step of generating second prompt information based on the first question statement, the history dialogue information, and the target knowledge fragment, The dialogue generation method according to claim 2, further comprising the steps of inputting the second prompt information into the generation formula model and obtaining the first response sentence output by the generation formula model.
5. The step of evaluating the first answer statement based on the first question statement, the first knowledge item, and the second knowledge item is: A step of generating third prompt information based on the first knowledge item, the first question, the second knowledge item, and the first answer; The dialogue generation method according to claim 1, further comprising the steps of inputting the third prompt information into an evaluation model and obtaining an evaluation result output by the evaluation model.
6. The step of generating third prompt information based on the first knowledge item, the first question, the second knowledge item, and the first answer is: A step of obtaining a third knowledge item associated with the first answer sentence from the aforementioned knowledge base, A step of fusing the third knowledge item and the second knowledge item to obtain the fusing knowledge item and the weight of the fusing knowledge item, A dialogue generation method according to claim 5, comprising the step of generating third prompt information based on the first knowledge item, the first question, the first answer, the fused knowledge item, and the weights of the fused knowledge item.
7. The step of determining the weights of the aforementioned merged knowledge items is: The steps include determining a third similarity between the merged knowledge item and the first answer statement, and determining the number of occurrences of the merged knowledge item in the second and third knowledge items, A dialogue generation method according to claim 6, comprising the step of determining the weight of the fused knowledge items based on the third similarity and / or the frequency of occurrence.
8. After the step of evaluating the first response, If the first response does not pass the evaluation, the evaluation result corresponding to the first response is input to the generation formula model to obtain a second response output by the generation formula model. The dialogue generation method according to claim 1, further comprising the step of returning to executing an evaluation operation until an evaluation-passing response is obtained and output based on the second response.
9. After outputting the first response statement, When a second question is received in response to the first answer, the process involves generating and outputting a third answer corresponding to the second question. If a third question has not been received for the third answer, the steps include generating a target answer corresponding to the first question based on the first answer and the third answer, The process further includes the step of saving the first question and the target answer to a pre-configured database. The dialogue generation method according to claim 1, wherein the data in the pre-configured database is used for updating and training the generative formula model.
10. A dialogue generation device, A first acquisition module configured to acquire the current first question and the history dialogue information associated with the first question, A second acquisition module is configured to acquire from a knowledge base a first knowledge item associated with the first question statement and a second knowledge item whose relationship to 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 generation formula model and obtain the first answer sentence output by the generation formula 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, The system includes an output module configured to output the first response if the first response passes the evaluation, The aforementioned evaluation module is Determine the first similarity between the first question and the first knowledge item, and the second similarity between the first answer and the second knowledge item. A dialogue generation device configured to determine that the first response sentence passes the evaluation if the difference between the first similarity and the second similarity is less than a distance threshold.
11. The aforementioned second acquisition module is Determine the first similarity between the first vector corresponding to the first question statement and the second vector corresponding to each knowledge item in the knowledge base. A knowledge item corresponding to a first similarity greater than the similarity threshold is determined as the first knowledge item. Based on a third vector corresponding to the first knowledge item, it is configured to determine a second knowledge item whose relationship to the first knowledge item is a response relationship. The dialogue generation device according to claim 10, wherein the third vector indicates the relationship between the first knowledge item and other knowledge items.
12. The aforementioned generation module is If there are multiple first knowledge items, the first contribution of each first knowledge item is determined based on the similarity corresponding to each first knowledge item. Based on the first question statement, the history dialogue information, the plurality of first knowledge items, and the first contribution of each of the first knowledge items, first prompt information is generated. The dialogue generation device according to claim 11, configured to input the first prompt information into the generation formula model and obtain a first response sentence output by the generation formula model.
13. The aforementioned generation module is If the first knowledge item is of a predetermined type, a second contribution of each knowledge fragment within the first knowledge item to the second vector corresponding to the first knowledge item is determined. Based on the second contribution, the target knowledge fragment is determined from the first knowledge item. Based on the first question, the history dialogue information, and the target knowledge fragment, a second prompt information is generated. The dialogue generation device according to claim 11, configured to input the second prompt information into the generation formula model and obtain the first response sentence output by the generation formula model.
14. The aforementioned evaluation module is Based on the first knowledge item, the first question, the second knowledge item, and the first answer, a third prompt information is generated. A dialogue generation device according to any one of claims 10 to 13, configured to input the third prompt information into an evaluation model and to obtain an evaluation result output by the evaluation model.
15. The aforementioned evaluation module is A third knowledge item associated with the first answer sentence is obtained from the aforementioned knowledge base. The third knowledge item and the second knowledge item are merged to obtain the merged knowledge item and the weight of the merged knowledge item. The dialogue generation device according to claim 14, configured to generate third prompt information based on the first knowledge item, the first question, the first answer, the fused knowledge item, and the weights of the fused knowledge item.
16. The aforementioned evaluation module is The third similarity between the merged knowledge item and the first answer sentence, and the number of times the merged knowledge item appears in the second and third knowledge items are determined. The dialogue generation device according to claim 15, configured to determine the weight of the fused knowledge items based on the third similarity and / or the frequency of occurrence.
17. The aforementioned evaluation module further, If the first response does not pass the evaluation, the evaluation result corresponding to the first response is input to the generation formula model, and the second response output by the generation formula model is obtained. A dialogue generation device according to any one of claims 10 to 13, configured to return to executing an evaluation operation until it obtains and outputs an evaluation-passing answer based on the second answer.
18. The output module further, When a second question is received in response to the first answer, a third answer corresponding to the second question is generated and output. If a third question has not been received in response to the third answer, a target answer corresponding to the first question is generated based on the first answer and the third answer. The system is configured to store the first question and the target answer in a pre-configured database. The dialogue generation device according to any one of claims 10 to 13, wherein the data in the pre-configured database is used for updating and training the generation formula model.
19. It is an electronic device, At least one processor, Includes memory communicated to at least one processor, An electronic device in which the memory stores instructions that can be executed by the at least one processor, and the at least one processor can execute the dialogue generation method according to any one of claims 1 to 9 by executing the instructions by the at least one processor.
20. A non-temporary, computer-readable storage medium in which computer instructions are stored, The computer instruction is a non-temporary computer-readable storage medium that causes a computer to execute the dialogue generation method described in any one of claims 1 to 9.
21. It is a computer program, A computer program in which, when executed by a processor, the steps of the dialogue generation method described in any one of claims 1 to 9 are 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