Semantic-based text generation method and device, equipment and medium

Through semantic analysis and adversarial network generation technology, the problem of personalized generation of healing stories by existing AI generation technology has been solved, and personalized story generation with strong logical coherence and emotional resonance has been achieved, which is suitable for personalized psychological intervention in the medical field.

CN120671744APending Publication Date: 2025-09-19PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510727746.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

Existing AI generation technology has difficulty in efficiently generating personalized, logically coherent, and emotionally resonant content when creating healing stories. In particular, there is a lack of personalized story text generation tools in the medical field, making it difficult to meet users' deep-seated needs.

Method used

The story type is determined through a preset semantic analysis model, construction information is obtained using the knowledge graph, the initial story framework is screened, the target character is constructed in combination with the adversarial network, and the storyline is expanded by advancing the decision-making algorithm to generate personalized story text.

Benefits of technology

It achieves efficient and in-depth generation of personalized story texts, meets user creation needs, enhances the logical coherence and emotional resonance of the story, and is suitable for personalized psychological intervention in the medical field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120671744A_ABST
    Figure CN120671744A_ABST
Patent Text Reader

Abstract

The invention discloses a semantic-based text generation method and device, equipment and a medium. The method can be applied to the field of medical health, and comprises the following steps: performing instruction analysis on a received user creation instruction through a preset semantic analysis model, determining a story type, and obtaining story construction information in a preset knowledge graph according to the story type; screening an initial story framework according to the story construction information, and generating a target story framework according to the initial story framework and the story construction information; constructing a target role through a preset adversarial network according to the target story framework and the story construction information; and expanding story plots of the target role and the target story framework through a preset promotion decision algorithm to generate a target story text. By implementing the method provided by the invention, the problem that the personalized story text is difficult to efficiently generate in the prior art can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of artificial intelligence and can be applied to fields such as medicine. In particular, it relates to a semantic-based text generation method, device, equipment and medium. Background Art

[0002] With the development of science and technology, cultural content creation and health management are gradually being integrated, but traditional creative methods still face efficiency bottlenecks. Taking the creation of healing stories as an example, creators need to combine interdisciplinary knowledge such as psychology and narrative medicine to manually design plots and metaphors, which is not only time-consuming and labor-intensive, but also difficult to quickly respond to personalized needs. Although existing AI generation technology can assist in creation, it generally has problems such as insufficient content depth, weak logical coherence, and lack of emotional resonance. Especially in scenarios involving complex metaphors or emotional healing, the generated content is often superficial and difficult to meet the deep needs of users. Although the medical field has verified the effectiveness of narrative therapy in psychological intervention, it is limited by the lack of tools and it is difficult to efficiently generate personalized story texts. Summary of the Invention

[0003] The embodiments of the present invention provide a semantic-based text generation method, apparatus, device, and medium, aiming to solve the problem in the prior art of difficulty in efficiently generating personalized story text.

[0004] In a first aspect, an embodiment of the present invention provides a semantic-based text generation method, which includes: performing instruction analysis on received user creation instructions through a preset semantic analysis model to determine the story type, and obtaining story construction information in a preset knowledge graph according to the story type; screening an initial story framework according to the story construction information, and generating a target story framework according to the initial story framework and the story construction information; constructing a target character through a preset adversarial network according to the target story framework and the story construction information; and expanding the storyline of the target character and the target story framework through a preset promotion decision algorithm to generate a target story text.

[0005] In the second aspect, an embodiment of the present invention also provides a semantic-based text generation device, which includes: an analysis unit, used to analyze the received user creation instructions through a preset semantic analysis model, determine the story type, and obtain story construction information in a preset knowledge graph according to the story type; a screening unit, used to screen the initial story framework according to the story construction information, and generate a target story framework according to the initial story framework and the story construction information; a construction unit, used to construct a target character through a preset adversarial network according to the target story framework and the story construction information; an expansion unit, used to expand the storyline of the target character and the target story framework through a preset promotion decision algorithm to generate a target story text.

[0006] In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above method when executing the computer program.

[0007] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the above method can be implemented.

