Eliminating the "AI Smell" in Novel Generation: Script Layer Architecture and Expansion Practices

    Generating long-form fiction with Large Language Models (LLMs) often results in text that feels mechanical, formulaic, and emotionally flat. This article explores how to solve this issue by introducing a "Script Layer" architecture that decouples the generation process. By breaking down the workflow into script generation, dialogue revision, and deep prose expansion, developers can significantly improve text quality, character authenticity, and overall generation efficiency while reducing inference time.

    When using Large Language Models (LLMs) for long-form text generation, such as novel writing, developers and content creators face a common challenge: the generated content often carries a strong “machine smell” (AI feel). This mechanical tone manifests as formulaic phrasing, flat emotional expression, contextual logic jumps, and disjointed dialogue and actions. Simply tweaking prompts or increasing randomness parameters only treats the symptoms, not the root cause. To fundamentally solve this, we must re-examine the text generation pipeline from a software architecture perspective and introduce an intermediate abstraction layer—the “Script Layer”—to decouple the process and divide responsibilities, thereby improving both text quality and generation efficiency.

    1. Technical Root Causes of the “Machine Smell”

    The fundamental reason AI-generated text feels mechanical lies in the cognitive overload LLMs experience during end-to-end generation. When asked to generate thousands of words of prose directly from an outline, the model must simultaneously process world-building, character consistency, plot progression, dialogue design, and environmental descriptions. Lacking intermediate reasoning and planning states, the model often degrades into stacking high-probability tokens, resulting in text that lacks depth and layers.

    Specifically, this flaw manifests in two main areas:

    • Hollow Dialogue: Character lines lack subtext and emotional tension, sounding like a mechanical recitation of settings.
    • Action-Dialogue Disconnect: Character behavioral logic mismatches the linguistic environment, creating a sense of incongruity.

    2. The Solution: Introducing a “Script Layer” Intermediate Architecture

    Borrowing from the screenwriting process of the film and television industry, we prepend a “Script Layer” to the AI prose generation pipeline. The core responsibility of this layer is lightweight skeleton planning, outputting only key dialogues, core action nodes, and the emotional tone of the scene. Once this structured planning is complete, it is handed over to the LLM for deep prose expansion.

    The improvements brought by this architecture are fundamental. The Script Layer forces the model to “think” and “deduce” first, establishing the focal conflict of the current scene and the character’s behavioral motives. When the model expands on this solid skeleton, its attention mechanism is effectively focused. It no longer needs to build logic from scratch, allowing it to allocate more “compute” to polishing rhetoric, rendering atmosphere, and detailing nuances.

    3. Dialogue Revision and Script Layer Synergy

    After the Script Layer is generated, introducing a dialogue revision mechanism is another critical step to eliminate the mechanical feel. Dialogue is the soul of novel characters, and direct expansion often leads to homogenized character tones. Through dialogue revision, we can perform a secondary calibration on the initial lines generated by the Script Layer based on specific character personality tags, cultural backgrounds, and current emotional states.

    For example, by setting specific system-level prompts, we can require the model to check whether the dialogue aligns with the character’s current psychological motives, whether it is overly formal, and to provide more colloquial or subtext-rich replacement suggestions. This three-stage pipeline—“generate skeleton, calibrate core elements, deep expansion”—makes the final text’s character interactions and emotional expressions more natural and authentic.

    4. Engineering Practices and Unexpected Performance Gains

    In actual engineering implementation, this step-by-step generation architecture not only improves text quality but also brings significant performance optimizations. According to development practice data, traditional end-to-end single-pass generation models often take over 30 minutes to generate a complete body of text for long-form prose (depending on the deployment environment and concurrency) due to high context window loads and frequent attention computations.

    After introducing the Script Layer, the pipeline is broken down into three lightweight steps: “Script Generation,” “Dialogue Revision,” and “Prose Expansion.” Because the input context for each step is more concise and the goal is clearer, model inference efficiency is drastically improved. The overall prose generation time dropped from over 30 minutes to about 12 minutes. Even accounting for the Script Layer’s organization and planning time, the overall process still saves about 10 minutes of processing time. This proves that decomposing complex tasks not only improves output quality but also effectively reduces the computational pressure of a single inference, increasing system throughput.

    5. Cloud-Native Engineering Deployment Recommendations

    To run this pipeline stably in a production environment, it typically needs to be deployed using a general cloud-native architecture. Below are recommended technical components and architectural design concepts:

    1. Task Scheduling and Message Queues: Utilize general message queue services to decouple the three steps: script generation, dialogue revision, and expansion. When the previous step is completed, the result is serialized and sent to the next queue, achieving asynchronous non-blocking processing.
    2. Object Storage and Context Management: Persist the novel’s world-building settings, character cards, and intermediate Script Layer states to object storage. During the expansion phase, pull relevant contexts on demand to avoid stuffing useless long historical contexts entirely into the prompt, further reducing inference latency.
    3. Logging Services and Monitoring Alerts: Integrate general logging services to record generation time, token consumption, and exception interruptions for each stage. When expansion time exceeds expected thresholds or generated content triggers safety interceptions, promptly trigger alerts and retries.

    Below is a simplified pseudocode snippet demonstrating how to orchestrate this multi-step generation pipeline through engineering means:

    1. class NovelGenerationPipeline:
    2. def __init__(self, llm_client, message_queue):
    3. self.llm = llm_client
    4. self.mq = message_queue
    5. def generate_script_layer(self, outline, character_profiles):
    6. """Generate script layer: plan key dialogues and actions"""
    7. prompt = self._build_script_prompt(outline, character_profiles)
    8. script = self.llm.complete(prompt, temperature=0.7)
    9. return script
    10. def revise_dialogue(self, script, character_persona):
    11. """Revise dialogue: calibrate lines based on character personality"""
    12. prompt = self._build_dialogue_revise_prompt(script, character_persona)
    13. revised_script = self.llm.complete(prompt, temperature=0.5)
    14. return revised_script
    15. def expand_to_prose(self, revised_script, scene_context):
    16. """Expand to prose: deep rendering based on the script skeleton"""
    17. prompt = self._build_expansion_prompt(revised_script, scene_context)
    18. prose = self.llm.complete(prompt, temperature=0.8, max_tokens=4096)
    19. return prose
    20. def execute_pipeline(self, task_data):
    21. # Pipeline orchestration: execute step-by-step and push states to the message queue
    22. script = self.generate_script_layer(task_data['outline'], task_data['characters'])
    23. self.mq.publish('script_generated', script)
    24. revised = self.revise_dialogue(script, task_data['focus_persona'])
    25. self.mq.publish('dialogue_revised', revised)
    26. final_prose = self.expand_to_prose(revised, task_data['context'])
    27. return final_prose

    Conclusion

    Using AI to write novels and eliminating the inherent “machine smell” is essentially an engineering problem that deeply integrates human creative thinking with machine reasoning capabilities. By introducing the Script Layer architecture to force structured pre-reasoning in the model, and combining it with a dialogue revision mechanism, we can effectively break the performance and quality bottlenecks of end-to-end generation. This not only makes the text more human-like in emotion and logic but also achieves significant time reductions at the engineering level, providing a highly cohesive, loosely coupled practical paradigm for automated long-form content generation.