arXiv:2507.20398cs.CL2025-07EMNLP被引 2

发现大模型内部能独立控制生成长度,不损失语义信息。

Length Representations in Large Language Models

  • 通过分析注意力机制,发现长度控制可解耦
  • 调整特定隐藏单元即可改变输出长度,保持内容质量
  • 部分单元随提示长度变化而激活,体现模型对长度的感知

大语言模型(LLMs)在各类任务中表现出色,其能力源于海量文本数据的学习。尽管模型能控制输出序列长度,尤其在指令设置下,但其内部实现机制尚不明确。本研究首次提供实证证据,揭示输出序列长度信息如何编码于模型内部表征中。结果表明,多头注意力机制在决定输出长度中起关键作用,且该控制可解耦实现。通过缩放模型中的特定隐藏单元,可在不损失生成文本信息量的前提下调控输出长度,说明长度信息部分与语义信息解耦。此外,当提示更具长度特异性时,某些隐藏单元活性显著上升,反映出模型对长度属性的内部感知。研究显示,LLMs已习得强大且自适应的内部机制来控制输出长度,无需外部干预。

原文摘要 · Abstract (English)

Large language models (LLMs) have shown remarkable capabilities across various tasks, that are learned from massive amounts of text-based data. Although LLMs can control output sequence length, particularly in instruction-based settings, the internal mechanisms behind this control have been unexplored yet. In this study, we provide empirical evidence on how output sequence length information is encoded within the internal representations in LLMs. In particular, our findings show that multi-head attention mechanisms are critical in determining output sequence length, which can be adjusted in a disentangled manner. By scaling specific hidden units within the model, we can control the output sequence length without losing the informativeness of the generated text, thereby indicating that length information is partially disentangled from semantic information. Moreover, some hidden units become increasingly active as prompts become more length-specific, thus reflecting the model's internal awareness of this attribute. Our findings suggest that LLMs have learned robust and adaptable internal mechanisms for controlling output length without any external control.

大模型长度控制注意力机制

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