[0008] Embodiments of the present invention provide a semantics-based text generation method, apparatus, device, and medium. The method includes: analyzing received user-generated instructions using a preset semantic analysis model to determine a story type, obtaining story construction information from a preset knowledge graph based on the story type; selecting an initial story framework based on the story construction information, and generating a target story framework based on the initial story framework and the story construction information; constructing a target character using a preset adversarial network based on the target story framework and the story construction information; and expanding the plot using a preset driving decision algorithm with the target character and the target story framework to generate a target story text. The embodiments of the present invention analyze received user-generated instructions using a preset semantic analysis model to understand the user's creative intent, facilitating the creation of story types that meet customer requirements. In the medical field, stories that meet patient intent can be therapeutic. The initial story framework is selected based on the story construction information, and a target story framework is generated based on the initial story framework and the story construction information. This provides a clear blueprint for subsequent semantics-based text generation, facilitates the subsequent construction of a target character using a preset adversarial network, and drives the plot development based on the target character, thereby generating the target story text. By creating the story framework, characters and plots in sequence according to user needs and expanding the plots, we can efficiently and deeply generate personalized story texts while meeting the user's creative needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0010] Figure 1 A flowchart of a semantics-based text generation method provided by an embodiment of the present invention;

[0011] Figure 2 A schematic diagram of a sub-process of a semantic-based text generation method provided by an embodiment of the present invention;

[0012] Figure 3 A schematic diagram of a sub-process of a semantic-based text generation method provided by an embodiment of the present invention;

[0013] Figure 4 A schematic diagram of a sub-process of a semantic-based text generation method provided by an embodiment of the present invention;

[0014] Figure 5 A schematic diagram of a sub-process of a semantic-based text generation method provided by an embodiment of the present invention;

[0015] Figure 6 A schematic diagram of a sub-process of a semantic-based text generation method provided by an embodiment of the present invention;

[0016] Figure 7 A schematic diagram of a sub-process of a semantic-based text generation method provided by an embodiment of the present invention;

[0017] Figure 8 A schematic block diagram of a semantics-based text generation device provided by an embodiment of the present invention;

[0018] Figure 9 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0019] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0020] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0021] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the present invention. As used in the specification and appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.

[0022] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0023] See also Figure 1 , Figure 1 A flow chart of a semantic-based text generation method provided for an embodiment of the present invention. The semantic-based text generation method in this embodiment can be applied to a semantic-based text generation system, wherein the generation system is provided with an intelligent agent (planning intelligent agent, shaping intelligent agent, plot intelligent agent, and knowledge intelligent agent) that deploys this method to complete story creation. Specifically, in the medical field, it can intelligently generate healing and guiding stories for patients with mental illness or in psychological distress. For example, a heartwarming story full of hope and warmth is generated for patients with psychological problems. By adopting this method, personalized story texts can be generated efficiently and in depth while meeting the user's creative needs.

[0024] Figure 1 1 is a flow chart of a semantic-based text generation method provided by an embodiment of the present invention. As shown in the figure, the method includes the following steps S110-S140.

[0025] S110. Analyze the received user creation instructions through a preset semantic analysis model to determine the story type, and obtain story construction information from a preset knowledge graph based on the story type.

[0026] In this embodiment, the user-generated instruction is a command or idea related to the story they wish to create, entered by the user in natural language. For example, a healthcare user might enter a voice command to create a healing story. The user-generated instruction is received via a preset interface, where the corresponding interface is not limited. The user-generated instruction is analyzed using a preset semantic analysis model to determine the story type. Based on the story type, story construction information is retrieved from a preset knowledge graph. Specifically, the semantic analysis model is a pre-trained model that understands the semantic information of natural language. The user-generated instruction is input into the semantic analysis model, which parses the instruction and extracts key information. For example, the model might identify keywords such as "disease recovery," "spiritual comfort," and "family warmth," and understand the relationships and overall semantics between these words. Through semantic analysis of the instruction, the model can determine the core intent of the user's story creation, namely, the type of story the user wants to create. Based on the key information and core intent analyzed by the semantic analysis model, the system matches the user's desired story with preset story types to determine the story type. For example, based on keywords and intents such as "family" and "warmth," the system determines that the user wants to create a story about a harmonious family. The knowledge graph is a structured way of representing knowledge, which stores various entities (such as people, places, events, etc.) and the relationships between them in the form of a graph. According to the determined story type, a search is performed in the knowledge graph to obtain story construction information related to the story type. Specifically, the semantic-based text generation system has a knowledge agent, wherein the knowledge agent has a knowledge preset knowledge graph and rich healing knowledge, such as the relationship between doctrines, characters, and events, and can convert query questions for obtaining story construction information into query statements for the knowledge graph, thereby obtaining corresponding knowledge information. The retrieved story construction information is integrated to obtain story construction information. By performing type analysis and information acquisition according to user creation instructions, a basis is provided for subsequent story creation, helping to generate story content that is more in line with user intentions.

