Narrative generation method and device, electronic equipment and storage medium

CN115879420BActive Publication Date: 2026-10-27IFLYTEK CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211734185.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-30
Publication Date
2026-10-27
Estimated Expiration
2042-12-30

AI Technical Summary

Technical Problem

这种方法往往难以把握故事中隐含的事件发展脉络,同时也常常无法关注到长文本中的长程逻辑依赖,对用户输入的信息关注度不佳

Benefits of technology

[0035]本发明提供的记叙文生成方法、装置、电子设备及存储介质,该方法首先获取用户输入的叙事情节概述;然后抽取叙事情节概述中的初始事件序列,并基于初始事件序列中各事件节点的关键信息,对初始事件序列进行扩展,得到目标事件序列;最后基于目标事件序列,生成目标记叙文文本。该方法通过抽取叙事情节概述中的初始事件序列并对其进行扩展,可以充分挖掘叙事情节概述中的事件关系,可以准确把握事件发展脉络,如此可以保证根据目标事件序列生成的目标记叙文文本具有清晰明确的逻辑发展,可读性更强,质量更高。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115879420B_ABST
    Figure CN115879420B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of natural language processing, and provides a narrative text generation method and device, electronic equipment and a storage medium. The method comprises the following steps: firstly, obtaining a narrative plot summary input by a user; then, extracting an initial event sequence in the narrative plot summary, and expanding the initial event sequence based on key information of each event node in the initial event sequence to obtain a target event sequence; and finally, generating a target narrative text based on the target event sequence. The method can fully mine the event relationship in the narrative plot summary by extracting and expanding the initial event sequence in the narrative plot summary, can accurately grasp the event development context, and thus can ensure that the target narrative text generated according to the target event sequence has a clear and definite logical development, is more readable, and has higher quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a narrative text generation method, apparatus, electronic device, and storage medium. Background Technology

[0002] Narrative writing is a genre that primarily records one's own or others' experiences. In the process of writing a narrative, the most important content is the development and changes of events, namely, the cause, development, and result of the event. Due to a lack of relevant life experience and writing skills, most students find it difficult to write a narrative that is rich in content, has a compelling plot, and conveys genuine emotion. Therefore, to meet the need to provide students with narrative writing ideas and materials, it is crucial to propose methods for generating narratives.

[0003] However, no narrative text generation method exists in the current technology. Since both stories and narrative texts belong to the category of narrative text, story generation methods and narrative text generation methods share certain similarities. However, one existing story generation method mainly relies on the story's title to generate key plot points, and then generates a complete story based on the title and key plot points. This method does not fully utilize information about event relationships when generating key plot points. Therefore, the generated stories suffer from problems such as repetition and logical inconsistencies. Another existing story generation method introduces common sense knowledge into the story generation process. It uses common sense knowledge from knowledge graphs as information sources, inputting the information sources along with a large-scale corpus into a pre-trained model for pre-training, thereby encoding the common sense knowledge into the story generation model. This method often struggles to grasp the implicit event development in the story and often fails to pay attention to long-range logical dependencies in long texts, showing poor attention to user input information. Specifically, the generated stories easily deviate from the user input information and lack clear logical development during the writing process.

[0004] Therefore, existing story generation methods are not effective when used to generate narrative texts, and there is an urgent need to provide a new narrative text generation method. Summary of the Invention

[0005] This invention provides a narrative text generation method, apparatus, electronic device, and storage medium to address the deficiencies in the prior art.

[0006] This invention provides a method for generating narrative text, comprising:

[0007] Obtain a narrative summary from user input;

[0008] Extract the initial event sequence from the narrative plot overview, and expand the initial event sequence based on the key information of each event node in the initial event sequence to obtain the target event sequence;

[0009] Based on the target event sequence, a target narrative text is generated.

[0010] According to a narrative text generation method provided by the present invention, the step of extracting the initial event sequence from the narrative plot overview includes:

[0011] The narrative summary is input into the event extraction model to obtain the initial event sequence output by the event extraction model;

[0012] The event extraction model is trained based on the first narrative text sample and the sequence of sample events therein.

[0013] According to a narrative text generation method provided by the present invention, the event extraction model is trained based on the following steps:

[0014] Based on the first narrative text sample and the sample event sequence therein, the initial extraction model is trained to obtain the candidate extraction model.

[0015] A second narrative text sample is determined and input into the candidate extraction model to obtain the sample event sequence in the second narrative text sample output by the candidate extraction model.

