RAG-based memory enhanced script generation agent system
Through the memory-enhanced script generation agent system based on RAG, the problems of insufficient autonomy, originality and logic of script generation in the prior art are solved, and high-quality, coherent and artistically valuable script generation are achieved.
Patent Information
- Application Number
- CN202510839303.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-23
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2045-06-23
AI Technical Summary
The existing artificial intelligence script generation technology has low autonomy, poor originality, incoherence of logic, prone to hallucinations and misunderstandings, and it is difficult to generate high-quality, professional and artistic scripts.
The memory-enhanced script generation agent system based on RAG is adopted to achieve accurate understanding and efficient generation of script format, structure and content through data collection and knowledge base construction, pre-learning and intensive training, self-learning script generation, long-term memory and knowledge tree management, and script evaluation and feedback closed-loop mechanism.
It improves the originality, logic and artistic nature of the script, avoids plot disconnection and hallucination, and ensures that the generated script meets professional requirements and has high quality and consistency.
Smart Images

Figure CN120337981A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a memory-enhanced script generation intelligent agent system based on RAG. Background Art
[0002] When existing artificial intelligence technologies are used to generate artworks, there are problems such as low autonomy, weak originality, low evolvability, simple imitation, lack of artistic concepts, and lack of script scoring rules.
[0003] Specifically, first, the format of the script is relatively special. Currently, when using artificial intelligence technology to generate a script, the first problem to face is that AI without professional guidance cannot quickly understand a script. Similarly, it cannot directly generate a script work that can be directly used to guide actors' performances according to the script format. Second, when current generative artificial intelligence products directly generate script content, the generated content has poor quality and lacks originality. It can be seen at a glance that the "assembled feeling" of the generated content is very serious, the written plot is relatively plain, all within the logical expectation, lacking interest, creativity, and artistic value. In addition, it is difficult to avoid hallucination phenomena when using generative artificial intelligence to generate scripts. Sometimes, it will generate some content that is completely illogical. Moreover, they cannot achieve long-term memory. Since a script is a long-text and highly continuous artistic work content, it requires strong consistency and coherent logic. Current generative artificial intelligence products cannot meet this requirement, and there will be problems such as plot disconnection, unclear protagonists, unclear logic, inconsistent character settings before and after, no core plot main line, overly simple and single plot, and it is also prone to ambiguous understanding. For example, when the user describes "Please give me a wonderful and good-looking picture", the generative AI will reply with a plot scene that is "good-looking" in the literal sense, such as having many colors, fire, flowers and plants, which does not match the actual needs of the user. In addition, it cannot understand some professional terms and there are understanding errors. Finally, the content produced by generative artificial intelligence often has low quality and can only achieve the most basic plot generation, but it is not a content that can be directly used. The design of its plot density, character scene arrangement, plot logic, plot ups and downs, and plot volume has not been fully considered. Moreover, they cannot fully understand the meaning of the plot uploaded by the user, cannot understand the metaphors or foreshadows behind it, and cannot understand the deep meaning of the plot. Eventually, the generated script content will be empty and superficial. Summary of the Invention
[0004] The purpose of the present invention is to provide a memory-enhanced script generation intelligent agent system based on RAG to solve the problems existing in the above background art.
[0005] To achieve the above object, the present invention provides a memory-enhanced script generation intelligent agent system based on RAG, a data collection and knowledge base construction module, which collects relevant professional terms, common expressions and polysemous words, and constructs a professional term dictionary, an ambiguity interpretation library and a script sample knowledge base; A pre-learning and reinforcement training module, which uses the professional term library, the ambiguity interpretation library and the script sample knowledge base as the pre-learning section, and trains the generation module using the reinforcement learning algorithm. At the same time, the requirements of the editor for the script are quantified into specific indicators to form a script scoring rule; A self-learning script generation module, a generation system composed of multiple intelligent agents, which jointly realizes script generation; A long-term memory and knowledge tree management module, which extracts, encodes and stores key information layer by layer to form a high-density representation of data condensation; A script evaluation and feedback closed-loop mechanism, which grades and scores the generated script through preset quantitative evaluation indicators and feeds it back to the self-learning script generation module.
[0006] Preferably, the data collection and knowledge base construction module uses web crawler technology to automatically collect relevant professional terms, common expressions and polysemous words of the script, and establishes a professional term dictionary and an ambiguity interpretation library. Specifically, the web crawler is implemented using the beautifulsoup library of python.
[0007] Preferably, the script sample knowledge base is a sample library containing various script types. By extracting the key information of the script, it provides format and style specifications for subsequent generation. When extracting the key information, a text analysis algorithm is used to perform word segmentation on the sample script, and the term frequency-inverse document frequency value of each keyword is calculated. The formula is: ; Among them, represents the term frequency of the word in the document ; represents the inverse document frequency of the word in the document , and will be saved according to the importance of word segmentation; The script sample knowledge base is stored distributively using the redis database.
[0008] Preferably, in the pre-learning and reinforcement training module, the reinforcement learning algorithm guides the intelligent agent to continuously optimize the strategy by setting a specific reward function. In the script generation task, the reward function is set as: ; Among them, is the total reward; is the format reward; is the style reward; For content rewards, , , are the weight coefficients of three rewards respectively, and ; Content reward is expressed as: ; Among them, is the high-quality score; is the high originality score; is an adjustable weight coefficient, set to , indicating that quality and originality are equally important for content; High-quality score is specifically refined into three parts: ; Among them, is the score of the number of characters; is the score of the number of plots; is the plot density score; , , all represent weight coefficients, which are 0.3, 0.3, and 0.4 respectively; ; ; ; Among them, is the large plot density; is the number of large plots; is the total number of plots; is the penalty coefficient; represents the th number of characters in the plot; represents the maximum number of characters in all plots; represents the specified maximum number of plots; High originality score This part is the originality score generated by the evaluation model: ; This score is obtained through the following prompt: Please evaluate the plot of the following script from the perspective of originality. A novel but logically reasonable plot is considered high originality, and a completely repeated template is considered low originality. The scoring range is 0-1.
[0009] Preferably, in the script generation task of the self-learning script generation module, the generated script content is regarded as a trajectory of an agent in the environment, and each node should maximize the quality of its story unit, and the objective function is: ; Among them, represents the policy parameter of the th node; represents the probability distribution of generating a trajectory according to the parameter ; represents the reward score of the generated short story unit; Through the policy gradient theorem, the agent gradually optimizes the script generation policy. The policy gradient formula for a single generation node is: ; Among them, represents the expected cumulative reward; represents taking the gradient with respect to the parameter ; represents the gradient of the function with respect to the parameter ; represents taking the weighted average of the content in all trajectories under the policy according to the probability of the trajectory appearance; is the expectation; represents that the trajectory is sampled from the trajectory probability distribution generated under the current policy parameter ; Using distributed computing, the long script generation task is split into multiple small task units, each unit is completed independently, and then the synthesis algorithm is used to ensure the logical consistency and narrative coherence of the entire script. Specifically: Initialization: Each node randomly initializes its own policy parameter: ; Single-step training loop: For each node , repeat the following process until local convergence: A. Sampling trajectory: ; B. Evaluating reward: ; C. Introducing a penalty term for distributed computing: Denote the trajectory generated by each node as , and this trajectory contains several text fragments , then the penalty function is defined as follows: ; Among them, is sensitive to duplicate penalties; It is greatly affected by semantic jumps; It is only for auxiliary control of length; repetition penalty : ; Plot jump penalty , calculated based on BERT semantic similarity: ; Among them, is the cosine similarity of BERT or sentence vectors; Length penalty : ; Among them, is the ideal script segment length; is the th generated script segment 's length; Modify the scoring function of the final node of the reward function to become: ; Gradient policy formula: ; Adopt an asynchronous method for parameter update: ; Among them, is the learning rate, used to control the update step size, set to 0.0005.
[0010] Preferably, the construction of the knowledge tree adopts a hierarchical coding mechanism, and the relationship between nodes in each layer is represented by the link of parent and child nodes. The information transfer formula between parent and child nodes is: ; Among them, represents the information vector of the parent node, represents the information vector of the child node, represents the information transfer function, and a linear transformation function is selected. Through the above method, the key information is refined and encoded layer by layer.
[0011] Preferably, the script evaluation and feedback closed-loop mechanism grades and scores the generated script through preset quantitative evaluation indicators, specifically: In terms of originality assessment, a text similarity algorithm is used to compare the generated script with a massive script database to detect the uniqueness and novelty of the script content. For logical consideration, with the help of causal relationship graph construction technology, the causal chain of the script plot is deeply analyzed to ensure that the plot development is reasonable and coherent. In terms of artistic judgment, an emotion dictionary is used to analyze the emotional tendency of the script text and calculate the emotional score of the text. Suppose the emotion dictionary contains positive and negative emotion words, and each word has a corresponding emotional weight. The formula for calculating the emotional score of the script text is: ; Among them, represents the th word; represents the total number of words; represents the emotional score of the word; The evaluation results are fed back to the self-learning script generation module in the form of environmental variables to form a closed-loop learning mechanism.
[0012] Therefore, the present invention adopts the above-mentioned RAG-based memory-enhanced script generation intelligent agent system, which has the following beneficial effects: (1) By using a professional term dictionary, an ambiguity interpretation library, and a script sample knowledge base, it realizes the accurate understanding of the specific format and structure of the script, ensuring that the generated script meets professional requirements in terms of format, style, and content. Guided by reinforcement learning and a quantitative index system (such as the number of characters, plot density, etc.), it effectively improves the originality, logic, and artistry of the script; (2) Distributed task decomposition and multi-agent collaborative work ensure the effective transmission of information between each script generation module, avoiding the problems of plot disconnection and logical confusion that are prone to occur in the prior art. The multi-layer knowledge tree management and long-term memory storage technology can maintain the coherence of the overall narrative when generating long texts, preventing inconsistencies; (3) By adopting the adaptive RAG and evaluation feedback mechanism, it can monitor and adjust unreasonable content in the generation process in real time, greatly reducing the risk of hallucinations and misunderstandings in the generation process. The coding and data representation technology efficiently condenses key information, enabling the system to more accurately capture user needs and the implicit meaning of the script in long text generation; (4) The multi-agent collaborative work not only improves the script generation efficiency but also provides conditions for the subsequent adaptive optimization of the system according to the actual generation effect.
[0013] Next, through the drawings and embodiments, the technical solutions of the present invention will be further described in detail. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 is a schematic structural diagram of the RAG-based memory-enhanced script generation intelligent agent system of the present invention; Figure 2 This is the overall process block diagram of the RAG-based memory-enhanced script generation intelligent agent system of the present invention. Detailed implementation manners
[0015] The following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of protection of the present invention.
[0016] Please refer to Figure 1 - Figure 2 , the RAG-based memory-enhanced script generation intelligent agent system includes: The data collection and knowledge base construction module specifically includes: Construction of a professional term dictionary and ambiguity interpretation library: Use web crawler technology to automatically collect professional terms, common expressions, and polysemous words related to the script field, and establish a standardized interpretation library. This library defines terms such as "point of view", "plot", "dramatic tension", etc. in detail to ensure the accurate understanding of professional terms by the generation module; at the same time, it includes common misreading examples that appear in user feedback to achieve accurate word meaning proofreading.
[0017] For example, for "point of view", it is defined as the angle and perspective of story narration, including first person, second person, third person limited perspective, and third person omniscient perspective, etc.; "plot" is defined as a series of events connected by causal logic in the script; "dramatic tension" is defined as the attraction and tension formed by the conflict in the plot. At the same time, it includes common misreading examples that appear in user feedback to achieve accurate word meaning proofreading. The crawler is implemented using the beautifulsoup library in python.
[0018] Script sample knowledge base: Construct a sample library covering various script types (drama, movie, TV series, etc.), extract key information such as script format, structure, character settings, and plot trends, and provide format and style specifications for subsequent generation. For example, for a movie script, the format includes elements such as scene description, character dialogue, and action instructions; the structure is usually divided into parts such as the beginning, development, climax, and ending; the character settings cover the personality characteristics and relationships of the protagonist and supporting roles; the plot trend includes key nodes such as the cause, conflict, turning point, and ending.
[0019] When extracting key information, use a text analysis algorithm to perform word segmentation on the sample script, calculate the term frequency-inverse document frequency (TF-IDF) value of each keyword, and the formula is: ; Among them, represents the word Word frequency in the document ; Indicates the inverse document frequency of the word in the document will be saved according to the importance of word segmentation; determine the importance based on the TF-IDF value and store it in the knowledge base together for the script generation agent to understand and generate scripts.
[0020] The script sample knowledge base is stored distributively using the redis database.
[0021] Preprocessing: Construct a comprehensive editing expert database through multi-source knowledge integration, which can guide the agent to generate high-quality scripts. Through key information extraction, the condensed key points of the data can be obtained, and more information can be carried through data refinement.
[0022] Pre-learning and reinforcement training module, specifically including: Multi-knowledge base reinforcement learning: Use the professional term library, ambiguity interpretation library, and script sample knowledge base as the pre-learning section, and adopt the reinforcement learning algorithm to train the generation module. The reinforcement learning algorithm guides the agent to continuously optimize the strategy by designing a specific reward function, enabling the system to "understand" the specific format and deep structure of the script, and solving the problems of insufficient understanding of the script format, single generation style, non-standard generated content, and easy misreading and hallucination of existing AI.
[0023] The design of the reward function is the key to reinforcement learning. The reward function for the script generation task is as follows: ; Among them, is the total reward; is the format reward; is the style reward; is the content reward, , , are the weight coefficients of the three rewards respectively, and ; Content reward is expressed as: ; Among them, is the high-quality score; is the high-originality score; is the adjustable weight coefficient, set to , indicating that quality and originality are equally important for the content; High-quality score is specifically refined into three parts: ; Among them, is the score (normalized) of the number of characters; is the score of the number of plots (normalized); is the plot density score; , , all represent weight coefficients, which are 0.3, 0.3, and 0.4 respectively; ; ; ; Among them, is the large plot density; is the number of large plots (≥5 people); is the total number of plots; is the penalty coefficient (set to ); represents the number of characters in the th plot; represents the maximum number of characters in all plots; represents the specified maximum number of plots; High originality score This part is the originality score generated by the evaluation model: ; This score is obtained through the following prompt: Please evaluate the plot of the following script from the perspective of originality. A high originality means the plot is novel but logically reasonable, and a low originality means it completely repeats the template. The scoring range is 0 - 1. A relatively innovative example is as follows:... (script content): Please give an originality score.
[0024] Index quantization design: Quantify the editor's requirements for "high quality" and "high originality" of the script into specific indicators (such as the number of characters, plot density, plot point settings, etc.). Define a plot as an independent small story or dialogue within a small scene. Define the scale of the plot as a large plot and a small plot according to the number of characters in the plot. When the number of characters is greater than or equal to 5, the plot is considered a large plot. High quality is quantified as the number of characters, the number of plots, and the density arrangement of the plots (define plot density as the number of large plots / the number of plots, and require the plot density to be between 0.4 - 0.6). High originality is defined as the originality score of the plot in the evaluation agent. Use the prompt: "The originality of the script refers to the novelty degree of the plot. The plot should be novel but logical. An innovative plot is as follows: xxx (example in the knowledge base), please evaluate the innovation." to form the script scoring rule, which serves as the goal orientation for the subsequent generation process.
[0025] Self-learning script generation module, specifically including: Multi-agent collaborative generation: Construct a generation system composed of multiple agents. Each agent is responsible for different task modules of the script (such as character setting, plot construction, scene description, etc.). The character setting agent uses the character personality feature model to endow each character with distinct and coherent personality traits to ensure the consistency of character behavior; the plot construction agent, based on the logical chain of the plot development, skillfully sets the ups and downs of the plot and accurately controls the plot direction; the scene description agent relies on the spatial environment feature library to render delicate scene pictures that fit the plot atmosphere. Information is communicated and collaborative work is achieved through intelligent communication to ensure the coherence and unity of the overall script.
[0026] Multi-module agent system: Multiple agent systems such as the script generation module, the script evaluation module, the multi-source knowledge integration pre-learning module, and the long-term memory storage module cooperate and communicate with each other to jointly achieve the generation of high-quality standard scripts. The script generation module calls the key information in the long-term memory storage module in real time during the creation process and sends the generated content to the script evaluation module for evaluation; the feedback information of the script evaluation module is timely transmitted to the script generation module to guide its optimization of the creation strategy.
[0027] In the script generation task, we regard the generated script content as a trajectory (a sequence of a series of states and actions) of the agent in the environment, and each node To maximize the quality of its story unit, the objective function is: ; Among them, represents the policy parameter of the th node (parameters used to control the model for unit generation, such as LLM); represents the probability distribution of generating the trajectory (i.e., the unit short story) according to the parameter ; represents the reward score of the generated short story unit (such as coherence and creativity scoring); Through the policy gradient theorem, the agent gradually optimizes the script generation strategy, and the policy gradient formula for a single generation node is: ; Among them, represents the expected cumulative reward, and the goal is to make it as large as possible; represents taking the gradient with respect to the parameter ; represents the gradient of the function with respect to the parameter ; represents the gradient at the policy Among all the trajectories, calculate the weighted average of the content according to the probability of the trajectory appearance; is the expectation; represents the trajectory is according to the current policy parameters The trajectory probability distribution generated below is obtained by sampling; Adopt distributed computing, split the long script generation task into multiple small task units, each unit completes independently, and then ensure the logical consistency and narrative coherence of the whole script through the synthesis algorithm. Specifically: Initialization: Each node randomly initializes its own policy parameters (a small random perturbation for the initialization parameters to prevent all nodes from generating exactly the same at the beginning): ; Single-step training loop: For each node , repeat the following process until local convergence: A. Sample the trajectory (generate a small story unit, generate the story content according to the probability from the policy): ; B. Evaluate the reward (score): ; C. Introduce a penalty term for distributed computing: Record each node The generated trajectory is , and this trajectory contains several text fragments , then the penalty function is defined as follows: ; Among them, is more sensitive to repeated penalties; has a greater impact on semantic jumps; is only used to assist in controlling the length; repeated penalty (highly repeated text fragments): ; Plot jump penalty (semantic break before and after), based on BERT semantic similarity calculation: ; Among them, is the cosine similarity of BERT or sentence vectors; Length penalty (too short or too long): ; Among them, is the ideal script fragment length (set to 80 - 100 words); For the length of the generated script segment; Modify the reward function (combined with the penalty term), and the scoring function of the final node becomes: ; Gradient policy formula: ; Adopt an asynchronous method for parameter update, and each node independently updates its policy: ; Among them, is the learning rate, which is used to control the update step size and is set to 0.0005.
[0028] Long-term memory and knowledge tree management module, specifically including: Multi-layer knowledge tree construction: A multi-layer knowledge tree structure is designed for the problems of long script generation and detailed modification. Key information is refined, encoded, and stored layer by layer to form a high-density representation of data condensation, which not only solves the problem of long-term memory storage but also avoids the hallucination phenomenon to a certain extent during the generation process.
[0029] The construction of the knowledge tree adopts a hierarchical coding mechanism. For example, the first-layer knowledge tree nodes store the macro information of the script, such as the theme, type, main characters, etc.; the second-layer nodes store the key information of each main plot unit, such as the plot goal, main conflict, etc.; the third-layer nodes store the detailed information such as specific scene descriptions and character dialogues. The relationship between the nodes of each layer is represented by the link of the parent and child nodes, and the information transfer formula between the parent and child nodes is: ; Among them, represents the information vector of the parent node, represents the information vector of the child node, represents the information transfer function, and a linear transformation function is selected. Through the above method, the key information is refined and encoded layer by layer.
[0030] Coding and data representation: The system adopts an advanced coding technology based on a deep neural network. It can transform the key information in the script, such as character personality characteristics, plot development clues, scene environment descriptions, etc., into high-dimensional data vectors. These data vectors are like the "digital fingerprints" of the script, which not only retain the core characteristics of the original information but also facilitate the system to perform fast retrieval and operations. The key information is transformed into data vectors by adopting advanced coding technology, which supports the invocation of long-term memory during the generation process and real-time adjustment by comparing the context to ensure the continuity of characters, plots, and narratives.
[0031] Script evaluation and feedback closed-loop mechanism, specifically including: Dynamic Script Scoring System: Through preset quantitative evaluation indicators, grade and score the generated scripts, and detect the performance of the generated scripts in terms of originality, logic, artistry, etc. in real time. In terms of originality assessment, the system uses an advanced text similarity algorithm to compare the generated script with a massive script database to accurately detect the uniqueness and novelty of the script content; for logical consideration, the system uses causal relationship graph construction technology to deeply analyze the causal chain of the script plot to ensure that the plot development is reasonable and coherent. In terms of artistic judgment, the system uses sentiment analysis algorithms and aesthetic feature extraction models to quantitatively score the depth of emotional expression, the fullness of character shaping, and the artistic appeal of the dialogue in the script. Use a sentiment dictionary to analyze the sentiment tendency of the script text and calculate the sentiment score of the text. Suppose the sentiment dictionary contains positive sentiment words and negative sentiment words, and each word has a corresponding sentiment weight. The formula for calculating the sentiment score of the script text is: ; Among them, represents the th word; represents the total number of words; represents the sentiment score of the word; Feedback Transmission and Self-Evolution: The evaluation results are fed back to the self-learning script generation module in the form of environmental variables. This process is not simply about transmitting scores, but deeply analyzing the scoring results to extract specific improvement suggestions, such as pointing out specific deficiencies in plot coherence, character motivation rationality, or emotional expression depth in the script. After receiving this feedback information, the self-learning script generation module will deeply integrate it with its previous generation experience and historical memory. Combining previous generation experience and memory, a closed-loop learning mechanism is formed, enabling the system to continuously self-evolve and improve the script quality and creation ability.
[0032] Therefore, the present invention adopts the above-mentioned RAG-based memory-enhanced script generation intelligent agent system, which not only solves the problems of insufficient format understanding, poor originality, logical incoherence, and hallucinations existing in the prior art during the script generation process, but also realizes the intelligent and efficient generation of high-quality scripts through the self-evolution mechanism and multi-layer memory management, providing strong technical support for guiding actor performances and further creations. And it independently designs quality evaluation dimensions, and transforms the professional measurement indicators of scripts into quantifiable learning indicators based on the actual needs of editors.
[0033] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions of the present invention or make equivalent replacements, and these modifications or equivalent replacements do not enable the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. A memory-enhanced script generation intelligent agent system based on RAG, characterized in that Including: A data collection and knowledge base construction module that collects relevant professional terms, common expressions, and polysemous words, and constructs a professional term dictionary, an ambiguity explanation library, and a script sample knowledge base; A pre-learning and reinforcement training module that uses the professional term library, the ambiguity explanation library, and the script sample knowledge base as the pre-learning section, and trains the generation module using the reinforcement learning algorithm. At the same time, quantifies the requirements of the editor for the script into specific indicators to form a script scoring rule; A self-learning script generation module, a generation system composed of multiple agents, jointly realizing script generation; A long-term memory and knowledge tree management module that extracts, encodes, and stores key information layer by layer to form a high-density representation with data condensation; A script evaluation and feedback closed-loop mechanism that grades and scores the generated script through preset quantitative evaluation indicators and feeds it back to the self-learning script generation module.
2. The RAG-based memory-enhanced script generation intelligent agent system according to claim 1, wherein: The data collection and knowledge base construction module uses web crawler technology to automatically collect professional terms, common expressions, and polysemous words related to the script, and establishes a professional term dictionary and an ambiguity explanation library. Specifically, the crawler is implemented using the beautifulsoup library in python.
3. The RAG-based memory-enhanced script generation intelligent agent system according to claim 1, characterized in that, The script sample knowledge base is a sample library containing various script types. By extracting the key information of the script, it provides format and style specifications for subsequent generation. When extracting key information, a text analysis algorithm is used to perform word segmentation on the sample script and calculate the term frequency-inverse document frequency value of each keyword. The formula is: ; Among them, represents the word frequency of the word in the document ; represents the inverse document frequency of the word in the document and will be saved according to the importance of word segmentation; The script sample knowledge base is stored distributively using the redis database.
4. The RAG-based memory-enhanced script generation intelligent agent system according to claim 1, wherein In the pre-learning and reinforcement training module, the reinforcement learning algorithm guides the agent to continuously optimize the strategy by setting a specific reward function. In the script generation task, the reward function is set as: ; Among them, is the total reward; is the format reward; is the style reward; is the content reward, , , are the weight coefficients of the three rewards respectively, and ; Content Reward Expressed as: ; Among them, is the high-quality score; is the high originality score; is an adjustable weight coefficient, set to , indicating that quality and originality are equally important for the content; High-quality score It is specifically refined into three parts: ; Among them, is the score for the number of characters; is the score for the number of plots; is the score for plot density; , , all represent weight coefficients, which are 0.3, 0.3, and 0.4 respectively; ; ; ; Among them, is the large plot density; is the number of large plots; is the total number of plots; is the penalty coefficient; represents the number of characters in the th plot; represents the maximum number of plots specified; High originality score This part is the originality score generated by the evaluation model: ; This score is obtained through the following prompt: Please evaluate the plot of the following script from the perspective of originality. Novel but logically reasonable is high originality, and completely repeating the template is low originality. The scoring range is 0-1.
5. The RAG-based memory-enhanced script generation intelligent agent system according to claim 1, wherein In the script generation task, the self-learning script generation module regards the generated script content as a trajectory of an agent in the environment, and each node To maximize the quality of its story units, the objective function is: ; Among them, represents the policy parameter of the th node; represents the probability distribution of generating a trajectory according to the parameter ; represents the reward score of the generated short story unit. Through the policy gradient theorem, the agent gradually optimizes the script generation strategy. The policy gradient formula for a single generation node is: ; Among them, represents the expected cumulative reward; represents taking the gradient with respect to the parameter ; represents the function with respect to the parameter gradient; represents that under the policy , in all trajectories, the content inside is weighted and averaged according to the probability of the trajectory appearance; is the expectation; represents that the trajectory is sampled according to the trajectory probability distribution generated under the current policy parameter ; Adopt distributed computing to split the long script generation task into multiple small task units. Each unit is completed independently, and then a synthesis algorithm is used to ensure the logical consistency and narrative coherence of the entire script. Specifically: Initialization: Each node randomly initializes its own policy parameters: ; Single-step training loop: For each node , repeat the following process until local convergence: A. Sampling trajectory: ; B. Evaluating rewards: ; C. Introduce a penalty term for distributed computing: Record each node The generated trajectory is , and this trajectory contains several text segments , then the penalty function is defined as follows: ; Among them, is more sensitive to repetition penalty; is greatly affected by semantic jumps; is only for auxiliary length control; repetition penalty : ; Plot Jump Penalty , based on BERT semantic similarity calculation: ; Among them, is BERT or the cosine similarity of sentence vectors; Length penalty : ; Among them, is the ideal script segment length; is the th generated script segment length; Modify the scoring function of the final node of the reward function to become: ; Gradient policy formula: ; Adopt an asynchronous method for parameter update: ; Among them, is the learning rate, which is used to control the update step size and is set to 0.0005.
6. The RAG-based memory-augmented script generation intelligent agent system according to claim 1, wherein The construction of the knowledge tree adopts a hierarchical coding mechanism. The relationship between nodes in each layer is represented by the link of the parent and child nodes. The information transfer formula between the parent and child nodes is: ; Among them, represents the information vector of the parent node, represents the information vector of the child node, represents the information transfer function. A linear transformation function is selected. Through the above method, the key information is refined and encoded layer by layer.
7. The RAG-based memory-enhanced script generation intelligent agent system according to claim 1, wherein The script evaluation and feedback closed-loop mechanism grades and scores the generated script through preset quantitative evaluation indicators. Specifically: In terms of originality assessment, a text similarity algorithm is used to compare the generated script with a massive script database to detect the uniqueness and novelty of the script content; for logical consideration, with the help of causal relationship graph construction technology, the causal chain of the script plot is deeply analyzed to ensure that the plot development is reasonable and coherent; in terms of artistic judgment, an emotion dictionary is used to conduct an emotion tendency analysis on the script text and calculate the emotion score of the text. Suppose the emotion dictionary contains positive emotion words and negative emotion words, and each word has a corresponding emotion weight. The formula for calculating the emotion score of the script text is as follows: ; Among them, represents the th word; represents the total number of words; represents the sentiment score of the word; The evaluation results are fed back to the self-learning script generation module in the form of environmental variables to form a closed-loop learning mechanism.
Citation Information
Patent Citations
Large language model-based script content generation method and device
CN117992568A
Memory enhanced artist agent autonomous learning and creation system and method
CN119294470A
Multi-agent-based automatic generation method, system and terminal for micro-drama
CN119383413A
Document knowledge question-answering method, document knowledge storage method and document knowledge question-answering device
CN119669429A
Text generation method and device, equipment and storage medium
CN119719334A
Cited By
Real-time deployment method of AI generation script playing killing method at virtual digital space end
CN120762915A
Real-time deployment method of AI-generated escape room play in virtual digital space
CN120762915B
Scenario-centered interaction-driven scene generation system
CN121364778A
Multi-agent cooperation and dynamic feedback long text generation system and method
CN121413623A
Multi-agent collaborative short-play digital production system
CN121525732A