[0027] In one embodiment, if Figure 2 As shown, step S110 includes steps S111-S112.

[0028] S111, using a preset web crawler to collect references of different story creation types, performing noise removal and word segmentation preprocessing on the references to generate reference data;

[0029] S112: Construct the preset knowledge graph based on the relationship between characters, events and features of the reference data.

[0030] In this embodiment, the pre-set web crawler is a program or script that automatically crawls internet information according to certain rules. The reference literature is available parameter data from different fields, for example, healing-related materials distributed across various academic databases, health information websites, and healing story forums. The pre-set web crawler collects reference literature for different story creation types, performs noise removal and word segmentation preprocessing on these reference literature to generate reference data. Specifically, a crawler framework such as Scrapy monitors well-known academic websites, healing story forums, professional databases, and other platforms in the health and wellness field in real time. The latest research results, healing cases, and cultural dynamics are captured according to pre-set rules. For example, when crawling healing cases, content such as the case title, background description, healing process, and final results are extracted. The collected reference literature may contain a large amount of information unrelated to the creation of healing stories, such as advertisements, web page navigation bars, and copyright notices. This information is referred to as noise. Methods such as regular expression matching and rule-based filtering are used to remove noise, and statistical-based and deep learning-based word segmentation methods are used to segment the denoised data to generate reference data. Identify various entities from the preprocessed reference data, such as people (therapists, patients, health experts, etc.), events (therapeutic processes, health activities, etc.), and features (physical symptoms, healing methods, health concepts, etc.). For example, in a document about a modern healer treating insomnia, entities such as "healer," "insomnia," "patient," and "meditation therapy" can be identified. Analyze relationships between entities, such as those between people (the doctor-patient relationship between healers and patients, the mentoring relationship between health experts and students), events (causal relationships, temporal relationships, etc.), and features and entities (corresponding to a specific physical symptom, a specific healing method, and the relief of a specific symptom). For example, in a story about a healer treating a patient, relationships such as "the healer used meditation therapy to help the patient improve their insomnia" and "the patient regained confidence in life due to improved sleep" can be extracted. A knowledge graph is constructed, using the identified entities as nodes and the extracted relationships as edges. A graph database (such as Neo4j) can be used to store and manage knowledge graphs for easy querying and analysis. For example, in Neo4j, you can use the Cypher query language to search for all events and people related to a specific medical treatment, or find the corresponding explanation of a medical symptom in health and wellness concepts, thereby providing rich material and inspiration for story creation. By collecting relevant reference materials for story creation and constructing a preset knowledge graph after preprocessing, it provides strong support for story creation.

[0031] S120 , screening an initial story framework according to the story construction information, and generating a target story framework according to the initial story framework and the story construction information.

[0032] In this embodiment, the semantic-based text generation system includes a planning agent, which is supported by a combination of rule-based and machine learning methods. The planning agent selects an initial story framework based on the story construction information. Specifically, it extracts story frameworks from the knowledge graph that align with the story's purpose and the desired message. For example, in the creation of healing stories, if the goal is to highlight the comprehensive physical and mental well-being of traditional healers, the planning agent will select story frameworks that include healers using Traditional Chinese Medicine techniques to diagnose and treat physical ailments, guide patients through psychological counseling and self-healing, and ultimately achieve physical and mental harmony. After determining the initial story framework, the planning agent combines it with the story construction information and popular story elements predicted by the machine learning model to develop the overall story framework and outline. For example, if it predicts that the plot of "patients breaking through difficulties" will attract attention in healing stories, it will incorporate this plot into the outline. By screening the initial story framework to generate a complete, vivid, and meaningful target story framework, the planning agent provides clear and comprehensive guidance for subsequent story creation.

