初衷
我一直希望创作一部以西晋末年至十六国初年为背景的历史群像故事。由于涉及大量历史人物、事件及错综复杂的关系,在正式写作之前,需要先建立足够丰富、可靠、便于使用的人物资料。
最初的设想是借助 AI,对相关历史原典进行系统整理:尽可能完整地收集人物事迹,保留可追溯的原文依据,再将这些材料转化为适合阅读和创作的人物资料卡。
我希望通过一套可重复执行的流程完成资料整理,将更多精力留给人物塑造和剧本创作。但随着探索深入,资料处理本身逐渐成为一个远比预想复杂的工程问题。
从 AI 整理到多阶段流水线
最初尝试由 Agent 直接根据我设定的规范阅读和整理本地的史料,史料包括四类:
第一类,正史与编年骨架,包括《晋书》、《资治通鉴》、《宋书》、《南齐书》、《魏书》等
第二类,别史与地方制度、地理,包括《十六国春秋》、《华阳国志》、《晋阳秋》、《汉晋春秋》、《水经注》等
第三类,故事与志怪,包括《世说新语》、《搜神记》 、《太平广记》 等
第四类,文集与其他,包括《艺文类聚》、《太平御览》、《全晋文》等
共26本书籍。
但几轮试验的结果并不理想。为了提高结果的可靠性和一致性,我开始将任务拆解为多个相对独立的阶段,包括原文提取、查缺、事件拆分、白话转述与分类、时间处理和人物资料卡生成。
在技术分工上,脚本负责数据传递、编号与格式校验,外部 LLM 承担批量语义处理,Codex 负责流程协调、异常判断与结果复核。
随着试验推进,为了避免重要信息在不同阶段丢失,又陆续加入摘要、提纲生成、提纲复核及失败重试等环节。
每一步的设计都有具体理由:材料过长需要压缩,内容容易遗漏需要提前规划,生成结果存在错误就需要检查和修正。
然而,这些局部合理的措施逐渐叠加成复杂的依赖关系。一个环节出现问题,可能引起后续多个阶段失效;反复生成与审查,也不一定带来更可靠的结果。
复杂流程暴露的问题
实验中主要是使用刘渊与石勒这两个人物进行的。
刘渊人物资料卡的一次试运行暴露了一个典型问题,遗漏与丢失,例如最终文本提到了其子继位,却遗漏了刘渊本人的死亡。
原本用于组织内容的提纲生成没有通过检查,Agent 为了继续执行,临时编造了一份结构合法但内容不充分的提纲。后续阶段虽然能够正常运行,关键事件却已经在上游丢失。
之后我要求流程不得通过临时补写来绕过失败检查。但随之出现了另一种困难:当一组记录中只有个别项目出错时,系统仍可能重新生成整组内容。重新生成不仅增加调用成本,还可能在原本正确的部分引入新问题。
过度的工程化导致一次试运行持续了三个半小时仍未完成。原本用于保障质量的检查和重试机制,反而成为妨碍交付的主要因素。
不得不重新思考:增加处理步骤,是否真的提高了结果质量?每一道检查究竟在解决什么问题,又是否引入了新的问题?
简化流程与重新划分职责
接下来的调整不能再眼于增加检查,而要重新审视每个环节的必要性。
人物资料本身已经按照主题和事件分类,额外生成摘要与动态提纲,未必能够提供足够的增量价值。所以我逐步取消了部分摘要、提纲及其复核流程,改为直接依据已有材料组织人物资料。
第一次精简并未立即成功。旧脚本仍然保留着过于严格的分类限制,使模型无法合理地综合不同类别中的关联信息。直到相应约束一并调整,资料卡生成阶段才顺利完成。
调整后的这一次试验,最终写作阶段使用约20分钟完成。虽然这个结果并不能证明整套流水线已经成熟,但至少说明,原先复杂的中间步骤并非全部必要。
与此同时,脚本、LLM 与 Codex 的职责也逐渐明确。
在写作任务中,脚本适合处理来源定位、稳定编号、数据映射和格式校验等确定性任务;LLM 更适合承担事件理解、文本组织与语义判断;Codex 则负责协调执行,并处理需要结合上下文作出判断的异常情况。
对原有路线的重新评价
另一项重要尝试,是让 Codex 暂时不依赖已经构建的本地史料处理成果,仅通过网络检索,独立编写石勒的人物研究资料。
两种方法形成了有意思的对照。原有流水线能够保留细致的事件记录、编号和原文追溯关系,但资料卡的组织与表达仍不够理想。独立联网研究得到的资料,在白话叙述、人物关系和事件解释方面反而更自然,也能够引入现代历史研究的观点,但缺少前者严格的逐条原文核验。
这让我开始重新考虑最初的任务设计。
我真正需要的,究竟是一套完整的历史事件证据数据库,还是能够充分理解人物、直接支持创作的研究资料?
两者并不矛盾,却不必采用完全相同的生产方法,也不一定需要投入同等程度的自动化工程。将完整流水线作为默认方案的思路开始动摇。
挫折与认识
这一轮探索建立了历史原典库,完成刘渊、石勒等人物的试运行资料,积累了事件拆分、史料追溯、时间处理、模型测试和批量任务管理等经验,也形成了独立联网人物研究的方法经验。
但原定的完整流水线经过多轮修改,仍未完成足够可信的、优质的、扎实的版本,以及流程。大量投入也没有直接转化为预期中的完整人物研究成果,更远远没有推进到正式剧本写作。
总的来说:
首先,工程流程的复杂程度与最终成果的质量并不成正比。 更多步骤、更多检查或更严格的格式约束,都需要通过实际结果证明其必要性。
其次,自动化的成本不能只计算模型调用。 上下文消耗、运行等待、异常恢复、反复返工,以及人的监督和判断,同样是工作流程的一部分。
更重要的是,技术方案始终应当服务于最终目标。 对于历史写作,可靠的史料基础不可缺少,但资料的可读性、研究深度和人物理解同样重要。完整的证据数据库与适合创作的人物资料,需要不同的组织方式和质量标准。
这次探索并未完成最初设想的完整系统,但技术基础和方法认识是有价值的。这也成为下一阶段探索的起点。
下个阶段的探索,我会开始尝试另一条路线:先通过联网研究建立内容丰富、结构清晰的候选人物资料,再利用本地历史原典进行针对性的事实核验。
Motivation
I have long wanted to write an ensemble story set in the late Western Jin and early Sixteen Kingdoms period. The story involves many historical figures, events, and complex relationships. Before writing, I needed to build a rich, reliable, and practical collection of biographical materials.
My initial idea was to use AI to systematically organize primary historical sources. I wanted to collect as much information as possible about each figure, preserve traceable references to the original texts, and turn the materials into readable biographical profiles for writing.
I hoped to complete this work through a repeatable process, leaving more time for character development and scriptwriting. However, as I explored further, organizing the materials became a much more complex engineering problem than I had expected.
From AI-Assisted Research to a Multi-Stage Pipeline
At first, I tried having an AI Agent read and organize locally stored historical texts according to my instructions. The source collection included four categories:
- Official histories and chronological records: Book of Jin, Zizhi Tongjian, Book of Song, Book of Southern Qi, Book of Wei, etc.
- Unofficial histories, regional records, institutions, and geography: Shiliuguo Chunqiu, Huayang Guozhi, Jinyang Qiu, Han Jin Chunqiu, Shuijing Zhu, etc.
- Anecdotes and supernatural tales: Shishuo Xinyu, Soushen Ji, Taiping Guangji, etc.
- Literary collections and other works: Yiwen Leiju, Taiping Yulan, Quan Jin Wen, etc.
The collection contained 26 historical works in total.
After several unsatisfactory trials, I began breaking the task into separate stages to improve reliability and consistency. These included extracting original text, searching for missing information, splitting historical events, rewriting in modern Chinese and classifying content, processing dates, and generating biographical profiles.
The work was divided among three components. Scripts handled data transfer, numbering, and format validation. External LLMs handled batch semantic processing. Codex coordinated the workflow, handled exceptions, and reviewed the results.
As testing continued, I added more steps to prevent information loss. These included summaries, outline generation, outline reviews, and retries for failed tasks.
Each step had a reason. Long materials needed to be shortened. Important information could be missed, so outlines seemed necessary. Generated results could contain errors, so they needed to be checked and corrected.
However, these individually reasonable measures gradually created complex dependencies. A failure in one step could affect several later stages. Repeated generation and review did not always produce more reliable results.
Problems Revealed by the Complex Pipeline
Most experiments used two historical figures: Liu Yuan and Shi Le.
One test run of Liu Yuan's biographical profile revealed a typical problem: missing information. The final text mentioned his son's succession but omitted Liu Yuan's own death.
The outline generation step had failed validation. To continue the process, the Agent improvised an outline that passed structural checks but lacked important content. The later stages ran normally, but a key event had already been lost earlier in the pipeline.
I then required the workflow to stop rather than bypass failed checks with temporary content. But this introduced another problem. When only one item in a batch was wrong, the system could regenerate the entire batch. This increased API costs and sometimes introduced new errors into previously correct content.
Overengineering left one test run unfinished after three and a half hours. The validation and retry mechanisms designed to ensure quality had become major obstacles to completing the work.
This forced me to reconsider two questions: Did adding more processing steps actually improve quality? What problem did each check solve, and what new problems did it create?
Simplifying the Pipeline and Redefining Responsibilities
The next changes could no longer focus on adding more checks. I needed to reconsider whether each step was necessary.
The historical materials were already organized by topics and events. Additional summaries and dynamic outlines did not necessarily add enough value. I gradually removed some of these steps and their review processes. Instead, I let the model organize the biographical profiles directly from the existing materials.
The first simplification did not work immediately. The old scripts still enforced overly strict category boundaries. This prevented the model from combining related information across categories. The profile generation stage only worked properly after these remaining constraints were also revised.
In the next test, the final writing stage finished in about 20 minutes. This did not prove that the entire pipeline was reliable, but it showed that some of the earlier intermediate steps were unnecessary.
At the same time, the roles of scripts, LLMs, and Codex became clearer.
For writing tasks, scripts were better suited to deterministic work, such as source location, stable numbering, data mapping, and format validation. LLMs were better suited to understanding events, organizing text, and making semantic judgments. Codex coordinated execution and handled exceptions that required contextual judgment.
Reassessing the Original Approach
Another important experiment was to ask Codex to write a biographical research profile of Shi Le using only online research, without relying on the existing local historical processing pipeline.
The two approaches produced an interesting comparison.
The original pipeline preserved detailed event records, stable IDs, and links to original sources. However, the resulting profiles were still not well organized or written.
The independent online research produced more natural modern Chinese, clearer explanations of relationships and events, and could include perspectives from modern historical scholarship. However, it lacked the original pipeline's strict, claim-by-claim verification against primary texts.
This made me reconsider the original task.
Did I really need a complete database of historical events and evidence, or did I need research materials that would help me understand the characters and write the story?
These goals were not contradictory. But they did not require exactly the same production process or the same level of automation. I began to question whether the full pipeline should remain the default approach.
Setbacks and Lessons
This stage of exploration produced a local collection of primary historical texts, test materials for figures including Liu Yuan and Shi Le, and practical experience with event extraction, source tracing, date processing, model testing, and batch task management. It also helped establish methods for independent online biographical research.
However, even after many revisions, the planned full pipeline had not reached a sufficiently reliable and satisfactory state. The considerable time and effort invested had not produced the complete biographical research materials I had originally expected. The project was still far from actual scriptwriting.
Looking back, I learned several lessons.
First, a more complex engineering process does not necessarily produce better results. More steps, more checks, and stricter formatting rules must prove their value through actual outcomes.
Second, the cost of automation goes beyond model API calls. Context usage, waiting time, error recovery, repeated work, and human supervision and judgment are all part of the total cost.
Most importantly, technical solutions must serve the final goal. Reliable historical sources are essential for historical writing. But readability, depth of research, and understanding of historical figures are equally important. A complete evidence database and biographical materials intended for creative writing require different structures and quality standards.
This exploration did not produce the complete system I had originally planned. However, it provided valuable technical foundations and practical lessons. These became the starting point for the next stage.
In the next stage, I would try a different approach: first use online research to build rich, well-structured collections of candidate biographical information, then use locally stored primary historical texts to verify specific claims.