[0016] Based on the second narrative text sample and the sample event sequence therein, the candidate extraction model is trained to obtain the event extraction model.

[0017] According to a narrative text generation method provided by the present invention, the step of training the candidate extraction model based on a second narrative text sample and a sequence of sample events therein to obtain the event extraction model includes:

[0018] Based on the chapter event matching rules and / or the logical correlation of event sequences, the data sample pairs consisting of the second narrative chapter sample and the sample event sequences therein are filtered to obtain target data sample pairs. Based on the target data sample pairs, the candidate extraction model is trained to obtain the event extraction model.

[0019] According to a narrative text generation method provided by the present invention, the step of generating target narrative text based on the target event sequence includes:

[0020] Receive the prompt information input by the user;

[0021] The prompt information and the target event sequence are input into the text generation model, which encodes the prompt information and the target event sequence respectively, and decodes the encoded results to obtain and output the target narrative text.

[0022] The text generation model is trained based on a third narrative text sample, sample prompts from the third narrative text sample, and sample event sequences from the third narrative text sample.

[0023] According to a narrative text generation method provided by the present invention, the loss function used in the training process of the text generation model includes an event node average interval distance penalty term, which is used to characterize the loss caused by the average length of the positional interval of each event node in the sample event sequence in the third narrative text sample.

[0024] According to a narrative text generation method provided by the present invention, the step of expanding the initial event sequence based on key information of each event node in the initial event sequence to obtain a target event sequence includes:

[0025] Receive the narrative title input by the user;

[0026] Based on the narrative title and the key information, the initial event sequence is expanded to obtain multiple alternative event sequences;

[0027] Based on the logical correlation of the event sequences, the multiple candidate event sequences are filtered to obtain the target event sequence.

[0028] The present invention also provides a narrative text generation system, comprising:

[0029] The acquisition module is used to acquire a narrative summary input by the user;

[0030] The event development planning module is used to extract the initial event sequence from the narrative plot overview, and expand the initial event sequence based on the key information of each event node in the initial event sequence to obtain the target event sequence;

[0031] The narrative text generation module is used to generate target narrative text based on the target event sequence.

[0032] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the narrative generation method as described above.

[0033] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the narrative generation method as described above.

[0034] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the narrative text generation method as described above.

[0035] The present invention provides a narrative text generation method, apparatus, electronic device, and storage medium. The method first obtains a narrative summary input by the user; then, it extracts an initial event sequence from the narrative summary and expands the initial event sequence based on key information of each event node to obtain a target event sequence; finally, it generates a target narrative text based on the target event sequence. This method, by extracting and expanding the initial event sequence from the narrative summary, can fully explore the event relationships within the summary and accurately grasp the development of events. This ensures that the target narrative text generated from the target event sequence has a clear and logical development, resulting in higher readability and quality. Attached Figure Description

[0036] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on the drawings described below without creative effort.

[0037] Figure 1 This is a flowchart illustrating the narrative text generation method provided by the present invention;

[0038] Figure 2 This is a schematic diagram of the narrative text generation system provided by the present invention;

[0039] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0040] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0041] There is currently a strong demand for AI-powered narrative writing in the online education field. However, existing products on the market are limited to generating complete narrative texts based on user input (such as essay titles and introductions). Users lack fine-grained control over the writing process, making it difficult to meet their customized narrative writing needs. Even existing story generation methods cannot produce excellent narrative texts. Therefore, this invention provides a narrative text generation method.

[0042] Figure 1 This is a flowchart illustrating a narrative text generation method provided in an embodiment of the present invention, such as... Figure 1 As shown, the method includes:

[0043] S1, Obtain the narrative summary input by the user;

[0044] S2, extract the initial event sequence from the narrative plot overview, and expand the initial event sequence based on the key information of each event node in the initial event sequence to obtain the target event sequence;

[0045] S3, Based on the target event sequence, generate the target narrative text.

[0046] Specifically, the narrative text generation method provided in this embodiment of the invention is executed by a narrative text generation system, which can be configured in a computer. The computer can be a local computer or a cloud computer. The local computer can be a computer, tablet, etc., and no specific limitation is made here.

[0047] First, perform step S1 to obtain a narrative summary input by the user. This user can be a student or someone else who needs to utilize the automatically generated target narrative text.

[0048] A narrative summary is a descriptive text of the narrative elements contained in the desired narrative text. It can be used to control the plot development of the subsequently generated target narrative text. Each narrative text may include one or more narrative elements, and consequently, each narrative summary may include one or more narrative elements, with each narrative summary corresponding to one narrative element.