[0033] In one embodiment, if Figure 3 As shown, step S120 includes steps S121-S122.

[0034] S121, extracting keywords from the story structure information, screening the preset story frameworks based on the keywords, and determining the initial story framework;

[0035] S122. Predicting hot elements through a preset machine learning model, and integrating the hot elements with the initial story framework to formulate the target story framework.

[0036] In this embodiment, the story planning agent pre-creates some basic story framework templates based on the user's input themes and requirements using a machine learning model. For example, a preset story framework is constructed based on a "cause-process-result" structure. Keywords are extracted from the story construction information. Specifically, the story construction information is analyzed sentence by sentence to identify representative vocabulary. The extracted keywords are then compared against the preset story frameworks to identify frameworks that closely match the keywords. For example, if a preset story framework contains plots related to keywords such as "patient" and "treatment," this framework is considered the initial story framework. The preset machine learning model is trained based on a large amount of historical data and is not limited to this. Hot elements are popular topics in the field, such as "spiritual transformation rituals." This is not limited and can be determined based on the specific creative type. Based on the initial story framework, plots related to the hot elements are added to generate the target story framework. By combining the hot elements with the initial story framework to create a target story framework that meets user needs and is attractive, the story's readability is increased. In addition, this embodiment also includes: text preprocessing of the collected healing-related classic literature, including noise removal (such as irrelevant punctuation, formatting marks, etc.), word segmentation, part-of-speech tagging, named entity recognition, and converting the text into a form that can be processed by the model. The user-created demand text is semantically analyzed and intent identified, key information is extracted, and encoded. The processed data is divided into training sets, validation sets, and test sets according to a certain ratio for subsequent model training and evaluation. The user-created demand text and the corresponding excellent target story framework in the training set are used as training data to train a model based on a combination of rules and machine learning to continuously adjust the model parameters. During the training process, cross-validation and other methods are used to evaluate the model performance and continuously optimize the model. By continuously training the model, the model can accurately generate a reasonable story framework and outline according to user needs.

[0037] S130: Construct a target character through a preset adversarial network according to the target story framework and the story construction information.

[0038] In this embodiment, the semantic-based text generation system includes a shaping agent, wherein the planning agent is supported by deep learning generative adversarial network (GAN) technology. The preset adversarial network consists of a generator and a discriminator. The generator is responsible for generating new data (such as character descriptions), while the discriminator is responsible for determining whether the generated data is authentic. A target character is constructed using a preset adversarial network based on the target story framework and the story construction information. Specifically, the preset adversarial network extracts key character features from the story construction information and the story framework. For a healing story, for the doctor character, key features such as "excellent medical skills," "profound medical attainments," and "kind-hearted" may be extracted; for the patient character, features such as "holding a deep well of unhappiness" and "urgently seeking healing" may be extracted. Character design is performed based on these key features to construct the target character. By constructing the target character based on the preset adversarial network, a character that fits the story framework is created, adding rich layers and readability to the story, making it easier for readers to immerse themselves in the atmosphere created by the story and experience the emotional resonance and ideological enlightenment brought by the character.

[0039] In one embodiment, if Figure 4 As shown, step S130 includes steps S131-S133.

[0040] S131, creating initial characters and character descriptions using the generator and a preset noise vector according to the target story framework and the story construction information;

[0041] S132, evaluating the authenticity of the initial character and the character description by the discriminator to generate an evaluation score;

[0042] S133. Update the initial character through the generator according to the evaluation score to generate the target character.

