ChatPaper.aiChatPaper

标尺:一种与模型无关的方法,用于控制大型语言模型生成的长度

Ruler: A Model-Agnostic Method to Control Generated Length for Large Language Models

September 27, 2024
作者: Jiaming Li, Lei Zhang, Yunshui Li, Ziqiang Liu, yuelin bai, Run Luo, Longze Chen, Min Yang
cs.AI

摘要

大型语言模型的指令遵循能力使人类能够以自然的方式与人工智能代理进行交互。然而,当需要生成特定长度的响应时,由于其在准确感知数字约束方面固有的困难,大型语言模型经常难以满足用户的需求。为了探索大型语言模型控制生成响应长度的能力,我们提出了目标长度生成任务(TLG),并设计了两个度量标准,即精确匹配(PM)和灵活匹配(FM),以评估模型在遵循指定响应长度方面的性能。此外,我们引入了一种新颖的、与模型无关的方法称为Ruler,它利用元长度标记(MLTs)来增强大型语言模型在受长度约束指令下的指令遵循能力。具体而言,Ruler赋予LLMs生成特定长度响应的能力,基于指令中的长度约束。此外,当长度约束未明确提供时,Ruler可以自动生成适当的MLT,展现出出色的通用性和泛化能力。全面的实验显示了Ruler在不同LLMs上的目标长度生成任务中的有效性,例如,在所有级别上PM平均增益为27.97,FM平均增益为29.57。此外,我们进行了大量消融实验,进一步证实了Ruler的功效和泛化能力。我们的代码和数据可在https://github.com/Geaming2002/Ruler 上获取。
English
The instruction-following ability of large language models enables humans to interact with AI agents in a natural way. However, when required to generate responses of a specific length, large language models often struggle to meet users' needs due to their inherent difficulty in accurately perceiving numerical constraints. To explore the ability of large language models to control the length of generated responses, we propose the Target Length Generation Task (TLG) and design two metrics, Precise Match (PM) and Flexible Match (FM) to evaluate the model's performance in adhering to specified response lengths. Furthermore, we introduce a novel, model-agnostic approach called Ruler, which employs Meta Length Tokens (MLTs) to enhance the instruction-following ability of large language models under length-constrained instructions. Specifically, Ruler equips LLMs with the ability to generate responses of a specified length based on length constraints within the instructions. Moreover, Ruler can automatically generate appropriate MLT when length constraints are not explicitly provided, demonstrating excellent versatility and generalization. Comprehensive experiments show the effectiveness of Ruler across different LLMs on Target Length Generation Task, e.g., at All Level 27.97 average gain on PM, 29.57 average gain on FM. In addition, we conduct extensive ablation experiments to further substantiate the efficacy and generalization of Ruler. Our code and data is available at https://github.com/Geaming2002/Ruler.

Summary

AI-Generated Summary

PDF302November 13, 2024