Long text generation method and device for science magical IP
By employing hierarchical training and multi-agent collaborative generation techniques, the problems of knowledge disconnect and consistency in the generation of long science fiction texts have been solved, achieving logically consistent and coherent science fiction text generation, thus improving generation efficiency and consistency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING INSTITUTE OF GRAPHIC COMMUNICATION
- Filing Date
- 2025-11-14
- Publication Date
- 2026-04-24
AI Technical Summary
Existing technologies for generating long science fiction texts suffer from problems such as knowledge gaps, sudden changes in character behavior, conflicts in worldviews, and low generation efficiency, making it difficult to meet the requirements of logical consistency, coherent settings, and stylistic adaptation.
A science fiction long text generation language model (Science-LLM) is constructed using hierarchical training. It generates long texts through dynamic collaboration of multiple agents and performs global consistency verification and correction, simulating the human creation process, including knowledge classification, text preprocessing, knowledge graph construction, multi-agent task decomposition and dynamic scheduling.
It achieves logical consistency, coherent setting, and style adaptation for long science fiction texts, improves generation efficiency by 50%, reduces resource consumption by 60%, and improves consistency by 80%.
Smart Images

Figure CN121920508A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing technology, and relates to generative artificial intelligence and multi-agent collaborative technology, and in particular to a method and apparatus for generating long texts for science fiction IP (intellectual property). Background Technology
[0002] With the development of generative artificial intelligence technology, text generation tasks have expanded from short summaries and dialogue responses to the creation of long texts with more complex structures and greater content depth. As a composite narrative genre that integrates the construction of a grand worldview, the setting of cutting-edge technology, and the projection of future scenarios, science fiction texts must meet requirements such as logical consistency, complete setting, and coherent multi-character / time-space narratives, posing extremely high challenges to the content comprehension, logical organization, and language expression capabilities of the generation system.
[0003] Current long text generation techniques based on Large Language Models (LLM) and Retrieval Augmented Generation (RAG) have significant shortcomings in science fiction long text scenarios, including: First, the problem of knowledge disconnect: the update of the knowledge base of existing technologies relies on subjective threshold settings, and multi-granularity retrieval is prone to conflicts of professional terms, resulting in confusion in the reference of science fiction settings; Second, insufficient consistency between characters and logic: Existing technologies have not optimized the verification mechanism for the multi-character and multi-temporal characteristics of science fiction texts, which is prone to sudden changes in character behavior and timeline paradoxes. Third, the imbalance between generation efficiency and quality: the existing multi-agent collaborative model adopts a global backtracking inspection, which is inefficient for modifying science fiction texts of tens of thousands of words, and its domain generalization ability is insufficient, making it difficult to adapt to the creative and professional needs of science fiction IPs. Summary of the Invention
[0004] To overcome the shortcomings of the existing technology, this invention provides a method and apparatus for generating long texts for science fiction IPs, which solves the problems of knowledge gaps, sudden changes in character behavior, conflicts in worldviews and low generation efficiency in the generation of long science fiction texts, and realizes the automated creation and generation of long science fiction texts with logical consistency, coherent settings and appropriate style.
[0005] This invention simulates the human science fiction content creation process by designing a three-tiered architecture: "layered training to construct a science fiction long text generation language model, multi-agent dynamic collaborative generation of long texts, and global consistency verification and correction." First, a science fiction long text generation language model (Science-LLM) is constructed based on classic science fiction IPs and general science fiction materials. Then, the multi-agent division of labor in Science-LLM performs inference, retrieval, writing, review, and polishing tasks. Finally, dynamic retrieval and structured verification ensure global logical consistency, forming a closed-loop technical solution for creating science fiction long texts.
[0006] The technical solution of this invention is: A method for generating long texts for science fiction IPs, comprising the following steps: 1) Construction of Science-LLM for Long-Term Science Fiction Text Generation 11) Perform knowledge classification to obtain a diverse dataset of science fiction elements: First, the multi-source science fiction data is categorized into two groups: Classic IP category: Classic science fiction works with excellent language style and high text quality (such as classic science fiction novels) are selected to train the model's writing ability and lay the foundation for science fiction narrative style. General science fiction material category: Resources such as online science fiction novels and scientific literature (rich in science fiction elements and incorporating professional knowledge) are integrated to build an external knowledge base, providing background knowledge support for writing. This approach maximizes the diversity of the dataset.
[0007] 12) Perform text preprocessing to extract science fiction elements: Both types of data underwent unified standardization processing to ensure data quality and structural consistency. First, text from different formats (PDF, EPUB, web pages, etc.) was uniformly converted to UTF-8 plain text, removing non-text content such as advertisements and comments, as well as garbled characters, and standardizing chapter, paragraph, and sentence structures. Then, "science fiction elements" (such as technological settings, future social structures, and characteristics of extraterrestrial civilizations) that carry key plot points were extracted to construct and label core information for subsequent datasets.
[0008] 13) Classic IP processing: Generate triplet labels of "science fiction element - original domain - contextual location", and construct a fine-tuned dataset through data augmentation: Define the domain classification of classic IPs, including science fiction, future society, and alien civilization; The specific process of the structured extraction method for science fiction elements is as follows: First, extract the objects: from sentences containing key plot points in classic IP texts, locate the core elements carrying the science fiction setting (such as technological principles, social structures, ethical principles, etc.). Second, classify: classify the element types according to the "domain", including technological setting categories (core technological principles / devices, such as "microgravity environment optimizes extraction efficiency"), ethical dilemma categories, etc. Finally, generate triple tags: label the extracted elements with the triple "science fiction element text - original domain - context position", for example ("asteroid mining requires utilizing microgravity environment to optimize extraction efficiency", technological setting category, AstroForge).
[0009] For the defined domains of science fiction, including technology setting (core technological principles / devices), future society (social structure / ethical dilemmas), and extraterrestrial civilization (racial characteristics / civilization forms), sentences containing science fiction elements are extracted using a structured extraction method, generating triple tags of "science fiction element - original defined domain - contextual location". The dataset is split into training and testing sets, and synthetic data is generated using data augmentation methods (including terminology synonym replacement) (ensuring isolation between training and testing information to prevent leakage), constructing a fine-tuned dataset adapted to the science fiction domain. This data processing workflow ensures both the accuracy of science fiction learning and the security of the science fiction element dataset.
[0010] 14) Knowledge Graph Construction: The core objective is to process general science fiction material and construct a knowledge graph (external knowledge base) capable of structured querying and semantic retrieval. First, it dynamically integrates newly added online novel chapters and science fiction literature crawled from the web. Entity relation extraction integrates these new online novel chapters and science fiction literature in real time, removing redundant content and accurately locating semantic units. Next, it extracts and identifies key semantic units in the text (entities include people / technological items / organizations; relations include technological dependencies / social structural associations, etc.), constructing nodes and edges in the knowledge graph accordingly. Concept normalization standardizes entity names, resolving aliases and ambiguities to ensure knowledge consistency. Finally, it constructs triples and vector relations to extract knowledge, generating the knowledge graph and creating vector indexes for entities and relations to support subsequent semantic retrieval.
[0011] 15) Layered training: A layered training strategy of "freezing the bottom layer + local fine-tuning" is adopted to balance general language ability and adaptability to the science fiction field; Existing large-scale models often employ general-domain fine-tuning, resulting in an inability to specifically adapt to the needs of the science fiction domain. This model training method significantly reduces the number of fine-tuning parameters, focusing on enhancing the model's depth of understanding of science fiction concepts, making the generated text more aligned with the narrative style of science fiction IPs. First, the underlying parameters of the existing large-scale language model are frozen (preserving general language comprehension capabilities) to avoid science fiction domain training overriding basic language abilities. Second, science fiction domain-enhanced training is performed: fine-tuning the mid- and upper-level parameters of the existing large-scale language model, focusing on improving the depth of understanding of science fiction concepts (such as "curvature engine" and "dark forest theory") and the adaptability to classic IP narrative styles, while simultaneously reducing training resource consumption.
[0012] 16) Model Fine-tuning: Based on a science fiction element dataset and knowledge graph, a three-stage mechanism of "semantic parsing - structural modeling - precise generation" is used to achieve precise adaptation of the model to the science fiction domain: First, key science fiction entities (such as "quantum entanglement" and "silicon-based civilization") are located, core keywords are extracted, and word embedding vectors that integrate semantic features of the science fiction domain are generated. Second, the model structure is built, and word embeddings are transformed into hidden vectors. Through the encoding module (including attention layer and topic interaction layer), the structured encoding of the science fiction worldview is deepened (such as capturing the implicit connection between "AI awakening" and "ethical dilemma"). Finally, the text is output through Sc-LLM (reusing precise expressions from classic IPs or knowledge graphs, such as citing the "Dark Forest Theory" standard description to generate target text; by freezing the underlying general model parameters and only fine-tuning the domain adaptation layer, the ability to generate science fiction domains is enhanced in a targeted manner).
[0013] 2) Establish multiple agents to collaboratively generate long-form science fiction texts. 21) Instruction parsing: Parsing the user's natural language writing requirements into structured vectors; The pre-trained sequence-to-sequence model BART (Bidirectional and Auto-Regressive Transformers) based on the Transformer architecture is used to parse users' natural language writing needs (such as "AI officers deal with rebellion in Jupiter's orbit") into structured vectors, which include dimensions such as subject, scene, conflict, style, and event nodes. 22) Task decomposition: The long text generation task is broken down into five types of atomic tasks: reasoning, retrieval, writing, reviewing, and polishing; 23) Establish multiple agents, corresponding to different task categories, to perform different tasks: Reasoning Agent: Based on Science-LLM, it generates event chains (including initiation event - relationship - result event) and chapter outlines; Search Agent: Parses outline keywords into vectors using the DPR encoder, retrieves Top-5 related knowledge from the FAISS (Facebook AISimilarity Search) vector database, and forms a knowledge support set; Writing Agent: Combines event chains, outlines, and knowledge sets to generate text chapter by chapter according to prompts (length, style); Review Agent: Based on knowledge sets, event chains, and outlines, detects issues such as logical inconsistencies and setting conflicts in the text; Polishing Agent: Employs Style Prompt to optimize text language and enhance literary quality; 24) Dynamic scheduling: Through the mechanism of "task status manager - conditional routing decision-maker - structured correction instruction", if the review fails, the task will be backtracked to the corresponding agent (such as logic problems backtracking to the reasoning agent), forming a closed loop; Specifically, dynamic scheduling is the core collaborative mechanism connecting the review agent's issue detection with other agents. First, the review agent completes text verification. If logical contradictions are detected, it is judged as "failed," and the issue information is synchronized to the task status manager. Then, the task status manager stores and tracks information in a structured manner, generating an "issue file" to ensure that the issue is traceable. Next, the conditional routing decision-maker determines the target agent based on the issue type in the issue file and the agent's responsibility matching rules. The dynamic scheduling system automatically generates a structured correction instruction, which clearly includes the target agent identifier, issue details, correction basis, and output requirements after correction. Finally, the target agent receives the instruction, completes the correction, and submits the result to the review agent for secondary verification. If it passes, it enters the polishing stage; if it fails, the process is repeated until the review is passed, ensuring the accuracy of the text logic and knowledge.
[0014] 25) Aggregated output: Integrate the generated results and output the main text content, Top-5 reference knowledge, and versions before and after modification.
[0015] 3) Perform consistency verification and correction steps on the generated science fiction long text. 31) Text segmentation: The text is modeled as an undirected weighted graph (nodes are semantic units and edge weights are semantic similarity) using a graph segmentation algorithm. Natural paragraphs are generated through spectral clustering and labeled with paragraph number, role, and time anchor point. 32) Feature extraction: Generate a structured object for each paragraph, containing the original text, Sentence-BERT semantic vectors and metadata such as entities and timelines; 33) Dynamic retrieval: Based on "global macro index (chapter centroid vector) + local partition index (metadata partition)," historical related paragraphs are retrieved back in paragraph order to form a candidate paragraph set; 34) Consistency check: Science-LLM is used to identify timeline conflicts (such as the reappearance of a character after death), setting contradictions (such as inconsistent equipment status), behavior jumps, and causal paradoxes, and output conflicting paragraphs and explanations. 35) Dynamic correction: Call Science-LLM, input the original text, conflict explanation, context and rewrite requirements, generate corrected paragraphs, and finally form a globally consistent science fiction long text.
[0016] In a specific implementation of this invention, a long text generation device for science fiction IPs is realized based on the above method. The device includes: (1) Science Fiction LLM Building Module: Includes knowledge classification unit, text preprocessing unit, classic IP processing unit, knowledge graph unit, hierarchical training unit, and model fine-tuning unit, used to build the science fiction-specific language model Science-LLM; (2) Agent collaborative generation module: includes instruction parsing unit, task decomposition unit, task execution unit (including reasoning agent, retrieval agent, writing agent, review agent, polishing agent), scheduling control unit, and aggregation output unit, used to dynamically and collaboratively complete text generation; (3) Consistency verification and correction module: includes text segmentation unit, feature extraction unit, dynamic retrieval unit, consistency verification unit and dynamic correction unit, used to ensure the global logical consistency of the text.
[0017] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention provides a method and apparatus for generating long-form science fiction IPs, addressing issues such as knowledge gaps, abrupt character behavior changes, worldview conflicts, and low generation efficiency in long-form science fiction text generation. It achieves automated creation and generation of logically consistent, coherently set, and stylistically appropriate long-form science fiction texts. The technical advantages of this invention include: (1) Solve the problem of knowledge disconnect in science fiction content: Through dynamic knowledge graph and hierarchical retrieval mechanism, the science fiction setting can be accurately invoked. Knowledge graph updates do not require subjective thresholds, and vector index supports semantic-level retrieval, reducing term conflict rate; (2) Improve the consistency of science fiction content: The combination of multi-agent dynamic scheduling and global consistency verification can identify and correct problems such as sudden changes in character behavior and timeline paradoxes, and improve the consistency of science fiction text across chapters by more than 80%; (3) Balancing the efficiency and quality of science fiction content generation: Chapter-based closed generation and local backtracking correction avoid global rewriting, improving the efficiency of generating tens of thousands of words of text by 50%, while Science-LLM ensures that the science fiction style and professionalism are compatible; (4) Reduce resource consumption: The layered training strategy freezes the underlying parameters and only fine-tunes the domain adaptation layer, reducing training resource consumption by 60%, and the generation of chapters reduces GPU memory pressure. Attached Figure Description
[0018] Figure 1 This is a structural block diagram of the long text generation device for science fiction IP provided by the present invention.
[0019] Figure 2 This is a schematic diagram of the working process of the task execution unit in the Agent collaborative generation module of the device of the present invention.
[0020] Figure 3 This is a schematic diagram illustrating the working process of the dynamic retrieval unit of the consistency verification and correction module of the present invention. Detailed Implementation
[0021] The present invention will be further described below with reference to the accompanying drawings and embodiments, but the scope of the invention is not limited in any way.
[0022] This invention provides a method and apparatus for generating long texts for science fiction IPs. Figure 1 The overall structure of the device of the present invention is illustrated. Figure 2 This illustrates the fine-tuning process of the science fiction long text generation model constructed in this invention. Figure 3 This illustrates the agent dynamic scheduling process. For example... Figure 1 As shown, the device of this invention adopts a collaborative architecture of "input-core module-auxiliary support-output". The input layer contains science fiction text data and writing requirement instructions; the core module consists of a science fiction LLM construction module and an agent collaborative generation module: the science fiction LLM construction module includes six units: knowledge classification, text preprocessing, classic IP processing, dynamic knowledge graph, hierarchical training, and model fine-tuning, which completes science fiction data classification processing, knowledge graph construction, and Science-LLM model generation. The knowledge classification unit distributes the data to the classic IP processing unit and the dynamic knowledge graph unit, and their outputs jointly support model training. The agent collaborative generation module includes five units: instruction parsing, task decomposition, task execution, scheduling control, and aggregated output. The instruction parsing unit transforms the requirements into a structured task matrix, the task decomposition unit breaks down the atomic tasks, and the scheduling control unit dynamically schedules the inference, retrieval, writing, review, and polishing agents to execute tasks, and finally aggregates and outputs long text drafts and version information. The consistency verification and correction module comprises five units: text segmentation, feature extraction, dynamic retrieval, consistency verification, and dynamic correction. After receiving a long draft text, it generates structured paragraphs through segmentation and feature extraction. The dynamic retrieval unit uses a hierarchical partitioned index to recall relevant historical paragraphs in real time. After the verification unit detects conflicts, the correction unit calls the model to rewrite the text. The auxiliary support unit constructs external science fiction knowledge base materials for the retrieval agent; its vector database stores paragraph semantic vectors to support dynamic retrieval. The output layer ultimately outputs a logically consistent long science fiction text. The various modules form a complete workflow through clearly defined data flow.
[0023] Figure 2The diagram illustrates the model fine-tuning process of this invention. Using text fragments of science fiction elements extracted by the classic IP processing unit as input, the data is first input to the dynamic knowledge injection module. The knowledge retrieval agent determines the content type of the text: if it involves technological settings / alien civilizations, the classic IP dataset is invoked; if it involves ethical dilemmas / social structures, the dynamic knowledge graph is queried, outputting enhanced data fused with related knowledge. Subsequently, the model enters a hierarchical fine-tuning phase, employing an optimization strategy of freezing the parameters of the underlying general language capability layer and only fine-tuning the science fiction domain adaptation layer. The fused data is injected into the large language model to enhance the understanding of science fiction concepts. Next, multi-task adversarial training is conducted to improve the accuracy of science fiction elements and the coherence of narrative logic. The text generation quality is optimized through adversarial collaboration between the generator and the discriminator. Finally, a consistency discriminator performs a binary check on the model's output text. If the check passes, the process terminates and outputs generated text that meets the science fiction domain adaptation requirements. If it fails, the process returns to the dynamic knowledge injection module to re-execute knowledge retrieval and injection until the discriminator passes, forming a complete self-iterative model fine-tuning closed-loop process.
[0024] Figure 3 The diagram illustrates the Agent dynamic scheduling process of this invention. Starting with the structured task matrix parsed from the user's writing request instruction, the basic Agent tasks are executed sequentially: the reasoning Agent generates an event chain and chapter outline; the retrieval Agent queries an external knowledge base based on outline keywords and outputs a Top-5 knowledge support set; and the writing Agent generates a preliminary text by chapter based on Science-LLM and the above results. Subsequently, the review Agent verifies the preliminary text using the knowledge support set and event chain, identifying three types of problems: logic, knowledge, and text. The task status manager records the review result status in real time and synchronizes it to the conditional routing decision-maker. Based on the status, a structured correction instruction containing the problem type, correction suggestions, and target agent is generated. If the review is passed, the polishing agent is scheduled to transform technical expressions into literary language to optimize the text. If the review is not passed, the process is backtracked according to the problem type (logic problems backtrack to the reasoning agent, knowledge problems backtrack to the retrieval agent, and text problems backtrack to the writing agent). After backtracking, the basic agent tasks and review steps are repeated. After the review is passed and the text optimization is completed, the aggregation output unit integrates the original text before polishing, review marks, knowledge sources, and other version information to output structured chapter text, finally reaching the task end node, realizing a dynamic scheduling and closed-loop correction process for multi-agent collaboration.
[0025] The following example, using "generating three chapters of hard science fiction text centered on 'Vestri-2', a 2035 asteroid mining probe, to deal with mineral extraction system failures and space debris impacts," systematically illustrates the implementation path of this invention. All materials, models, and parameters involved are derived from publicly available resources.
[0026] First, execute the science fiction LLM build, corresponding to... Figure 1 "Science Fiction LLM Building Blocks" and Figure 3 Process. The knowledge classification unit collects two types of real data sources: classic science fiction IP texts (science fiction novels, totaling approximately 2 million words, with rigorous science fiction settings) for training the model's writing ability; and general science fiction materials, including relevant space agency open papers, relevant company deep space mining open reports (300,000 words, including content on "Vestri probe design" and "asteroid resource extraction"), and related data such as next-generation artificial intelligence ethics guidelines, for building an external knowledge base. The text preprocessing unit uses the Python chardet library to detect encoding of classic science fiction IP texts, converts them to UTF-8 plain text using the iconv library, cleans redundant content using regular expressions, splits chapters by "# Chapter X", and uses a structured extraction method for science fiction elements. After unified standardization, it extracts elements such as "thermal-driven mineral separation" and "emergency response to space debris impacts" and marks them as "science fiction elements". For relevant open papers, it retains the original text and Chinese explanations of technical terms such as "Marangoni effect" and "thermal fraction decomposition" to ensure the accuracy of professional expressions.
[0027] The structured extraction method for science fiction elements is a core step in constructing a fine-tuned dataset using classic IP processing units. The specific process is as follows: First, extract the objects: from sentences containing key plot points in classic IP texts, locate the core elements carrying the science fiction setting (such as technological principles, social structures, ethical principles, etc.). Second, classify: classify elements according to their "domain," including technological setting elements (core technological principles / devices, such as "microgravity environment optimizes extraction efficiency") and ethical dilemma elements (ethical controversies arising from technology, such as "AI autonomous decision-making must adhere to the principle of prioritizing human well-being"). Finally, generate triplet labels: label the extracted elements with a triplet of "science fiction element text - original domain - contextual location," for example, ("Asteroid mining requires utilizing a microgravity environment to optimize extraction efficiency," technological setting category, AstroForge).
[0028] The Classic IP processing unit is responsible for extracting triplet tags from tagged text, such as ("Asteroid mining requires utilizing microgravity environments to optimize extraction efficiency," a science fiction text, AstroForge) and ("AI autonomous decision-making must comply with the ethical principle of 'human welfare first,'" an ethical dilemma text). This unit splits the Classic IP data into training and testing sets in an 8:2 ratio and generates 420,000 words of synthetic data through "term synonym substitution" (e.g., "thermally driven separation" → "thermally induced mineral separation") (ensuring no overlap between training and testing information), ultimately forming a fine-tuned dataset. The knowledge graph unit processes science fiction material: A Python Scrapy crawler is used to regularly crawl AstroForge's official website for technical updates every 7 days. A BERT-CRF model (a combination of BERT (Bidirectional Encoder Representations from Transformers) and CRF (Conditional Random Field)) is employed to identify entities (parameters: num_labels=10, max_length=128, batch_size=16, referencing publicly available implementations on CSDN), accurately identifying entities such as "Vestri-2 probe," "thermal-driven separation system," and "space debris." The RE-BERT model is used to extract relationships such as "Vestri-2 - onboard - thermal-driven separation system" and "space debris - impact - probe," and the names "Vestri-2" and "Asteroid Mining Probe V2" are standardized. The constructed triples are stored in the Neo4j graph database, and a 768-dimensional vector index is built using the high-dimensional vector data tool FAISS.
[0029] Synonym substitution is a key data augmentation technique in the IP processing unit of this model, used to expand the diversity of training data and avoid overfitting. Specifically, it involves replacing original terms with synonyms or near-synonyms for science fiction terminology, generating semantically consistent but differently expressed synthetic text. For example, "thermal-driven separation" is replaced with "thermally induced mineral separation," maintaining the core concept while enriching the language variations. This increases the scale of the training data (generating 420,000 words of synthetic data), improving the model's generalization ability to different expressions of the same concept; it also ensures information isolation between the training and test sets (by substitution preventing terms from the test set from directly appearing in the training data), preventing data leakage from affecting the model's evaluation accuracy. It is mainly applied to the expansion of classic IP datasets, especially for scientific and technological terms (such as "microgravity environment" and "autonomous decision-making algorithm"), enhancing the model's ability to flexibly utilize science fiction terminology.
[0030] The hierarchical training unit is based on the publicly available Llama 2-13B (Llama 2-13 billion parameter language model) LLM model, employing a "freeze bottom layer + local fine-tuning" strategy: freezing the parameters of the first 20 layers of the LLM model, fine-tuning the top 12 layers, and configuring the training parameters (learning rate 2.5e-5, batch size 16, 12 training epochs, AdamW optimizer, weight decay coefficient 0.01). The model fine-tuning unit executes as follows: Figure 3 The process is as follows: In the semantic parsing stage, TextRank is used to extract core keywords such as "heat-driven system failure" and "AI ethical decision-making," and a 300-dimensional word embedding vector is generated using the GloVe model (training corpus consists of NASA papers and AstroForge reports). In the structural modeling stage, four concatenated encoding modules are implemented, and the weight of the "AI-fault repair-human safety" association edge is set to 0.85. In the precise generation stage, attention and replication mechanisms are integrated. After fine-tuning, a consistency discriminator detects the issue. When a conflict is found between "AI-priority repair equipment and ethical guidelines," the process returns to the dynamic knowledge injection module to retrieve relevant clauses from the EU AI ethics guidelines until a Science-LLM model is generated (accuracy of science fiction elements ≥91%, style fit ≥89%). Entering the Agent collaborative generation stage, corresponding Figure 1 "Agent Collaborative Generation Module" and Figure 3 The process is as follows: The instruction parsing unit receives the user's request: "Generate a three-chapter hard science fiction text about the Vestri-2 probe's response to thermal drive system failure and space debris impact in 2035, including plot points such as 'debris impact triggering system overload' and 'AI refusing to execute the 'sacrifice equipment to save data' instruction. The language must blend technical rigor with a science fiction feel." This unit uses the BART model to parse out the main themes "Vestri-2 probe and ground control center," the scene "asteroid mining area," and the conflicts "equipment failure + external impact + ethical choices," encoding them as a 512-dimensional semantic vector input. The task decomposition unit breaks down the task into atomic tasks of reasoning, retrieval, writing, reviewing, and polishing. The scheduling and control unit drives the Agent flow according to logic. The inference agent invokes Science-LLM to generate an event chain: "Space debris impacts the probe's side module → Thermal drive system overload failure (S1) → AI initiates fault diagnosis (R1) → Ground command requires 'sacrifice equipment to preserve data' (S2) → AI refuses to execute based on ethical guidelines (R2) → AI autonomously optimizes the repair plan (S3)". The chapter outline is set as impact alarm, ethical choice, and fault repair. The retrieval agent searches the FAISS database based on keywords and returns the Top-5 knowledge support (including NASA's paper "System Emergency Repair Process" and AstroForge report "Vestri Probe Structure").
[0031] The writing agent generates an initial draft text, with the prompt explicitly stating "cites the 'thermal drive system principle' from a NASA paper, including the plot 'At 14:20 on June 18, 2035, Vestri-2 was struck by a 1.2-meter diameter space debris, causing the thermal drive separation system's temperature to surge beyond critical levels'." The review agent finds a conflict between "system repair time set to 2 hours" and NASA's paper's statement that "repair under microgravity requires 4 hours," marking it as a "knowledge issue," and the task status manager records it as "to be corrected." The conditional routing decision-maker generates instructions to backtrack to the writing agent, correcting it to "4-hour repair cycle," and the second review is passed. The polishing agent optimizes "thermal drive system temperature exceeding critical levels" to "the temperature display of the thermal drive separation system fluctuates wildly, the red value finally settling at 580K—far exceeding the critical threshold of 420K, and the metal pipes in the microgravity environment begin to emit a piercing hum," preserving both technical details and literary merit. All three chapters of text were generated through this process. The aggregated output unit integrates the "original text, review records, and knowledge source annotations" to form a preliminary draft text (approximately 5,700 words in total).
[0032] Finally, consistency checks and corrections are performed, corresponding to... Figure 1 The "Consistency Verification and Correction Module" receives the draft text, divides it into 114 semantic units (40-60 characters per unit), and generates a 768-dimensional vector using Sentence-BERT. It then constructs an undirected weighted graph (with an edge weight cosine similarity threshold set to 0.75), uses a spectral clustering algorithm (K=30) to generate paragraph structures, and annotates metadata (e.g., annotating the fourth paragraph of Chapter 2 of the generated long text as: "Time: June 18, 2035, 16:00; Event: AI Rejects Ground Commands"). The dynamic retrieval unit, leveraging the consistency correction HPI-DR mechanism, precisely locates the "Ethical Choice" block at the upper layer and activates the "AI Ethics" metadata partition at the lower layer when retrieving paragraphs from the "AI Ethics Decision-Making" chapter, successfully recalling the paragraph "AI Follows Human Safety Guidelines" to form a logical pair. The consistency verification unit detects a causal conflict between the chapter "Repair Time: 4 Hours" and the chapter "Remaining Energy After Debris Impact is Only Enough to Sustain for 3 Hours," marking it as a "Logical Paradox." The dynamic correction unit calls Science-LLM to rewrite the code, combining it with the context of "AI optimizing energy allocation" to generate new content: "Vestri-2's AI autonomously shuts down non-core payloads, concentrating energy on the repair system, reducing the repair cycle to 2.5 hours, while the remaining energy can still maintain communication," ensuring logical consistency. After the correction is complete, the system outputs a globally coherent multi-chapter science fiction text.
Claims
1. A method for generating long texts for science fiction IPs, characterized in that, A science fiction long-text generation language model, Science-LLM, is constructed. Through multi-agent division of labor within Science-LLM, tasks such as reasoning, retrieval, writing, review, and polishing are performed in the long-text generation process. Dynamic retrieval and structured verification ensure the global logical consistency of the generated science fiction long-text. The process includes the following steps: 1) Constructing a science fiction long text generation language model, Science-LLM; 11) Classify multi-source science fiction data to obtain a diverse science fiction dataset; 12) Perform text preprocessing and design a structured extraction method for science fiction elements to extract the science fiction elements; 13) Define the domain classification of classic IP data, process classic IP data, generate triplet labels of science fiction elements-original domain-contextual location, and build a fine-tuned dataset through data augmentation; 14) Construct an external knowledge base that can be structured and semantically retrieved, and generate a science fiction knowledge graph; 15) For the science fiction long text generation language model Science-LLM, a layered training strategy of "freezing the bottom layer + local fine-tuning" is adopted for layered training. 16) Based on the constructed science fiction dataset and knowledge graph, the Science-LLM model, a language model for generating long science fiction texts, is fine-tuned through a three-stage mechanism of "semantic parsing-structural modeling-precise generation" to achieve precise adaptation of the model to the science fiction domain. 2) Establish multiple agents to collaboratively generate long-form science fiction texts; 21) Instruction parsing: Parsing the user's natural language writing requirements into structured vectors; 22) Task decomposition: Break down the long text generation task into multiple categories of atomic tasks; 23) Establish multiple agents to perform different tasks; 3) Perform consistency checks and corrections on the generated science fiction long texts.
2. The long text generation method for science fiction IP as described in claim 1, characterized in that, In step 12), the structured extraction method for science fiction elements includes the following process: First, identify the core elements that carry the science fiction setting from sentences containing key plot points in classic science fiction IP texts, including technological principles, social structures, and ethical principles; Secondly, based on the domain of definition, science fiction elements are categorized into types, including those with technological settings and those with ethical dilemmas. Finally, the extracted science fiction elements are labeled with a triplet consisting of "science fiction element text - original domain - context position" to generate triplet tags.
3. The long text generation method for science fiction IP as described in claim 1, characterized in that, In step 13), data augmentation specifically targets science fiction terminology by using synonyms or near-synonyms to generate synthetic science fiction texts that are semantically consistent but express different terms.
4. The long text generation method for science fiction IP as described in claim 1, characterized in that, In step 15), the layered training adopts the strategy of "freezing the bottom layer + local fine-tuning". Specifically, for the Llama 2-13B basic LLM model, the parameters of the first 20 layers of the LLM model are frozen, and the parameters of the upper 12 layers are fine-tuned.
5. The long text generation method for science fiction IP as described in claim 1, characterized in that, In step 22), the categories of long text generation tasks that are broken down into atomic tasks include: reasoning, retrieval, writing, review, and polishing.
6. The long text generation method for science fiction IP as described in claim 1, characterized in that, Step 3) The consistency verification and correction process for the generated science fiction long text includes: 31) Text segmentation: The text is modeled as an undirected weighted graph using a graph segmentation algorithm, with nodes as semantic units and edge weights as semantic similarity. Natural paragraphs are generated through spectral clustering and labeled with paragraph numbers, roles, and time anchors. 32) Feature extraction: Generate a structured object for each paragraph, including the original text, Sentence-BERT semantic vectors and entities, and timeline metadata; 33) Dynamic retrieval: Based on the global macro index and local partition index, historical related paragraphs are retrieved back in paragraph order to form a candidate paragraph set; 34) Consistency check: Science-LLM is used to identify timeline conflicts, setting contradictions, behavioral jumps and causal paradoxes, and output conflicting paragraphs and explanations; 35) Dynamic correction: Input the original text, conflict explanations, context and rewrite requirements into Science-LLM to generate corrected paragraphs and form a globally consistent long science fiction text.
7. A long text generation device for science fiction IPs implemented using the method of claim 1, characterized in that, include: The system comprises a science fiction LLM build module, an agent co-generation module, and a consistency verification and correction module; among which: The Science-LLM building blocks are used to build large language models for generating long science fiction texts. The Agent collaborative generation module is used to dynamically and collaboratively generate long science fiction texts. The consistency verification and correction module is used to ensure the global logical consistency of the generated science fiction long text.
8. The long text generation device for science fiction IP as described in claim 7, characterized in that, The science fiction LLM building blocks include: a knowledge classification unit, a text preprocessing unit, a classic IP processing unit, a knowledge graph unit, a hierarchical training unit, and a model fine-tuning unit.
9. The long text generation device for science fiction IP as described in claim 8, characterized in that, The Agent collaborative generation module includes an instruction parsing unit, a task decomposition unit, a task execution unit, a scheduling and control unit, and an aggregation output unit.
10. The long text generation device for science fiction IP as described in claim 9, characterized in that, The consistency verification and correction module includes a text segmentation unit, a feature extraction unit, a dynamic retrieval unit, a consistency verification unit, and a dynamic correction unit.