[0043] In this embodiment, the pre-set adversarial network generator and discriminator are used. The generator creates an initial character based on the target story framework and the story construction information. Specifically, the noise vector can be a randomly generated value, which is used to break the generator's fixed pattern and produce a more creative character. The character features in the target story framework and the story construction information are encoded into a conditional vector, which serves as one of the inputs to the generator. The generator combines the noise vector and the conditional vector to generate an initial character and character description. For example, it generates a preliminary description of a doctor character, including their basic characteristics, skills, and personality. The discriminator, another part of the GAN, is responsible for evaluating the authenticity of the character description generated by the generator. It compares the generated character description with the character description in real stories to determine whether it is reasonable and credible. The discriminator evaluates the character features in the story construction information, the requirements of the target story framework, and the general characteristics of medical stories, generating an evaluation score. Based on the evaluation score provided by the discriminator, the generator updates and optimizes the initial character. If the discriminator deems the character description unrealistic or not in line with the theme, the generator adjusts its internal parameters and regenerates the character. The generator and discriminator gradually improve the quality and authenticity of the generated characters through multiple confrontations and optimizations. After multiple iterations and optimizations, the generator ultimately generates a target character that meets the requirements. For example, for a healer character in a healing story, key features might be extracted, such as "superb medical skills and rich experience," "expert in a variety of healing techniques," and "extremely patient and caring for patients." For a patient character, features might be extracted, such as "complex and long-standing illness," "anxious and eager to recover," and "full of anticipation and some concern about the healing process." Through continuous iterations of the generator and discriminator, the target character required by the story is constructed, providing a rich and three-dimensional character image for story creation. In addition, this embodiment also includes using a generative adversarial network (GAN) training method, where the generator and discriminator perform adversarial training on real character description data from the training set, enabling the generator to continuously attempt to generate more realistic character descriptions and the discriminator to continuously improve its ability to judge the authenticity of generated descriptions. Through multiple iterative training, the characters generated by the generator can meet the user's requirements for character personalization.

[0044] S140: Expand the plot of the target character and the target story framework through a preset advancement decision algorithm to generate a target story text.

[0045] In this embodiment, the semantic-based text generation system includes a plot agent, wherein the plotting agent is supported by a reinforcement learning method based on a Markov decision process (MDP). The preset advancement decision algorithm is a reinforcement learning method based on a Markov decision process (MDP). The Markov decision process (MDP) is a mathematical model for sequential decision-making. It is used to describe the process by which an agent makes decisions and takes actions in an environment. It contains elements such as states, actions, transition probabilities, and rewards. The different stages of the story progression are considered states in the MDP. The probability of transitioning from one state to another is determined based on the characteristics and logic of the story. For example, in the state "The patient has just arrived at the treatment center and has not yet communicated with the therapist," with a certain probability, the state will transition to "The patient and therapist begin a conversation." This probability can be set based on the frequency of plot developments in similar stories in the past. Using the MDP model, the agent (story facilitator) selects actions based on the current state and transition probabilities to move the story from one state to another. After each action is executed, the corresponding reward is obtained according to the reward mechanism. By continuously repeating this process until a suitable end state is reached, a complete target story text is finally generated. The storyline is gradually expanded according to a preset advancement decision algorithm to generate a story text with rich content. In addition, the present embodiment also includes training on the storyline sequence data in the training set through a reinforcement learning method based on a Markov decision process (MDP). The intelligent agent learns the optimal plot advancement strategy based on the reward feedback obtained by continuously trying different plot advancement actions, making the generated plot both coherent and attractive. During the training process, parameters such as the reward function and the state transition probability are continuously adjusted to optimize the performance of the intelligent agent.

[0046] In one embodiment, if Figure 5 As shown, step S140 includes steps S141-S143.

[0047] S141, generating different plot segments by using the preset advancement decision algorithm for the target character and the target story frame;

[0048] S142, evaluating the generated plot segments to generate reward scores;

[0049] S143: Select a target plot segment according to the reward score, and generate a target story text according to the target plot segment.

[0050] In this embodiment, the preset advancement decision algorithm is used to guide the progression of the storyline, generating multiple possible plot segments based on the story framework and character traits. After the target character and the target story framework are combined using the preset advancement decision algorithm to generate different plot segments, the generated plot segments are then evaluated. This evaluation can be performed manually or using a preset automatic evaluation system. Each plot segment is scored, with the score reflecting its quality. For example, segment 1 scores high because it aligns with the medical theme and advances the story. Segment 2 scores moderately because it adds conflict but may not align with the character's characteristics. Segment 3 scores high because it deepens the character's inner world and aligns with the theme. High-scoring plot segments are selected as target plot segments. These segments are generally more consistent with the story theme, logically coherent, and resonate with readers. For example, segments 1 and 3 are selected because they have high scores and effectively advance the story. The selected target plot segments are combined to form a coherent story text. The target story text is generated by selecting highly scored target plot segments to ensure that the transitions between each segment are natural and the overall story aligns with the creative theme.

