Story generation method, device, electronic device and storage medium
By selecting the appropriate ending in story generation and utilizing the story generation model, the problem of unreasonable and fluent story generation is solved, more efficient and lower-cost story generation is achieved, and user participation and the logical coherence of the story are enhanced.
Patent Information
- Application Number
- CN202210652711.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-07
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2042-06-07
AI Technical Summary
The story generation scheme in the prior art directly continues the story, resulting in the generated story being unreasonable and fluent, possibly diverging, and lacking logical coherence and completeness.
By determining the story background and user input content, a suitable ending is selected from several alternative story endings, and a pre-built story generation model is used to generate story content, which is spliced together based on the story background and input content to screen out a reasonable story ending.
It avoids the problem of unreasonable and incoherent story generation, reduces costs and improves generation efficiency, and enhances user participation and the logical coherence of generated stories.
Smart Images

Figure CN115130451B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of natural language processing, and in particular to a story generation method, device, electronic device, and storage medium. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the present disclosure that are recited in the claims. No statement herein is admitted to be prior art by virtue of its inclusion in this section.
[0003] Story generation means giving the characters and the beginning scene of a story and letting the model continue the story.
[0004] However, the story generation scheme in the prior art directly continues the story, and the generated story will be more divergent and not reasonable and smooth. Summary of the Invention
[0005] In view of this, the purpose of the present disclosure is to provide a method, device, electronic device and storage medium for generating a story.
[0006] Based on the above objectives, the exemplary embodiments of the present disclosure provide a method for generating a story, including:
[0007] Determining a story background and user input, and determining a story ending from a plurality of alternative story endings based on the input;
[0008] Inputting the story background, the input content, and the story ending into a pre-built story generation model to obtain the story content output by the story generation model;
[0009] The story content is spliced with the corresponding story background, the input content and the story ending to obtain the story.
[0010] In some exemplary embodiments, determining a story ending from a plurality of alternative story endings based on the input content includes:
[0011] The input content is respectively concatenated with several of the alternative story endings to obtain several concatenated sentences, perplexity values of the concatenated sentences are respectively determined, and at least one of the story endings is determined based on the perplexity values.
[0012] In some exemplary embodiments, the method further comprises:
[0013] Obtaining an original text set; wherein the original text set includes a plurality of texts, and the plurality of texts are arranged in a preset order;
[0014] Dividing the original text set to obtain a plurality of training text sets; wherein the training text sets include training story backgrounds, training story contents, and training story endings;
[0015] The story generation model is obtained by training the training text set.
[0016] In some exemplary embodiments, dividing the original text set to obtain several training text sets includes:
[0017] Creating an empty candidate training text set, and sequentially adding the texts in the original text set to the candidate training text set;
[0018] For any of the current texts and any of the current candidate training text sets, in response to determining that, after adding the current text to the current candidate training text set, the character length of the current candidate training text set is less than or equal to a preset first threshold, continuing to add the next text to the current candidate training text set until the character length of the current candidate training text set is greater than the first threshold;
[0019] In response to determining that, after adding the current text to the current candidate training text set, the character length of the current candidate training text set is greater than the first threshold, further determining whether the current candidate training text set meets a preset training text set standard; and in response to determining that the current candidate training text set meets the training text set standard, determining the current candidate training text set as the training text set;
[0020] In response to determining that the current candidate training text set does not meet the training text set standard, the current candidate training text set is deleted, a new candidate training text set with empty content is created, and the text starting from the current text is added to the new candidate training text set in sequence, and the above operation is repeated until a preset number of training text sets are obtained.
[0021] In some exemplary embodiments, the training text set standard includes:
[0022] The number of leading quotation marks and the number of trailing quotation marks in the training text set are the same;
[0023] The ending of the training story does not include quotation marks;
[0024] The character length of the training story ending is greater than or equal to a preset threshold;
[0025] The character length of the training text set is greater than or equal to a preset second threshold; wherein the second threshold is less than the first threshold.
[0026] In some exemplary embodiments, the method further comprises:
[0027] A preset number of adjacent texts including the last text in the training text set are collectively used as the training story endings, and the other texts are used as training non-story endings;
[0028] According to a preset character length threshold of the training story background, traversing the training non-story ending from front to back to obtain the training story background, and using the remaining text in the training non-story ending as the training story content;
[0029] or,
[0030] According to a preset character length threshold of the training story content, the training non-story ending is traversed from back to front to obtain the training story content, and the remaining text in the training non-story ending is used as the training story background.
[0031] In some exemplary embodiments, the story generation model includes an encoder and a decoder;
[0032] Then, the story generation model is obtained by training the training text set, including:
[0033] The training story background and the training story ending are input into the encoder to obtain the encoded data output by the encoder, and the encoded data and the training story content are input into the decoder to train and obtain the story generation model.
[0034] In some exemplary embodiments, the story generation model includes a decoder;
[0035] Then, the story generation model is obtained by training the training text set, including:
[0036] splicing the training story background, the training story ending, and the training story content to obtain spliced data, inputting the spliced data into the decoder, and training to obtain the story generation model;
[0037] Among them, in the spliced data, the ending of the training story is used as the two end data of the spliced data, and the background of the training story and the content of the training story are used together as the middle data of the spliced data.
[0038] In some exemplary embodiments, before obtaining the story generation model through training the training text set, the method further includes:
[0039] The story generation model is pre-trained.
[0040] In some exemplary embodiments, the story generation model includes any one of the following:
[0041] T5 model or GPT model.
[0042] Based on the same inventive concept, the exemplary embodiments of the present disclosure further provide a story generating device, comprising:
[0043] a story ending determination module configured to determine the story background and user input content, and determine the story ending from a plurality of alternative story endings based on the input content;
[0044] a story content generation module configured to input the story background, the input content, and the story ending into a pre-built story generation model to obtain the story content output by the story generation model;
[0045] The story determination module is configured to combine the story content with the corresponding story background, the input content and the story ending to obtain the story.
[0046] Based on the same inventive concept, an exemplary embodiment of the present disclosure further 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 implements any of the above methods when executing the program.
[0047] Based on the same inventive concept, an exemplary embodiment of the present disclosure further provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute any of the above methods.
[0048] As can be seen from the above, the story generation method, device, electronic device, and storage medium provided by the embodiments of the present disclosure include: determining a story background and user input content, and determining a story ending from a number of alternative story endings based on the input content; inputting the story background, the input content, and the story ending into a pre-built story generation model to obtain story content output by the story generation model; and splicing the story content with the corresponding story background, the input content, and the story ending to obtain the story. The present disclosure screens story endings based on user input content, thereby preventing the generated stories from being unreasonable and incoherent, while also reducing costs and improving efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the present disclosure or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0050] Figure 1 A schematic diagram of an application scenario of a story generation method provided according to an exemplary embodiment of the present disclosure;
[0051] Figure 2 A flowchart of a method for generating a story provided by an exemplary embodiment of the present disclosure;
[0052] Figure 3 A flowchart of a method for training a story generation model according to an exemplary embodiment of the present disclosure is provided;
[0053] Figure 4 A schematic diagram of a method for training a story generation model according to an exemplary embodiment of the present disclosure;
[0054] Figure 5 Another schematic diagram of a method for training a story generation model according to an exemplary embodiment of the present disclosure;
[0055] Figure 6 A schematic diagram of a pre-training method for a story generation model provided according to an exemplary embodiment of the present disclosure;
[0056] Figure 7 A schematic structural diagram of a story generating device provided by an exemplary embodiment of the present disclosure;
[0057] Figure 8 A schematic structural diagram of an electronic device provided by an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0058] To make the objectives, technical solutions, and advantages of the present disclosure more clearly understood, the principles and spirit of the present disclosure will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided solely to enable those skilled in the art to better understand and implement the present disclosure, and are not intended to limit the scope of the present disclosure in any way. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0059] According to an embodiment of the present disclosure, a method, device, electronic device, and storage medium for generating a story are proposed.
[0060] It should be understood herein that any number of elements in the drawings is for illustration only and not for limitation, and any naming is only for distinction and does not have any limiting meaning.
[0061] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present disclosure should have the usual meanings understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the embodiments of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative position relationships. When the absolute position of the described object changes, the relative position relationship may also change accordingly.
[0062] The principles and spirit of the present disclosure are explained in detail below with reference to several representative embodiments of the present disclosure.
[0063] In related technologies, the generated stories are rather divergent and not reasonable and fluent enough.
[0064] The inventors of the present disclosure have discovered that the reasons why the stories generated in the above-mentioned related technologies tend to be divergent and not rational and coherent are:
[0065] Since the story is directly continued, the content generated by the model will be very divergent, and characters and plots outside the scene may be randomly inserted; in addition, it may lead to incomplete storytelling, leaving people with an aftertaste; directly continuing the story lacks a purpose, and the ending is not taken into consideration during the continuation process, so the continued story may be incoherent and illogical when spliced together with all the endings.
[0066] To address the aforementioned issues, the present disclosure provides a story generation solution, specifically comprising: determining a story background and user input content, and determining a story ending from a number of alternative story endings based on the input content; inputting the story background, the input content, and the story ending into a pre-built story generation model to obtain story content output by the story generation model; and concatenating the story content with the corresponding story background, the input content, and the story ending to generate the story. By screening story endings based on user input content, the present disclosure can avoid generating stories that are not logically coherent, while also reducing costs and improving efficiency.
[0067] After introducing the basic principles of the present disclosure, various non-limiting embodiments of the present disclosure are described in detail below.
[0068] refer to Figure 1 , which is a schematic diagram of an application scenario of the story generation method provided by an embodiment of the present disclosure. The application scenario includes a terminal device 101, a server 102 and a data storage system 103. Among them, the terminal device 101, the server 102 and the data storage system 103 can be connected through a wired or wireless communication network. The terminal device 101 includes but is not limited to a desktop computer, a mobile phone, a mobile computer, a tablet computer, a media player, a smart wearable device, a personal digital assistant (PDA) or other electronic devices that can realize the above functions. The server 102 and the data storage system 103 can be independent physical servers, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0069] Server 102 is used to provide story generation services to users of terminal devices 101. Terminal devices 101 are installed with a client that communicates with server 102. Users can use this client to input a text message, which is then sent to server 102 as input. Server 102 retrieves the story context and several alternative story endings from data storage system 103, and determines the ending from among the several alternative story endings based on the input message. The story context, input message, and story ending are then input into a pre-built story generation model, generating the story content output by the story generation model. The story content is then combined with the corresponding story context, input message, and story ending to generate a story. Server 102 sends the story to the client, which then displays the story to the user.
[0070] The data storage system 103 stores a large amount of training data. Each training data set includes a data pair consisting of a training story background and a training story ending, and the training story content corresponding to the data pair. The server 102 can train the story generation model based on the large amount of training data, so that the story generation model can obtain the story content based on the input story background and story ending. The sources of training data include but are not limited to existing databases, data crawled from the internet, or data uploaded by users when using the client. When the accuracy of the story generation model output meets certain requirements, the server 102 can provide story generation services to users based on the story generation model. At the same time, the server 102 can also continuously optimize the story generation model based on the newly added training data.
[0071] The following combination Figure 1 The present invention will now describe the method for training a story generation model and the method for generating stories according to an exemplary embodiment of the present invention, using an application scenario. It should be noted that the above application scenario is merely provided to facilitate understanding of the spirit and principles of the present invention, and the embodiments of the present invention are not limited in this respect. Rather, the embodiments of the present invention can be applied to any applicable scenario.
[0072] refer to Figure 2 , which is a flowchart of a story generation method provided by an exemplary embodiment of the present disclosure.
[0073] The story generation method includes the following steps:
[0074] Step S210: Determine the story background and the user's input content, and determine the story ending from several alternative story endings based on the input content.
[0075] Among them, the story background refers to the historical or real-time situation that affects the characters and events in the story, such as character settings and events.
[0076] For example, consider a character setting: the NPC (non-player character) is a gentle, middle-aged boatman with a young son; the user is a young warrior, a recent martial artist traveling in Bianjing. For example, consider an event: as you pass by a dock, a boatman sobs and asks for help: "Young man, two years ago, when I went out to sea, I promised my son I'd bring him an ironwood sword. But when the boat docked, it accidentally fell into the water. I've searched for it for a long time, following the markings on the side of the boat, but I can't find it. What should I do?"
[0077] The input content refers to the content input by the user that may affect the plot direction of the story, such as character language and character actions.
[0078] In related technologies, several options that affect the direction of the story are usually provided for users to choose from. In this case, users can only choose content that affects the direction of the story from a limited number of options, which is less open, has a lower degree of freedom, and a weaker sense of participation.
[0079] In the present disclosure, users can input any text to influence the plot direction of the story, which is more open, has a higher degree of freedom, and a stronger sense of participation.
[0080] As an example, enter content such as: Young man helps the boatman to go into the water to fish.
[0081] In some exemplary embodiments, the type of the input content is determined, and a rewriting template is determined according to the type. The input content is rewritten according to the rewriting template to obtain rewritten input content.
[0082] As an example, if the input content type is language, then add "story generation theory" before the input content, such as "young hero said";
[0083] If the input content is of action type, add the subject (NPC or user) before the input content. For example, add the subject "young man" before the input content "help the boatman to go into the water to fish".
[0084] The purpose of rewriting the input content is to make the rewritten input content easier for the model to understand and process, with higher accuracy and efficiency, while saving costs.
[0085] The story generation scheme provided by the exemplary embodiments of the present disclosure is to generate story content according to story background, input content and story ending.
[0086] In some exemplary embodiments, determining a story ending from a plurality of alternative story endings based on the input content includes:
[0087] The input content is respectively concatenated with several of the alternative story endings to obtain several concatenated sentences, perplexity values of the concatenated sentences are respectively determined, and at least one of the story endings is determined based on the perplexity values.
[0088] Among them, several alternative story endings are pre-configured. However, among these alternative story endings, there are alternative story endings that contradict the input content. The purpose of this step is to filter out the alternative story endings that contradict the input content to avoid unnecessary calculations, improve efficiency, and save costs.
[0089] As an example, for example, if the input content is "The young man helps the boatman to retrieve the sword", then for the alternative story endings "The boatman's son obtains the ironwood sword", "The boatman breaks his promise and fails to bring the ironwood sword back to the child", and "The young man and the boatman fight", the alternative story ending "The young man and the boatman fight" is inconsistent with the input content "The young man helps the boatman to retrieve the sword". In this case, the alternative story ending "The young man and the boatman fight" is filtered out.
[0090] In some exemplary embodiments, a method for calculating the perplexity value of a sentence specifically includes:
[0091]
[0092] Among them, PP(S) represents the perplexity value of sentence S; N represents the length of sentence S; p(wi) represents the probability of the i-th word in sentence S; p(wi|w1w2w3…wi-1) represents the probability of the i-th word calculated based on the first i-1 words.
[0093] The smaller PP(S), the larger p(wi), which means that the probability of each word in sentence S is higher, indicating that the sentence S has a better fit, that is, the input content has a better fit with the alternative story ending, that is, they are not contradictory to each other; conversely, the larger PP(S), the smaller p(wi), which means that the probability of each word in sentence S is lower, indicating that the sentence S has a poor fit, that is, the input content has a poor fit with the alternative story ending, that is, they are contradictory to each other.
[0094] In some exemplary embodiments, alternative story endings corresponding to concatenated sentences with perplexity values greater than a preset threshold may be filtered to obtain a story ending.
[0095] Among them, there may be multiple determined story endings. For each story ending, alternative story content is generated based on the story background and the story ending to obtain multiple alternative story contents. A preset number of alternative story contents are selected from the multiple alternative story contents as the determined story content.
[0096] In some exemplary embodiments, the alternative story ending corresponding to the concatenated sentence with the smallest perplexity value may be determined as the story ending.
[0097] There is only one definite story ending, and the story content is generated based on the story background and the story ending.
[0098] Step S220: Input the story background, the input content, and the story ending into a pre-built story generation model to obtain the story content output by the story generation model.
[0099] It should be noted that the present disclosure essentially regards the input content as part of the story background. Therefore, it can be understood that during the training process of the story generation model, the input of the story generation model is the story background and the story ending, and during the application process of the story generation model, the input of the story generation model is the story background, input content and the story ending.
[0100] refer to Figure 3 , which is a flowchart of a training method for a story generation model provided according to an exemplary embodiment of the present disclosure.
[0101] In some exemplary embodiments, a method for training a story generation model includes:
[0102] Step S310: Obtain an original text set; wherein the original text set includes a plurality of texts, and the plurality of texts are arranged in a preset order.
[0103] In this disclosure, a sentence (a sentence ending with a period, question mark or exclamation mark) is referred to as a text, and a paragraph including at least one sentence or a chapter including at least one paragraph is referred to as a text set.
[0104] In specific implementation, the original text collection can be literary works such as poetry, prose, novels, plays, scripts, fables and fairy tales. There are certain logical relationships between sentences in literary works, such as contextual relationships or causal relationships. These logical relationships are reflected in the text collection, that is, the texts in the text collection have a preset sequential relationship.
[0105] Step S320: Divide the original text set to obtain a plurality of training text sets; wherein the training text sets include training story background, training story content and training story ending.
[0106] In some exemplary embodiments, dividing the original text set to obtain several training text sets includes:
[0107] Creating an empty candidate training text set, and sequentially adding the texts in the original text set to the candidate training text set;
[0108] For any of the current texts and any of the current candidate training text sets, in response to determining that, after adding the current text to the current candidate training text set, the character length of the current candidate training text set is less than or equal to a preset first threshold, continuing to add the next text to the current candidate training text set until the character length of the current candidate training text set is greater than the first threshold;
[0109] In response to determining that, after adding the current text to the current candidate training text set, the character length of the current candidate training text set is greater than the first threshold, further determining whether the current candidate training text set meets a preset training text set standard; and in response to determining that the current candidate training text set meets the training text set standard, determining the current candidate training text set as the training text set;
[0110] In response to determining that the current candidate training text set does not meet the training text set standard, the current candidate training text set is deleted, a new candidate training text set with empty content is created, and the text starting from the current text is added to the new candidate training text set in sequence, and the above operation is repeated until a preset number of training text sets are obtained.
[0111] In some exemplary embodiments, the training text set standard includes:
[0112] The number of leading quotation marks and the number of trailing quotation marks in the training text set are the same;
[0113] The ending of the training story does not include quotation marks;
[0114] The character length of the training story ending is greater than or equal to a preset threshold;
[0115] The character length of the training text set is greater than or equal to a preset second threshold; wherein the second threshold is less than the first threshold.
[0116] In some exemplary embodiments, a method for determining a training story background, a training story content, and a training story ending in a training text set includes:
[0117] A preset number of adjacent texts including the last text in the training text set are collectively used as the training story endings, and the other texts are used as training non-story endings;
[0118] According to a preset character length threshold of the training story background, traversing the training non-story ending from front to back to obtain the training story background, and using the remaining text in the training non-story ending as the training story content;
[0119] or,
[0120] According to a preset character length threshold of the training story content, the training non-story ending is traversed from back to front to obtain the training story content, and the remaining text in the training non-story ending is used as the training story background.
[0121] In specific implementation, the last text in the training text set can be used as the ending of the training story.
[0122] Step S330: Obtain the story generation model through training with the training text set.
[0123] When training the model, it is necessary to construct a sample set including several samples; wherein, the samples include: sample data and label data; in the present disclosure, the training text set is the sample, the training story background and the training story ending are the sample data, and the training story content is the label data.
[0124] The present disclosure processes existing literary works to obtain a sample set, and does not require manual participation in compiling the sample set, thereby reducing labor costs.
[0125] In some exemplary embodiments, the story generation model includes any one of the following:
[0126] T5 model or GPT model.
[0127] Next, we will introduce the story generation model built based on the T5 model and the story generation model built based on the GPT model respectively.
[0128] refer to Figure 4 , which is a schematic diagram of a training method for a story generation model provided according to an exemplary embodiment of the present disclosure.
[0129] In some exemplary embodiments, the story generation model is a T5 model 400 , which includes an encoder 402 and a decoder 404 .
[0130] Then, the story generation model is obtained by training the training text set, including:
[0131] The training story background and the training story ending are input into the encoder 402 to obtain the encoded data output by the encoder 402, and the encoded data and the training story content are input into the decoder 404 to train and obtain the story generation model.
[0132] In specific implementation, the training story background and the training story ending are connected through preset symbols, and the encoded data and the training story content are connected, and the characters are connected through spaces.
[0133] As an example:
[0134] The training text read: "All the new disciples are here, Master." His expression remained unchanged, his boots tapping on a tall branch not far away. He looked down from above, his brows slender, and the faint golden veins at the corners of his black robes made him look even more solemn. A flute with a red tassel was tucked at his waist, and his blood-red hairband swayed lightly in the wind, spotless. At first glance, it seemed as if the world had stood still.
[0135] Among them, the background story for training is: "The new disciples are all here, Master." His expression did not change, the toes of his boots stepped on the tall branches not far away, looking down from above, with slender eyebrows,
[0136] The content of the training story is: The golden texture faintly visible on the corners of the black clothes makes her look more solemn, a flute with a red tassel is tied at her waist, and a blood-red hairband sways in the wind, spotless.
[0137] The ending of the training story is: At first glance, it seems as if the world has stopped.
[0138] Then, the input to encoder 402 is: "The new disciples are all here, Master." His expression remained unchanged, and he stepped on the high branches of a nearby tree, looking down from above with his slender eyebrows.<extra_id_0> At first glance, it seemed as if the world had stopped.
[0139] in,<extra_id_0> Used to connect the background of the training story and the ending of the training story, and to indicate the end.
[0140] Then, the input of decoder 404 is: coded data<extra_id_0> The faint golden patterns on the corners of his black robe made him look more solemn. A flute with a red tassel was pinned to his waist, and his blood-red hairband swayed in the wind, looking spotless.<extra_id_1>
[0141] in,<extra_id_0> and<extra_id_1> Used to connect to training story content.
[0142] When the model is being trained, the decoder 404 learns the N+1th character from the first N characters.
[0143] In some exemplary embodiments, before obtaining the story generation model through training the training text set, the method further includes:
[0144] The story generation model is pre-trained.
[0145] In specific implementation, the model is not trained from scratch. Instead, it is based on a T5 model 400 that has been pre-trained on a large number of data sets. The T5 model 400 is further trained on the pre-processed data set to learn to generate the middle part of the story (story content) from the previous context (story background) and the following context (story ending) of the story.
[0146] refer to Figure 5 , which is another schematic diagram of a training method for a story generation model provided according to an exemplary embodiment of the present disclosure.
[0147] In some exemplary embodiments, the story generation model is a GPT model 500 , which includes a decoder 502 .
[0148] Then, the story generation model is obtained by training the training text set, including:
[0149] Splicing the training story background, the training story ending, and the training story content to obtain spliced data, and inputting the spliced data into the decoder 502 to train the story generation model;
[0150] Among them, in the spliced data, the ending of the training story is used as the two end data of the spliced data, and the background of the training story and the content of the training story are used together as the middle data of the spliced data.
[0151] In specific implementations, the training story background and the training story content are considered as a whole. There is no need to distinguish the boundary between the training story background and the training story content, that is, there is no need to separate them with preset symbols. In this case, when the model generates the story, the story background can be in any position (it can have a terminator or an incomplete position), and the story generation model will continue to write the next story. For example, the last sentence of the story background can be "I will help you fish it out", and the story generation model will continue to write "The sword, you don't have to worry..."; or it can be "I will help you fish it out," and the story generation model will continue to write "After saying this, the young man jumped into the water, like a fish swimming..."
[0152] In some exemplary embodiments, before obtaining the story generation model through training the training text set, the method further includes:
[0153] The story generation model is pre-trained.
[0154] In specific implementation, the model is not trained from scratch. Instead, it is based on a GPT model that has been pre-trained on a massive data set. The pre-trained parameters are fixed and the newly added parameters are optimized according to the training text set to learn to generate the middle (story content) and ending of the story from the ending of the story and the context (story background) of the story.
[0155] The GPT model is a decoder structure. When pre-training GPT, the input is a continuous text, but this text does not necessarily represent a complete story. The specific method of GPT model training is to learn from the first N characters to maximize the probability of the N+1th character.
[0156] The closer the retrained data format (downstream task) is to the pretrained data format, the better the effect and the more the knowledge learned by the pretrained model can be retained. Therefore, when training the story generation based on the ending, the format is a special symbol [] surrounding the ending. The story above + the middle of the story + [ending] is a continuous text segment. The model can learn the coherence of the story and end when it reaches the specified ending. The endings before and after are surrounded by [] to keep consistent and easy for the model to understand. If the ending after is replaced by <s> and< / s> The effect of enclosing is not good, which may be because the two special symbols have special meanings in the pre-training stage, representing the beginning and end of continuous text segments respectively, so they cannot be directly used to enclose the subsequent ending.
[0157] As an example, for example:
[0158] The model's input was: "[At first glance, it's as if the world has stood still.] All the new disciples are here, Master." His expression remained unchanged, his boots tapping on a tall branch not far away. He looked down from above, his brows slender. The faint golden veins at the corners of his black robes accentuated his solemnity. A flute with a red tassel was tucked at his waist, and his blood-red hairband swayed lightly in the wind, spotless. [At first glance, it's as if the world has stood still.]
[0159] refer to Figure 6 , which is a schematic diagram of a pre-training method for a story generation model provided according to an exemplary embodiment of the present disclosure.
[0160] Among them, the pre-trained GPT model is used to continue the story. The pre-trained GPT model is obtained after training on massive data for a long time. The model has learned the characteristics and information of massive data, and has mastered many natural language expressions and some common sense.
[0161] If you want to train a model with outcome considerations based on this model, you'll need a batch of data to further train (fine-tune) the model parameters. Fine-tuning all model parameters can lead to forgetting and losing information learned by the pre-trained model, focusing only on the fine-tuning data. Furthermore, if you fine-tune the pre-trained model, you'll need to save all the parameters after fine-tuning, doubling the number of parameters compared to the pre-trained model and doubling the space resources used.
[0162] To address these issues, there are several ways to add parameters to the model. Adapters add parameter operations sequentially to each layer of the pretrained model; prefix-tuning adds trainable key and value parameters to each layer's attention; and prompt-tuning appends trainable parameters to the input of the first layer. Choose any of these methods based on your needs. All three methods add no more than 2% of the original pretrained parameters.
[0163] Step S230: Splice the story content with the corresponding story background, the input content and the story ending to obtain the story.
[0164] As an example, the background of the story is: when you pass by the dock, a boatman choked up and asked you for help: "Young man, when I went out to sea two years ago, I promised my son that I would bring him an ironwood sword, but when the boat docked, the sword accidentally fell into the water. I searched for a long time along the marks engraved on the side of the boat but couldn't find it. What should I do?" The young man helped the boatman go into the water to fish it out.
[0165] The story generated by the story generation model built on the T5 model is as follows: He put one foot into the water, and for some reason it suddenly retracted. The boatman asked curiously, "Young man, what's wrong?" The young man replied, "I'm afraid of water!"
[0166] The story ends with the boatman breaking his promise and failing to bring back the ironwood sword for his son.
[0167] The story goes like this: You're passing by a dock when a boatman, choking up with sobs, asks for help: "Young man, two years ago, when I went out to sea, I promised my son I'd bring him an ironwood sword. But when the boat docked, the sword accidentally fell into the water. I've searched for it for a long time, following the marks carved on the side of the boat, but I can't find it. What should I do?" The young man helps the boatman dive into the water to retrieve it. He dips a foot into the water, but for some reason, he pulls it back. Curious, the boatman asks, "Young man, what's wrong?" The young man replies, "I'm afraid of water!" The boatman breaks his promise and fails to bring his son the ironwood sword.
[0168] As an example, the background of the story is: when you pass by the dock, a boatman choked up and asked you for help: "Young man, when I went out to sea two years ago, I promised my son that I would bring him an ironwood sword, but when the boat docked, the sword accidentally fell into the water. I searched for a long time along the marks engraved on the side of the boat but couldn't find it. What should I do?" The young man helped the boatman go into the water to fish it out.
[0169] The story generated by the story generation model built on the T5 model is as follows: The young man fished for a long time, while the boatman waited anxiously on the shore. The young man returned with the sword. The boatman burst into tears when he took the ironwood sword. After the young man left, the boatman sat on the bow of the boat.
[0170] The story ends with the boatman's son getting the ironwood sword and being very happy.
[0171] The story goes like this: As you pass by the dock, a boatman, choking with tears, calls out to you for help: "Young man, two years ago, when I went out to sea, I promised my son I'd bring him an ironwood sword. But when the boat docked, the sword accidentally fell into the water. I've searched for it for a long time, following the marks carved on the side of the boat, but I can't find it. What should I do?" The young man helps the boatman by diving into the water to retrieve it. He fishes for a long time, while the boatman waits anxiously on the shore. The young man returns, clutching the sword. The boatman bursts into tears as he takes it. After the young man leaves, the boatman sits on the bow of the boat. The boatman's son is overjoyed to have the ironwood sword.
[0172] As can be seen from the above, the story generation method provided by the embodiment of the present disclosure includes: determining a story background and user input content, and determining a story ending from a number of alternative story endings based on the input content; inputting the story background, the input content, and the story ending into a pre-built story generation model to obtain story content output by the story generation model; and splicing the story content with the corresponding story background, the input content, and the story ending to obtain the story. The present disclosure screens story endings based on user input content, thereby preventing the generated stories from being unreasonable and incoherent, while also reducing costs and improving efficiency.
[0173] Furthermore, because the ending and the previous story context are given, story generation is constrained, preventing the intrusion of characters from outside the scene. Since the ending can be generated simultaneously, the story is relatively complete because the model learns the coherence between the contexts.
[0174] Since the pre-trained model parameters remain unchanged, only one copy needs to be saved. Different tasks can share this set of parameters. For example, one task can directly continue the story, while another task can read the pre-trained parameters and newly added parameters to generate a story based on the ending. Adding downstream tasks does not result in an exponential increase in the number of new parameters, effectively saving space.
[0175] Furthermore, since the number of newly added parameters is relatively small, relatively little training data is required, speeding up training time. Since the pre-trained model's parameters remain unchanged, forgetting and loss of knowledge learned by the pre-trained model are reduced, which helps improve generalization in real-world use. In real-world applications, various story contexts may arise. For example, if the dataset used to train the newly added parameters doesn't have any information related to Lao Jian, then the knowledge learned by the pre-trained model must contain relevant information to generate a more reasonable story. Otherwise, if the model doesn't understand Lao Jian, it will naturally be unable to generate a reasonable story.
[0176] It should be noted that the method of the embodiments of the present disclosure can be performed by a single device, such as a computer or server. The method of the embodiments of the present disclosure can also be applied in a distributed scenario, where multiple devices cooperate to perform the method. In such a distributed scenario, one of the multiple devices may only perform one or more steps of the method of the embodiments of the present disclosure, and the multiple devices will interact with each other to complete the method.
[0177] It should be noted that the above description is limited to some embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in an order different from that described in the above embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0178] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present disclosure further provides a story generating device.
[0179] refer to Figure 7 , the story generating device comprises:
[0180] A story ending determination module 710 is configured to determine the story background and the user's input content, and determine the story ending from a plurality of alternative story endings based on the input content;
[0181] The story content generation module 720 is configured to input the story background, the input content, and the story ending into a pre-built story generation model to obtain the story content output by the story generation model;
[0182] The story determination module 730 is configured to combine the story content with the corresponding story background, the input content and the story ending to obtain the story.
[0183] In some exemplary embodiments, the story ending determination module 710 is specifically configured to:
[0184] The input content is respectively concatenated with several of the alternative story endings to obtain several concatenated sentences, perplexity values of the concatenated sentences are respectively determined, and at least one of the story endings is determined based on the perplexity values.
[0185] In some exemplary embodiments, the story generating device is further configured to:
[0186] Obtaining an original text set; wherein the original text set includes a plurality of texts, and the plurality of texts are arranged in a preset order;
[0187] Dividing the original text set to obtain a plurality of training text sets; wherein the training text sets include training story backgrounds, training story contents, and training story endings;
[0188] The story generation model is obtained by training the training text set.
[0189] In some exemplary embodiments, the story generating device is further configured to:
[0190] Creating an empty candidate training text set, and sequentially adding the texts in the original text set to the candidate training text set;
[0191] For any of the current texts and any of the current candidate training text sets, in response to determining that, after adding the current text to the current candidate training text set, the character length of the current candidate training text set is less than or equal to a preset first threshold, continuing to add the next text to the current candidate training text set until the character length of the current candidate training text set is greater than the first threshold;
[0192] In response to determining that, after adding the current text to the current candidate training text set, the character length of the current candidate training text set is greater than the first threshold, further determining whether the current candidate training text set meets a preset training text set standard; and in response to determining that the current candidate training text set meets the training text set standard, determining the current candidate training text set as the training text set;
[0193] In response to determining that the current candidate training text set does not meet the training text set standard, the current candidate training text set is deleted, a new candidate training text set with empty content is created, and the text starting from the current text is added to the new candidate training text set in sequence, and the above operation is repeated until a preset number of training text sets are obtained.
[0194] In some exemplary embodiments, the training text set standard includes:
[0195] The number of leading quotation marks and the number of trailing quotation marks in the training text set are the same;
[0196] The ending of the training story does not include quotation marks;
[0197] The character length of the training story ending is greater than or equal to a preset threshold;
[0198] The character length of the training text set is greater than or equal to a preset second threshold; wherein the second threshold is less than the first threshold.
[0199] In some exemplary embodiments, the story generating device is further configured to:
[0200] A preset number of adjacent texts including the last text in the training text set are collectively used as the training story endings, and the other texts are used as training non-story endings;
[0201] According to a preset character length threshold of the training story background, traversing the training non-story ending from front to back to obtain the training story background, and using the remaining text in the training non-story ending as the training story content;
[0202] or,
[0203] According to a preset character length threshold of the training story content, the training non-story ending is traversed from back to front to obtain the training story content, and the remaining text in the training non-story ending is used as the training story background.
[0204] In some exemplary embodiments, the story generation model includes an encoder and a decoder;
[0205] Then, the story generating device is further configured to:
[0206] The training story background and the training story ending are input into the encoder to obtain the encoded data output by the encoder, and the encoded data and the training story content are input into the decoder to train and obtain the story generation model.
[0207] In some exemplary embodiments, the story generation model includes a decoder;
[0208] Then, the story generating device is further configured to:
[0209] splicing the training story background, the training story ending, and the training story content to obtain spliced data, inputting the spliced data into the decoder, and training to obtain the story generation model;
[0210] Among them, in the spliced data, the ending of the training story is used as the two end data of the spliced data, and the background of the training story and the content of the training story are used together as the middle data of the spliced data.
[0211] In some exemplary embodiments, before obtaining the story generation model through training the training text set, the story generation device is further configured to:
[0212] The story generation model is pre-trained.
[0213] In some exemplary embodiments, the story generation model includes any one of the following:
[0214] T5 model or GPT model.
[0215] For the convenience of description, the above devices are described as being functionally divided into various modules. Of course, when implementing the present disclosure, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0216] The apparatus of the above embodiment is used to implement the corresponding story generation method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0217] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the story generation method described in any of the above embodiments is implemented.
[0218] Figure 8 10 is a schematic diagram showing a more specific hardware structure of an electronic device provided in this embodiment. The device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are communicatively connected to each other within the device via the bus 1050.
[0219] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0220] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 1020 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1020 and is called and executed by the processor 1010.
[0221] The input / output interface 1030 is used to connect an input / output module to implement information input and output. The input / output module can be configured as a component in the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Input devices may include a keyboard, mouse, touch screen, microphone, various sensors, etc., and output devices may include a display, speaker, vibrator, indicator light, etc.
[0222] The communication interface 1040 is used to connect to a communication module (not shown) to enable communication between the device and other devices. The communication module can communicate via a wired method (such as USB, network cable, etc.) or a wireless method (such as mobile network, WiFi, Bluetooth, etc.).
[0223] The bus 1050 comprises a path for transmitting information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).
[0224] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, it will be understood by those skilled in the art that the above device may only include the components necessary to implement the embodiments of this specification, and does not necessarily include all the components shown in the figure.
[0225] The electronic device of the above embodiment is used to implement the corresponding story generation method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0226] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present disclosure also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the story generation method described in any of the above embodiments.
[0227] The above-mentioned non-transitory computer-readable storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO)), optical storage (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (such as ROMs, EPROMs, EEPROMs, non-volatile memories (NAND FLASH), solid-state drives (SSDs)), etc.
[0228] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the story generation method described in any embodiment in the above exemplary method part, and have the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0229] Those skilled in the art will appreciate that embodiments of the present disclosure may be implemented as a system, method, or computer program product. Therefore, the present disclosure may be implemented in the following forms: entirely in hardware, entirely in software (including firmware, resident software, microcode, etc.), or in a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, the present disclosure may also be implemented in the form of a computer program product in one or more computer-readable media containing computer-readable program code.
[0230] Any combination of one or more computer-readable media can be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (non-exhaustive examples) of computer-readable storage media can include, for example: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0231] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0232] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0233] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0234] It should be understood that each block in the flowchart and / or block diagram, and combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine. These computer program instructions are executed by the computer or other programmable data processing device to produce a device that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0235] These computer program instructions can also be stored in a computer-readable medium that enables a computer or other programmable data processing device to operate in a specific manner. In this way, the instructions stored in the computer-readable medium produce a product that includes an instruction device that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0236] Computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, such that the instructions executed on the computer or other programmable apparatus provide a process that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0237] Furthermore, although the operations of the disclosed method are described in a particular order in the accompanying drawings, this does not require or imply that the operations must be performed in that particular order, or that all of the operations shown must be performed to achieve the desired results. Rather, the steps depicted in the flowcharts may be performed in a different order. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into a single step, and / or a single step may be broken down into multiple steps.
[0238] The use of the verbs "comprise", "include" and their conjugations in the application documents does not exclude the presence of elements or steps other than those stated in the application documents. The article "a" or "an" preceding an element does not exclude the presence of a plurality of such elements.
[0239] Although the spirit and principles of the present disclosure have been described with reference to several specific embodiments, it should be understood that the present disclosure is not limited to the specific embodiments disclosed, and the division into various aspects does not mean that the features of these aspects cannot be combined to benefit. Such division is merely for the convenience of expression. The present disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims. The scope of the appended claims is to be accorded the broadest interpretation so as to encompass all such modifications and equivalent structures and functions.
Claims
1. A method for generating a story, characterized in that: include: Determining a story background and user input, and determining a story ending from a plurality of alternative story endings based on the input; The story background, the input content and the story ending are input into a pre-built story generation model to obtain the story content output by the story generation model; wherein, the training method of the story generation model includes: obtaining an original text set; wherein, the original text set includes a plurality of texts, and the plurality of texts are arranged in a preset order; creating an empty alternative training text set, and adding the texts in the original text set to the alternative training text set in sequence; for any current text and any current alternative training text set, in response to determining that after adding the current text to the current alternative training text set, the character length of the current alternative training text set is less than or equal to a preset first threshold, continuing to add the next text to the current alternative training text set until the character length of the current alternative training text set is greater than the first threshold; in response to determining that the current text is added to the current alternative training text set, After the text is added to the current candidate training text set, if the character length of the current candidate training text set is greater than the first threshold, further determining whether the current candidate training text set meets the preset training text set standard, in response to determining that the current candidate training text set meets the training text set standard, determining the current candidate training text set as the training text set; in response to determining that the current candidate training text set does not meet the training text set standard, deleting the current candidate training text set, creating a new candidate training text set with empty content, and sequentially adding the text starting from the current text to the new candidate training text set, repeating the above operation until a preset number of training text sets are obtained; wherein the training text set includes a training story background, a training story content, and a training story ending; and obtaining the story generation model through training with the training text set; The story content is spliced with the corresponding story background, the input content and the story ending to obtain the story.
2. The method according to claim 1, characterized in that Determining a story ending from a plurality of alternative story endings according to the input content includes: The input content is respectively concatenated with several of the alternative story endings to obtain several concatenated sentences, perplexity values of the concatenated sentences are respectively determined, and at least one of the story endings is determined based on the perplexity values.
3. The method according to claim 1, characterized in that The training text set standards include: The number of leading quotation marks and the number of trailing quotation marks in the training text set are the same; The ending of the training story does not include quotation marks; The character length of the training story ending is greater than or equal to a preset threshold; The character length of the training text set is greater than or equal to a preset second threshold; wherein the second threshold is less than the first threshold.
4. The method according to claim 1, wherein The method further comprises: A preset number of adjacent texts including the last text in the training text set are collectively used as the training story endings, and the other texts are used as training non-story endings; According to a preset character length threshold of the training story background, traversing the training non-story ending from front to back to obtain the training story background, and using the remaining text in the training non-story ending as the training story content; or, According to a preset character length threshold of the training story content, the training non-story ending is traversed from back to front to obtain the training story content, and the remaining text in the training non-story ending is used as the training story background.
5. The method according to claim 1, wherein The story generation model includes an encoder and a decoder; Then, the story generation model is obtained by training the training text set, including: The training story background and the training story ending are input into the encoder to obtain the encoded data output by the encoder, and the encoded data and the training story content are input into the decoder to train and obtain the story generation model.
6. The method according to claim 1, wherein The story generation model includes a decoder; Then, the story generation model is obtained by training the training text set, including: splicing the training story background, the training story ending, and the training story content to obtain spliced data, inputting the spliced data into the decoder, and training to obtain the story generation model; Among them, in the spliced data, the ending of the training story is used as the two end data of the spliced data, and the background of the training story and the content of the training story are used together as the middle data of the spliced data.
7. The method according to claim 1, characterized in that Before obtaining the story generation model through training the training text set, the method further includes: The story generation model is pre-trained.
8. The method according to claim 1, characterized in that The story generation model includes any of the following: T5 model or GPT model.
9. A story generating device, characterized in that: include: a story ending determination module configured to determine the story background and user input content, and determine the story ending from a plurality of alternative story endings based on the input content; A story content generation module is configured to input the story background, the input content and the story ending into a pre-built story generation model to obtain the story content output by the story generation model; wherein, the training method of the story generation model includes: obtaining an original text set; wherein, the original text set includes a plurality of texts, and the plurality of texts are arranged in a preset order; creating an empty alternative training text set, and adding the texts in the original text set to the alternative training text set in sequence; for any current text and any current alternative training text set, in response to determining that after adding the current text to the current alternative training text set, the character length of the current alternative training text set is less than or equal to a preset first threshold, continuing to add the next text to the current alternative training text set until the character length of the current alternative training text set is greater than the first threshold; After determining that the current text is to be added to the current candidate training text set, and the character length of the current candidate training text set is greater than the first threshold, further determining whether the current candidate training text set meets the preset training text set standard, in response to determining that the current candidate training text set meets the training text set standard, determining the current candidate training text set as the training text set; in response to determining that the current candidate training text set does not meet the training text set standard, deleting the current candidate training text set, creating a new candidate training text set with empty content, and sequentially adding the text starting from the current text to the new candidate training text set, repeating the above operation until a preset number of training text sets are obtained; wherein the training text set includes a training story background, a training story content, and a training story ending; and obtaining the story generation model through training with the training text set; The story determination module is configured to combine the story content with the corresponding story background, the input content and the story ending to obtain the story.
10. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 8 is implemented.
11. A non-transitory computer-readable storage medium, characterized in that The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a computer to execute the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Story generation model training method and device, equipment and storage medium
CN111414737A
Semantic representation model generation method and device, electronic equipment and storage medium
CN111950291A
Story text prediction method and device and electronic equipment
CN114139524A
Text generation method fusing double-language model and sentence detection
CN114298010A