Scenario generation method and device, equipment, medium and product
By optimizing the logic of the unit scripts and making corrections using the preceding scripts, the problem of inconsistent plots in the scripts generated by the large language model was solved, and the logic and accuracy of the scripts were improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-25
- Publication Date
- 2026-03-24
AI Technical Summary
Existing script generation methods based on large language models are prone to inconsistencies in plot and logical confusion, leading to reduced accuracy in script generation.
After obtaining the story content text and generating candidate scripts, each unit script is logically optimized and revised using the previous unit scripts to ensure plot coherence. The optimized unit scripts are generated using a large language model and logical optimization prompts, and finally the target script is generated.
It improved the logical consistency and accuracy of the script's plot, corrected logical problems such as inconsistencies in information throughout the story, and enhanced the quality of the generated script.
Smart Images

Figure CN121723973A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of script generation technology, and more specifically, to a script generation method, apparatus, device, medium, and product. Background Technology
[0002] A script is a literary text created for theatrical works such as plays, films, and television series, providing a complete creative basis for subsequent filming or stage performances. Scriptwriting is usually done manually by screenwriters, which is time-consuming and costly. With the development of natural language processing technology, script generation based on large language models has become a new approach to scriptwriting. However, the large language model script generation process involves processing a large amount of text and other data, making the output script prone to errors and reducing the accuracy of the generated script. Summary of the Invention The embodiments of this application provide a script generation method, script generation device, electronic device, computer-readable storage medium, and computer program product, which can ensure the logical consistency of the plot in the script and improve the accuracy of the script.
[0003] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0004] According to one aspect of the embodiments of this application, a script generation method is provided, comprising: obtaining story content text for describing story content; generating candidate scripts of the story content text based on the story content text; wherein the candidate scripts include a plurality of unit scripts arranged in sequence; for each unit script, performing logical optimization on each unit script based on the preceding unit script of each unit script to obtain an optimized unit script of each unit script; and generating a target script of the story content text based on the optimized unit scripts corresponding to the plurality of unit scripts respectively.
[0005] According to one aspect of the embodiments of this application, a script generation apparatus is provided, comprising: an acquisition module for acquiring story content text describing story content; a generation module for generating candidate scripts of the story content text based on the story content text; wherein the candidate scripts include a plurality of unit scripts arranged in sequence; an optimization module for performing logical optimization on each unit script based on the preceding unit script of each unit script to obtain an optimized unit script of each unit script; the generation module is further configured to generate a target script of the story content text based on the optimized unit scripts corresponding to the plurality of unit scripts respectively.
[0006] In one embodiment of this application, the generation module is specifically used for: performing plot analysis on the story content text to generate basic content element information of the story content text; the basic content element information includes at least one of plot summary information, world structure information, and character setting information; splitting the story content text to obtain multiple original text fragments; generating a stage script corresponding to each original text fragment based on the basic content element information and each original text fragment; wherein, the stage script includes at least one unit script arranged in sequence; and generating candidate scripts for the story content text based on the stage scripts corresponding to the multiple original text fragments respectively.
[0007] In one embodiment of this application, the generation module is specifically used to: split the story content text to obtain multiple story stages and content description information corresponding to each of the multiple story stages; and split the story content text according to the content description information corresponding to each of the multiple story stages to obtain original text fragments corresponding to each of the multiple story stages.
[0008] In one embodiment of this application, the generation module is specifically used to: extract the plot of each original text fragment to generate the original plot of each original text fragment; expand the original plot of each original text fragment according to the basic content element information to generate the plot outline corresponding to each original text fragment; and generate the stage script corresponding to each original text fragment according to each original text fragment and the plot outline corresponding to each original text fragment.
[0009] In one embodiment of this application, the generation module is specifically used for: performing plot expansion processing on the original plot of each original text fragment according to the basic content element information to generate a candidate plot outline for each original text fragment; extracting content information from the candidate plot outline to obtain first expanded content information corresponding to each original text fragment; performing quality detection on the candidate plot outline according to the original content information and the first expanded content information corresponding to each original text fragment to obtain a quality score for the candidate plot outline; the original content information is obtained by extracting content information from each original text fragment; if the quality score is higher than the outline score threshold, then the candidate plot outline is used as the plot outline corresponding to each original text fragment to generate the plot outline corresponding to each original text fragment.
[0010] In one embodiment of this application, where the original content information includes the original core plot extracted from each original text fragment, and the first expanded content information includes the expanded core plot extracted from the candidate plot outline, the generation module is specifically configured to: find overlapping storylines from the original core plot and the expanded core plot, and calculate the proportion of the overlapping storylines in the storylines included in the original core plot to obtain the original plot proportion; find expanded storylines included in the expanded core plot but not included in the original core plot, and calculate the proportion of the expanded storylines in the storylines included in the original core plot to obtain the expanded plot proportion; and calculate the quality score of the candidate plot outline based on the original plot proportion and the expanded plot proportion.
[0011] In one embodiment of this application, the generation module is specifically used for: calculating a first score based on the original plot ratio; wherein the first score is positively correlated with the original plot ratio; calculating a second score based on the expanded plot ratio; wherein the second score and the expanded plot ratio have a downward-opening unimodal function relationship; performing a weighted summation of the first score and the second score to calculate the quality score of the candidate plot outline; wherein the weight of the first score is greater than the weight of the second score.
[0012] In one embodiment of this application, the generation module is specifically configured to: search for overlapping events from the original core event set contained in the original content information and the expanded core event set contained in the first expanded content information; the original core event set contains core events extracted from each original text fragment; the expanded core event set contains core events extracted from the candidate plot outline; calculate an event consistency score based on the proportion of overlapping events in the original core event set; and calculate a quality score for the candidate plot outline based on the event consistency score, the proportion of the original plot, and the proportion of the expanded plot.
[0013] In one embodiment of this application, the generation module is specifically used to: if the quality score of the candidate plot outline is lower than or equal to the outline score threshold, then based on the basic content element information, perform plot expansion processing on the original plot of each original text fragment to generate a new candidate plot outline for each original text fragment, until the generation stop condition is met; the generation stop condition includes at least one of the following conditions: the quality score of the candidate plot outline is higher than the outline score threshold, and the number of generated candidate plot outlines reaches at least one of the number thresholds; and select the candidate plot outline with the highest quality score from the generated candidate plot outlines to generate the plot outline corresponding to each original text fragment.
[0014] In one embodiment of this application, the generation module is specifically configured to: obtain candidate stage scripts corresponding to each original text fragment; wherein the candidate stage scripts include optimized unit scripts corresponding to at least one unit script of each original text fragment; extract content information from the candidate stage scripts corresponding to each original text fragment to generate second expanded content information corresponding to each original text fragment; perform quality detection on the candidate stage scripts based on the original content information and the second expanded content information corresponding to each original text fragment to obtain a quality score for the candidate stage scripts; the original content information is obtained by extracting content information from each original text fragment; if the quality score is higher than the script score threshold, then the candidate stage scripts are used as target stage scripts corresponding to each original text fragment; generate the target scripts of the story content text based on the target stage scripts corresponding to the plurality of original text fragments respectively.
[0015] In one embodiment of this application, where the second expanded content information is generated by the generative model extracting content information from the candidate stage script, the apparatus further includes a training module, configured to: acquire a training sample set and a model to be trained, and perform supervised training on the model to be trained based on the training sample set to obtain an initial generative model; the training sample set includes sample scripts and target content information of the sample scripts; extract content information from the sample scripts using the initial generative model to generate predicted content information of the sample scripts; generate a reinforced sample script for reinforcement learning training based on the sample scripts, the predicted content information of the sample scripts, and the target content information, as well as first content information and second content information corresponding to the reinforced sample scripts; the first content information is superior to the second content information; and perform reinforcement learning training on the initial generative model based on the reinforced sample scripts, the first content information, and the second content information to obtain the generative model.
[0016] In one embodiment of this application, the training module is specifically used to: input each sample script in the training sample set, the predicted content information and the target content information of each sample script into a large language model to obtain the optimal content indication of each sample script output by the large language model; the optimal content indication is used to indicate the optimal content information in the predicted content information and the target content information of each sample script; according to the optimal content indication, select the enhanced sample script from multiple sample scripts included in the training sample set, and generate the first content information and the second content information corresponding to the enhanced sample script based on the optimal content indication, the predicted content information and the target content information corresponding to the enhanced sample script.
[0017] In one embodiment of this application, the training module is specifically configured to: select, according to the optimal content indication, from multiple sample scripts included in the training sample set, an enhanced sample script whose target content information is superior to the predicted content information; optimize the target content information of the enhanced sample script using a large language model based on the enhanced sample script and the predicted content information of the enhanced sample script to obtain the optimized content information of the enhanced sample script; generate first content information of the enhanced sample script based on the optimized content information; and generate second content information of the enhanced sample script based on the predicted content information of the enhanced sample script.
[0018] In one embodiment of this application, the training module is specifically used for: inputting the enhanced sample script into the initial generation model for probability prediction, obtaining a first probability that the initial generation model outputs the first content information based on the enhanced sample script, and a second probability that the initial generation model outputs the second content information based on the enhanced sample script; inputting the enhanced sample script into a reference model for probability prediction, obtaining a third probability that the reference model outputs the first content information based on the enhanced sample script, and a fourth probability that the reference model outputs the second content information based on the enhanced sample script; the reference model includes the historical model of the initial generation model; calculating the loss value corresponding to the enhanced sample script based on the first probability, the second probability, the third probability, and the fourth probability, and updating the model parameters of the initial generation model according to the loss value to obtain the generation model; wherein, the loss value is negatively correlated with the first probability and the fourth probability, and positively correlated with the second probability and the third probability.
[0019] In one embodiment of this application, the optimization module is specifically used to: for each unit script, find the preceding unit script in the stage script to which each unit script belongs, and perform logical optimization on each unit script based on the association information of the stage script to which each unit script belongs and the preceding unit script, to obtain an optimized unit script for each unit script; the association information includes at least one of the following: the original text fragment corresponding to the stage script to which each unit script belongs, the plot outline corresponding to the stage script to which each unit script belongs, and the content description information corresponding to the stage script to which each unit script belongs.
[0020] In one embodiment of this application, the optimization module is specifically used to: for each unit script, perform logical optimization on each unit script based on the preceding unit script to obtain an initial optimized unit script for each unit script; and polish the initial optimized unit script based on at least one of the preceding unit script and script format requirement information to obtain an optimized unit script for each unit script.
[0021] According to one aspect of the embodiments of this application, an electronic device is provided, including one or more processors; and a storage device for storing one or more computer programs, which, when executed by the one or more processors, cause the electronic device to implement the script generation method as described above.
[0022] According to one aspect of the embodiments of this application, an embodiment of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor of an electronic device, causes the electronic device to perform the script generation method as described above.
[0023] According to one aspect of the embodiments of this application, an embodiment of this application provides a computer program product, including a computer program stored in a computer-readable storage medium, wherein a processor of an electronic device reads from the computer-readable storage medium and executes the computer program, causing the electronic device to perform the script generation method as described above.
[0024] In the technical solution provided in the embodiments of this application, after obtaining the story content text used to describe the story content, candidate scripts for the story content text are first generated based on the story content text. The candidate scripts contain multiple unit scripts arranged in sequence. Then, for each unit script, each unit script is logically optimized based on the preceding unit script to obtain an optimized unit script for each unit script. This can correct logical problems such as inconsistencies in the plot information in the script. Then, based on the optimized unit scripts corresponding to the multiple unit scripts, the target script for the story content text is generated, which can ensure the logical consistency of the plot in the script and improve the accuracy of the script.
[0025] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0026] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0027] Figure 1 This is a schematic diagram of one implementation environment involved in this application.
[0028] Figure 2 This is a flowchart illustrating a script generation method in an exemplary embodiment of this application.
[0029] Figure 3 This is a schematic diagram illustrating another script generation method as shown in an exemplary embodiment of this application.
[0030] Figure 4 This is a schematic diagram illustrating another script generation method as shown in an exemplary embodiment of this application.
[0031] Figure 5 This is a schematic diagram illustrating another script generation method as shown in an exemplary embodiment of this application.
[0032] Figure 6 This is a schematic diagram illustrating another script generation method as shown in an exemplary embodiment of this application.
[0033] Figure 7 This is a schematic diagram illustrating another script generation method as shown in an exemplary embodiment of this application.
[0034] Figure 8 This is a schematic diagram illustrating another script generation method as shown in an exemplary embodiment of this application.
[0035] Figure 9 This is a schematic diagram illustrating the script generation process in an exemplary embodiment of this application.
[0036] Figure 10 This is a schematic diagram illustrating the script generation process in an exemplary embodiment of this application.
[0037] Figure 11 This is a structural block diagram of a script generation apparatus illustrated in an exemplary embodiment of this application.
[0038] Figure 12 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Detailed Implementation
[0039] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0040] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0041] The flowcharts shown in the accompanying diagrams are merely illustrative and do not necessarily include all content and operations, nor do they necessarily have to be executed in the described order. For example, some operations may be broken down, while others may be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0042] It should also be noted that "multiple" as mentioned in this application refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0043] The technical solutions of the embodiments of this application will be described in detail below.
[0044] To improve the reliability of plot generation and the accuracy of the script, this application provides a script generation scheme. Please refer to [link / reference]. Figure 1 , Figure 1 This is a schematic diagram of an implementation environment related to this application. The implementation environment includes a terminal device 101 and a server 102, wherein: Terminal devices 101 include, but are not limited to, mobile phones, computers (such as tablets, laptops, desktop computers, etc.), smart home devices (such as televisions, refrigerators, air conditioners, washing machines, robot vacuums, etc.), smart wearable devices (such as wristbands, watches, etc.), and augmented reality devices (such as virtual reality devices, augmented reality devices, mixed reality devices, etc.).
[0045] Server 102 can be a standalone physical server, or a server cluster or distributed system composed of multiple physical servers. The server cluster or distributed system includes cloud servers used to provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Terminal device 101 establishes a communication connection with server 102 via a wired or wireless network. Figure 1 The number of terminal devices 101 and servers 102 shown is merely illustrative; any number of terminal devices 101 and servers 102 can be used as needed.
[0046] In an optional embodiment of this application, the script generation method provided in the embodiments of this application can be executed by a terminal device 101. The terminal device 101 runs an application for providing script generation services. The terminal device 101 can obtain story content text for describing the story through the application. For example, it can display the script generation interface corresponding to the application, and the user can input the story content text through the text input interface contained in the interface, or load a file containing the story content text through the file input interface contained in the interface. Then, the terminal device 101 generates candidate scripts for the story content text based on the story content text, wherein the candidate scripts contain multiple unit scripts arranged in sequence. For each unit script, each unit script is logically optimized based on the preceding unit script of each unit script to obtain an optimized unit script for each unit script, so as to generate the target script for the story content text based on the optimized unit scripts corresponding to the multiple unit scripts respectively.
[0047] In an optional embodiment of this application, the script generation method provided in the embodiments of this application can be executed by server 102. Server 102 can obtain story content text and generate candidate scripts for story content text based on the story content text. For each unit script, each unit script is logically optimized based on the preceding unit script of each unit script to obtain an optimized unit script for each unit script, so as to generate the target script for story content text based on the optimized unit scripts corresponding to multiple unit scripts respectively.
[0048] In an optional embodiment of this application, the script generation method provided in the embodiments of this application can be jointly executed by terminal device 101 and server 102. For example, after terminal device 101 obtains the story content text through an application, it sends the story content text to server 102. Server 102 generates candidate scripts for the story content text based on the story content text. For each unit script, based on the preceding unit script, each unit script is logically optimized to obtain an optimized unit script for each unit script. Based on the optimized unit scripts corresponding to multiple unit scripts, a target script for the story content text is generated. Optionally, server 102 sends the target script to terminal device 101, and terminal device 101 displays the target script in the script generation interface of the application for user preview.
[0049] In the specific implementation of this application, user-related data such as story content text are involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0050] The following describes in detail the various implementation details of the technical solutions in the embodiments of this application.
[0051] like Figure 2 As shown, Figure 2 This is a flowchart illustrating a script generation method according to an embodiment of this application, which can be applied to... Figure 1 The implementation environment shown indicates that this method can be executed by a terminal device or a server, or by both a terminal device and a server. This script generation method may include steps S201-S204, which are described in detail below.
[0052] S201, Obtain the story content text used to describe the story content.
[0053] Story content text is natural language text used to describe the story's content. It contains a relatively complete story outline, including characters, plot, and setting. Its types include, but are not limited to, at least one of novels, news articles, and script synopses. Optionally, story content text can be text entered by the user in the text input boxes included in the script generation interface, text contained in files uploaded by the user through the file upload interface in the script generation interface, or text extracted from publicly available information based on the name of a novel, news article, or multimedia content entered by the user.
[0054] S202, Generate candidate scripts for the story content text based on the story content text; wherein, the candidate scripts contain multiple unit scripts arranged in sequence.
[0055] A candidate script is a script-style text corresponding to the story content, including scene descriptions, dialogue, action cues, and background descriptions. A complete script typically contains multiple sequentially arranged unit scripts. A unit script is a modular script fragment that carries an independent narrative function within the overall framework of the complete script; for example, it can be a single-episode script or a scene script for a single scene. Multiple unit scripts can be arranged in the order of story development or the order of broadcast.
[0056] Optionally, candidate scripts can be generated using a general large language model or based on a script generation model. The script generation model is a network model specifically designed for generating scripts, which is a model trained specifically based on training samples in a script generation scenario.
[0057] S203, for each unit script, based on the preceding unit script, perform logical optimization on each unit script to obtain the optimized unit script for each unit script.
[0058] The script generation process involves handling a significant amount of text, which may lead to inconsistencies and plot conflicts. For example, in a previous scene, character A might have told character B, "I've fallen for you." If later, character A tells character B, "I've realized I'm smitten," the subsequent statement should logically be "I like you even more." Therefore, to avoid logical problems, candidate scripts undergo logical optimization. Each unit script is preceded by a unit script in the order of its preceding unit script. Optionally, considering that closer proximity generally indicates a higher degree of connection between plot points and greater relevance for logical optimization, for each unit script to be optimized, a preceding unit script with a gap less than a set value can be selected from the candidate scripts. This serves as a reference factor for logical optimization of each unit script. The set value can be flexibly adjusted according to actual needs. For instance, logical optimization of the current episode's script can be based on the previous episode's script.
[0059] Logic optimization is used to identify and correct logical problems in the preceding unit scripts of the unit script to be optimized. During logic optimization, the plot development, character inner conflicts, and dialogue content of both the preceding and preceding unit scripts are analyzed separately. This allows for revisions to ensure the story development follows logical rules, character inner conflicts remain consistent throughout dialogue, and character actions are consistent and uncontradictory, thus improving the script's logic and quality. Optionally, logic optimization can be implemented using a large language model combined with prompts. Specifically, for the unit script to be optimized, logic optimization prompts are generated based on both the unit script and the preceding unit scripts. These prompts are then input into the large language model, which outputs the logically optimized unit script based on these prompts.
[0060] S204, Generate the target script for the story content text based on the optimized unit scripts corresponding to the multiple unit scripts.
[0061] The target script is the complete script corresponding to the story content text, generated based on the optimized unit script.
[0062] exist Figure 2 In the illustrated embodiment, optimizing the unit script based on the preceding unit script of each unit script can correct logical problems such as inconsistencies in the plot information in the script, improve the logical consistency of the plot in the generated target script, and improve the accuracy of the script.
[0063] In one embodiment of this application, another script generation method is provided, which can be applied to... Figure 1 The implementation environment shown is as follows: Figure 3 As shown, this script generation method is in Figure 2 Based on the above, the process of generating candidate scripts for story content text in S202 is expanded to S301-S304, which are described in detail below.
[0064] S301, Perform plot analysis on the story content text to generate basic content element information of the story content text; the basic content element information includes at least one of plot summary information, world structure information, and character setting information.
[0065] Basic content element information refers to the natural language text describing the most core and fundamental content elements needed to construct a story; it is the "skeleton" upon which the story stands. Its types include, but are not limited to, at least one of the following: plot summary information, world-building information, and character setting information. Plot summary information is a summary of the story's plot, which may include the core storyline, key character relationships, core conflicts, and the ending. The plot summary can be a story outline, plot summary, etc. World-building information, i.e., the worldview, defines the physical and social laws of the story's world, clarifying the spatiotemporal environment and core rules in which the story takes place, such as a magical world, a realistic world, or a futuristic science fiction world. Character setting information, i.e., character design, includes basic settings such as appearance and identity, as well as deeper settings such as personality, preferences, abilities, and inner conflicts. Appearance includes, but is not limited to, age, height, and hairstyle. Optionally, in the process of extracting character setting information, character settings not described in the story content text should not be inferred.
[0066] Optionally, the basic content element information can be obtained through a large language model. If multiple types of basic content element information need to be extracted, for each type, corresponding generation prompts are generated based on the story text and information type, resulting in multiple types of generation prompts. These prompts are then input into the large language model, allowing it to extract the corresponding type of basic content element information from the story text based on the generated prompts. This method allows the large language model to process only one type of prompt information at a time and output only one type of basic content element information, avoiding the situation where the large language model processes too much text at once, leading to inaccurate extraction of basic content element information. For example, if the story text is a novel, the generation prompts used to extract world structure information, character settings, and plot summary information are as follows: Please provide the world-building settings for the following novel, along with its content: xxx.
[0067] Please provide all character settings for the following novel, such as {"Name":{"Appearance":age, height, hairstyle, etc., "Personality":xx,"Preferences":xx, "Abilities":xx,"Inner Conflicts":xx},}. Do not describe appearance information not provided in the novel. Novel content: xxx.
[0068] Please summarize the plot of the following novel, such as {Summary: xxx}, novel content: xxx.
[0069] S302, split the story content text to obtain multiple original text fragments.
[0070] The original text fragments are the original text within the story content and are a part of the story content. Splitting methods include, but are not limited to: 1. Splitting based on a set text length; 2. Splitting based on the story's development stage, resulting in each original text fragment corresponding to a relatively independent story stage.
[0071] In an optional implementation, the process of splitting the story content text to obtain multiple original text fragments may include: splitting the story content text to obtain multiple story stages and content description information corresponding to each of the multiple story stages; and splitting the story content text according to the content description information corresponding to each of the multiple story stages to obtain original text fragments corresponding to each of the multiple story stages.
[0072] The story unfolds through different stages. First, the story content text is analyzed to break it down into multiple story stages and their corresponding descriptive information. This descriptive information describes the story content of each stage, such as plot, events, and storylines. Based on the descriptive information corresponding to each story stage, the original text corresponding to this information is extracted from the story content text, resulting in the original text fragments for each stage. In this implementation, on the one hand, by breaking down the story content text based on its development stages, each original text fragment corresponds to a story stage, ensuring that the narrative between these fragments is relatively complete and independent. This independence allows for the independent generation of stage scripts for each original text fragment, enabling parallel generation and preventing any stage script from revealing the plot of subsequent stages. On the other hand, by generating scripts using a network model (e.g., a large language model), only one original text fragment needs to be input into the network model at a time for script generation, reducing the data processing load on the network model during script generation.
[0073] Optionally, the process of splitting the story content text may include: splitting the story content text according to multiple preset story development stages to generate content description information corresponding to each preset story stage. Each preset story stage includes its definition or name. Optionally, to improve the accuracy of the content description information, each preset story stage may also include the definitions or names of multiple sub-stages (e.g., multiple processes) corresponding to that stage. Based on the definitions or names of the preset story stages and sub-stages, the story content is split to generate content description information for each story stage. The content description information for each story stage includes the content descriptions of its corresponding multiple sub-stages. Optionally, during the splitting process, care should be taken to ensure the content of each sub-stage is coherent to avoid omissions. The pre-set story development stages can be one of the following: 1. A four-stage structure: introduction, development, transition, and conclusion. The introduction includes at least one of the following processes: environmental rules, protagonist's appearance, inciting event, external goal, stepping out of comfort zone, etc.; the development includes at least one of the following processes: exploring a new world, making allies, initial success, encountering enemies, suffering setbacks, etc.; the transition includes at least one of the following processes: crisis escalation, difficult choice, first decisive battle, suffering a major setback, etc.; the conclusion includes at least one of the following processes: decision to reflect, resolving conflict, hard training and growth, final decisive battle, returning to normalcy, etc. 2. A three-step structure: setup stage, conflict stage, and resolution stage.
[0074] Optionally, the process of decomposing the story content text may include: analyzing the story content text to determine the story structure, dividing the story content into multiple story stages based on the story structure, and generating content description information for each story stage. In other words, story stages can also be decomposed directly based on the story development logic contained within the story content text itself, without pre-setting story stages.
[0075] Optionally, story content can be segmented using a large language model. This involves generating segmentation prompts based on the story content text, inputting these prompts into the large language model, and then outputting content description texts corresponding to multiple story stages. The segmentation prompts guide the story content segmentation process. Besides containing the story content text and the task objective (e.g., "Segment the novel into four stages: introduction, development, climax, and conclusion, and generate content descriptions for each stage"), the prompts may also include segmentation constraints, such as "Ensure the content of each stage is coherent and complete." They may also include formatting requirements for the content description text, indicating the structure and format of the output descriptions, such as "Output story content text in JSON format." An example of story content segmentation prompts is as follows: "Analyze the given novel, dividing the story into its various stages according to the sequence of introduction, development, climax, and conclusion. Describe the content of each stage, provide reasons, and return examples {"Introduction: {"Environmental Rules": x, "Protagonist's Appearance": x, "Incentive Event": x, "External Goal": x, "Stepping Out of Comfort Zone": x}}. Note that the content of each stage should be coherent and complete. Novel: xxx; Stages corresponding to introduction, development, climax, and conclusion: xxx."
[0076] Optionally, during the process of splitting the story content text based on the content description information, for each story stage, it is necessary to distinguish its content from the adjacent preceding and following story stages, and only split out the original text fragments of each story stage to avoid overlap between the original text fragments of each story stage. For example, for the development stage, the content between the introduction and development stage should be distinguished from the content between the development stage and the transition stage. Only the original text fragments corresponding to the development stage should be split out to avoid overlap between the original text fragments of the introduction and development stage, and overlap between the original text fragments of the development stage and the transition stage.
[0077] Optionally, a large language model can be used to segment the story content text to obtain original text fragments. To improve the accuracy of the original text fragments, text segmentation prompts are generated for each story stage, and these prompts are input into the large language model separately, so that the large language model outputs the original text fragments of only one story stage at a time. The text segmentation prompts for any story stage include, in addition to the content description information of each story stage, the story content text, and the text segmentation target indicating the story stage to be segmented (e.g., extracting the original text from the novel), text segmentation constraints can also be included, such as "pay attention to the sequence of content in adjacent story stages to avoid overlap of original text in adjacent story stages," as well as the formatting requirements of the original text fragments. For example, taking the text splitting into introduction, development, transition, and conclusion as an example, the text splitting prompt message is as follows: "Split the novel text according to the following introduction, development, transition, and conclusion, and return the text of part s1. Note that you must strictly distinguish the content of s2, and only return the content of part s1. This part cannot have any text repetition with the preceding and following parts. Return the result directly, do not output a summary or the basis for the splitting, do not analyze, and do not output content that is not part s1. Description of the content of introduction, development, transition, and conclusion: xxx; Novel content: xxx", where s1 and s2 are paired, and the values are as follows: {s1: introduction; s2: introduction and development}, {s1: development; s2: introduction and development, development and transition}, {s1: transition; s2: development and transition, transition and conclusion}, {s1: conclusion; s2: transition and conclusion}.
[0078] S303, Based on the basic content element information and each original text fragment, generate a stage script corresponding to each original text fragment; wherein, the stage script contains at least one unit script arranged in sequence.
[0079] A stage script is a script corresponding to a single original text fragment. It is generated based on the basic content element information corresponding to the entire story text and the corresponding original text fragment.
[0080] Each stage script contains at least one unit script arranged in sequence. The number of unit scripts in a single stage script can be flexibly set according to actual needs, for example, it can be 10, 20, etc.
[0081] S304, Generate candidate scripts for the story content text based on the stage scripts corresponding to multiple original text fragments.
[0082] Arrange the stage scripts corresponding to multiple original text fragments to obtain candidate scripts for the story content text.
[0083] In an optional implementation, in S203, for each unit script, logical optimization is performed on each unit script based on the preceding unit script to obtain an optimized unit script for each unit script. This includes: for each unit script, searching for the preceding unit script in the stage script to which each unit script belongs, and performing logical optimization on each unit script based on the association information of the stage script to which each unit script belongs, and the preceding unit script to obtain an optimized unit script for each unit script. The association information includes at least one of the following: the original text fragment corresponding to the stage script to which each unit script belongs, the plot outline corresponding to the stage script to which each unit script belongs, and the content description information corresponding to the stage script to which each unit script belongs.
[0084] In this implementation, the preceding unit scripts referenced during the logical optimization process of each unit script are selected from the stage scripts to which the unit script belongs, thereby preventing subsequent plot leaks and allowing script generation for each story segment to be performed independently. Furthermore, the logical optimization process not only references the preceding unit scripts but also basic content element information and the related information of the stage scripts to which the unit script belongs. This not only improves the accuracy of the logical optimization but also the accuracy of the optimized script. Moreover, the logical optimization only references information corresponding to the stage scripts to which the unit script belongs, without involving information from other stage scripts. This not only prevents plots from other scripts from appearing in the scripts corresponding to each stage script, thus avoiding leaks, but also allows the logical optimization of each stage script to be performed in parallel, improving optimization efficiency.
[0085] The logic optimization process can be implemented using a large language model. Based on the unit script to be optimized and reference information, logic optimization prompts are generated, defining the rules and constraints for logic optimization. For example, given a story text that is a novel, a unit script that is an episode script, and a story structured as introduction, development, climax, and conclusion, the logic optimization prompts for the unit script corresponding to the introduction section are as follows: Based on the novel's plot summary, the plot outline of the introduction section, the current script, the previous episode script, character settings, and the original text of the introduction section, the current script is corrected to ensure it better aligns with character settings and plot development. This ensures that the characters' inner conflicts remain consistent throughout dialogue, that their words and actions are consistent and uncontradictory, that the script's logic is stronger, and that their words and actions better reflect their character settings, striving to faithfully reproduce the dialogue from the original work.
[0086] exist Figure 3 In the illustrated embodiment, on the one hand, the story content text is first split into multiple original text fragments. Then, a stage script corresponding to each original text fragment is generated. Based on the stage scripts corresponding to the multiple original text fragments, a candidate script for the entire story content text is generated. This reduces the amount of text data that needs to be processed during the generation of stage scripts, thus improving the accuracy of script generation. On the other hand, the stage script corresponding to each original text fragment is based on the basic content element information of the original text fragment and the entire story content text. This not only improves the matching degree between the stage script and the corresponding original text fragment, avoiding the loss of important plots, but also prevents the plot of the stage script from deviating from the basic content elements of the entire story. For example, it prevents the plot of the stage script from violating the world structure and character settings, thus improving the accuracy of script generation.
[0087] In one embodiment of this application, another script generation method is provided, which can be applied to... Figure 3 The implementation environment shown is as follows: Figure 4 As shown, this script generation method is in Figure 3 Based on the above, the process of generating the stage script corresponding to each original text fragment in S303 according to the basic content element information and each original text fragment is expanded to S401-S403, which are described in detail below.
[0088] S401, extract the plot for each original text fragment to generate the original plot for each original text fragment.
[0089] The original plot of the original text fragment is the plot extracted from the original text fragment. The original plot can be at least one of the following: complete plot, core plot, plot summary, plot outline, etc. Among them, the complete plot includes all events; the core plot, also known as the key plot, is the important plot and includes the core events; the plot summary is a concise and objective summary of the complete plot, summarizing the main plot lines of the story in the text and including the core plot.
[0090] Optionally, the original plot can be extracted using a large language model. Based on the original text fragments, prompts for plot extraction can be generated. The prompts include the task objective for extracting plot information and the original text fragments from which the plot needs to be extracted. The prompts are then input into the large language model, which extracts the plot based on the prompts to output the original plot. S402, based on the basic content element information, perform plot expansion processing on the original plot of each original text fragment to generate a plot outline corresponding to each original text fragment.
[0091] Based on the original plot, more storylines are expanded to generate a plot outline for each original text fragment. The plot outline is a systematic overview of the story's core framework, used to clarify the core settings, character relationships, and plot development. Each original text fragment's plot outline is an episode outline, containing outlines for multiple episodes. Each episode outline contains multiple scene plots, which provide information about the events, scenes, and characters of that scene—that is, which character did what / what happened in which scene. Scene plots can be short texts, such as a complete sentence or syntactic unit.
[0092] The number of episodes included in the plot outlines of different original text fragments can be the same. For example, each original text fragment may have a plot outline containing 10 episodes, with each episode containing 3-5 scenes. The number of episodes included in the plot outlines of different original text fragments can also be different. For instance, the longer the original text fragment, the more episodes it contains in the plot outline; or, the more important the story phase corresponding to the original text fragment, the more episodes it contains in the plot outline. The dimensions for judging the importance of a story phase include, but are not limited to, the type of story phase itself (e.g., a transition is more important than a beginning), the number of events corresponding to the story phase, the level of plot excitement, and the number of core events included.
[0093] Plot expansion involves enriching the story by adding more plot points or details. This expansion can include elements or subplots that contribute to the function of story segments, the progression of core conflicts and contradictions, story development, and character development. Examples include meaningful dialogue, subtle actions, and dramatic highlights or moments of excitement. Optionally, the expansion process aims to retain as much of the original plot as possible to avoid omissions. During plot expansion, at least one of the following basic elements is referenced: plot summary information, world-building information, and character development information from the original text. Optionally, if the original text is broken down into story stages, the expansion process can also refer to the definitions or names of these stages to ensure the expanded plot aligns with the story's development.
[0094] Optionally, during the process of expanding the plot, the output plot outline can be controlled to only include the original plot in the corresponding original text fragments, so as to avoid prematurely revealing the later content of the story text.
[0095] Optionally, a large language model is invoked to perform plot expansion processing on the original plot. This involves generating plot expansion prompts based on the original plot and basic content element information of each original text fragment. These prompts include the current plot to be expanded (i.e., the original plot) and basic content element information, indicating the task objective of the plot expansion. Optionally, the plot expansion prompts may also include constraints on the plot expansion, such as "expand a small episode in life" or "do not reveal later content in the story text." They may also include formatting requirements for the plot outline, controlling the content and format of the output plot outline, such as "the outline section uses a list format with bullet points." For example, regarding the original plot of the novel, the plot expansion prompt is as follows: "Based on the overall plot of the novel and the current plot of the novel, and referring to the world structure and character settings, please expand the current plot to form a 10-episode plot outline, with 3 to 5 sentences per episode (each sentence representing one scene). The outline should be presented in a list format, with each item in the list representing one episode's content. The final outline should include all the plot points in the current plot of the novel, while also expanding on some minor life events that help advance the novel's functions, core conflicts, and antagonisms (such as meaningful words and subtle actions, or some dramatic highlights and moments of excitement). Note that only the outline of the current plot of the novel should be provided; do not reveal the later content of the novel in advance, and do not disrupt the overall world structure and character settings of the novel." Here, the overall plot refers to the novel's plot summary, and the current plot of the novel refers to the original plot of the novel.
[0096] S403, Generate a stage script corresponding to each original text fragment based on each original text fragment and the plot outline corresponding to each original text fragment.
[0097] Each stage script for an original text fragment is generated based on the original text fragment and the corresponding plot outline. Each stage script contains at least one unit script, and each unit script contains at least one scene script. The scene script can be generated based on the scene script in the plot outline.
[0098] Optionally, during the script generation process, if dialogue from the original text fragments is involved, the original dialogue will be used to avoid missing plot details from the original text fragments. Optionally, the type of theatrical work corresponding to the generated script can also be obtained, and dialogue for each character in the script can be generated based on the style corresponding to the theatrical work type. Theatrical work types include, but are not limited to, at least one of the following: stage play, film, short video, long drama, episodic drama, and micro-drama.
[0099] Optionally, a large language model is invoked to generate stage scripts. For each original text fragment, based on the original text fragment and its plot outline, script generation prompts are generated for that original text fragment. These prompts are then input into the large language model, which generates and outputs the stage script corresponding to the original text fragment. The script generation prompts guide the model on how to generate the script and include the original text fragment (i.e., the original text from which the script needs to be generated), the plot outline, and the task objective for generating the script (e.g., generate the script based on the original text and plot outline). Optionally, constraints on the script generation method are also included, indicating the rules, methods, and requirements for script generation, such as "the original text's plot must be complete, and the dialogue should be designed in a micro-drama style." Script format constraints can also be included to control the format and structure of the output script, such as "each episode's script is returned in a dictionary format with multiple (scene ID, scene script string)." Optionally, if the original text fragment corresponds to a story stage, the script generation prompts may also include the story stage it belongs to, as well as the multiple story stages contained in the story content text. For example, under the condition of generating a script for a short drama based on a novel, the script generation prompts for the beginning of the novel are as follows: "Based on the original text of the beginning of the novel's plot and the episode outline of the beginning (each sentence in the outline represents one scene), generate a script text consisting of multiple scenes for each episode. When dialogue from the original plot is involved, use the original dialogue. For expanded details, design dialogue with appropriate tone based on the character settings. The original plot should not be missing, and the dialogue should be designed in the style of a short drama. Each scene script should begin with the scene, time, and character information, such as 'Scene: xxx Time: xxx Character: xxx Script Text'."
[0100] exist Figure 4In the illustrated embodiment, the original plot of each original text fragment is first expanded based on the basic content element information of the story content text to generate a plot outline. Then, a stage script is generated based on the plot outline and the original text fragments. This not only enriches the plot, but also ensures that the rich plot does not violate the world structure, character settings, etc., thus improving the accuracy of script generation.
[0101] In one embodiment of this application, another script generation method is provided, which can be applied to... Figure 1 The implementation environment shown is as follows: Figure 5 As shown, this script generation method is in Figure 4 Based on the above, the process in S402 of expanding the original plot of each original text fragment according to the basic content element information to generate the plot outline corresponding to each original text fragment is expanded into S501-S504, which are described in detail below.
[0102] S501, based on the basic content element information, perform plot expansion processing on the original plot of each original text fragment to generate a candidate plot outline for each original text fragment.
[0103] For details on how the plot can be expanded, please refer to the description in the aforementioned embodiments.
[0104] S502, extract content information from the candidate plot outlines to obtain the first expanded content information corresponding to each original text fragment.
[0105] S503, based on the original content information and the first expanded content information corresponding to each original text fragment, perform quality detection on the candidate plot outline to obtain a quality score for the candidate plot outline; the original content information is obtained by extracting content information from each original text fragment.
[0106] For each original text fragment, the original content information is extracted from the original text fragment, and the first expanded content information is extracted from the candidate plot outline of the original text fragment. Content information is natural language text used to describe the story content; it is more concise than the original text fragment and the candidate plot outline. The types of content information include, but are not limited to, at least one of plot and event set. Optionally, content information can be complete content information, containing at least one of a complete plot and a complete event set, where the complete event set contains all events in the corresponding text; content information can also be core content information, containing at least one of a core plot and a core event set, where the core event set contains core events.
[0107] The quality score of the candidate plot outline is generated based on the comparison between the original content information and the first expanded content information. The higher the quality score, the closer the candidate plot outline is to the original plot development, and the more accurate the outline. The quality score can be a value between 0 and 1, or between 1 and 100, etc., and the specific value range can be flexibly adjusted. The evaluation can be based on two dimensions: whether the original plot is retained and how much plot has been expanded. The more original plot is retained, the higher the score, while the proportion of expanded plot needs to be within a reasonable range, avoiding too much or too little.
[0108] In one embodiment of this application, under the condition that the original content information includes the original core plot extracted from each original text fragment, and the first expanded content information includes the expanded core plot extracted from the candidate plot outline, the process of performing quality detection on the candidate plot outline based on the original content information corresponding to each original text fragment and the first expanded content information to obtain a quality score for the candidate plot outline may include: finding overlapping storylines from the original core plot and the expanded core plot, and calculating the proportion of overlapping storylines in the storylines included in the original core plot to obtain the original plot proportion; finding expanded storylines included in the expanded core plot but not included in the original core plot, and calculating the proportion of expanded storylines in the storylines included in the original core plot to obtain the expanded plot proportion; and calculating the quality score for the candidate plot outline based on the original plot proportion and the expanded plot proportion.
[0109] In this implementation, the candidate plot outlines are quality-checked from two dimensions: original plot retention and expanded plot ratio. This ensures that the generated script retains the storylines from the original text fragments while also enriching the plot and avoiding excessive or insufficient expansion. For each original text fragment, the original core plot is extracted from the original text fragment; the expanded core plot is extracted from the candidate plot outline of the original text fragment. Since the plot contains storylines, to prevent the candidate plot outline from having too much expanded plot and too much plot from the original text fragments missing, overlapping storylines contained in the original core plot and present in the expanded core plot are identified from both the original and expanded core plots. Additionally, expanded storylines not present in the original core plot but included in the expanded core plot are identified. The original plot ratio = number of overlapping storylines / number of storylines contained in the original core plot, representing the proportion of storylines from the original text fragment appearing in the candidate plot outline. The expanded plot ratio = number of expanded storylines / number of storylines contained in the original core plot. The original plot ratio represents the proportion of plot information in the candidate plot outline to the additional storylines compared to the original text, reflecting the extent of expansion of the original text. Optionally, in other implementations, the expanded plot ratio = the number of expanded storylines / the number of storylines included in the expanded core plot.
[0110] In an optional implementation, the process of calculating the quality score of the candidate plot outline based on the original plot ratio and the expanded plot ratio may include: calculating a first score based on the original plot ratio, wherein the first score is positively correlated with the original plot ratio; calculating a second score based on the expanded plot ratio, wherein the second score and the expanded plot ratio have a downward-opening unimodal function relationship; and performing a weighted summation of the first score and the second score to calculate the quality score of the candidate plot outline, wherein the weight of the first score is greater than the weight of the second score.
[0111] A higher proportion of the original plot indicates a higher degree of plot fidelity in the candidate plot outline, resulting in a higher first score. Conversely, a low proportion of expanded plot fails to enrich the plot, while a high proportion significantly increases the discrepancy between the candidate plot outline and the original text fragments, reducing the accuracy of the expanded plot. Therefore, the second score and the expansion proportion exhibit a downward-opening unimodal function relationship. In other words, within the range of the expansion proportion (0%~100%), the second score initially increases and then decreases as the expansion proportion increases. This approach prioritizes plot fidelity to ensure the storyline fidelity of the candidate outline. Furthermore, it controls the expansion proportion within a reasonable range, avoiding both insufficient expansion (too little content in the candidate plot outline) and excessive expansion (mismatch between the expanded content and the original text fragments), thereby improving the accuracy of the script generated based on the candidate plot outline.
[0112] Optionally, the range of the expanded storyline proportion can be divided into multiple intervals, and a mapping relationship between the proportion and the score can be set for each interval. Based on the expanded storyline proportion and the mapping relationship, a second score can be calculated. The mapping relationship between the intervals and the score can be flexibly adjusted according to actual needs. For example, if the expanded storyline proportion is 30%–50%, the second score is 1; if the expanded storyline proportion is 0–30% or 50%–60%, the second score is 0.5; if the expanded storyline proportion is 60%–80%, the second score is 0.4; if the expanded storyline proportion is greater than 80%, then the second score = 1 - expanded storyline proportion.
[0113] The first score and the second score are weighted and summed to obtain the quality score. To avoid omitting plot points from the original text in the script, the first score has a higher weight than the second score. The specific weighting can be flexibly set according to actual needs; for example, Quality - Score = 0.8. score1+0.2 score 2, where score1 and score2 are the first and second scores, respectively.
[0114] In an optional implementation, the process of calculating the quality score of the candidate plot outline based on the original plot ratio and the expanded plot ratio may include: finding overlapping events from the original core event set contained in the original content information and the expanded core event set contained in the first expanded content information; the original core event set contains core events extracted from each original text fragment; the expanded core event set contains core events extracted from the candidate plot outline; calculating an event consistency score based on the proportion of overlapping events in the original core event set; and calculating the quality score of the candidate plot outline based on the event consistency score, the original plot ratio, and the expanded plot ratio.
[0115] The original core event set contains core events extracted from the original text fragments; the expanded core event set contains core events extracted from the candidate plot outlines. The event sets can be presented as a list. Overlapping events are those contained in the original text fragments and also exist in the candidate plot outlines. The event consistency score is calculated as f(number of overlapping events / number of events in the original core event set), where f is a positive correlation function. This means that the higher the proportion of overlapping events in the original core event set, the higher the event consistency score, thus preventing events from being omitted from the original text in the script. The first score, the second score, and the event consistency score are weighted and summed to obtain the quality score. The weights of each score can be flexibly set according to actual needs.
[0116] In this implementation, the plot outline is scored from multiple dimensions, including events, storylines, and plot, based on the degree of plot fidelity and the degree of plot expansion. This avoids situations where the plot outline omits events, storylines, and plots from the original text fragments, and prevents the plot from being expanded too much or too little, thereby improving the accuracy of the script.
[0117] The preceding implementation described the process of calculating the quality score under the condition that the plot contained in the original content information and the first expanded content information is the core plot and the event set is the core event set. In other implementations, the plot contained in the original content information and the first expanded content information can be other types of plot (e.g., complete plot, plot summary) and the event set can be other types of event set (e.g., complete event set). The method of calculating the quality score based on other types of plot and other types of event set is similar to the method of calculating the score based on the core plot and the core event set, and will not be described again.
[0118] S504, if the quality score is higher than the outline score threshold, then the candidate plot outline is used as the plot outline corresponding to each original text fragment to generate the plot outline corresponding to each original text fragment.
[0119] The outline scoring threshold is used to determine whether the quality of candidate plot outlines meets the standard. Its specific value can be flexibly set according to actual needs, such as 0.7, 0.8, etc. If the quality score of a candidate plot outline is higher than the threshold, it will be used as the final plot outline.
[0120] In an optional implementation, the process of generating a plot outline corresponding to each original text fragment may further include: if the quality score of a candidate plot outline is lower than or equal to an outline score threshold, then, based on the basic content element information, the original plot of each original text fragment is re-expanded to generate a new candidate plot outline for each original text fragment, until the generation stop condition is met; the generation stop condition includes at least one of the following conditions: the quality score of a candidate plot outline is higher than an outline score threshold, and the number of generated candidate plot outlines reaches at least one of the following quantity thresholds; the candidate plot outline with the highest quality score is selected from the generated candidate plot outlines to generate a plot outline corresponding to each original text fragment.
[0121] In other words, the process of outputting the plot outline from the original text fragment is an iterative loop. The termination condition includes at least one of the following: the quality score of the latest candidate plot outline is higher than the outline score threshold; or the number of generated candidate plot outlines reaches a threshold (i.e., the number of iterations reaches a threshold). During each iteration, after generating candidate plot outlines, it checks whether the termination condition is met. If not, it proceeds to the next iteration; if so, the candidate plot outline with the highest quality score is selected as the target plot outline. This not only improves the fidelity of the plot outline and avoids missing too much plot, but also enhances the fidelity of the script generated based on this outline, preventing plot omissions and enriching the script's plot.
[0122] exist Figure 5 In the illustrated embodiment, based on the original content information of the original text fragment and the first expanded content information of the corresponding candidate plot outline, the candidate plot outline is quality checked, and the candidate plot outline with a higher quality score is used as the target outline of the original text fragment. This can improve the fidelity of the plot outline and the accuracy of script generation.
[0123] In one embodiment of this application, another script generation method is provided, which can be applied to... Figure 1 The implementation environment shown is as follows: Figure 6 As shown, this script generation method is in Figure 3 Based on the above, the process of generating the target script of story content text according to the optimized unit scripts corresponding to multiple unit scripts in S204 is expanded to include S601-S605, which are described in detail below.
[0124] S601, obtain the candidate stage scripts corresponding to each original text segment; wherein, the candidate stage scripts include the optimized unit scripts corresponding to at least one unit script of each original text segment.
[0125] For each original text fragment, each unit script in its stage script is optimized to obtain candidate stage scripts.
[0126] S602, extract content information from the candidate stage script corresponding to each original text fragment to generate the second expanded content information corresponding to each original text fragment.
[0127] For each original text fragment, its second expanded content information is extracted from the corresponding candidate stage script, and the extraction method is similar to that for extracting the first expanded content information.
[0128] S603, based on the original content information and the second expanded content information corresponding to each original text fragment, perform quality detection on the candidate stage scripts to obtain the quality score of the candidate stage scripts; the original content information is obtained by extracting content information from each original text fragment.
[0129] The quality scoring method for the candidate stage scripts is similar to that for the candidate plot outlines in the aforementioned embodiments, except that the first expanded content information is replaced with the second expanded content information. For example, for each original text fragment, assuming the original content information contains the original core plot and the second expanded content information contains the expanded core plot, overlapping storylines are identified from both the original and expanded core plots, and the proportion of these overlapping storylines within the original core plot is calculated to obtain the original plot proportion. Expanded storylines included in the expanded core plot but not included in the original core plot are then identified, and their proportion within the original core plot is calculated to obtain the expanded plot proportion. Based on the original plot proportion and the expanded plot proportion, the quality score for the preferred stage script is calculated. Here, the expanded plot is extracted from the candidate stage scripts.
[0130] S604. If the quality score is higher than the script score threshold, the candidate stage script will be used as the target stage script for each original text fragment.
[0131] The script scoring threshold is used to determine whether the quality of the script in the candidate stage meets the standard. The specific value can be flexibly set according to actual needs. It can be the same as or different from the outline scoring threshold.
[0132] Optionally, if the quality score of a candidate stage script is lower than or equal to the script score threshold, the stage script of the original text fragment is regenerated, and each unit script in the stage script is optimized to obtain a new candidate stage script. The quality of the new candidate stage script is then checked to obtain a quality score for the new candidate stage script, until the termination condition is met. The termination condition includes at least one of the following: the quality score of the latest candidate stage script is higher than the script score threshold, the number of iterations reaches the threshold, and then the candidate stage script with the highest quality score is selected as the target stage script.
[0133] S605, Generate the target script of story content text based on the target stage scripts corresponding to multiple original text fragments.
[0134] The target script is obtained by combining the target stage scripts corresponding to multiple original text fragments.
[0135] exist Figure 6 In the illustrated embodiment, the candidate stage scripts are quality checked based on the original content information of the original text fragments and the second expanded content information of the corresponding candidate stage scripts. The scripts with higher quality scores are selected as the target stage scripts, and the target scripts are generated based on the target stage scripts. This can improve the fidelity of the scripts and the accuracy of script generation.
[0136] In one embodiment of this application, another script generation method is provided, which can be applied to... Figure 1 The implementation environment shown is as follows: Figure 7 As shown, the training process for the generative model has been added, including S701-S704, which are detailed below.
[0137] S701, Obtain the training sample set and the model to be trained, and perform supervised training on the model to be trained based on the training sample set to obtain the initial generated model; the training sample set contains sample scripts and target content information of the sample scripts.
[0138] The model to be trained is a language model that learns how to generate content information (plot, event set, etc.) from a script. It can be a general-purpose large language model, such as Qwen, ChatGPT, or DeepSeek-R1, which has natural language understanding and generation capabilities. The generation model is used to extract plot, event, and other content information from texts such as scripts, plot outlines, and story content texts, such as the aforementioned second expanded content information.
[0139] The training sample set contains multiple training samples, each containing a sample script and target content information. The types of sample scripts include movie scripts, TV series scripts, short drama scripts, etc. Scripts matching the application scenario can be collected as sample scripts. For example, if the application scenario is to generate short drama scripts, short drama scripts can be collected to generate sample scripts. Each sample script can be a continuous script with a specified number of scenes, such as 2-3 scenes. After collecting the complete script, it can be split into multiple sample scripts according to scenes. The target content information is the objective that the generation model needs to learn. It can be manually annotated, extracted based on rules, or generated through a large language model.
[0140] In the process of generating target content information through a large language model, a sample script is input into the large language model to obtain content information generated by the large language model based on the sample script, which serves as the target content information. This content information includes prompts generated based on the sample script to extract content information. These prompts guide the large language model on how to generate content information and may include the sample script, the task objective for generating the content information, and generation constraints to indicate generation requirements and rules, such as "accurately summarize the plot using logical language." They may also include format requirements to control the structure and format of the output content information. In one optional example, the prompt is as follows: "Please carefully read the following plot, outline the relationships between characters and the plot structure, and summarize the key plot points. Requirements: Summarize the plot accurately using logical language; do not describe the characters' identities or relationships; focus on describing the key interactions between characters and their emotional changes, without omitting specific behavioral and emotional descriptions; state facts without commenting; if a time point in the 'year' dimension is mentioned, retain the time information in the result; flashbacks indicate recalling past events or plots, and if it is a flashback plot, indicate 'Recalling Plot:' in the result. Only answer the final plot, do not answer other information."
[0141] For example, the input to the large language model generates the following prompt: The script reads as follows: (5. Street corner square, daytime exterior) △ Several pigeons land in the center of the square. A group of innocent children run among the pigeons. The pigeons are startled and fly away, and the children laugh happily. △ The familiar, old, patina-covered tote bag is placed on a bench not far away. △ Mr. Zhang sits on the bench, staring blankly at the children playing in the distance. △ Mr. Zhang's shoes are very dirty, his jeans haven't been washed in a long time, his hair is spiky, and his beard has grown long. Mr. Zhang looks extremely dejected. 3 / Flashback / △ A series of shots. △ On television, on mobile phones, and on the internet, information and photos of Mr. Zhang's missing child are everywhere.
[0142] The core plot output by the large language model is as follows: "Zhang was in the square, looking at the playing children. His clothes were shabby and he looked down and out. Recall the plot: Zhang's child went missing, and there were information and photos of the child everywhere in the news."
[0143] During the supervised training process: input the sample script into the model to be trained. The model to be trained makes a probability prediction to obtain the probability distribution matrix output by the model to be trained. Search for the prediction probability corresponding to the target content information of the sample script in the probability distribution matrix (representing the probability that the model to be trained outputs the target content information based on the sample script). Based on the prediction probability, calculate the loss value corresponding to the sample script. Among them, the prediction probability is negatively correlated with the loss value. Perform backpropagation based on the loss value to update the model parameters of the model to be trained, thereby obtaining the initial generation model. Among them, for any training sample {"input": x (sample script), "output": y (target content information)}, assuming that y contains n tokens (word elements), the model will predict and output the probability distribution matrix yp. m is the number of tokens contained in the dictionary. Any element p in the matrix ij , represents the probability that the j-th token in the dictionary is at the i-th position. According to the true tokens at each position in y, find the probability yp' of y from yp. That is to say, yp' is a matrix. Exemplarily, assuming y is "The popular drama this year is A", then the probability distribution matrix yp is matrix. Find the probability that the token is "this" from the m probabilities corresponding to the first row, and then based on the probabilities corresponding to each position found, obtain yp'.
[0144] Optionally, the supervised training can be supervised fine-tuning (SFT).
[0145] S702, through the initial generation model, extract the content information of the sample script to generate the predicted content information of the sample script.
[0146] Input the sample script into the initial generation model to obtain the predicted content information extracted by the initial generation model based on the sample script. Optionally, generate a prompt information for indicating the generated content information based on the sample script, input the prompt information into the initial generation model, and obtain the predicted content information output by the initial generation model based on the prompt information.
[0147] S703, based on the sample script, the predicted content information of the sample script, and the target content information, generate a reinforcement sample script for reinforcement learning training, as well as first content information and second content information corresponding to the reinforcement sample script; the first content information is superior to the second content information.
[0148] During reinforcement learning training, Direct Preference Optimization (DPO) is performed. The reinforcement training samples include model input and model output. The model output includes chosen responses and rejected responses. Chosen refers to outputs that are more compliant, of higher quality, or more acceptable, i.e., primary content information. Rejected refers to outputs that are relatively uncompliant, of lower quality, or not acceptable, i.e., secondary content information.
[0149] After obtaining the sample script, the predicted content information of the sample script, and the target content information, the sample script that is more suitable for reinforcement learning training can be selected from the sample script to obtain the reinforcement sample script. The specific selection method can be flexibly adjusted according to actual needs. For example, considering that it is necessary to clarify which content information is better in the reinforcement training sample, if the predicted content information and the target content information are equally good or not much different, then the sample script is not suitable as a reinforcement sample script.
[0150] From the predicted and target content information of the reinforced sample script, relatively superior content information is determined to generate the first content information, and relatively inferior content information is determined to generate the second content information. The superior content information can be directly used as the first content information, or a large language model can be used to optimize the superior content information based on the reinforced sample script and the inferior content information to obtain the first content information. Optionally, if the superior content information is the target content information, and the target content information is manually labeled, it is considered optimal and no further optimization is needed.
[0151] In an optional implementation, the process of generating reinforcement sample scripts for reinforcement learning training, and the first and second content information corresponding to the reinforcement sample scripts, based on the sample scripts, the predicted content information of the sample scripts, and the target content information, may include: inputting each sample script in the training sample set, the predicted content information of each sample script, and the target content information into a large language model to obtain the optimal content indication of each sample script output by the large language model; the optimal content indication is used to indicate the optimal content information in the predicted content information and the target content information of each sample script; according to the optimal content indication, selecting reinforcement sample scripts from multiple sample scripts included in the training sample set, and generating the first and second content information corresponding to the reinforcement sample scripts based on the optimal content indication, the predicted content information, and the target content information corresponding to the reinforcement sample scripts.
[0152] In this implementation, the predicted content information and target content information of the sample script are compared using a large language model to determine which content information is better. This automatically generates samples for reinforcement training, reducing the difficulty of obtaining training data. Optionally, when the content information is a plot summary, the following prompts are input into the large language model to obtain the optimal content indication: Which summary is better? Only answers "equally good", "Summary 1 is better", "Summary 2 is better" are provided. Script: xxx, Summary 1: xxx, Summary 2: xxx.
[0153] In an optional implementation, the process of selecting enhanced sample scripts from multiple sample scripts included in the training sample set according to the optimal content indication, and generating first and second content information corresponding to the enhanced sample scripts based on the optimal content indication, predicted content information, and target content information of the enhanced sample scripts, may include: selecting enhanced sample scripts from multiple sample scripts included in the training sample set whose target content information is better than the predicted content information according to the optimal content indication; optimizing the target content information of the enhanced sample scripts using a large language model based on the enhanced sample scripts and their predicted content information to obtain optimized content information of the enhanced sample scripts; generating first content information of the enhanced sample scripts based on the optimized content information; and generating second content information of the enhanced sample scripts based on their predicted content information.
[0154] In this implementation, considering that target content information is generally more accurate, the sample script with target content information is preferred over the sample script with predicted content information. To further improve the accuracy of target content information, the enhanced sample script, the corresponding predicted content information, and the target content information can be input into a large language model. The large language model optimizes the target content information based on the enhanced sample script and the predicted content information, and outputs optimized content information. The optimized content information is used as the first content information, and the predicted content information is used as the second content information. Specifically, the optimization of the plot in the target content request ensures that it is consistent with the plot and content of the script, without any deviations, and is more user-friendly. The optimization of the event list in the target content request ensures that it is consistent with the content expressed in the script and is unambiguous. For example, when the content information includes a plot summary, the optimized prompt information is as follows: Referring to the script's summary 1 and summary 2, optimize summary 1 to make it more unambiguous and consistent with the original plot of the script, and more user-friendly. When the content information includes an event set, the optimized prompt information is as follows: Referring to the script's event list 1 and 2, optimize event list 1 to make it more consistent with the content to be expressed in the original script and without omissions. Among them, Summary 1 and Event List 1 correspond to the target content information.
[0155] In an optional implementation, given that both the predicted content information and the target content information contain plot information and the event set, and considering that events are less important than plot information in maintaining the outline and plot development, and to conserve training resources, for the enhanced sample script, only the plot information in the predicted content information is compared with the plot information in the target content information. First content information is generated based on the content information with better plot information, and second content information is generated based on the content information with poorer plot information. The plot information can be a plot summary.
[0156] S704, based on the reinforcement sample script, the first content information and the second content information, the initial generative model is trained by reinforcement learning to obtain the generative model.
[0157] The first and second content information are compared, enabling the model to learn how to generate better content information during reinforcement learning training, thus obtaining a generative model.
[0158] In an optional implementation, the process of training an initial generative model using reinforcement learning based on a reinforced sample script, first content information, and second content information to obtain a generative model may include: inputting the reinforced sample script into the initial generative model for probability prediction to obtain a first probability that the initial generative model outputs first content information based on the reinforced sample script, and a second probability that the initial generative model outputs second content information based on the reinforced sample script; inputting the reinforced sample script into a reference model for probability prediction to obtain a third probability that the reference model outputs first content information based on the reinforced sample script, and a fourth probability that the reference model outputs second content information based on the reinforced sample script; the reference model includes the historical model of the initial generative model; calculating the loss value corresponding to the reinforced sample script based on the first probability, second probability, third probability, and fourth probability, and updating the model parameters of the initial generative model according to the loss value to obtain the generative model; wherein the loss value is negatively correlated with the first probability and fourth probability, and positively correlated with the second probability and third probability.
[0159] The reinforcement learning script is input into the initial generation model, which outputs a probability matrix. From this matrix, the predicted probability corresponding to the first content information (the first probability) and the predicted probability corresponding to the second content information (the second probability) are selected. Similarly, the reinforcement learning script is input into the reference model, which outputs a probability matrix. From this matrix, the predicted probabilities corresponding to the first and second content information are selected, yielding the third and fourth probabilities, respectively. The reference model is used for comparison with the initial generation model. To automate the process and reduce training costs, the reference model is a historical model of the initial generation model. It should be understood that during the reinforcement learning training of the initial generation model, it undergoes multiple iterations and updates. Each update results in a new initial generation model. After any update, the current initial generation model is obtained. The historical model of the current initial generation model is the initial generation model obtained before any update. For example, it could be the initial generation model obtained in the previous update, or it could be an initial generation model that has not yet undergone reinforcement learning training, i.e., an initial generation model obtained through supervised training. To ensure the model's output is more biased towards the superior first content information, the model loss is negatively correlated with the first and fourth probabilities, and positively correlated with the second and third probabilities. Optionally, the loss value during reinforcement learning training is calculated based on the cross-entropy loss function. Specifically, for the reinforcement training sample {"input": x (i.e., the sample script), "output": (First content information) (Second content information)}, its loss value The calculation formula is as follows:
[0160] in, , The value can be flexibly set according to actual needs. , These represent the first and second probabilities corresponding to the sample script x, respectively, indicating that, given input x, the initial generation model produces predictions with better content information. The probability of occurrence, and the occurrence of poor content information. The probability of; , These represent the third and fourth probabilities corresponding to the sample script x, respectively, indicating that, given input x, the reference model produces predictions with better content information. The probability of occurrence, and the presence of poor content information. The probability of.
[0161] Optional, assuming , The dictionary contains n1 and n2 tokens arranged sequentially. After inputting x into the initial generation model, the model will predict the output based on x and the dictionary. probability distribution matrix ,according to The real tokens in each position, from Found probability , it is Similarly, from the formation Found probability , it is The matrix, n max The value of x is the maximum of n1 and n2. Similarly, after inputting x into the reference model, the reference model will output... The probability distribution matrix y ref From y ref turn up , The search process is similar to finding the probability yp' of y in yp, and will not be elaborated here.
[0162] After calculating the loss value, the model parameters of the initial generative model are updated with the goal of reducing the loss value to obtain the generative model.
[0163] Optionally, in other implementations, the loss value is calculated based only on the first probability and the second probability.
[0164] exist Figure 7In the illustrated embodiment, the generative model is obtained by first supervising the training samples corresponding to the script and then performing reinforcement learning training. This improves the accuracy of the script's plot, event set, and other information extracted by the generative model. Furthermore, the training samples for reinforcement learning training are automatically constructed based on the training set of supervised training and the initial generative model obtained from supervised training. This reduces the difficulty of obtaining training samples, improves training efficiency, and makes subsequent reinforcement learning training easier to converge.
[0165] In one embodiment of this application, another script generation method is provided, which can be applied to... Figure 1 The implementation environment shown is as follows: Figure 8 As shown, this script generation method is in Figure 2 Based on the above, the process in S203 of logically optimizing each unit script according to the preceding unit script to obtain the optimized unit script for each unit script is expanded to S801-S802, which are described in detail below.
[0166] S801: For each unit script, based on the previous unit script, perform logical optimization on each unit script to obtain the initial optimized unit script for each unit script.
[0167] The specific process of logic optimization can be found in the description of the foregoing embodiments, and will not be repeated here. Optionally, in the logic process, in addition to referring to the previous unit script, at least one of the following information may also be referenced: the plot summary of the story content text, character setting information, world structure information, the original text fragment corresponding to the stage script to which the unit script belongs, the plot outline corresponding to the stage script to which the unit script belongs, and the content description information corresponding to the stage script to which the unit script belongs.
[0168] S802, based on at least one of the preceding unit scripts and script format requirements, the initial optimized unit scripts are polished to obtain the optimized unit scripts for each unit script.
[0169] The script format requirements information specifies the requirements for the script's content structure and format. It can be set according to the style of the script to be generated. For example, the script format requirements information includes content requirements, such as inserting environment description information.
[0170] Optionally, during the polishing process, at least one of the following information may be referenced: the plot summary of the story content text, character setting information, world structure information, the original text fragments corresponding to the stage script to which the unit script belongs, the plot outline corresponding to the stage script to which the unit script belongs, and the content description information corresponding to the stage script to which the unit script belongs.
[0171] A large language model can be used to polish unit scripts. First, polishing hints are generated and input into the large language model to obtain the polished unit script output by the model. The polishing hints guide the large language model on how to polish the script and may include polishing rules. For example, the polishing hints for the corresponding unit script are as follows: Please refine the current script based on the novel's plot synopsis, the episode outline of the beginning section, the current script, the previous script, character settings, and the original text of the beginning section. Each scene in the current script should begin with a descriptive section starting with a triangle (including: scene / atmosphere / character states or emotions / actions / relative positions between characters). Add descriptive sections starting with triangles when necessary during dialogue. 1-1 Scene: Exterior - Imperial Palace Road Time: Night People: A certain imperial concubine, palace maids △The imperial city at night, in heavy rain.
[0172] Palace maid A: (loudly) Everyone in front, make way! △A concubine on a palanquin, adorned with gold ornaments and dressed in magnificent palace attire, gazes straight ahead. exist Figure 8 In the illustrated embodiment, not only can logical problems in the script be corrected, but the script's format and expression can also be modified to better meet the requirements and improve the script's accuracy.
[0173] To better understand this invention, a novel-based script generation method is used as an example for illustration. See [link to documentation]. Figure 9 As shown, Figure 9 The flowchart for generating the script mainly includes the following processes: Get Novel: Displays the script generation interface, where the user enters the novel they want to convert into a script.
[0174] Plot Analysis: After acquiring the novel, the overall plot summary, world view, and character settings of the novel are extracted through a large language model.
[0175] Plot Expansion and Validation: Using a large language model, the novel is divided into multiple story stages (e.g., four stages: introduction, development, climax, and conclusion) according to the story's development, and a content description for each story stage is generated. Then, for each story stage, the content descriptions corresponding to each stage and the original novel text are input into the large language model. Based on the content descriptions of each story stage, the large language model extracts the corresponding original text fragments from the original novel text. The large language model or a generative model is then invoked to extract the core plot and core events from the original text fragments, resulting in a list of original core plot and original core events. Finally, for each story stage, a plot outline is generated through the following steps: Step 1.1: Call the large language model to expand the plot of the original text fragments of the story stage based on the plot contained in the novel (e.g., plot summary, plot summary, or complete plot), the plot contained in the original text fragments of the story stage (e.g., plot summary, plot summary, or complete plot), the world view, and the character settings, so as to output the candidate plot outline corresponding to the story stage. The episode outline contains multiple episode outlines (e.g., 10 episodes), and each episode outline contains multiple scene plots (e.g., 3 to 5 scenes). Each scene plot corresponds to a sentence. Step 1.2: Use the generative model to extract the core plot and core events from the candidate plot outlines of the story stage, and obtain the list of core plot and core events after the first expansion; Step 1.3: Calculate the original plot ratio and the expanded plot ratio based on the original core plot and the core plot after the first expansion for each story stage. Calculate the event consistency score based on the original event list and the event list after the first expansion. Calculate the quality score of the candidate plot outline based on the original plot ratio, the expanded plot ratio, and the event consistency score.
[0176] Step 1.4: Return to Step 1.1 and iterate until the quality score of the candidate plot outline is greater than the outline score threshold, or the number of iterations reaches the set value. The candidate plot outline with the highest quality score is then used as the plot outline for the story stage.
[0177] The script generation and script analysis and scoring process is an iterative loop. For each story stage, the corresponding candidate stage script is first generated, and then the candidate stage script is scored. The above process is repeated until the number of iterations reaches a set value, or the quality score of the candidate node script is higher than the script score threshold. The candidate stage script with the highest quality score is then taken as the target stage script for the story stage.
[0178] The script generation process is as follows: For each story stage, a large language model is invoked to generate a stage script based on the story stage's plot outline and original text fragments. Each stage script contains episode scripts. Each episode script is used as the current episode script to be optimized. First, the large language model is invoked to correct the current episode script based on the novel's plot summary, the story stage's plot outline, character settings, the current episode script, the previous episode script, and original text fragments of story nodes, resulting in a logically optimized current episode script. Then, the large language model is invoked again to polish the current episode script based on the novel's plot summary, the story stage's plot outline, character settings, the current episode script (logically optimized), the previous episode script, and original text fragments of story nodes, resulting in an optimized current episode script. After logical optimization and polishing of each episode script contained within the story stage's stage scripts, candidate stage scripts for the story stage are obtained.
[0179] The script analysis and scoring process is as follows: For each story stage, the generative model is invoked to extract the core plot and core events from the candidate stage plot, resulting in a second expanded core plot and a second expanded core event list. Based on the original core plot and the second expanded core plot of the story stage, the original plot ratio and the expanded plot ratio are calculated. Based on the original event list and the second expanded event list, the event consistency score is calculated. Based on the original plot ratio, the expanded plot ratio, and the event consistency score, the quality score of the candidate stage script is calculated.
[0180] Script Preview: Combine the target stage scripts corresponding to multiple story stages to obtain the target script of the novel, and display the novel's script in the preview interface for users to view, review, and revise.
[0181] For example, see Figure 10 As shown, the process of turning a novel into a screenplay requires first extracting the worldview, plot summary, and character settings from the novel. Then, the story is divided into segments to obtain story stages. Based on the story stages, the plot outline of each story stage is determined. The plot outline of each story stage is then enriched. Based on the enriched plot outline, a stage script is generated. Finally, the stage script is optimized in terms of logic and expression.
[0182] The following describes the generative models involved in the above process. The generative model is obtained by first performing SFT training on the model to be trained to obtain an initial generative model, and then performing DPO training on the initial generative model. The model to be trained uses the DeepSeekR1 Distill Qwen-32B model (a distilled version of the large language model), whose core structure is a multi-layer Transformer stack. The pre-training parameters of this model are based on the parameters distilled from DeepSeekR1 onto the Qwen32B structure model.
[0183] The Qwen32B model consists of a 64-layer decoder structure, with each layer employing a multi-head self-attention mechanism and a feedforward network stacked alternately. The main structural parameters of the model are as follows: Number of Qwen2DecoderLayers: 64; Hidden layer dimensions (Q, K, V, O): 5120; Number of attention heads: 40; Number of key-value heads (kv heads): 8; Context sliding window length (model size): 131072; Vocabulary size: 152064; MLP intermediate size: 27648. As shown in Table 1, this is the main structure of the model.
[0184] Table 1 The output of lm_head is the prediction of token IDs. For example, for a dictionary of 150,000 token IDs (idslength=152064), the prediction is 1. 152064 vectors.
[0185] As shown in Table 2, it is a Qwen2DecoderLayer structure.
[0186]
[0187] Table 2 Both SFT and DPO training employ the full-parameter SFT training method, meaning only the cross-attention mapping layer of the transformer module is fine-tuned. The main processes of SFT and DPO training are identical, differing only in the training samples and loss calculation methods. A single training sample in SFT training consists of {"input": x (sample script), "output": y (story summary)}; a single training sample in DPO training consists of {"input": x, "output": y}. w (Plot summary), y l (Plot summary)
[0188] The training process is as follows: For N training samples, randomly select bs unlearned samples for batch training. Repeat the above training until each sample has been traversed once, completing one epoch. Perform multiple epochs of iteration until the epoch loss no longer decreases in a certain epoch. During each batch learning: (1) Obtain the training samples for the current batch; (2) Model forward pass: For SFT training, input x into the model to be trained, and the forward pass process obtains the probability matrix corresponding to the prediction result; for DPO training, input x into the initial generator model and the reference model, and perform the forward pass process respectively to obtain the probability matrix corresponding to the prediction result. (3) Calculate the loss value: For SFT training, obtain the predicted probability yp' of y in the probability matrix, and calculate the loss corresponding to yp' based on the cross-entropy loss function; for DPO training, select the chosen probability (i.e., yp') from the probability matrices output by the initial generator model and the reference model respectively. w ) and rejected (i.e., y l ) predict the probability and calculate the DPO loss.
[0189] (4) Model backward propagation: The loss backpropagation network calculates the gradients of each parameter of the network.
[0190] (5) Model parameter update: Update each parameter according to the gradient of each parameter of the above network.
[0191] Here, epoch loss is calculated based on the loss value of the training samples corresponding to the epoch. Optionally, epoch loss is the average of the batch loss of multiple batches contained in the epoch. Batch loss is calculated based on the loss value of multiple training samples corresponding to the batch, and it can be the average of the loss values of multiple training samples. Epoch loss no longer decreasing can mean that: for a series of consecutive epochs (e.g., 3 to 5 epochs), the decrease in epoch loss of each epoch compared to the previous epoch is less than a set minimum threshold.
[0192] In this embodiment, a script can be automatically generated based on a novel. By splitting the story content, scripts corresponding to each story stage are generated separately, saving labor costs, improving script generation efficiency, reducing the amount of text processed during script generation, and avoiding the output of a single large model not meeting expectations. By iteratively generating and scoring the plot outline and generated script, the plot fidelity of the script can be improved, avoiding too much missing plot, while plot expansion enriches the plot and increases the number of episodes. Logic optimization and polishing ensure the accuracy of the script and avoid inconsistencies.
[0193] This application provides a script generation apparatus that can be deployed on a terminal device or a server, such as... Figure 11As shown, the device includes: an acquisition module 1101, used to acquire story content text describing the story content; a generation module 1102, used to generate candidate scripts for the story content text based on the story content text; wherein the candidate scripts include multiple unit scripts arranged in sequence; an optimization module 1103, used to perform logical optimization on each unit script based on the preceding unit scripts of each unit script, to obtain an optimized unit script for each unit script; the generation module 1102 is also used to generate target scripts for the story content text based on the optimized unit scripts corresponding to the multiple unit scripts respectively.
[0194] In one embodiment of this application, the generation module 1102 is specifically used for: performing plot analysis on the story content text to generate basic content element information of the story content text; the basic content element information includes at least one of plot summary information, world structure information, and character setting information; splitting the story content text to obtain multiple original text fragments; generating a stage script corresponding to each original text fragment based on the basic content element information and each original text fragment; wherein, the stage script includes at least one unit script arranged in sequence; and generating candidate scripts for the story content text based on the stage scripts corresponding to the multiple original text fragments respectively.
[0195] In one embodiment of this application, the generation module 1102 is specifically used to: split the story content text into story content segments to obtain multiple story stages and content description information corresponding to each of the multiple story stages; Based on the content description information corresponding to each of the multiple story stages, the story content text is split to obtain the original text fragments corresponding to each of the multiple story stages.
[0196] In one embodiment of this application, the generation module 1102 is specifically used to: extract the plot of each original text fragment to generate the original plot of each original text fragment; expand the original plot of each original text fragment according to the basic content element information to generate the plot outline corresponding to each original text fragment; and generate the stage script corresponding to each original text fragment according to each original text fragment and the plot outline corresponding to each original text fragment.
[0197] In one embodiment of this application, the generation module 1102 is specifically used for: performing plot expansion processing on the original plot of each original text segment based on basic content element information to generate a candidate plot outline for each original text segment; extracting content information from the candidate plot outlines to obtain first expanded content information corresponding to each original text segment; performing quality detection on the candidate plot outlines based on the original content information and the first expanded content information corresponding to each original text segment to obtain a quality score for the candidate plot outlines; the original content information is obtained by extracting content information from each original text segment; if the quality score is higher than the outline score threshold, the candidate plot outline is used as the plot outline corresponding to each original text segment to generate a plot outline corresponding to each original text segment.
[0198] In one embodiment of this application, given that the original content information includes the original core plot extracted from each original text fragment, and the first expanded content information includes the expanded core plot extracted from the candidate plot outline, the generation module 1102 is specifically used to: find overlapping storylines from the original core plot and the expanded core plot, and calculate the proportion of overlapping storylines in the storylines included in the original core plot to obtain the original plot proportion; find expanded storylines included in the expanded core plot but not included in the original core plot, and calculate the proportion of expanded storylines in the storylines included in the original core plot to obtain the expanded plot proportion; and calculate the quality score of the candidate plot outline based on the original plot proportion and the expanded plot proportion.
[0199] In one embodiment of this application, the generation module 1102 is specifically used for: calculating a first score based on the original plot ratio; wherein the first score is positively correlated with the original plot ratio; calculating a second score based on the expanded plot ratio; wherein the second score and the expanded plot ratio have a downward-opening unimodal function relationship; and performing a weighted summation of the first score and the second score to calculate a quality score for the candidate plot outline; wherein the weight of the first score is greater than the weight of the second score.
[0200] In one embodiment of this application, the generation module 1102 is specifically used to: search for overlapping events from the original core event set contained in the original content information and the expanded core event set contained in the first expanded content information; the original core event set contains core events extracted from each original text fragment; the expanded core event set contains core events extracted from the candidate plot outline; calculate the event consistency score according to the proportion of overlapping events in the original core event set; and calculate the quality score of the candidate plot outline according to the event consistency score, the proportion of the original plot, and the proportion of the expanded plot.
[0201] In one embodiment of this application, the generation module 1102 is specifically used to: if the quality score of the candidate plot outline is lower than or equal to the outline score threshold, then based on the basic content element information, perform plot expansion processing on the original plot of each original text fragment to generate a new candidate plot outline for each original text fragment, until the stopping generation condition is met; the stopping generation condition includes at least one of the following conditions: the quality score of the candidate plot outline is higher than the outline score threshold, and the number of generated candidate plot outlines reaches at least one of the number thresholds; and select the candidate plot outline with the highest quality score from the generated candidate plot outlines to generate the plot outline corresponding to each original text fragment.
[0202] In one embodiment of this application, the generation module 1102 is specifically used for: obtaining candidate stage scripts corresponding to each original text fragment; wherein, the candidate stage scripts include optimized unit scripts corresponding to at least one unit script for each original text fragment; extracting content information from the candidate stage scripts corresponding to each original text fragment to generate second expanded content information corresponding to each original text fragment; performing quality detection on the candidate stage scripts based on the original content information and second expanded content information corresponding to each original text fragment to obtain a quality score for the candidate stage scripts; the original content information is obtained by extracting content information from each original text fragment; if the quality score is higher than the script score threshold, the candidate stage scripts are used as target stage scripts corresponding to each original text fragment; and generating target scripts for the story content text based on the target stage scripts corresponding to multiple original text fragments.
[0203] In one embodiment of this application, where the second expanded content information is generated by the generative model extracting content information from candidate stage scripts, the apparatus further includes a training module for: acquiring a training sample set and a model to be trained, and performing supervised training on the model to be trained based on the training sample set to obtain an initial generative model; the training sample set includes sample scripts and target content information of the sample scripts; extracting content information from the sample scripts using the initial generative model to generate predicted content information of the sample scripts; generating reinforced sample scripts for reinforcement learning training based on the sample scripts, the predicted content information of the sample scripts, and the target content information, as well as first content information and second content information corresponding to the reinforced sample scripts; the first content information is superior to the second content information; and performing reinforcement learning training on the initial generative model based on the reinforced sample scripts, the first content information, and the second content information to obtain a generative model.
[0204] In one embodiment of this application, the training module is specifically used to: input each sample script in the training sample set, the predicted content information of each sample script, and the target content information into the large language model to obtain the optimal content indication of each sample script output by the large language model; the optimal content indication is used to indicate the optimal content information in the predicted content information and the target content information of each sample script; according to the optimal content indication, select reinforcement sample scripts from multiple sample scripts included in the training sample set, and generate the first content information and the second content information corresponding to the reinforcement sample script based on the optimal content indication, the predicted content information, and the target content information corresponding to the reinforcement sample script.
[0205] In one embodiment of this application, the training module is specifically used to: select, according to the optimal content indication, from multiple sample scripts included in the training sample set, enhance sample scripts whose target content information is better than the predicted content information; optimize the target content information of the enhanced sample scripts using a large language model based on the enhanced sample scripts and the predicted content information of the enhanced sample scripts to obtain optimized content information of the enhanced sample scripts; generate first content information of the enhanced sample scripts based on the optimized content information; and generate second content information of the enhanced sample scripts based on the predicted content information of the enhanced sample scripts.
[0206] In one embodiment of this application, the training module is specifically used for: inputting the enhanced sample script into the initial generation model for probability prediction, obtaining a first probability that the initial generation model outputs first content information based on the enhanced sample script, and a second probability that the initial generation model outputs second content information based on the enhanced sample script; inputting the enhanced sample script into the reference model for probability prediction, obtaining a third probability that the reference model outputs first content information based on the enhanced sample script, and a fourth probability that the reference model outputs second content information based on the enhanced sample script; the reference model includes the historical model of the initial generation model; calculating the loss value corresponding to the enhanced sample script based on the first probability, the second probability, the third probability, and the fourth probability, and updating the model parameters of the initial generation model according to the loss value to obtain the generation model; wherein, the loss value is negatively correlated with the first probability and the fourth probability, and positively correlated with the second probability and the third probability.
[0207] In one embodiment of this application, the optimization module 1103 is specifically used to: for each unit script, search for the preceding unit script in the stage script to which each unit script belongs, and perform logical optimization on each unit script based on the association information of the stage script to which each unit script belongs and the preceding unit script, to obtain an optimized unit script for each unit script; the association information includes at least one of the following: the original text fragment corresponding to the stage script to which each unit script belongs, the plot outline corresponding to the stage script to which each unit script belongs, and the content description information corresponding to the stage script to which each unit script belongs.
[0208] In one embodiment of this application, the optimization module 1103 is specifically used to: for each unit script, perform logical optimization on each unit script based on the preceding unit script to obtain an initial optimized unit script for each unit script; and polish the initial optimized unit script based on at least one of the preceding unit script and script format requirement information to obtain an optimized unit script for each unit script.
[0209] It should be noted that the apparatus provided in the above embodiments and the method provided in the above embodiments belong to the same concept, and the specific way in which each module and unit performs operations has been described in detail in the method embodiments, and will not be repeated here.
[0210] Embodiments of this application also provide an electronic device, including one or more processors and a storage device, wherein the storage device is used to store one or more computer programs, which, when executed by one or more processors, cause the electronic device to implement the script generation method as described above.
[0211] Figure 12 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown.
[0212] It should be noted that, Figure 12 The computer system 1200 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application, wherein the electronic device may be a terminal device or a server.
[0213] like Figure 12As shown, the computer system 1200 includes a central processing unit (CPU) 1201, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on a program stored in read-only memory (ROM) 1202 or a program loaded from storage portion 1208 into random access memory (RAM) 1203. Various programs and data required for system operation are also stored in RAM 1203. The CPU 1201, ROM 1202, and RAM 1203 are interconnected via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.
[0214] In some embodiments, the following components are connected to the I / O interface 1205: an input section 1206 including a keyboard, mouse, etc.; an output section 1207 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 1210 as needed so that computer programs read from it can be installed into the storage section 1208 as needed.
[0215] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as a computer program. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1209, and / or installed from removable medium 1211. When the computer program is executed by processor (CPU) 1201, it performs various functions defined in the system of this application.
[0216] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0217] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, or they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and a computer program. The units or modules described in the embodiments of this application may be implemented in software or hardware, and the described units or modules may also be located in a processor. The names of these units or modules do not, in some cases, constitute a limitation on the unit or module itself.
[0218] Another aspect of this application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the script generation method as described above. This computer-readable storage medium may be included in the electronic device described in the above embodiments, or it may exist independently without being assembled into the electronic device. Another aspect of this application provides a computer program product comprising a computer program stored in a computer-readable storage medium. A processor of an electronic device reads the computer program from the computer-readable storage medium and executes the computer program, causing the electronic device to perform the script generation method as described above in the various embodiments.
[0219] It should be noted that although several modules or units for the device used to perform actions are mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units. Other embodiments of this application will be readily apparent to those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary technical means in the art not disclosed in this application. The above content is only a preferred exemplary embodiment of this application and is not intended to limit the embodiments of this application. Those skilled in the art can easily make corresponding modifications or alterations based on the main concept and spirit of this application; therefore, the scope of protection of this application should be determined by the scope of protection claimed in the claims.
Claims
1. A script generation method, characterized in that, The method includes: Retrieve the story content text used to describe the story content; Based on the story content text, candidate scripts for the story content text are generated; wherein, the candidate scripts contain multiple unit scripts arranged in sequence; For each unit script, based on the preceding unit script, each unit script is logically optimized to obtain an optimized unit script. Based on the optimized unit scripts corresponding to the multiple unit scripts, the target script for the story content text is generated.
2. The method as described in claim 1, characterized in that, The step of generating candidate scripts for the story content text based on the story content text includes: The story content text is analyzed to generate basic content element information of the story content text; the basic content element information includes at least one of plot summary information, world structure information, and character setting information; The story content text was split into multiple original text fragments; Based on the basic content element information and each original text fragment, a stage script corresponding to each original text fragment is generated; wherein, the stage script contains at least one unit script arranged in sequence; Based on the stage scripts corresponding to the multiple original text fragments, candidate scripts for the story content text are generated.
3. The method as described in claim 2, characterized in that, The process of splitting the story content text yields multiple original text fragments, including: The story content text is split into multiple story stages and content description information corresponding to each of the multiple story stages; Based on the content description information corresponding to each of the multiple story stages, the story content text is split to obtain the original text fragments corresponding to each of the multiple story stages.
4. The method as described in claim 2, characterized in that, The step of generating a stage script corresponding to each original text fragment based on the basic content element information and each original text fragment includes: The plot is extracted from each of the original text fragments to generate the original plot for each of the original text fragments; Based on the basic content element information, the original plot of each original text fragment is expanded to generate a plot outline corresponding to each original text fragment; Based on each original text fragment and the corresponding plot outline, a stage script corresponding to each original text fragment is generated.
5. The method as described in claim 4, characterized in that, The step of expanding the original plot of each original text fragment based on the basic content element information to generate a plot outline corresponding to each original text fragment includes: Based on the basic content element information, the original plot of each original text fragment is expanded to generate a candidate plot outline for each original text fragment. Content information is extracted from the candidate plot outlines to obtain the first expanded content information corresponding to each original text fragment; Based on the original content information corresponding to each original text fragment and the first expanded content information, the candidate plot outline is subjected to quality detection to obtain a quality score for the candidate plot outline; the original content information is obtained by extracting content information from each original text fragment. If the quality score is higher than the outline score threshold, then the candidate plot outline is used as the plot outline corresponding to each original text fragment to generate the plot outline corresponding to each original text fragment.
6. The method as described in claim 5, characterized in that, The original content information includes the original core plot extracted from each original text fragment, and the first expanded content information includes the expanded core plot extracted from the candidate plot outline; The step of performing quality checks on the candidate plot outlines based on the original content information corresponding to each original text fragment and the first expanded content information, to obtain a quality score for the candidate plot outlines, includes: From the original core plot and the expanded core plot, find overlapping storylines and calculate the proportion of the overlapping storylines in the storylines included in the original core plot to obtain the original plot proportion; Find the expanded storylines that are included in the expanded core storyline but not in the original core storyline, and calculate the proportion of the expanded storylines in the original core storyline to obtain the expanded storyline proportion. The quality score of the candidate plot outline is calculated based on the original plot ratio and the expanded plot ratio.
7. The method as described in claim 6, characterized in that, The quality score of the candidate plot outline is calculated based on the original plot ratio and the expanded plot ratio, including: A first score is calculated based on the original plot ratio; wherein the first score is positively correlated with the original plot ratio. Calculate the second score based on the expanded plot ratio; wherein the second score and the expanded plot ratio have a downward-opening unimodal function relationship. The first score and the second score are weighted and summed to calculate the quality score of the candidate plot outline; wherein the weight of the first score is greater than the weight of the second score.
8. The method as described in claim 6, characterized in that, The quality score of the candidate plot outline is calculated based on the original plot ratio and the expanded plot ratio, including: Find overlapping events from the original core event set contained in the original content information and the expanded core event set contained in the first expanded content information; the original core event set contains core events extracted from each original text fragment; the expanded core event set contains core events extracted from the candidate plot outline. Calculate the event consistency score based on the proportion of the overlapping events in the original core event set; The quality score of the candidate plot outline is calculated based on the event consistency score, the original plot ratio, and the expanded plot ratio.
9. The method as described in claim 5, characterized in that, The step of expanding the original plot of each original text fragment based on the basic content element information to generate a candidate plot outline for each original text fragment also includes: If the quality score of the candidate plot outline is lower than or equal to the outline score threshold, then based on the basic content element information, the original plot of each original text fragment is reprocessed for plot expansion to generate a new candidate plot outline for each original text fragment, until the generation stop condition is met; the generation stop condition includes at least one of the following conditions: the quality score of the candidate plot outline is higher than the outline score threshold, and the number of generated candidate plot outlines reaches at least one of the number thresholds; The candidate plot outline with the highest quality score is selected from the generated candidate plot outlines to generate the plot outline corresponding to each original text fragment.
10. The method as described in claim 2, characterized in that, The step of generating the target script for the story content text based on the optimized unit scripts corresponding to the multiple unit scripts includes: Obtain candidate stage scripts corresponding to each original text segment; wherein, the candidate stage scripts include optimized unit scripts corresponding to at least one unit script of each original text segment; Content information is extracted from the candidate stage script corresponding to each original text fragment to generate the second expanded content information corresponding to each original text fragment; Based on the original content information corresponding to each original text fragment and the second expanded content information, the candidate stage script is subjected to quality detection to obtain a quality score for the candidate stage script; the original content information is obtained by extracting content information from each original text fragment. If the quality score is higher than the script score threshold, then the candidate stage script will be used as the target stage script corresponding to each original text segment. Based on the target stage scripts corresponding to the multiple original text fragments, a target script for the story content text is generated.
11. The method as described in claim 10, characterized in that, The second expanded content information is generated by the generative model extracting content information from the candidate stage scripts. The generative model is trained in the following manner: A training sample set and a model to be trained are obtained, and supervised training is performed on the model to be trained based on the training sample set to obtain an initial generated model; the training sample set contains sample scripts and target content information of the sample scripts. The initial generation model is used to extract content information from the sample script to generate predicted content information for the sample script. Based on the sample script, the predicted content information of the sample script, and the target content information, a reinforcement sample script for reinforcement learning training is generated, along with first content information and second content information corresponding to the reinforcement sample script; the first content information is superior to the second content information. The initial generative model is trained using reinforcement learning based on the reinforced sample script, the first content information, and the second content information to obtain the generative model.
12. The method as described in claim 11, characterized in that, The step of generating reinforcement sample scripts for reinforcement learning training based on the sample scripts, the predicted content information of the sample scripts, and the target content information, and the first content information and second content information corresponding to the reinforcement sample scripts, includes: Each sample script in the training sample set, the predicted content information of each sample script, and the target content information are input into the large language model to obtain the optimal content indication of each sample script output by the large language model; the optimal content indication is used to indicate the optimal content information in the predicted content information and the target content information of each sample script. Based on the optimal content indication, the enhanced sample script is selected from multiple sample scripts included in the training sample set, and based on the optimal content indication, predicted content information and target content information corresponding to the enhanced sample script, the first content information and the second content information corresponding to the enhanced sample script are generated.
13. The method as described in claim 12, characterized in that, The step of selecting the enhanced sample script from multiple sample scripts included in the training sample set according to the optimal content indication, and generating first content information and second content information corresponding to the enhanced sample script based on the optimal content indication, predicted content information, and target content information corresponding to the enhanced sample script, includes: Based on the optimal content indication, from the multiple sample scripts contained in the training sample set, the enhanced sample scripts whose target content information is better than the predicted content information are selected. Based on the enhanced sample script and the predicted content information of the enhanced sample script, the target content information of the enhanced sample script is optimized through a large language model to obtain the optimized content information of the enhanced sample script. Based on the optimized content information, the first content information of the enhanced sample script is generated; Based on the predicted content information of the enhanced sample script, the second content information of the enhanced sample script is generated.
14. The method as described in claim 11, characterized in that, The step of training the initial generation model through reinforcement learning based on the reinforced sample script, the first content information, and the second content information to obtain the generation model includes: The enhanced sample script is input into the initial generation model for probability prediction to obtain a first probability that the initial generation model outputs the first content information based on the enhanced sample script, and a second probability that the initial generation model outputs the second content information based on the enhanced sample script. The enhanced sample script is input into the reference model for probability prediction to obtain a third probability that the reference model outputs the first content information based on the enhanced sample script, and a fourth probability that the reference model outputs the second content information based on the enhanced sample script; the reference model includes the historical model of the initial generation model; Based on the first probability, the second probability, the third probability, and the fourth probability, the loss value corresponding to the enhanced sample script is calculated, and the model parameters of the initial generation model are updated according to the loss value to obtain the generation model; wherein, the loss value is negatively correlated with the first probability and the fourth probability, and positively correlated with the second probability and the third probability.
15. The method as described in claim 2, characterized in that, For each unit script, logical optimization is performed based on the preceding unit scripts to obtain an optimized unit script, including: For each unit script, find the preceding unit script that is listed before each unit script in the stage script to which each unit script belongs; Based on the association information of the stage script to which each unit script belongs, and the preceding unit script, each unit script is logically optimized to obtain an optimized unit script for each unit script; the association information includes at least one of the following: The original text fragments corresponding to the stage script to which each unit script belongs, The plot outline corresponding to the stage script to which each unit script belongs, The content description information corresponding to the stage script to which each unit script belongs.
16. The method as described in claim 1, characterized in that, For each unit script, logical optimization is performed based on the preceding unit scripts to obtain an optimized unit script, including: For each unit script, based on the preceding unit script, each unit script is logically optimized to obtain the initial optimized unit script for each unit script; Based on at least one of the preceding unit scripts and script format requirements, the initial optimized unit scripts are polished to obtain the optimized unit scripts for each unit script.
17. A script generation device, characterized in that, The device includes: The acquisition module is used to acquire the story content text used to describe the story content; A generation module is used to generate candidate scripts for the story content text based on the story content text; wherein, the candidate scripts contain multiple unit scripts arranged in sequence; The optimization module is used to perform logical optimization on each unit script based on the preceding unit script of each unit script, so as to obtain the optimized unit script of each unit script; The generation module is also used to generate the target script of the story content text based on the optimized unit scripts corresponding to the multiple unit scripts respectively.
18. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more computer programs that, when executed by one or more processors, cause the electronic device to perform the method of any one of claims 1-16.
19. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by the processor of the electronic device, causes the electronic device to perform the method described in any one of claims 1-16.
20. A computer program product, characterized in that, The method includes a computer program that, when executed by a processor of an electronic device, causes the electronic device to perform the method described in any one of claims 1-16.