[0051] In one embodiment, if Figure 6 As shown, step S143 includes steps S1431-S1432.

[0052] S1431, selecting a plot to be mutated from the plurality of target plot segments using a preset genetic algorithm;

[0053] S1432: Expand the plot to be mutated using the preset genetic algorithm to generate a target story text.

[0054] In this embodiment, the preset genetic algorithm is an optimization algorithm that simulates natural selection and genetic mechanisms. The plot to be mutated is the plot to be expanded. The preset genetic algorithm selects the plot to be mutated from the target plot segments. Specifically, the generated initial plot is represented as a gene sequence, with each gene representing a plot segment or element. For example, a plot sequence such as "The protagonist hears about a new healing concept - The protagonist attempts healing - The protagonist experiences setbacks during healing - The protagonist overcomes difficulties and gradually recovers with the help of a therapist" can be encoded as the gene sequence [g1, g2, g3, g4]. During the mutation process, genes are randomly selected for mutation with a certain mutation probability p_m. For example, gene g_3 is selected for mutation, changing "The protagonist attempts healing" to "The protagonist is misled by others and falls into confusion." The mutated plot is then supplemented to complete the target story text. The quality of the target plot segment sequence is evaluated using the fitness function F(x). Plot sequences that meet the requirements are assigned a higher fitness value. Plot sequences with high fitness are selected for mutation and screening in the next generation, ultimately generating a healing story with a unique plot. By mutating the storyline through genetic algorithms, we can effectively optimize and expand the storyline and generate richer and more attractive story texts.

[0055] In one embodiment, if Figure 7 As shown, step S140 includes steps S1401-S1402.

[0056] S1401, evaluating the target story text using a reward function preset in the fusion model to generate a story reward score;

[0057] S1402: Optimize the generation process of the target story text according to the story reward score.

[0058] In this embodiment, the pre-set fusion model is a large language model based on the Transformer architecture, such as GPT-Neo and BERT. The model is trained to learn the universal features of language and its semantic understanding capabilities. Specifically, it is first pre-trained on a large-scale general text dataset to enable the model to learn the universal features of language and its semantic understanding capabilities. It is then fine-tuned for different datasets. During the fine-tuning process, optimization algorithms such as stochastic gradient descent are used to continuously adjust model parameters, enabling the model to better understand and generate relevant text. Simultaneously, a reinforcement learning reward mechanism is incorporated to further optimize model performance by providing rewards or penalties based on the quality of the model-generated text (e.g., whether the plot is plausible). The trained fusion model is deployed in the planning agent, the shaping agent, and the plot agent. The target story text is evaluated using the reward function in the pre-set fusion model to generate a story reward score. Specifically, the reward function is used to evaluate the target story text to generate a comprehensive reward score. This score reflects the story's performance in various aspects. The reward score serves as feedback to guide the optimization of the generation process. By analyzing the score, strengths and weaknesses in the story can be identified. For example, if the story scores low on innovation, it may be necessary to introduce more novel plots or character settings. The generation process of the target story text is optimized according to the story reward score. For example, if the score of the story framework part is low, the part generating the story framework is further optimized. Through this evaluation and optimization process based on the reward function, the generated story text can be continuously improved so that it is more in line with the story creation theme and has higher artistic value and appeal. In addition, the present embodiment also includes modifying the story text according to user feedback. Specifically, when the target story text is sent to the user, the user inputs "add a role of a wise old man to guide the protagonist to become happy". It is identified that the user's intention is to add a role and clarify its role. This information is passed to the corresponding intelligent agent (such as a role shaping intelligent agent and a plot advancement intelligent agent). The intelligent agent adjusts the creative content in real time according to user needs. At the same time, the generated story fragment is fed back to the user in real time, and the user can continue to propose amendments, forming a good interactive cycle, thereby creating a more personalized story text.