[0049] For example, considering the user's own situation and the effect of the subsequent generated target narrative text, the narrative plot summary can preferably be 3.

[0050] In addition to inputting a narrative summary, users can also input prompts, which may include the narrative title and preceding text. The narrative title refers to the title of the narrative the user needs, representing the main content and theme. The preceding text provides detailed information for generating the target narrative.

[0051] Then, step S2 is executed to extract the initial event sequence from the narrative overview. Each narrative overview corresponds to an initial event sequence, which is a coarse-grained main event chain, a sequence of event descriptions that references the actual development order of events, and can fully summarize the main event development logic in the narrative overview. The initial event sequence may include several logically related event nodes, used to represent the causal relationships and logical connections between events in the narrative. Each event node is an event description.

[0052] For example, the narrative could be summarized as "Dad took me hiking in People's Park, and I also brought a book to read. Just as I was engrossed in reading, suddenly, 'smack!' I bumped into a tree, and my face was covered in tree bark, and I had a small bump on my forehead. It hurt so much that I saw stars." The extracted initial event sequence could include 6 event nodes: "Dad-took-me", "I-went-to-People's Park", "I-brought-a-book", "I-bumped-a-tree", "My face-covered-tree-bark" and "My forehead-grown-a-small bump".

[0053] The initial event sequence extraction process can be implemented through an event extraction model or other methods, without specific limitations here.

[0054] Furthermore, key information for each event node in the initial event sequence can be determined. This key information may include key figures and their emotional polarity. Key figures can be extracted using Named Entity Recognition (NER) tools, and emotional polarity can be determined using a sentiment dictionary method.

[0055] Since the initial event sequence often lacks detailed information on the development of events, directly using it to generate the target narrative text may result in disjointed and difficult-to-understand content. Here, we utilize the narrative title and key information from each event node in the initial event sequence to expand it, thus obtaining the target event sequence. The purpose of this expansion is to address the mismatch between the amount of information in the user-input narrative summary and the amount of information required to generate the target narrative text.

[0056] The expansion process involves inserting event descriptions based on key information between each event node in the initial event sequence. This enhances the detailed description capabilities of the initial event sequence while maintaining its original event development logic, resulting in a complete target event sequence. This target event sequence can be explicitly matched one-to-one with text fragments in the subsequently generated target narrative text. The target event sequence can be displayed to the user, who can then modify it to further guide the generation of the target narrative text, making it more aligned with user needs.

[0057] Finally, step S3 is executed to generate a high-quality target narrative text based on the target event sequence. This means that a complete target narrative text can be generated according to the logical development path of the events constrained by the target event sequence. This target narrative text can be a text that is consistent with the event plot summary and has fluent language and clear logic. Since the target event sequence already contains the plot development and logical information required to generate the target narrative text, the discrete and atomized event nodes can be transformed into a coherent, logical, readable, and easily understood target narrative text by converting the target event sequence into natural language.

[0058] In other words, the target event sequence obtained in step S2 provides a coarse-grained plot framework for the automatic generation of the target narrative text, while step S3 refines this coarse-grained plot framework, outputting a coherent and logical target narrative text corresponding to the event development plan. Therefore, this narrative text generation method can be considered a two-stage automatic narrative text generation method. Step S2 is the first stage, namely the stage of generating the target event sequence, and step S3 is the second stage, namely the stage of generating the target narrative text. The separation of the two stages allows each stage to focus more on its respective task.

[0059] The narrative text generation method provided in this embodiment of the invention first obtains a narrative plot overview input by the user; then, it extracts an initial event sequence from the narrative plot overview and expands the initial event sequence based on the key information of each event node in the initial event sequence to obtain a target event sequence; finally, it generates a target narrative text based on the target event sequence. This method, by extracting and expanding the initial event sequence from the narrative plot overview, can fully explore the event relationships within the overview and accurately grasp the development of events. This ensures that the target narrative text generated based on the target event sequence has a clear and explicit logical development, resulting in stronger readability and higher quality.

[0060] An ideal event sequence should be able to fully summarize the main events in the corresponding narrative passage and abstract the interrelationships between characters and events. For example, an event triple extraction method based on custom rules and part-of-speech tagging can be used; however, this method does not produce high-quality event sequences, which greatly affects the effectiveness of subsequent work.

[0061] Therefore, based on the above embodiments, the narrative text generation method provided in this embodiment of the invention, wherein extracting the initial event sequence from the narrative plot overview includes:

[0062] The narrative summary is input into the event extraction model to obtain the initial event sequence output by the event extraction model;

