深入探讨:Agent全自动写作长篇小说技术原理解析

AI 写作8个月前更新 aiziy
0 0

很多人对AI在文字创作方面都抱有很大的期望,尤其是经过我们不断地调教后,大家都盼望着能有一个工具,让AI稳稳地输出一本风格统一的长篇小说。现如今,Agent技术已经完美地满足了这个愿望。

前些天,社群里的小伙伴们讨论一个全自动写小说的Agent工具:「gpt-author」。你只需给它一个初步的设定和预想的章节数量,剩下的就交给它。短短的几分钟,一本新小说即可面世。

不仅如此,这个工具还结合了GPT-4Stable
Diffusion API
Anthropic API等技术,甚至能自动设计出小说的封面,并生成PDF或电子书版本。这整个过程API费用只需4美元,而且Agent是开源的!

可能你会好奇,这背后是怎样的原理?别急,今天我就来揭秘这个小说创作神器。放心,我不会让你们看代码的,只带大家认识一下这个神奇的小说写作Agent的底层逻辑。

gpt-author」的核心思想其实并不复杂。它将小说创作过程划分为7个关键步骤,每个步骤都有相应的Python方法和提示词来实现。只要设定好,AI就能为你一步步地写出完整的小说。

最最核心的部分,就是这7个步骤和每个步骤对应的提示词了,我们一起看一下吧。

01

基于设定生成小说情节

用户只需提供一个小说的基本设定,比如场景简介,要生成的章节数及期望的写作风格。Agent工具会根据这些提示,自动构思出10个多章节的小说情节框架。

提示词

英文版:
You are a creative assistant that generates engaging fantasy novel
plots.Generate 10 fantasy novel plots based on this prompt: {prompt}

中文版:

你是一个富有创造力的助手,可以生成迷人的奇幻小说情节。根据以下提示生成10个奇幻小说情节:{prompt}

02

选择最优情节

Agent从步骤1生成的10个情节中,选定最吸引人的一个作为后续小说创作的素材,间接提高小说创作质量。

提示词

英文版:
You are an expert in writing fantastic fantasy novel plots. Here are a number
of possible plots for a new novel: {plots} Now, write the final plot that we
will go with. It can be one of these, a mix of the best elements of multiple,
or something completely new and better. The most important thing is the plot
should be fantastic, unique, and engaging. 

中文版:

你是撰写奇幻小说情节的专家。这里有一些新小说的可能情节:{plots} 现在,请写出我们最终会采用的情节。它可以是其中的一个,多个情节的综合,或者一个全新的、更好的情节。最重要的是这个情节应该奇幻、独特、引人入胜。

03

完善选定的情节

新建一个Agent角色,润色优化步骤2精选出来的故事情节。

提示词

英文版:

You are an expert in improving and refining
story plots. Improve this plot: {plot}\” 

中文版:

你是改进和精炼故事情节的专家。请改进以下情节:{plot}

04

根据情节创建书名

根据优化后的小说情节,为小说创建一个书名。

提示词

英文版:

You are an expert writer. Here is the plot:
{plot} What is the title of this book? Just respond with the title, do nothing
else. 

中文版:

你是专业作家。情节是:{plot} 这本书的标题是什么?

只需要回复标题,不要做其他任何事。

05

生成小说故事线

基于给定的提示,生成包含多个章节的小说故事线:该任务包含两个Agent,一个负责生成,另一个对生成的内容进行润色优化。

提示词

英文版:

Task1Generate

You are a world-class fantasy writer. Your
job is to write a detailed storyline, complete with chapters, for a fantasy
novel. Don\’t be flowery — you want to get the message across in as few words
as possible. But those words should contain lots of information. Write a
fantastic storyline with {num_chapters} chapters and high-level details based
on this plot: {prompt}. Do it in this list of dictionaries format {json_format}
        

Task2Improve

You are a world-class fantasy writer. Your
job is to take your student\’s rough initial draft of the storyline of a fantasy
novel, and rewrite it to be significantly better. Here is the draft storyline
they wrote: {response[\’choices\’][0][\’message\’][\’content\’]} Now, rewrite the
storyline, in a way that is far superior to your student\’s version. It should
have the same number of chapters, but it should be much improved in as many
ways as possible. Remember to do it in this list of dictionaries format {json_format} 

中文版:

任务1:生成

你是一流的奇幻小说作家。你的工作是为一本奇幻小说写一个详细的故事线索,包括章节。不要过于言辞华丽——你想用尽可能少的话来表达意思。但这些话应该包含大量信息。根据这个情节{prompt},{num_chapters}个章节和高层次的细节写一个极好的故事线索。用这个列表字典格式{json_format}来完成。

任务2:改进

你是一流的奇幻小说作家。你的工作是把你学生粗糙的奇幻小说故事线索初稿改写得更好。这里是他们写的故事线索草稿:{response[\’choices\’][0][\’message\’][\’content\’]} 现在,以一种比你学生的版本大大改进的方式重写这个故事线索。它应该有相同数量的章节,但在尽可能多的方面都应该更出色。记住用这个列表字典格式{json_format}来完成。

06