[0059] Figure 8 is a schematic block diagram of a semantic-based text generation device 200 provided by an embodiment of the present invention. Figure 8 As shown, corresponding to the above semantic-based text generation method, the present invention also provides a semantic-based text generation device. The semantic-based text generation device includes a unit for executing the above semantic-based text generation method, and the device can be configured in a desktop computer, tablet computer, laptop computer, etc. Specifically, please refer to Figure 8The semantic-based text generation device includes an analyzing unit 210 , a screening unit 220 , a constructing unit 230 and an expanding unit 240 .

[0060] The analysis unit 210 is used to analyze the received user creation instructions through a preset semantic analysis model, determine the story type, and obtain story construction information in a preset knowledge graph based on the story type.

[0061] In one embodiment, the analysis unit 210 includes a collection unit and a map construction unit.

[0062] A collection unit is used to collect references of different story creation types through a preset web crawler, perform noise removal and word segmentation preprocessing on the references, and generate reference data;

[0063] The graph construction unit is used to construct the preset knowledge graph based on the relationship between the reference data, events and features.

[0064] The screening unit 220 is configured to screen an initial story frame according to the story construction information, and generate a target story frame according to the initial story frame and the story construction information.

[0065] In one embodiment, the screening unit 220 includes an extraction unit and a fusion unit.

[0066] an extraction unit, configured to extract keywords from the story construction information, and screen the preset story frameworks according to the keywords to determine the initial story framework;

[0067] A fusion unit is used to predict hot elements through a preset machine learning model, and fuse the hot elements with the initial story framework to formulate the target story framework.

[0068] The construction unit 230 is configured to construct a target character through a preset adversarial network according to the target story framework and the story construction information.

[0069] In one embodiment, the construction unit 230 includes a creation unit, an evaluation unit, and an update unit.

[0070] A creation unit, configured to create an initial character and character description according to the target story framework and the story construction information by using the generator and a preset noise vector;

[0071] an evaluation unit, configured to evaluate the authenticity of the initial character and the character description through the discriminator and generate an evaluation score;

[0072] An updating unit is configured to update the initial character through the generator according to the evaluation score to generate the target character.

[0073] The expansion unit 240 is configured to expand the plot of the target character and the target story framework through a preset advancement decision algorithm to generate a target story text.

[0074] In one embodiment, the expansion unit 240 includes a generation unit, a judgment unit, and a selection unit.

[0075] A generating unit, configured to generate different plot segments from the target character and the target story frame through the preset advancement decision algorithm;

[0076] A judging unit, used to judge the generated plot segments and generate reward scores;

[0077] A selection unit is used to select a target plot segment according to the reward score and generate a target story text according to the target plot segment.

[0078] In one embodiment, the expansion unit 240 includes a mutation unit and an expansion sub-unit.

[0079] a mutation unit, configured to select a plot to be mutated from the plurality of target plot segments by using a preset genetic algorithm;

[0080] The expansion subunit is used to expand the plot to be mutated through the preset genetic algorithm to generate a target story text.

[0081] In one embodiment, the expansion unit 240 includes a mutation unit and an expansion sub-unit.

[0082] An evaluation unit, configured to evaluate the target story text using a reward function preset in the fusion model to generate a story reward score;

[0083] An optimization unit is used to optimize the generation process of the target story text according to the story reward score.

[0084] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned semantic-based text generation device 200 and each unit can refer to the corresponding description in the aforementioned method embodiment. For the convenience and brevity of the description, it will not be repeated here.

[0085] The above-mentioned semantic-based text generation device can be implemented in the form of a computer program, which can be used in Figure 9 Runs on the computer device shown.

[0086] See also Figure 9 , Figure 9This is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 can be a terminal or a server. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, personal digital assistant, wearable device, or other electronic device with communication capabilities. The server can be a standalone server or a server cluster consisting of multiple servers.

[0087] See Figure 9 The computer device 500 includes a processor 502 , a memory, and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .

[0088] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, which, when executed, can enable the processor 502 to execute a semantics-based text generation method.

[0089] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500.

[0090] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a semantic-based text generation method.