[0063] The event extraction model is trained based on the first narrative text sample and the sequence of sample events therein.

[0064] Specifically, when extracting the initial event sequence, an event extraction model can be introduced. This involves inputting a narrative summary into the event extraction model to obtain the initial event sequence output by the model. This event extraction model can be built based on the BART model and trained using the first narrative text sample and its sample event sequences.

[0065] The first batch of narrative text samples can be extracted from a large number of narrative texts obtained through web scraping. The event sequences in these first batch of narrative text samples can be obtained through manual annotation. An event triple annotation model is trained using these manually annotated event sequences. Considering the complexity of event triples and the phenomenon of partial overlap, a text generation paradigm is used to implement the event extraction model. The event extraction model is then applied to a large number of narrative texts, resulting in a substantial number of sample event sequences and their corresponding first batch of narrative text samples.

[0066] When training the BART model, the first narrative text sample can be input into the BART model to obtain the extraction result output by the BART model. Then, the loss function is calculated using the sample event sequence in the first narrative text sample and the extraction result. When the loss function converges, the trained event extraction model is obtained.

[0067] In this embodiment of the invention, the initial event sequence is extracted using an event extraction model, which can greatly improve the extraction efficiency and the accuracy of the initial event sequence, thereby generating high-quality target narrative text.

[0068] Based on the above embodiments, the narrative text generation method provided in this embodiment of the invention uses an event extraction model trained based on the following steps:

[0069] Based on the first narrative text sample and the sample event sequence therein, the initial extraction model is trained to obtain the candidate extraction model.

[0070] A second narrative text sample is determined and input into the candidate extraction model to obtain the sample event sequence in the second narrative text sample output by the candidate extraction model.

[0071] Based on the second narrative text sample and the sample event sequence therein, the candidate extraction model is trained to obtain the event extraction model.

[0072] Specifically, when training an event extraction model, the sample size used during training can be expanded to improve the performance of the event extraction model.

[0073] We can first use conventional training methods, using the first narrative text sample and its sample event sequences, to train the initial extraction model and obtain a candidate extraction model. This candidate extraction model already has the function of extracting event sequences.

[0074] After that, a second narrative sample can be determined. This second narrative sample can also be obtained from a large number of narrative samples crawled from the Internet, but the event sequence in this second narrative sample does not need to be manually labeled.

[0075] The second narrative text sample is then input into the candidate extraction model, which extracts and outputs the sequence of sample events.

[0076] Then, the candidate extraction model can be trained using the second narrative text sample and the sample event sequence therein to obtain the event extraction model.

[0077] In this embodiment of the invention, by applying the alternative extraction model to a large-scale unsupervised second narrative text sample, the sample can be expanded, thereby improving the performance of the event extraction model.

[0078] Based on the above embodiments, the narrative text generation method provided in this embodiment of the invention, wherein training the candidate extraction model based on the second narrative text sample and the sample event sequence therein to obtain the event extraction model includes:

[0079] Based on the chapter event matching rules and / or the logical correlation of event sequences, the data sample pairs consisting of the second narrative chapter sample and the sample event sequences therein are filtered to obtain target data sample pairs. Based on the target data sample pairs, the candidate extraction model is trained to obtain the event extraction model.

[0080] Specifically, after obtaining the second narrative text samples and the sample event sequences therein, each second narrative text sample and its sample event sequence can constitute a data sample pair. To further improve the quality of the data sample pairs used to train the candidate extraction model, the data sample pairs consisting of the second narrative text samples and their sample event sequences can be filtered.

[0081] Filtering strategies can include filtering based on chapter event matching rules and filtering based on the logical relevance of event sequences. Either strategy can be chosen, or they can be executed sequentially. In this case, the execution order can be set as needed, and no specific limitation is made here.

[0082] The text event matching rules can be manually designed and derived from relevant linguistic research literature to match event information in narrative texts. When using text event matching rules for filtering, the data sample pairs consisting of the second narrative text sample and the sample event sequences within it can be matched one by one with each text event matching rule. Data sample pairs that match are retained, while data sample pairs that fail to match are discarded.

[0083] As a highly abstract representation of the development logic of events in a narrative text, an event sequence should obviously exhibit a strong logical correlation between adjacent event nodes. Therefore, sample selection can be performed by calculating the logical correlation score of the event sequence. Here, logical correlation refers to the logical relationship between each event node within the event sequence.

