LARFT: Closing the Cognition-Action Gap for Length Instruction Following in Large Language Models

TL;DR

LARFT combines length-aware reinforcement learning and hindsight length awareness, improving length instruction following by +20.92 points on average.

cs.CL 🔴 Advanced 2026-02-25 39 views
Wei Zhang Lintong Du Yuanhe Zhang Zhenhong Zhou Kun Wang Li Sun Sen Su
NLP Reinforcement Learning Model Fine-tuning Length Control Deep Learning

Key Findings

Methodology

LARFT integrates length-oriented reinforcement learning using the GRPO algorithm with a novel hindsight length awareness mechanism. It transforms on-policy generated trajectories into self-supervised tasks, enabling the model to internalize length concepts by relabeling outputs with prompts like 'Count the words.' This creates a feedback loop where the model jointly optimizes its internal length representations and output policies. The training employs a dynamic weighted joint loss, balancing reinforcement signals with length awareness, gradually shifting focus from length cognition to precise generation, effectively closing the cognition-action gap in length following.

Key Results

  • Across four base models, LARFT achieves an average improvement of 20.92 points on length instruction benchmarks, with only a 1.45-point decline on general capability benchmarks, demonstrating both effectiveness and robustness.
  • On datasets like LIFEBench and LongBench, LARFT significantly reduces length deviation and increases length scores, with improvements of up to 12.30 points over second-best methods, confirming its superior control in both short and long-form generation.
  • Ablation studies reveal that the length awareness component is critical for performance gains, and the joint optimization ensures the model maintains general abilities while excelling at length following.

Significance

This work addresses a fundamental bottleneck in large language models: the lack of an internal length concept. By embedding length cognition into the training process, LARFT enables models to follow length constraints with high precision, which is crucial for applications like report writing, creative content, and long-form QA. It bridges the gap between what models 'know' about length and what they 'do,' advancing the state-of-the-art in controllable generation. The approach offers a new paradigm for integrating cognitive concepts into neural models, with broad implications for AI interpretability and controllability.

Technical Contribution

LARFT introduces a unified training framework that combines reinforcement learning with a hindsight-based length awareness mechanism, enabling models to learn length concepts internally. Its key innovation lies in relabeling on-policy trajectories with length recognition prompts, transforming sparse reward signals into dense supervision. The dynamic loss balancing strategy ensures stable training and effective convergence. This approach extends reinforcement learning applications in NLP, providing theoretical guarantees for length control and practical improvements across multiple models and tasks.

Novelty

This research is the first to systematically incorporate a hindsight length awareness mechanism into reinforcement learning for language models, effectively enabling models to internalize length concepts. Unlike prior external control methods or reward-only approaches, LARFT establishes an internal length representation, resulting in more accurate and robust length following. Its combination of relabeling, joint optimization, and dynamic balancing sets a new standard for controllable text generation.

Limitations

  • The method relies on predefined length reward functions, which may struggle with highly variable or ambiguous length instructions, requiring further adaptation for diverse real-world scenarios.
  • Training complexity and computational costs are high due to the joint optimization process, posing challenges for large-scale deployment.
  • The current approach is primarily validated on text length; extending to multi-modal or multi-language settings remains an open challenge.

Future Work

Future research will focus on reducing training costs through more efficient algorithms, extending the framework to multi-modal tasks such as video or speech, and exploring adaptive reward functions for more flexible length control. Additionally, integrating this approach with other cognitive modules could further enhance model understanding and controllability, broadening its application scope in AI systems.

AI Executive Summary

Large language models (LLMs) have revolutionized natural language processing, demonstrating remarkable abilities in following complex instructions. Yet, controlling output length with high precision remains a persistent challenge, hampered by models' lack of an internal concept of length. Existing solutions, such as external tokens or reward-based policy optimization, often fall short in achieving consistent, accurate length adherence, especially as output windows grow larger.