编写第一章内容

编写小说的第一章,可以选择使用Claude模型或GPT-4模型,该部分同上包含两个Agent,一个负责生成内容,另一个负责润色优化。

提示词

英文版:

Task1Generate

 You are a world-class fantasy writer. Here is the
high-level plot to follow: {plot} Write the first chapter of this novel:
`{first_chapter_title}`. Make it incredibly unique, engaging, and well-written.
Here is a description of the writing style you should use: `{writing_style}`
Include only the chapter text. There is no need to rewrite the chapter
name. 

Task2Improve

You are a world-class fantasy writer. Your job is to
take your student\’s rough initial draft of the first chapter of their fantasy
novel, and rewrite it to be significantly better, with much more detail. Here
is the high-level plot you asked your student to follow: {plot} Here is the
first chapter they wrote: {response[\’choices\’][0][\’message\’][\’content\’]} Now,
rewrite the first chapter of this novel, in a way that is far superior to your
student\’s chapter. It should still follow the exact same plot, but it should be
far more detailed, much longer, and more engaging. Here is a description of the
writing style you should use: `{writing_style}`\” 

中文版:

任务1:生成

你是一流的奇幻小说作家。这里是要遵循的高层次情节:{plot} 请写出这本小说的第一章:{first_chapter_title}。让它非常独特、引人入胜且写得很好。这里是你应该使用的写作风格的描述:{writing_style} 只包括章节文本。不需要重写章节名称。

任务2:改进

你是一流的奇幻小说作家。你的工作是把你学生对他们奇幻小说第一章的粗糙初稿改写得更好,增加更多细节。这里是你要求学生遵循的高层次情节:{plot} 这里是他们写的第一章:{response[\’choices\’][0][\’message\’][\’content\’]}
现在,以一种远胜过你学生版本的方式重写这本小说的第一章。它仍应遵循完全相同的情节,但应该更加细致,篇幅更长,更吸引人。这里是你应该使用的写作风格的描述:{writing_style}

07

编写小说后续章节

续写小说的后续章节,可以选择使用Claude模型或GPT-4模型。注意:这个提示词需配合Python的循环调用一些代码才能正确执行,直接复制到ChatGPT需要做一些修改。该部分同样有生成和优化两个Agent

提示词

英文版:

Task1: Generate You are a
world-class fantasy writer. Your job is to write a detailed storyline, complete
with chapters, for a fantasy novel. Don\’t be flowery — you want to get the
message across in as few words as possible. But those words should contain lots
of information. Write a fantastic storyline with {num_chapters} chapters and
high-level details based on this plot: {prompt}. Do it in this list of
dictionaries format {json_format}

Task2: Improve You are a
world-class fantasy writer. Your job is to take your student\’s rough initial
draft of the storyline of a fantasy novel, and rewrite it to be significantly
better. Here is the draft storyline they wrote: {response[\’choices\’][0][\’message\’][\’content\’]}
Now, rewrite the storyline, in a way that is far superior to your student\’s
version. It should have the same number of chapters, but it should be much
improved in as many ways as possible. Remember to do it in this list of
dictionaries format {json_format}

中文版:

任务1:生成 你是一流的奇幻小说作家。你的工作是为一本奇幻小说写一个详细的故事线索,包括章节。不要过于言辞华丽——你想用尽可能少的话来表达意思。但这些话应该包含大量信息。根据这个情节{prompt},{num_chapters}个章节和高层次的细节写一个极好的故事线索。用这个列表字典格式{json_format}来完成。

任务2:改进 你是一流的奇幻小说作家。你的工作是把你学生粗糙的奇幻小说故事线索初稿改写得更好。这里是他们写的故事线索草稿:{response[\’choices\’][0][\’message\’][\’content\’]} 现在,以一种比你学生的版本大大改进的方式重写这个故事线索。它应该有相同数量的章节,但在尽可能多的方面都应该更出色。记住用这个列表字典格式{json_format}来完成。

除了上述的小说编排流程,「gpt-author」还解决了一些基础的技术问题,例如调用API设计封面,以及生成电子书等。背后都有一些技术工程支持,不过,这部分细节就不展开啰嗦了,感兴趣的小伙伴可以在社群里讨论。

仔细看完我公众号系列文章的朋友,对这个框架中描述的整个小说写作Agent的设计,并不会有特别多的意外。我们使用ChatGPT写多章节小说,也是这个步骤,不过我们的流程更多的是靠手工管理,通过多次复制粘贴来实现多章节文字写作。

虽然Agent这个工具看起来很酷,但它并不是万能的。如果我们无法用ChatGPTClaude创作出高质量的内容,那么即使加上最顶尖的Agent工具,我们也难以得到想要的效果。Agent只是一个提高效率的小助手,核心还在于我们对AI的调教。

所以,小伙伴们,建议大家先专心打磨自己的提示词技巧,等真正掌握了如何使用AI创作出高质量内容,再考虑使用Agent工具来提升效率。

出自:https://mp.weixin.qq.com/s/V0Dg0mGK63QXev63ufNZfg

© 版权声明

相关文章

暂无评论

暂无评论...