[0084] For the sample event sequences in the second narrative text sample, their logical relevance scores can be determined using the head-and-tail event logical relevance model. The training data for the head-and-tail event logical relevance model can be manually proofread Chinese ATOMIC event graph data. The model task can be defined as a binary text classification task involving positive and negative classification. The event logical relevance score can be defined as the probability that the input text is classified as a positive example by the head-and-tail event logical relevance model. Positive samples are constructed by concatenating the head and tail events of each sample in the ATOMIC event graph data; negative samples are constructed by selecting the same head event as the original sample and randomly selecting the tail events of other samples.

[0085] After obtaining the head-and-tail event logical correlation model, the sample event sequences from the second narrative text sample can be input into the head-and-tail event logical correlation model to obtain the event logical correlation scores between adjacent event nodes in the sample event sequences output by the head-and-tail event logical correlation model. By calculating the mean of the event logical correlation scores between adjacent event nodes in the sample event sequences, the event sequence logical correlation score of the sample event sequence can be obtained. Through case analysis in actual situations, sample event sequences with event sequence logical correlation scores higher than 0.6 and their corresponding data sample pairs formed with the second narrative text sample can be selected as target data sample pairs.

[0086] For example, if the sample event sequence in the second narrative text sample includes the above 6 event nodes, and the event logical correlation scores between the above 6 event nodes are 0.95, 0.54, 0.61, 0.97 and 0.19 respectively, with a mean of 0.652, then the sample event sequence can be retained and form a target data sample pair with its corresponding second narrative text sample.

[0087] Finally, based on the target data sample pairs, the candidate extraction models are trained to obtain the event extraction model.

[0088] In this embodiment of the invention, by filtering data sample pairs, the quality of the samples used to train the candidate extraction model can be improved, thereby improving the performance of the event extraction model.

[0089] Based on the above embodiments, the narrative text generation method provided in this embodiment of the invention, wherein generating target narrative text based on the target event sequence includes:

[0090] Receive the prompt information input by the user;

[0091] The prompt information and the target event sequence are input into the text generation model, which encodes the prompt information and the target event sequence respectively, and decodes the encoded results to obtain and output the target narrative text.

[0092] The text generation model is trained based on a third narrative text sample, sample prompts from the third narrative text sample, and sample event sequences from the third narrative text sample.

[0093] Specifically, since topic-related errors such as disconnection from event chains and contradictory contexts are relatively common when generating narrative text, the system can first receive prompts from the user when generating the target narrative text. These prompts can include the narrative title, as well as previous prompts and other information.

[0094] The prompt information and the target event sequence are then input into the text generation model. The text generation model encodes the prompt information and the target event sequence respectively, and decodes the encoded results to obtain and output the target narrative text. This text generation model can be based on a traditional Encoder-Decoder language model, adding a new Encoder parallel to the original Encoder. That is, the text generation model includes two encoders, Encoder1 and Encoder2. Encoder1 is used to encode the prompt information to obtain the prompt information encoded representation, and Encoder2 is used to encode the target event sequence to obtain the sequence encoded representation.

[0095] The decoder in the text generation model is connected to Encoder1 and Encoder2 respectively. It is used to decode the encoded representation of the prompt information and the encoded representation of the sequence to obtain and output the target narrative text.

[0096] In text generation models, the outputs of Encoder1 and Encoder2 can be fused using a learnable gating parameter σ, i.e.:

[0097] Output=σ·Output(Encoder1)+(1-σ)·Output(Encoder2)

[0098] Output is the fusion result, which serves as the input to the Decoder. Output(Encoder1) represents the output of Encoder1, i.e., the encoded representation of the prompt information, and Output(Encoder2) represents the output of Encoder2, i.e., the encoded representation of the sequence.

[0099] Therefore, the importance of event sequence information in narrative text generation is emphasized in the structure of the text generation model.

[0100] The text generation model can be trained using samples of a third narrative text, sample prompts from those samples, and sequence of sample events from those samples. For example, the sample prompts and sequence of sample events from the third narrative text can be input into the initial model to obtain the generated result. Then, a loss function can be calculated using the third narrative text samples and the generated result. When the loss function converges, the trained text generation model is obtained.

[0101] In this embodiment of the invention, the input of a target event sequence with highly abstract logical information can exert strong control over the long-distance narrative text generation process of the text generation model, so that the generation result of the text generation model will not deviate from the event development path envisioned by the user, and at the same time will not excessively affect the fluency of the generated text.

[0102] Based on the above embodiments, the narrative text generation method provided in this embodiment of the invention uses a loss function during the training process of the text generation model, which includes an event node average interval distance penalty term. The event node average interval penalty term is used to characterize the loss caused by the average length of the positional interval of each event node in the sample event sequence in the third narrative text sample.

