arXiv:2409.18943cs.CL2024-09被引 1

让大模型精准按要求长度生成文本,提升指令遵循能力。

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

  • 引入元长度标记(MLT)实现对生成长度的精准控制。
  • 在多种模型上平均提升27.97%(PM)和29.57%(FM)
  • 无需显式长度提示也能自动适配,适合通用场景

大语言模型的指令遵循能力使人类能以自然方式与AI交互。然而,当需生成特定长度的响应时,模型常因难以感知数值约束而表现不佳。为此,我们提出目标长度生成任务(TLG),并设计精确匹配(PM)和柔性匹配(FM)两个指标来评估模型对指定长度的遵循能力。进一步提出一种新的、与模型无关的方法Ruler,通过引入元长度标记(MLTs)增强模型在长度约束指令下的指令遵循能力。Ruler使大模型能够根据指令中的长度约束生成指定长度的回应;且当长度约束未明确提供时,可自动生成合适的MLT,展现出优异的泛化性。大量实验表明,Ruler在不同大模型上均有效,如在所有层级平均提升PM达27.97%,FM达29.57%。我们还进行了广泛消融实验,验证其有效性与通用性。代码与数据已开源。

原文摘要 · Abstract (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.

长度控制指令遵循大模型生成质量

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。