Back

Novel Generator

Background

Writing novels was one of my hobbies during my school years, and I also attempted to create novels myself. However, during the actual writing process, I gradually realized that individual writing poses significant challenges in pacing control and overall structural design, especially in the following aspects:

  • Whether plot pacing and conflict design are engaging
  • Structural handling of openings and endings
  • Consistency of character design, plot progression, and world-building
  • Stability and coherence of detailed descriptions (characters, events, environments, etc.)

With limited writing experience, the overall quality often fell short of expectations.

With the development of large language models, I began to wonder whether AI could be used to assist or even fully generate structured long-form novels, while also addressing consistency and quality issues in ultra-long text generation across non-single-session contexts.


Project Overview

Introduction

This project implements an automated long-form novel generation system based on multi-role large language models (LLMs).

The system is designed to address the following challenges:

  • Limited context length of a single LLM, making it difficult to generate long and coherent narratives
  • Lack of long-term memory mechanisms in long-text generation, leading to drifting characters and plot inconsistencies
  • Unstable output quality and lack of structural constraints
  • Limited controllability of the generation process, making staged review and correction difficult

Highlights

Multi-Agent Collaborative Writing Architecture

The system is designed with multiple collaborating roles to simulate a “writing team” workflow:

  • Outline Generator: Generates a chapter-level outline for the entire novel, providing structural planning for the overall plot
  • Outline Reviewer: Evaluates the generated outline for consistency and quality, and decides whether regeneration is needed based on scoring mechanisms
  • Chapter Writer: Generates chapter content based on the current outline segment and compressed historical context
  • Chapter Reviewer: Evaluates chapter quality and consistency, triggering regeneration if necessary
  • Chapter Information Extractor: Extracts key plot points and information from each chapter for downstream context construction
  • Historical Summary Module: Maintains a global story summary at the chapter level to ensure long-term consistency and memory continuity

Unified and Structured Prompt Framework

A unified prompt template system is designed to ensure that different LLM roles follow clear responsibilities and output constraints at different stages:

  • Differentiated prompt strategies for early-stage and late-stage generation
  • Strict structured output formats to improve system parsability
  • Explicit constraints on required output fields for each module to improve stability

Generation Pipeline and Engineering Control Mechanisms

  • Introduces a “generate–evaluate–refine” closed-loop mechanism to improve output quality
  • Supports automatic retry and regeneration strategies based on failure reasons (retry mechanism)
  • Structures and logs model decision processes into the context to improve traceability and stability

User Experience Design

Users only need to provide basic novel information (e.g., genre, title, number of chapters). Optional inputs are also supported:

  • Character settings
  • World-building background
  • Initial outline

After configuration, the system can be launched with a single click to automatically generate a complete novel.


Cost Optimization

Generation workflows are optimized by leveraging available API resources, reducing usage cost while maintaining output quality (can also be “free-tier friendly”).


Progress

The project has been fully implemented with support for both CLI and GUI interfaces.

It has been packaged into a Windows executable (.exe) and has undergone real-world distribution testing and validation.


UI and Sample Generated Content

Create a novel project
Create a novel project
Visual generation process and file export
Visual generation process and file export
··· ···
第二战未息,箭谷少主早已按捺不住。

他身着月白衣裳,背负长弓羽箭,气态如岳风。此人名唤谷言,少年俊逸,却天性争强好胜。据传他此次前来,并非荣誉,而为夺一举登榜之机。

“修罗大人,箭谷请赐教。”

沈不打正想着趁乱溜走,还没转身,那箭已出——骤然破空。

他一声惨叫,本能地低头,那支箭带着劲风掠过耳边,射进身后旗杆。旗杆震荡,抖下一串尘灰直扑谷言眼中。

少年倒吸凉气,双目一阵剧痛,慌乱间连发三箭全数射偏。第三箭反弹回擂台脚边,“砰”的一声撞翻了护栏。

谷言踉跄后退,满口苦笑:

“不愧是修罗……以气御箭,神乎其神……”

沈不打被风压推得连退几步,茫然地望着自己双手:

“我什么都没干啊!”

台下人群炸了锅,呐喊声直冲云霄。

“箭谷少主认输!修罗神威!”

钱三目光微闪,暗中扇子一合,嘴角划过一丝若笑非笑的弧度。
··· ···
Sample Novel Excerpt 1
··· ···
押解沈宴的队伍缓缓前行。夜色掩去他们的神情,唯有火把的光在雪中跳跃,映出一张张被寒意刻出的面孔。

沈宴坐在简陋囚车中,木栏冰冷,车壁透风。他手上的铁锁磨出细碎血痕,却不曾皱眉。窗缝透来的雪粒落在他眉间,融化成冰水。

他低垂着头,看似沉寂,实则脑海中正一遍遍回推案情脉络。

那卷案宗是在宣判前第三日送入刑部的,他亲手校对过一次,字迹分明。可当审判之时,签印页却换成了他弟子誊写的隶体。

那字迹,沈宴熟得不能再熟——刑部副吏署陈卿的手笔。

他曾是沈宴一手提拔的校正,如今……却成了将他送上断头台的罪证来源。

他闭上眼,心头涌上一丝苦涩:

“朝堂翻覆,人心比冬夜更冷。”

王晨策马行在队伍前方。那少年身披铁甲,雪花在盔面上结成薄霜。几次回头,他都见囚车里的男人稳坐如山,不言不语。

副官低声道:

“王校尉,可怜他作甚?此人已是死罪。”

王晨侧目,语气微低:

“我不是怜他,只觉此行奇怪。命令本可让刑部差役押送,为何抽我们北营?再说——北道今冬兵乱方息,道上不安。”

曲扬冷笑:

“命令自有深意。上头说北境有人要借流犯生事,若真有刺客劫人,咱们便立功。”

“立功?”王晨喃喃。

风雪扑来,将他的话吞没。
··· ···
Sample Novel Excerpt 2
··· ···
阿晴看着她沉默了几秒,轻轻叹了一口气:

“你以前啊,总觉得不往前冲几步就会被世界落下。现在呢,看起来是被世界撞了一下,撞得不轻。”

小小低下头,指尖在杯壁上画圈。

她知道好友没有恶意。阿晴一向说话直接,却总能准确踩在问题的中心。

“那天……”小小犹豫着开口,“那天晚上在港口广场,我听到一家店里放的歌,有一段和弦,很像我以前写过的一段。”

阿晴愣了愣,随即笑出声:

“你说那个啊,那就是你写的。”

“什么?”小小抬头。

阿晴靠在椅背上:

“你高三那年,给我做了一个小 demo,说是送我当‘人生主题曲’。我把那段旋律给市中心那家酒吧老板听,他说可以拿来做店里的背景循环。那家酒吧后来搬到了港口广场,歌也跟着过去了。”

她顿了顿,看着小小的眼睛:

“你以为自己的声音消失了,其实它一直在这儿绕圈圈,只是你不在,所以没听见。”

这句话像一颗小石子落进她心里那潭早已沉静的水中。

涟漪慢慢散开,带着难以言喻的酸涩与微弱的温热。

“那……给你钱了吗?”小小突然问。

阿晴愣了一下,随后笑:

“给了几张饮品券。不过我觉得值了。你不在的时候,我偶尔会去那儿坐一会儿,听那段旋律,就感觉你好像还在某个地方没走远。”

空气静了一瞬。

“对不起。”小小低声说。

“你跟我道什么歉?”阿晴皱眉,“又不是你欠我的。”
··· ···
Sample Novel Excerpt 3