[0091] The network interface 505 is used to communicate with other devices through the network. Figure 9 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0092] The processor 502 is configured to run a computer program 5032 stored in the memory to implement the steps of the above method.

[0093] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0094] Those skilled in the art will appreciate that all or part of the steps in the method of the above-described embodiment can be implemented by instructing the relevant hardware through a computer program. The computer program includes program instructions, which can be stored in a storage medium that is computer-readable. The program instructions are executed by at least one processor in the computer system to implement the steps in the method of the above-described embodiment.

[0095] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor performs the steps of the above method.

[0096] The storage medium may be any computer-readable storage medium that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk.

[0097] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0098] In the several embodiments provided herein, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the various units is merely a logical functional division, and actual implementation may employ other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented.

[0099] The steps in the methods of the embodiments of the present invention may be adjusted in order, combined, or deleted as needed. The units in the devices of the embodiments of the present invention may be combined, divided, or deleted as needed. Furthermore, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit.

[0100] If this integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, terminal, or network device, etc.) to execute all or part of the steps of the method described in various embodiments of the present invention.

[0101] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.

Claims

1. A semantic-based text generation method, characterized in that: include: Analyze the received user creation instructions through a preset semantic analysis model to determine the story type, and obtain story construction information from a preset knowledge graph based on the story type; screening an initial story frame according to the story construction information, and generating a target story frame according to the initial story frame and the story construction information; Constructing a target character through a preset adversarial network according to the target story framework and the story construction information; The target character and the target story frame are expanded with the storyline through a preset advancement decision algorithm to generate a target story text.

2. The method according to claim 1, characterized in that Before the step of obtaining story construction information in a preset knowledge graph according to the story type, the method includes: Collect references of different story creation types through a preset web crawler, perform noise removal and word segmentation preprocessing on the references to generate reference data; The reference data is used to construct the preset knowledge graph based on the relationship between people, events and features.

3. The method according to claim 1, characterized in that The step of screening the initial story framework according to the story construction information and generating the target story framework according to the initial story framework and the story construction information includes: Extracting keywords from the story structure information, screening the preset story frameworks based on the keywords, and determining the initial story framework; Hot elements are predicted by a preset machine learning model, and the hot elements are integrated with the initial story framework to formulate the target story framework.

4. The method according to claim 1, wherein The preset adversarial network includes a generator and a discriminator. The step of constructing a target character through the preset adversarial network according to the target story framework and the story construction information includes: Creating initial characters and character descriptions using the generator and a preset noise vector according to the target story framework and the story construction information; evaluating the authenticity of the initial character and the character description by the discriminator to generate an evaluation score; The initial character is updated by the generator according to the evaluation score to generate the target character.

5. The method according to claim 1, wherein The step of expanding the plot of the target character and the target story framework through a preset advancement decision algorithm to generate a target story text includes: The target character and the target story frame are used to generate different plot segments through the preset advancement decision algorithm; Evaluate the generated plot segments and generate reward scores; A target plot segment is selected according to the reward score, and a target story text is generated according to the target plot segment.

6. The method according to claim 5, characterized in that The step of generating a target story text according to the target plot fragment further includes: Selecting a plot to be mutated from a plurality of target plot segments by using a preset genetic algorithm; The plot to be mutated is expanded through the preset genetic algorithm to generate a target story text.

7. The method according to claim 6, characterized in that After the step of expanding the storyline by using the preset advancement decision algorithm to generate the target story text, the method further includes: Evaluate the target story text using a reward function preset in the fusion model to generate a story reward score; The generation process of the target story text is optimized according to the story reward score.

8. A semantic-based text generation device, characterized in that: include: An analysis unit, configured to analyze received user creation instructions using a preset semantic analysis model, determine the story type, and obtain story construction information from a preset knowledge graph based on the story type; a screening unit, configured to screen an initial story frame according to the story construction information, and generate a target story frame according to the initial story frame and the story construction information; A construction unit, configured to construct a target character through a preset adversarial network according to the target story framework and the story construction information; The expansion unit is used to expand the plot of the target character and the target story framework through a preset advancement decision algorithm to generate a target story text.

9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.

10. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the method according to any one of claims 1 to 7 can be implemented.