[0103] Specifically, traditional text generation models typically use standard cross-entropy as the loss function. However, cross-entropy often leads text generation models to focus on representing the information of the input text in the output, thus lacking creativity. This greatly affects the performance of open-ended text generation tasks. That is, the target narrative text generated by the text generation model often ends hastily after expressing the complete information of the input target event sequence, lacking detailed descriptions of events and diverse expressions.

[0104] To enhance the text generation model's focus on non-event chain related information in the target narrative text, a special token can be introduced into the third narrative passage sample during the model's training process. This token is appended to sentences that, while not expressing event chain related information, still possess a certain amount of information. Additionally, in the objective function, besides the cross-entropy term, a penalty loss based on the average interval distance between event nodes is introduced. dist loss dist The loss is defined as the average length of the positional intervals of each event node in the corresponding input sample event sequence within the third narrative text sample. The positions of each event node can be labeled using position identifiers (Tokens). This loss is introduced into the objective function. dist This allows text generation models to focus on the textual representation of non-event nodes during training, thereby enabling them to generate informative descriptions of the relationships between event nodes while fully covering the input event sequence information during inference generation.

[0105] In this embodiment of the invention, the text generation model focuses on the text related to the event sequence and the text between the event sequences in the third narrative text sample from the perspectives of structure and loss function, so that the generated target narrative text has both strong event development logic and richness and diversity in text narration.

[0106] Based on the above embodiments, the narrative text generation method provided in this embodiment of the invention, which expands the initial event sequence based on the key information of each event node in the initial event sequence to obtain a target event sequence, includes:

[0107] Receive the narrative title input by the user;

[0108] Based on the narrative title and the key information, the initial event sequence is expanded to obtain multiple alternative event sequences;

[0109] Based on the logical correlation of the event sequences, the multiple candidate event sequences are filtered to obtain the target event sequence.

[0110] Specifically, when determining the target event sequence, we can first receive the narrative title input by the user, and then expand the initial event sequence using the narrative title and key information to obtain multiple candidate event sequences. Here, an event expansion model can be introduced, where the narrative title and key information are concatenated before the initial event sequence and separated using a special delimiter, thus obtaining the input sequence for the event expansion model. Subsequently, the event expansion model encodes and decodes the input sequence to obtain and output multiple candidate event sequences.

[0111] This event-extended model can be trained on a base model using narrative text samples carrying sample titles and key information. The sample titles and key information can be manually annotated, or the narrative text samples can be automatically augmented using a generative paradigm. The base model can be a language model, such as the BART model.

[0112] For any character s in the input sequence i The loss function of the event extension model can be the cross-entropy loss, and its specific calculation process is shown in formulas (1)-(3):