In response, this paper introduces LARFT, a novel Length-Aware Reinforcement Fine-Tuning framework that fundamentally addresses the cognition-action gap in length instruction following. The core idea is to enable models to internalize length concepts through a combination of reinforcement learning guided by verifiable length rewards and a hindsight mechanism that relabels generated trajectories with length recognition prompts. This process creates a self-reinforcing loop where the model learns to recognize and control its output length internally.

LARFT’s architecture comprises three main components: length-oriented reinforcement learning using the GRPO algorithm, a hindsight length awareness mechanism that relabels trajectories with length recognition prompts, and a dynamic joint optimization strategy that balances length cognition with instruction adherence. This integrated approach allows the model to develop a robust internal length representation, leading to significantly improved length following—average gains of 20.92 points across four models—while maintaining general language capabilities.

Extensive experiments on benchmarks such as LIFEBench and LongBench demonstrate that LARFT not only outperforms existing baselines in length control but also preserves the model’s ability to perform well on broader NLP tasks. Ablation studies confirm that the length awareness component is critical for these gains. The approach paves the way for more controllable, interpretable, and reliable language generation systems.

Looking ahead, future work will aim to extend this framework to multi-modal tasks, reduce training costs, and further enhance the model’s understanding of complex, multi-faceted instructions. Overall, LARFT represents a significant step toward truly intelligent, self-aware language models capable of precise, reliable output control.

Deep Analysis

Background

近年来,预训练大模型在自然语言处理领域取得突破,尤其在指令遵循方面表现优异(如GPT-3、PaLM等)。然而,模型在长度控制方面仍存在瓶颈,主要源于其缺乏对长度的内在认知能力。传统方法多采用外部标记(如长度特定token)或奖励机制(如RLHF),但难以实现高精度、泛化良好的长度控制。随着长文本应用需求增长,如何让模型理解“多少字”这一概念,成为研究焦点。此前的研究多关注内容质量与语义理解,少有系统性解决长度认知问题,限制了模型在长文生成、内容定制等场景中的表现。

Core Problem

模型在遵循长度指令时表现不稳定,常出现超长或过短的输出。原因在于模型缺乏对长度的内在认知,导致其难以独立控制输出长度。现有方法依赖外部标记或奖励信号,受限于模型架构和训练数据,难以实现高精度、泛化良好的长度控制。长文本生成对模型的长度理解提出了更高要求,特别是在长篇报告、小说等场景中,控制不当会严重影响内容质量和用户体验。因此,建立模型的长度认知能力,成为提升指令遵循的关键。

Innovation

本研究提出LARFT框架,核心创新包括:1)引入后见式长度认知机制,将模型生成轨迹重标记为长度认知任务,强化模型内部的长度表征;2)结合长度导向强化学习(采用GRPO算法)实现明确的长度奖励优化;3)设计动态平衡策略,逐步由长度认知转向内容生成,形成认知与行动的闭环。这一机制突破了传统外部控制的限制,赋予模型自主理解和遵循长度指令的能力。与现有方法相比,LARFT在样本效率、控制精度和泛化能力方面均有显著提升。

Methodology

  • �� 设计长度奖励函数,将生成内容的字数与目标长度偏差作为奖励信号。
  • �� 利用GRPO算法,通过采样轨迹,优化模型的长度遵循能力。
  • �� 引入后见式机制,将轨迹重标记为长度认知任务,训练模型识别自身生成内容的长度。
  • �� 采用联合优化策略,动态调整长度认知与指令遵循的目标权重,逐步强化模型的长度理解。
  • �� 训练过程中,利用轨迹重标记和奖励机制形成闭环,提升模型的内在认知能力。
  • �� 实现过程中,结合多样化数据集,涵盖不同长度约束,确保模型在多场景下的适应性。

Experiments

