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

Ruler:一种与模型无关的控制大语言模型生成长度的方法

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

Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences(中国科学院深圳先进技术研究院);University of Chinese Academy of Sciences(中国科学院大学)

Jiaming Li, Lei Zhang, Yunshui Li, Ziqiang Liu, yuelin bai, Run Luo, Longze Chen, Min Yang

AI总结:

本文提出与模型无关的Ruler方法,利用元长度令牌增强大语言模型在长度约束下的生成控制能力,并构建目标长度生成任务及PM、FM指标验证其有效性。

摘要:

大语言模型的指令遵循能力使人类能够以自然方式与AI智能体交互。然而,当被要求生成特定长度的回复时,大语言模型往往难以满足用户需求,因为它们在准确感知数值约束方面存在固有困难。为探索大语言模型控制生成回复长度的能力,我们提出了目标长度生成任务(TLG),并设计了两个指标——精确匹配(PM)和灵活匹配(FM),用于评估模型在遵循指定回复长度方面的表现。此外,我们引入了一种新颖的、与模型无关的方法Ruler,该方法利用元长度令牌(MLTs)来增强大语言模型在长度受限指令下的指令遵循能力。具体而言,Ruler使大语言模型能够基于指令中的长度约束生成指定长度的回复。此外,当长度约束未被明确提供时,Ruler可以自动生成合适的MLT,展现出优异的通用性和泛化能力。综合实验表明,Ruler在目标长度生成任务上对不同大语言模型均有效,例如在All Level上PM平均提升27.97,FM平均提升29.57。此外,我们进行了大量消融实验,进一步证实了Ruler的有效性和泛化能力。我们的代码和数据可在https://github.com/Geaming2002/Ruler获取。

英文摘要:

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.

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

↑