[0113] h i =TransformerDecoder(s i (1)

[0114] y i+1 =Softmax(Linear(h) i (2)

[0115] loss i =CrossEntropy(y i+1 ,s i+1 (3)

[0116] Among them, h i Represents the character s iThe vector representation y after being encoded by the TransformerDecoder of the base model i+1 Indicates according to h i The predicted next character, loss i The character y is the result of the prediction. i+1 and real character s i+1 The cross-entropy loss.

[0117] Subsequently, multiple candidate event sequences can be filtered based on their logical relevance to obtain the target event sequence. For example, a head-and-tail event logical relevance model can be used to obtain the logical relevance score of each candidate event sequence, and then the candidate event with the highest logical relevance score can be selected as the target event sequence.

[0118] In this embodiment of the invention, the introduction of narrative titles can improve the consistency between each candidate event sequence and user needs. Furthermore, by filtering multiple candidate event sequences through the logical correlation of event sequences, the internal logic of the target event sequence can be further improved, ensuring the quality of the target event sequence.

[0119] In summary, this invention provides a two-stage narrative text generation method based on event sequences. It starts with a coarse-grained simple event sequence (i.e., the initial event sequence) input by the user, automatically expands it into a fine-grained complex event sequence (i.e., the target event sequence), and further generates a complete target narrative text based on the information from the fine-grained complex event sequence. This method can be applied to intelligent writing assistants and related products, providing students with writing ideas and stimulating their writing inspiration, thereby assisting students in narrative writing and improving their narrative writing skills.

[0120] like Figure 2 As shown, based on the above embodiments, this embodiment of the invention provides a narrative text generation system, including:

[0121] Module 21 is used to obtain a narrative summary input by the user;

[0122] The event development planning module 22 is used to extract the initial event sequence from the narrative plot overview, and expand the initial event sequence based on the key information of each event node in the initial event sequence to obtain the target event sequence;

[0123] The narrative text generation module 23 is used to generate target narrative text based on the target event sequence.

[0124] Based on the above embodiments, the narrative text generation system provided in this embodiment of the invention, wherein the event development planning module is specifically used for:

[0125] The narrative summary is input into the event extraction model to obtain the initial event sequence output by the event extraction model;

[0126] The event extraction model is trained based on the first narrative text sample and the sequence of sample events therein.

[0127] Based on the above embodiments, the narrative text generation system provided in this embodiment of the invention further includes a training module, used for:

[0128] Based on the first narrative text sample and the sample event sequence therein, the initial extraction model is trained to obtain the candidate extraction model.

[0129] A second narrative text sample is determined and input into the candidate extraction model to obtain the sample event sequence in the second narrative text sample output by the candidate extraction model.

[0130] Based on the second narrative text sample and the sample event sequence therein, the candidate extraction model is trained to obtain the event extraction model.

[0131] Based on the above embodiments, the narrative text generation system provided in this embodiment of the invention, wherein the training module is specifically used for:

[0132] Based on the chapter event matching rules and / or the logical correlation of event sequences, the data sample pairs consisting of the second narrative chapter sample and the sample event sequences therein are filtered to obtain target data sample pairs. Based on the target data sample pairs, the candidate extraction model is trained to obtain the event extraction model.

[0133] Based on the above embodiments, the narrative text generation system provided in this embodiment of the invention, wherein the narrative text generation module is specifically used for:

[0134] Receive the prompt information input by the user;

[0135] The prompt information and the target event sequence are input into the text generation model, which encodes the prompt information and the target event sequence respectively, and decodes the encoded results to obtain and output the target narrative text.

[0136] The text generation model is trained based on a third narrative text sample, sample prompts from the third narrative text sample, and sample event sequences from the third narrative text sample.

[0137] Based on the above embodiments, the narrative text generation system provided in this embodiment of the invention uses a loss function during the training process of the text generation model, which includes an event node average interval distance penalty term. The event node average interval penalty term is used to characterize the loss caused by the average length of the positional interval of each event node in the sample event sequence in the third narrative text sample.

[0138] Based on the above embodiments, the narrative text generation system provided in this embodiment of the invention, wherein the event development planning module is specifically used for:

[0139] Receive the narrative title input by the user;

[0140] Based on the narrative title and the key information, the initial event sequence is expanded to obtain multiple alternative event sequences;

[0141] Based on the logical correlation of the event sequences, the multiple candidate event sequences are filtered to obtain the target event sequence.

[0142] Specifically, the functions of each module in the narrative text generation system provided in this embodiment of the invention correspond one-to-one with the operation flow of each step in the above method-like embodiments, and the achieved effects are also the same. For details, please refer to the above embodiments, and this will not be repeated in this embodiment of the invention.

[0143] The narrative text generation system provided in this embodiment of the invention is a two-stage narrative text generation system based on event sequences. Its core modules include an event development planning module and a narrative text generation module. The first-stage event development planning module provides a coarse-grained plot framework for the automatic generation of the narrative text, while the second-stage narrative text generation module refines this coarse-grained plot framework and outputs the target narrative text corresponding to the event development plan.

[0144] This narrative text generation system first takes a coarse-grained, simple event sequence input by the user and automatically expands it into a fine-grained, complex event sequence, which is then presented to the user. The user can then modify the automatically expanded complex event sequence according to their preferences. Finally, the system generates a complete target narrative text based on the current event sequence. This approach better reflects real-world application scenarios for automatic narrative text generation and, to some extent, avoids the uncontrollable issues inherent in automatic narrative text generation, thus ensuring the system can produce higher-quality target narrative texts.

[0145] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include a processor 310, a communications interface 320, a memory 330, and a communication bus 340, wherein the processor 310, the communications interface 320, and the memory 330 communicate with each other via the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute the narrative text generation method provided in the above embodiments. The method includes: obtaining a narrative plot overview input by the user; extracting an initial event sequence from the narrative plot overview, and expanding the initial event sequence based on the key information of each event node in the initial event sequence to obtain a target event sequence; and generating a target narrative text based on the target event sequence.

[0146] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0147] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the narrative text generation method provided in the above embodiments. The method includes: obtaining a narrative plot overview input by a user; extracting an initial event sequence from the narrative plot overview, and expanding the initial event sequence based on key information of each event node in the initial event sequence to obtain a target event sequence; and generating a target narrative text based on the target event sequence.

[0148] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program is implemented to perform the narrative text generation method provided in the above embodiments. The method includes: obtaining a narrative plot overview input by a user; extracting an initial event sequence from the narrative plot overview, and expanding the initial event sequence based on key information of each event node in the initial event sequence to obtain a target event sequence; and generating a target narrative text based on the target event sequence.

[0149] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0150] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for generating narrative text, characterized in that, include: Obtain a narrative summary from user input; Extract the initial event sequence from the narrative plot overview, and expand the initial event sequence based on the key information of each event node in the initial event sequence to obtain the target event sequence; Based on the target event sequence, generate the target narrative text; The step of expanding the initial event sequence based on the key information of each event node in the initial event sequence to obtain the target event sequence includes: Receive the narrative title input by the user; Based on the narrative title and the key information, the initial event sequence is expanded to obtain multiple alternative event sequences; the narrative title and the key information are concatenated before the initial event sequence and separated by a special delimiter to obtain the input sequence of the event expansion model; Based on the logical relevance of event sequences, the multiple candidate event sequences are filtered to obtain the target event sequence. Through the head-tail event logical relevance model, the logical relevance score of each candidate event sequence is obtained, and the candidate event sequence with the highest logical relevance score is selected as the target event sequence.

2. The narrative text generation method according to claim 1, characterized in that, The extraction of the initial event sequence from the narrative outline includes: The narrative summary is input into the event extraction model to obtain the initial event sequence output by the event extraction model; The event extraction model is trained based on the first narrative text sample and the sequence of sample events therein.

3. The narrative text generation method according to claim 2, characterized in that, The event extraction model is trained based on the following steps: Based on the first narrative text sample and the sample event sequence therein, the initial extraction model is trained to obtain the candidate extraction model. A second narrative text sample is determined and input into the candidate extraction model to obtain the sample event sequence in the second narrative text sample output by the candidate extraction model. Based on the second narrative text sample and the sample event sequence therein, the candidate extraction model is trained to obtain the event extraction model.

4. The narrative text generation method according to claim 3, characterized in that, The step of training the candidate extraction model based on the second narrative text sample and the sample event sequence therein to obtain the event extraction model includes: Based on the chapter event matching rules and / or the logical correlation of event sequences, the data sample pairs consisting of the second narrative chapter sample and the sample event sequences therein are filtered to obtain target data sample pairs. Based on the target data sample pairs, the candidate extraction model is trained to obtain the event extraction model.

5. The narrative text generation method according to any one of claims 1-4, characterized in that, The step of generating the target narrative text based on the target event sequence includes: Receive the prompt information input by the user; The prompt information and the target event sequence are input into the text generation model, which encodes the prompt information and the target event sequence respectively, and decodes the encoded results to obtain and output the target narrative text. The text generation model is trained based on a third narrative text sample, sample prompts from the third narrative text sample, and sample event sequences from the third narrative text sample.

6. The narrative text generation method according to claim 5, characterized in that, The loss function used in the training process of the text generation model includes an event node average interval distance penalty term, which is used to characterize the loss caused by the average length of the positional interval of each event node in the sample event sequence in the third narrative text sample.

7. A narrative text generation system, characterized in that, include: The acquisition module is used to acquire a narrative summary input by the user; The event development planning module is used to extract the initial event sequence from the narrative plot overview, and expand the initial event sequence based on the key information of each event node in the initial event sequence to obtain the target event sequence; The narrative text generation module is used to generate target narrative text based on the target event sequence; The event development planning module is specifically used for: Receive the narrative title input by the user; Based on the narrative title and the key information, the initial event sequence is expanded to obtain multiple candidate event sequences; the narrative title and the key information are concatenated before the initial event sequence and separated by a special delimiter to obtain the input sequence of the event expansion model; the input sequence is encoded and decoded based on the event expansion model to obtain the multiple candidate event sequences. Based on the logical relevance of event sequences, the multiple candidate event sequences are filtered to obtain the target event sequence. Through the head-tail event logical relevance model, the logical relevance score of each candidate event sequence is obtained, and the candidate event sequence with the highest logical relevance score is selected as the target event sequence.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the narrative generation method as described in any one of claims 1-6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the narrative generation method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Event extraction method and device, equipment and storage medium

    CN112861527A

  • Computer implemented event prediction in narrative data sequences using semiotic analysis

    US20170277996A1