AI知识库

53AI知识库

学习大模型的前沿技术与行业应用场景


LongWriter:现在 LLM 可以生成 20,000 字的输出
发布日期:2024-09-29 18:51:05 浏览次数: 1570


在本文中,我们将探讨 LongWriter,它能够生成更长的序列。它可以生成高质量且连贯的 20,000 字

LLMs的问题是什么?

为什么现有的LLMs无法生成超过2K字的输出?

在这个八月份,发布了一项名为LongWriter的研究发现,现有的预训练LLMs无法生成超过2K字的长序列。这是因为在SFT(监督微调)阶段提供的数据长度有限而导致的困难。

然而,输入没有问题。LLM可以接受更长的输入,比如100,000字。

模型实验

在实验中,要求写一篇关于任何主题的文章,并指定字数,比如10,000字。以下是一个提示的例子。

Write a 10000-word article on the history of the Roman Empire

这个提示的例子请求了总共8个LLM。4个是专有的,4个是开源的。

但是它们都无法生成超过2,000字的长序列。

训练实验

为了确认观察到的假设,使用不同长度的数据集训练特定模型。

通过用三种不同长度设置(500,1000和2000)训练GLM-4-9B模型。但我们可以观察到模型难以生成超过提供的数据长度。

观察的结论

由于训练数据集中缺乏更长的序列,模型将无法生成更长的序列。

如何生成更长的输出?

对于更长的输出,比如一篇文章,通常会有多个主题和子主题。作为人类,首先要对想法进行概述,然后写下每个主题和子主题的内容。

我们也可以使用 LLM 做同样的事情。

第一步:撰写文章大纲(计划)

首先,我们要求 LLM 制定主要观点及其所需的内容长度。输出必须每个主题占一行。

## PROMPT OF GENERATE OUTLINE ##

I need you to help me break down the following long-form writing instruction into multiple
subtasks. Each subtask will guide the writing of one paragraph in the essay, and should include
the main points and word count requirements for that paragraph.
The writing instruction is as follows:
{User Instruction}
Please break it down in the following format, with each subtask taking up one line:
Paragraph 1 - Main Point: [Describe the main point of the paragraph, in detail] - Word Count:
[Word count requirement, e.g., 400 words]
Paragraph 2 - Main Point: [Describe the main point of the paragraph, in detail] - Word Count:
[word count requirement, e.g. 1000 words].
...
Make sure that each subtask is clear and specific, and that all subtasks cover the entire content
of the writing instruction. Do not split the subtasks too finely; each subtask’s paragraph should
be no less than 200 words and no more than 1000 words. Do not output any other content.

第2步:根据提供的主题撰写内容

在第二阶段,我们将根据第一步的输出生成内容。在这一阶段,我们将之前生成的内容整合,以使输出更连贯。

这意味着我们不能并行生成输出内容。

## PROMPT OF WRITE BASED on TOPIC ##

You are an excellent writing assistant. I will give you an original writing instruction and my
planned writing steps. I will also provide you with the text I have already written. Please help
me continue writing the next paragraph based on the writing instruction, writing steps, and the
already written text.
Writing instruction:
{User Instruction}
Writing steps:
{The writing plan generated in Step I}
Already written text:
{Previous generated (n-1) paragraphs}
Please integrate the original writing instruction, writing steps, and the already written text, and
now continue writing {The plan for the n-th paragraph, i.e., the n-th line in the writing plan}

一旦我们拥有所有内容,我们将其合并以获得最终结果。这种方法在LongWriter论文中称为AgentWrite管道

评估

AgentWrite的评估有两种方式。第一是长度比较,第二是生成输出的质量。质量通过六个不同的维度进行衡量:相关性、准确性、一致性、清晰度、广度和深度,使用LLM-as-a-judge

使用GPT-4o进行的实验发现,超过4K的输出,模型的长度评分显著降低。

通过使用这种方法模型,您可以在长度上获得良好的得分,并匹配质量。但是并行执行模型在连贯性方面表现不佳。

教授模型生成更长的输出

一位研究人员并没有止步于此;他们使用AgentWrite管道生成了一个更长序列的数据集。

生成了一个包含6,000条指令的数据集,并与General SFT(180K)数据集结合。

它对GLM和Llama模型进行了如下微调:

  • LongWriter-9B (GLM-4–9B)

  • LongWriter-8B (Llama-3.1–8B)

这些模型能够生成更长的序列。

您可以在HuggingFace上找到这些模型并进行实验。它还支持vLLM推理引擎。

源代码

预训练模型

结论:

在生成应用程序中,特别是文本方面,我们希望生成更长的序列。首先,我们必须为整个概念制定一个计划,在第一步中生成大纲并将其分解为小问题。然后提供每个输入,以生成逐步解决方案。



53AI,企业落地应用大模型首选服务商

产品:大模型应用平台+智能体定制开发+落地咨询服务

承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业

联系我们

售前咨询
186 6662 7370
预约演示
185 8882 0121

微信扫码

与创始人交个朋友

回到顶部

 
扫码咨询