采用AM-DeepSeek和Chinese-DeepSeek等数据集,构建包含不同长度指令的训练集。对比基线包括SFT、RL、SFT+RL等,评估指标涵盖长度Score、误差(MAE)、生成质量(ROUGE-L)及通用能力指标(MMLU等)。在四个基础模型(Qwen2.5、Llama-3)上进行训练和测试。通过消融实验验证长度感知机制的作用,分析不同训练策略的效果,确保模型在长文本和短文本场景中的表现均优。

Results

LARFT在三项长度指令任务中平均提升20.92分,误差降低显著,且在长文本生成任务中Sl指标最高,提升1.11至4.36分。模型在保持通用能力方面影响极小,通用基准仅下降1.45分。消融实验显示,长度感知机制是性能提升的关键,联合优化策略确保了模型在不同场景下的鲁棒性。这些结果表明,LARFT有效解决了模型长度认知不足的问题,显著提升了指令遵循的精度。

Applications

该方法适用于内容创作、报告生成、对话系统等场景,尤其在需要严格控制输出长度的应用中表现优越。模型可作为内容生成的基础模块,通过微调实现个性化长度控制,满足行业对内容长度的多样化需求。未来,结合多模态信息和更高效的训练策略,有望在长文本理解、自动摘要、智能写作等领域实现广泛应用,推动自然语言生成技术的商业落地。

Limitations & Outlook

当前模型训练成本较高,联合优化策略对硬件要求较大,实际部署时需优化效率。对极端长度或复杂指令的适应性仍有限,未来需增强模型的泛化能力。此外,模型在多模态任务中的表现尚未验证,需结合视觉、声音等多模态信息进行扩展。未来研究还应关注模型在多语言、多任务环境中的适应性与鲁棒性,解决实际应用中的多样化需求。

Plain Language Accessible to non-experts

想象你在一个工厂里,工人们需要按照订单生产不同长度的产品。有的订单要求短一些,有的要长一些。以前,工厂只用一个简单的指南,工人们只知道要做“多长”,但不真正理解“多长”意味着什么。有时候工人做得太短或太长,不能满足客户需求。现在,这个工厂引入了一套新系统,工人们不仅知道“多长”,还能自己数一数做了多少。这个系统会不断教工人们,怎样自己判断“多长”,让他们能更准确地完成订单。这个新方法就像LARFT,让模型像工人一样,自己理解“长度”的概念,做出符合指令的内容,既精准又可靠。

ELI14 Explained like you're 14

你知道在学校里写作文,有时候老师会告诉你要写“100个字”,但你其实不知道自己写了多少字。以前,你写完后可能太短或太长,老师不满意。现在,想象有个聪明的助手,不仅告诉你“你写了多少字”,还教你怎么自己数,确保写得正好。这个助手会反复练习,让你变得更擅长控制字数。它用一种特别的方法,让你自己学会“数字”的概念,而不是只听老师的指令。这样,你写作文时就能更准确地满足老师的要求,也不用担心写得太多或太少。这就像论文里的LARFT,让模型自己理解“长度”的意思,写出符合要求的内容,既快又准。

Abstract

Despite the strong performance of Large Language Models (LLMs) on complex instruction-following tasks, precise control of output length remains a persistent challenge. Existing methods primarily attempt to enforce length constraints by externally imposing length signals or optimization objectives, while largely overlooking the underlying limitation: the model's intrinsic deficit in length cognition. To address this, we propose LARFT (Length-Aware Reinforcement Fine-Tuning), a training framework that aligns the model's length cognition with its action. Specifically, LARFT integrates length-oriented reinforcement learning with a hindsight length awareness. By transforming on-policy data into hindsight self-awareness tasks where the model learns to identify the actual length of its own generation, LARFT jointly optimizes the model's internal representation of length information and refines its policy to satisfy length constraints, thereby achieving precise and reliable length instruction following. Extensive experiments across four base models demonstrate that LARFT outperforms existing baselines, achieving an average improvement of +20.92 points across three length instruction following benchmarks with only a marginal decline of -1.45 points on four general capability benchmarks.

cs.CL cs.AI