arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2412.11937cs.CL
收藏

大型语言模型中的精确长度控制

Precise Length Control in Large Language Models

Strategic Research Group(战略研究组)

Bradley Butcher, Michael O'Keefe, James Titchener

AI总结:

本文提出通过引入长度差位置编码(LDPE)和Max New Tokens++扩展,使大型语言模型能够精确或按上限控制响应长度,在问答和摘要任务中实现平均误差小于3个令牌且不损失质量。

摘要:

大型语言模型(LLMs)越来越多地用于生产系统,为聊天机器人、摘要生成和问答等应用提供支持。尽管它们取得了成功,但控制其响应长度仍然是一个重大挑战,尤其是对于需要结构化输出或特定细节程度的任务。在这项工作中,我们提出了一种方法,用于调整预训练的解码器型LLMs以实现响应长度的精确控制。我们的方法将一种次级长度差位置编码(LDPE)引入输入嵌入中,该编码会倒数至用户设定的响应终止长度。使用LDPE进行微调使模型能够学会在所需长度处连贯地终止响应,实现平均令牌误差小于3个令牌。我们还引入了Max New Tokens++,这是一种扩展,可实现灵活的上限长度控制,而非精确目标。在问答和文档摘要等任务上的实验结果表明,我们的方法能够在不损害响应质量的情况下实现精确的长度控制。

英文摘要:

Large Language Models (LLMs) are increasingly used in production systems, powering applications such as chatbots, summarization, and question answering. Despite their success, controlling the length of their response remains a significant challenge, particularly for tasks requiring structured outputs or specific levels of detail. In this work, we propose a method to adapt pre-trained decoder-only LLMs for precise control of response length. Our approach incorporates a secondary length-difference positional encoding (LDPE) into the input embeddings, which counts down to a user-set response termination length. Fine-tuning with LDPE allows the model to learn to terminate responses coherently at the desired length, achieving mean token errors of less than 3 tokens. We also introduce Max New Tokens++, an extension that enables flexible upper-bound length control, rather than an exact target. Experimental results on tasks such as question answering and document summarization demonstrate that our method enables precise length control without compromising response quality.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