Story continuation and dynamic knowledge base based dialogue generation method and system
Patent Information
- Application Number
- CN202211475495.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-23
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2042-11-23
AI Technical Summary
[0004]然而,上述对话生成方式采用的KGD系统的结构一般是构建一个稳定的知识资源池,构建的对话系统的自我成长性不足,在保持长期对话趣味性的能力上不足,很容易使用户失去兴趣,最终放弃对话
[0030]本申请的实施例提供的技术方案至少带来以下有益效果:本申请先对用户输入的初始背景故事进行抽取,并补充外部知识以构建可以动态更新的知识库。然后根据知识库内容和故事内容生成对话与用户交互,并对对话内容进行知识抽取,结合原故事进行故事续写。再根据续写的故事更新知识库,进行下一轮的对话生成和交互。通过迭代进行上述过程,实现故事续写和知识库的动态更新。从而,本申请实现基于初始背景故事和动态知识库进行故事续写,并将知识维护、故事续写和对话生成进行合理组合生成对话系统的结构。由此,在构建对话系统的同时,为其后台不断维护一个自增长的动态知识库和延伸的背景故事,从而使得对话系统更加真实,对话内容更加具有新颖性和趣味性,有利于引起用户的兴趣,增长交互时间,提升用户体验。
Smart Images

Figure CN115827838B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a dialogue generation method and system based on story continuation and dynamic knowledge base. Background Technology
[0002] With the development of natural language processing (NLP) technology, the application rate of ultra-large-scale pre-trained language models has gradually increased, leading to more comprehensive solutions for various downstream NLP tasks. As one of the core tasks of NLP, the generation of dialogues between intelligent AI robots and users is also developing towards higher realism and stronger performance.
[0003] In related technologies, when building a dialogue system, the knowledge-grounded dialogue (KGD) method is generally used. KGD involves adding knowledge-related corpora or text content before the normal dialogue system is generated, in order to improve the information content and accuracy of the dialogue generation results.
[0004] However, the KGD systems used in the aforementioned dialogue generation methods typically construct a stable knowledge resource pool. This results in a dialogue system with insufficient self-evolution capabilities and a lack of ability to maintain long-term engagement, easily causing users to lose interest and ultimately abandon the conversation. Furthermore, this method is prone to errors and logical confusion during the control of the large model needed for generation, further reducing credibility and appeal.
[0005] Therefore, improving the realism of dialogue systems and the engaging nature of generated content has become an urgent problem to be solved. Summary of the Invention
[0006] This application aims to at least partially address one of the technical problems in the related art.
[0007] Therefore, the first objective of this application is to propose a dialogue generation method based on story continuation and dynamic knowledge base. This method generates dialogue based on the framework of dynamic knowledge base and character story continuation, which improves the realism and fun of dialogue with AI.
[0008] The second objective of this application is to propose a dialogue generation system based on story continuation and a dynamic knowledge base.
[0009] The third objective of this application is to provide a non-transitory computer-readable storage medium.
[0010] To achieve the above objectives, a first aspect of this application proposes a dialogue generation method based on story continuation and a dynamic knowledge base, comprising the following steps:
[0011] Obtain the initial story input by the user, and determine the dialogue characters from the initial story;
[0012] A knowledge base is constructed by extracting knowledge related to the dialogue characters from the initial story and storing it in the knowledge base, and by acquiring external supplementary knowledge related to the existing knowledge in the knowledge base to update the knowledge base.
[0013] Based on the updated knowledge in the knowledge base and the initial story, generate a dialogue for interaction with the user, and obtain the dialogue returned by the user;
[0014] Extract event knowledge from the dialogue content, and continue the story based on the initial story and the event knowledge, and store the continued story in the knowledge base;
[0015] Based on the continued story, the knowledge base is updated, interactive dialogue with the user is conducted, and the story is continued in a loop until the dialogue ends.
[0016] Optionally, in one embodiment of this application, extracting knowledge related to the dialogue character from the initial story includes: training a preset pre-trained model to generate an information extraction model as an extractor; and extracting knowledge triplets related to the dialogue character from the initial story using the information extraction model according to the outline of the first extraction task.
[0017] Optionally, in one embodiment of this application, obtaining external supplementary knowledge related to existing knowledge in the knowledge base includes: obtaining the external supplementary knowledge from an external knowledge base, or searching for the external supplementary knowledge on the Internet through an external search engine.
[0018] Optionally, in one embodiment of this application, the knowledge base includes: structured knowledge and unstructured text, wherein the structured knowledge includes the knowledge triples related to the dialogue character and the external supplementary knowledge, and the unstructured text is extensible story content.
[0019] Optionally, in one embodiment of this application, generating a dialogue for interaction with the user based on the updated knowledge in the knowledge base and the initial story includes: generating the dialogue based on the knowledge in the knowledge base and the initial story using a preset dialogue generation framework within a machine reading comprehension framework, using a preset pre-trained language model as a base.
[0020] Optionally, in one embodiment of this application, extracting event knowledge from the dialogue content includes: extracting the event knowledge from the dialogue content using the information extraction model according to the outline of the second extraction task.
[0021] Optionally, in one embodiment of this application, story continuation based on the initial story and the event knowledge includes: performing post-mask prediction based on the initial story and the event knowledge, and extending and completing the initial story through a pre-trained language model.
[0022] To achieve the above objectives, a second aspect of this application proposes a dialogue generation system based on story continuation and a dynamic knowledge base, comprising the following modules:
[0023] The acquisition module is used to acquire the initial story input by the user and determine the dialogue characters from the initial story;
[0024] The update module is used to build a knowledge base, extract knowledge related to the dialogue characters from the initial story and store it in the knowledge base, and obtain external supplementary knowledge related to the existing knowledge in the knowledge base to update the knowledge base;
[0025] The generation module is used to generate a dialogue for interaction with the user based on the updated knowledge in the knowledge base and the initial story, and to obtain the dialogue returned by the user.
[0026] The continuation module is used to extract event knowledge from the dialogue content, and to continue the story based on the initial story and the event knowledge, and to store the continued story in the knowledge base;
[0027] The loop module is used to continuously update the knowledge base, interact with the user, and continue writing the story based on the continued story, until the dialogue ends.
[0028] Optionally, in one embodiment of this application, the update module is specifically used to: train a preset pre-trained model to generate an information extraction model as an extractor; and extract knowledge triples related to the dialogue characters from the initial story according to the outline of the first extraction task using the information extraction model.
[0029] To implement the above embodiments, a third aspect of this application also proposes a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the dialogue generation method based on story continuation and dynamic knowledge base in the above embodiments.
[0030] The technical solution provided by the embodiments of this application brings at least the following beneficial effects: This application first extracts the initial background story input by the user and supplements it with external knowledge to build a dynamically updated knowledge base. Then, it generates dialogue and interacts with the user based on the knowledge base content and story content, extracts knowledge from the dialogue content, and continues the story by combining it with the original story. The knowledge base is then updated based on the continued story, and the next round of dialogue generation and interaction is performed. By iteratively performing the above process, the dynamic updating of the story continuation and knowledge base is achieved. Thus, this application realizes the structure of a dialogue system by reasonably combining knowledge maintenance, story continuation, and dialogue generation based on the initial background story and dynamic knowledge base. Therefore, while building the dialogue system, a self-growing dynamic knowledge base and extended background stories are continuously maintained in its backend, making the dialogue system more realistic, the dialogue content more novel and interesting, which is conducive to arousing user interest, increasing interaction time, and improving user experience.
[0031] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0032] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein
[0033] Figure 1 A flowchart illustrating a dialogue generation method based on story continuation and a dynamic knowledge base proposed in an embodiment of this application;
[0034] Figure 2 A flowchart illustrating a specific dialogue generation method based on story continuation and a dynamic knowledge base, as proposed in an embodiment of this application;
[0035] Figure 3 This is a schematic diagram illustrating the principle of generating a dialogue according to an embodiment of this application;
[0036] Figure 4 This is a schematic diagram of the structure of a dialogue generation system based on story continuation and dynamic knowledge base proposed in an embodiment of this application. Detailed Implementation
[0037] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0038] It should be noted that current dialogue generation methods typically use KGD systems that build a static knowledge resource pool, lacking rapid knowledge updates and personalization of the agent. Their primary goal is to generate highly informative dialogues, but their anthropomorphism and engaging nature are limited, making it difficult to foster long-term dependence and trust in the dialogue. Therefore, this application proposes a dialogue generation method and system based on story continuation and a dynamic knowledge base to enhance the realism and engaging nature of the generated content in dialogue AI.
[0039] The following description, with reference to the accompanying drawings, illustrates a dialogue generation method and system based on story continuation and a dynamic knowledge base, as proposed in an embodiment of the present invention.
[0040] Figure 1 This is a flowchart of a dialogue generation method based on story continuation and a dynamic knowledge base proposed in an embodiment of this application, as shown below. Figure 1 The method includes the following steps:
[0041] Step S101: Obtain the initial story input by the user and determine the dialogue characters from the initial story.
[0042] It should be noted that the dialogue generation method of this application links the two tasks of story continuation and dialogue generation. Furthermore, this application is not merely a supplement to the integrity of the story, but rather an organic combination of story and dialogue, enabling dialogue between the story and the user.
[0043] Specifically, the initial story refers to the background and beginning of a story. Users can select the story they wish to engage in dialogue with and input it into the intelligent AI dialogue robot according to their preferences. Only the initial part of the story needs to be input, and this application can conduct dialogue with the user within the story background set by the user. The input story can be different types of narrative text, such as novels or plays, and there are no restrictions in this application.
[0044] In this context, the dialogue character is the target of the conversation with the user, and the dialogue character can be a character in the story input by the user. For example, the content of the initial story can be analyzed to determine the protagonist of the story as the dialogue character.
[0045] Step S102: Construct a knowledge base by extracting knowledge related to the dialogue characters from the initial story and storing it in the knowledge base, and by acquiring external supplementary knowledge related to the existing knowledge in the knowledge base to update the knowledge base.
[0046] Specifically, while building the dialogue system, an updatable database is created for the system's backend to continuously maintain this self-growing, dynamic knowledge base. Then, knowledge related to the dialogue characters is extracted from the initial input story and stored in the knowledge base.
[0047] Among them, the knowledge related to the dialogue characters can be a series of related knowledge such as the characters' relationships, personalities, preferences, external characteristics and other features. The extracted knowledge is stored in a certain form in the knowledge base, so that the database can start to be updated.
[0048] When extracting knowledge related to the dialogue characters, as a possible implementation method, this application can first train a preset pre-trained model to generate an information extraction model as an extractor, and then use the information extraction model to extract knowledge triplets related to the dialogue characters from the initial story according to the outline of the first extraction task.
[0049] In this embodiment, the preset pre-trained model is determined according to the information extraction model to be generated. For example, when this application selects open knowledge extraction models such as Universal Information Extraction (UIE) as extractors for knowledge extraction, ERINE can be selected as the pre-trained model.
[0050] The ERINE model employs the Transformer's Encoder as its backbone for training, applying a three-tiered Knowledge Masking strategy to the pre-training tasks during the ERINE pre-training process. These three levels of tasks enable ERINE to learn more language knowledge. The UIE model can perform various key information extraction tasks, including entity extraction, relation extraction, event extraction, and sentiment analysis. Because the UIE model supports information extraction from different domains and with different extraction targets, its use as an extractor in this application is better suited to different types of user-input stories.
[0051] In practice, the UIE model can be trained based on the ERNIE 3.0 pre-trained model. The specific training process can refer to the methods in related technologies, such as constructing the objective function for pre-training from three perspectives: from unstructured text to structured output, generation of structural relationships, and improvement of semantic representation.
[0052] Furthermore, after generating the UIE model, knowledge triples related to the dialogue characters are extracted from the initial story using the UIE model. Specifically, the UIE model can represent different information extraction task structures through a unified structure generation operation, thereby generating a unified structure output under different information extraction tasks. However, it is understandable that because different related knowledge needs to be extracted, the UIE model may perform different extraction tasks. The UIE model can extract the knowledge required for a specific task based on the outline (schema) of the extraction task.
[0053] In this embodiment, the first extraction task is to extract knowledge related to the dialogue characters from the initial story. The schema for this task can be "character: {personality, character relationships, preferences}" to extract knowledge triples related to the dialogue characters. In practice, the schema for this task can be added before the initial story and input into the UIE model. The UIE model, after fine-tuning the schema, extracts knowledge triples related to the dialogue characters, such as "(character A, characteristics, handsome)".
[0054] Furthermore, after acquiring knowledge related to the dialogue characters and storing it in the knowledge base, external knowledge is used to supplement it. External knowledge refers to knowledge not present in the established story, acquired through external means, and is also related to the dialogue characters, thus supplementing the extracted knowledge. For example, after extracting the knowledge of "(Character A, Characteristics, Handsome)" in the above example, the acquired external knowledge could be "(Character A, Gentle Personality)" or "(Character A, Hobbies, Reading)".
[0055] In a specific implementation, in one embodiment of this application, obtaining external supplementary knowledge related to existing knowledge in the knowledge base includes: obtaining external supplementary knowledge from an external knowledge base, or searching for external supplementary knowledge on the Internet through an external search engine.
[0056] Specifically, for the first approach, the external knowledge base can be a pre-defined database storing a large amount of knowledge, such as ATOMIC_zh, from which supplementary knowledge related to existing knowledge can be retrieved. For the second approach, the scope of knowledge searched by the dialogue system is expanded to the entire internet. By making the knowledge search scope sufficiently large and the update speed sufficiently fast, dynamic knowledge capabilities can be achieved in certain scenarios. Specifically, this can be accomplished by leveraging external search engines to find relevant content.
[0057] Therefore, the dynamic knowledge base is further updated by acquiring external knowledge. As described in the above embodiments, the content of the dynamic knowledge base constructed in this application includes: structured knowledge and unstructured text, i.e. Among them, structured knowledge K = <k i This includes extracting knowledge triples related to the dialogue characters and external supplementary knowledge, and unstructured text S = i >It refers to expandable story content, that is, the initial story set by the user and the story content that is subsequently written.
[0058] Step S103: Based on the knowledge in the updated knowledge base and the initial story, generate a dialogue for interaction with the user and obtain the dialogue returned by the user.
[0059] Specifically, based on the content in the current knowledge base and the initial story content, dialogue is generated in a controlled manner to produce language for communication with users.
[0060] In one embodiment of this application, generating a dialogue for user interaction includes: within a machine reading comprehension framework, using a pre-trained language model as a base, generating a dialogue based on knowledge in a knowledge base and an initial story through a pre-defined dialogue generation framework.
[0061] Specifically, machine reading comprehension (MRC) frameworks can extract corresponding answer spans from the context using queries to perform two multi-classification tasks. This application uses frameworks such as MRC for controllable dialogue generation. When generating dialogue sentences, a pre-trained language model (PLM) is first used as the basis for pre-training. The PLM uses a large amount of corpus data for pre-learning of ultra-large-scale parameters. This application uses such a model to easily generate high-quality, fluent language text. In specific applications, a specific pre-trained language model can be selected according to the actual dialogue needs. For example, the Chinese version of GLM-10B can be used as the basis, or a bilingual, bidirectional, dense model such as GLM-130B can also be used. Then, after training, XDAI's dialogue generation framework is used to combine knowledge base content and story content to generate the dialogue for this round of user interaction.
[0062] After the dialogue system generates a dialogue, if the dialogue is not closed, that is, if the user has multiple rounds of dialogue with the dialogue system, the dialogue returned by the user can be obtained in each round of dialogue. This allows for subsequent story continuation and dynamic knowledge base updates based on the user's words, and the generation of the next round of dialogue based on the user's words, making the generated dialogue more targeted.
[0063] Step S104: Extract event knowledge from the dialogue content, and continue the story based on the initial story and event knowledge, and store the continued story in the knowledge base.
[0064] The dialogue content includes the dialogue generated by the system in the previous round and the dialogue returned by the user. This application extracts events from the dialogue content of each round between the user and the system, and continues the initial story based on the knowledge of these events.
[0065] In one embodiment of this application, extracting event knowledge from dialogue content includes: extracting event knowledge from the dialogue content using an information extraction model based on the outline of a second extraction task. Specifically, the information extraction model is the model used in the above embodiments for extracting knowledge related to dialogue roles; in this embodiment, it is the UIE model. The second extraction task is the task of extracting event knowledge from the dialogue content. Since the current extraction task is to extract events from the dialogue, the outline schema of the second extraction task is "role: {event}". The specific process of extracting event knowledge can be referred to the above description of extracting knowledge related to dialogue roles, and will not be repeated here.
[0066] Furthermore, story continuation is performed based on the existing initial story and extracted event knowledge, that is, the subsequent content of the initial story is completed. In one embodiment of this application, story continuation based on the initial story and event knowledge includes: performing post-mask prediction based on the initial story and event knowledge, and extending and completing the initial story using a pre-trained language model. Specifically, the pre-trained language model used for story continuation can be the same as the pre-trained language model used when generating the dialogue. In this embodiment, post-mask prediction is performed using the event knowledge in the original story and dialogue, and story completion and generation are performed using GLM. Then, the story of this round of continuation is added to the knowledge base to achieve further updates to the knowledge base.
[0067] Step S105: Based on the continued story, the knowledge base is updated, interactive dialogue with the user is conducted, and the story is continued in a loop until the dialogue ends.
[0068] Specifically, the process involves determining whether the dialogue has ended, for example, by checking if the user has inputted a message to end the dialogue, such as "Okay, goodbye" or "Conversation ended." If the dialogue has not ended, the process of updating the knowledge base, interacting with the user, and continuing the story is repeated. That is, in the new round of dialogue, the relevant operations in steps S102 to S104 above are repeated, including extracting knowledge using the UIE model based on the event knowledge from the previous round of dialogue interaction, acquiring external supplementary knowledge, and generating the current round of dialogue. If the dialogue is not closed after the current round of dialogue ends, the process of extracting event knowledge and continuing the story continues until the dialogue ends.
[0069] Thus, this application realizes a story continuation method based on an initial background story and a dynamic knowledge base, as well as a dialogue system structure that rationally combines knowledge maintenance, story continuation, and dialogue generation.
[0070] In summary, the dialogue generation method based on story continuation and a dynamic knowledge base in this application first extracts the initial background story input by the user and supplements it with external knowledge to construct a dynamically updated knowledge base. Then, it generates dialogue for user interaction based on the knowledge base content and the story content, extracts knowledge from the dialogue content, and combines it with the original story to continue the story. Next, it updates the knowledge base based on the continued story and proceeds to the next round of dialogue generation and interaction. By iteratively performing the above process, the dynamic updating of the story continuation and knowledge base is achieved. Thus, this method enables story continuation based on the initial background story and a dynamic knowledge base, and rationally combines knowledge maintenance, story continuation, and dialogue generation to generate the structure of a dialogue system. Therefore, while constructing the dialogue system, this method continuously maintains a self-growing dynamic knowledge base and extended background stories in its backend, making the dialogue system more realistic, the dialogue content more novel and interesting, which is conducive to arousing user interest, increasing interaction time, and improving user experience.
[0071] Based on the above embodiments, in order to more clearly describe the specific processing flow of the dialogue generation method based on story continuation and dynamic knowledge base of this application, a specific dialogue generation method proposed in conjunction with a specific background story is described below in one embodiment of this application. Figure 2 The flowchart illustrates a specific dialogue generation method based on story continuation and a dynamic knowledge base, as proposed in an embodiment of this application. Figure 3 This is a schematic diagram illustrating the principle of generating a dialogue according to an embodiment of this application.
[0072] like Figure 2 As shown, the method includes the following steps:
[0073] Step S201: Obtain the user's input settings and confirm the role.
[0074] Specifically, in this embodiment, the user-inputted story is first obtained, and the characters in the story are used as the settings for the AI dialogue robot. The story is: "Once upon a time, there was a miller who, when he died, left his three sons only a mill, a donkey, and Puss in Boots. This inheritance was quickly divided up by the sons, without a notary or a lawyer present, because if they came, they would surely take everything for themselves. As a result, the strongest eldest son took the mill, the smartest second son took the donkey, and in the end, only the cat was left to the handsome but only handsome youngest son. Although this cat seemed only capable of catching mice, there were no mice in the house..." By analyzing the content of this story, the character is identified as "Puss in Boots".
[0075] Step S202: The knowledge base begins to be updated.
[0076] Specifically, using open knowledge extraction models such as UIE, knowledge triples related to the dialogue characters are extracted: "(Puss in Boots, former owner, miller), (Puss in Boots, current owner, third son), (third son, characteristics, handsome)...". In this process, this embodiment uses ERINE as a pre-trained model and UIE extraction tool as the extractor, setting the schema as "character: {personality, relationships, preferences}".
[0077] Step S203: Obtain supplementary external knowledge.
[0078] Specifically, additional supplementary knowledge related to existing knowledge can be obtained from external knowledge bases, such as ATOMIC_zh, such as "(a cat is a mammal) (a cat likes to catch mice) (a cat respects its owner)", to further update the knowledge base.
[0079] Step S204: Perform controllable generation of dialogue.
[0080] Specifically, based on knowledge base content and story content, and using frameworks such as MRC, dialogue is generated in a controllable manner. The generation mainly uses the Chinese version of the pre-trained language model GLM-10B as the base and uses XDAI's dialogue generation framework for generation.
[0081] Step S205: Determine whether the dialogue is closed. If it is not closed, extract event knowledge.
[0082] Specifically, if the dialogue is closed, the process ends; if the dialogue is not closed, the UIE model is used to extract knowledge from the dialogue based on the dialogue content, and the schema is set to "role: {event}".
[0083] Step S206: Complete and generate the story.
[0084] Specifically, based on step S205, the event knowledge in the original story and dialogue is used to perform post-mask prediction, and GLM is used to complete and generate the story.
[0085] Step S207: Repeat the knowledge update.
[0086] Specifically, based on step S206, the UIE model is used again to extract relevant knowledge, and steps S202 to S204 are repeated.
[0087] Therefore, the principle of dialogue generation in this application is as follows: Figure 3 As shown, while building the dialogue system, a self-growing dynamic knowledge base and extended background stories are continuously maintained in its backend, making the dialogue system more realistic and the content more novel and interesting.
[0088] It should be noted that the specific implementation of each step in this embodiment can be referred to the relevant description in the above embodiment, and will not be repeated here.
[0089] To achieve the above embodiments, this application also proposes a dialogue generation system based on story continuation and dynamic knowledge base. Figure 4 This is a schematic diagram of the structure of a dialogue generation system based on story continuation and dynamic knowledge base proposed in an embodiment of this application.
[0090] like Figure 4 As shown, the system includes an acquisition module 100, an update module 200, a generation module 300, a continuation module 400, and a loop module 500.
[0091] The acquisition module 100 is used to acquire the initial story input by the user and determine the dialogue characters from the initial story.
[0092] The update module 200 is used to build a knowledge base. It extracts knowledge related to the dialogue characters from the initial story and stores it in the knowledge base. It also obtains external supplementary knowledge related to the existing knowledge in the knowledge base to update the knowledge base.
[0093] The generation module 300 is used to generate dialogues that interact with the user based on the knowledge in the updated knowledge base and the initial story, and to obtain the dialogues returned by the user.
[0094] The continuation module 400 is used to extract event knowledge from the dialogue content, and to continue the story based on the initial story and event knowledge, and then store the continued story in the knowledge base.
[0095] The loop module 500 is used to continuously update the knowledge base, interact with the user, and continue writing the story based on the continued story, until the dialogue ends.
[0096] Optionally, in one embodiment of this application, the update module 200 is specifically used to: train a preset pre-trained model to generate an information extraction model as an extractor; and extract knowledge triples related to the dialogue characters from the initial story according to the outline of the first extraction task through the information extraction model.
[0097] Optionally, in one embodiment of this application, the update module 200 is further configured to: obtain external supplementary knowledge from an external knowledge base, or complete the search for external supplementary knowledge on the Internet through an external search engine.
[0098] Optionally, in one embodiment of this application, the knowledge base includes structured knowledge and unstructured text, wherein the structured knowledge includes knowledge triples related to the dialogue characters and external supplementary knowledge, and the unstructured text is extensible story content.
[0099] Optionally, in one embodiment of this application, the generation module 300 is specifically used to: generate the dialogue based on knowledge in the knowledge base and the initial story through a preset dialogue generation framework, using a preset pre-trained language model as the basis, within a machine reading comprehension framework.
[0100] Optionally, in one embodiment of this application, the continuation module 400 is specifically used to: extract event knowledge from the dialogue content according to the outline of the second extraction task through an information extraction model.
[0101] Optionally, in one embodiment of this application, the continuation module 400 is further configured to: perform subsequent mask prediction based on the initial story and event knowledge, and extend and complete the initial story through a pre-trained language model.
[0102] It should be noted that the foregoing description of the dialogue generation method based on story continuation and dynamic knowledge base is also applicable to the system of this embodiment, and the implementation principle is the same, so it will not be repeated here.
[0103] In summary, the dialogue generation system based on story continuation and a dynamic knowledge base in this application first extracts the initial background story input by the user and supplements it with external knowledge to construct a dynamically updated knowledge base. Then, it generates dialogue for user interaction based on the knowledge base content and the story content, extracts knowledge from the dialogue content, and combines it with the original story to continue the story. The knowledge base is then updated based on the continued story, leading to the next round of dialogue generation and interaction. By iteratively performing the above process, the dynamic updating of the story continuation and knowledge base is achieved. Thus, this system realizes story continuation based on the initial background story and a dynamic knowledge base, and rationally combines knowledge maintenance, story continuation, and dialogue generation to generate the structure of the dialogue system. Therefore, while constructing the dialogue system, the system continuously maintains a self-growing dynamic knowledge base and extended background stories in its backend, making the dialogue system more realistic, the dialogue content more novel and interesting, which helps to arouse user interest, increase interaction time, and improve user experience.
[0104] To implement the above embodiments, the present invention also proposes a non-transitory computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the dialogue generation method based on story continuation and dynamic knowledge base described in the first aspect of the present application.
[0105] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the use of illustrative expressions for the above terms in multiple embodiments or examples does not imply that these embodiments or examples are identical. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0106] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0107] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0108] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0109] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0110] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it includes one or a combination of the steps of the method embodiments.
[0111] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0112] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A dialogue generation method based on story continuation and a dynamic knowledge base, characterized in that, Includes the following steps: Obtain the initial story input by the user, and determine the dialogue characters from the initial story; A knowledge base is constructed by extracting knowledge related to the dialogue characters from the initial story and storing it in the knowledge base, and by acquiring external supplementary knowledge related to the existing knowledge in the knowledge base to update the knowledge base. The extraction of knowledge related to the dialogue characters from the initial story includes: Train the pre-trained model to generate an information extraction model as an extractor; The information extraction model extracts knowledge triplets related to the dialogue characters from the initial story according to the outline of the first extraction task. The knowledge base includes: structured knowledge and unstructured text, wherein the structured knowledge includes the knowledge triples related to the dialogue character and the external supplementary knowledge, and the unstructured text is extensible story content; The acquisition of external supplementary knowledge related to existing knowledge in the knowledge base includes: The external supplementary knowledge can be obtained from an external knowledge base, or the external supplementary knowledge can be searched on the Internet through an external search engine; Based on the updated knowledge in the knowledge base and the initial story, generate a dialogue for interaction with the user, and obtain the dialogue returned by the user; The information extraction model extracts event knowledge from the dialogue content according to the outline of the second extraction task, and continues the story based on the initial story and the event knowledge. The continued story is then stored in the knowledge base. The process of continuing the story based on the initial story and the knowledge of the events includes: Based on the initial story and the event knowledge, a subsequent mask prediction is performed, and the initial story is extended and completed using a pre-trained language model; Based on the continued story, the knowledge base is updated, interactive dialogue with the user is conducted, and the story is continued in a loop until the dialogue ends.
2. The dialogue generation method according to claim 1, characterized in that, The step of generating a dialogue for interaction with the user based on the updated knowledge base and the initial story includes: Within the machine reading comprehension framework, a pre-trained language model is used as the base, and a pre-defined dialogue generation framework is used to generate the dialogue based on the knowledge in the knowledge base and the initial story.
3. A dialogue generation system based on story continuation and a dynamic knowledge base, characterized in that, Includes the following modules: The acquisition module is used to acquire the initial story input by the user and determine the dialogue characters from the initial story; The update module is used to build a knowledge base, extract knowledge related to the dialogue characters from the initial story and store it in the knowledge base, and obtain external supplementary knowledge related to the existing knowledge in the knowledge base to update the knowledge base; The update module is specifically used for: Train the pre-trained model to generate an information extraction model as an extractor; The information extraction model extracts knowledge triplets related to the dialogue characters from the initial story according to the outline of the first extraction task. The knowledge base includes: structured knowledge and unstructured text, wherein the structured knowledge includes the knowledge triples related to the dialogue character and the external supplementary knowledge, and the unstructured text is extensible story content; The acquisition of external supplementary knowledge related to existing knowledge in the knowledge base includes: The external supplementary knowledge can be obtained from an external knowledge base, or the external supplementary knowledge can be searched on the Internet through an external search engine; The generation module is used to generate a dialogue for interaction with the user based on the updated knowledge in the knowledge base and the initial story, and to obtain the dialogue returned by the user. The story continuation module is used to extract event knowledge from the dialogue content according to the outline of the second extraction task using the information extraction model, and to continue the story based on the initial story and the event knowledge, storing the continued story in the knowledge base. The process of continuing the story based on the initial story and the knowledge of the events includes: Based on the initial story and the event knowledge, a subsequent mask prediction is performed, and the initial story is extended and completed using a pre-trained language model; The loop module is used to continuously update the knowledge base, interact with the user, and continue writing the story based on the continued story, until the dialogue ends.
4. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the dialogue generation method based on story continuation and dynamic knowledge base as described in any one of claims 1-2.
Citation Information
Patent Citations
Text generation algorithm fusing multi-type knowledge base and reasoning technology
CN115358289A
Story Development Tool
US20160136524A1
