Table of Contents
Fetching ...

Can LLMs Track Their Output Length? A Dynamic Feedback Mechanism for Precise Length Regulation

Meiman Xiao, Ante Wang, Qingguo Hu, Zhongjian Miao, Huangjun Shen, Longyue Wang, Weihua Luo, Jinsong Su

TL;DR

Precise control of output length in LLMs remains challenging. The authors propose a dynamic length feedback mechanism that intermittently inserts a length counter during generation, enabling adaptive adjustments toward target lengths in tokens, words, or sentences without additional training. Empirically, training-free feedback improves length adherence while preserving quality across summarization, biographies, and long-form QA; supervised fine-tuning with feedback further enhances generalization and training efficiency. The approach outperforms prior multi-stage methods in both efficiency and versatility, and suggests a path toward robust controllability of LLM outputs across diverse length constraints.

Abstract

Precisely controlling the length of generated text is a common requirement in real-world applications. However, despite significant advancements in following human instructions, Large Language Models (LLMs) still struggle with this task. In this work, we demonstrate that LLMs often fail to accurately measure input text length, leading to poor adherence to length constraints. To address this issue, we propose a novel length regulation approach that incorporates dynamic length feedback during generation, enabling adaptive adjustments to meet target lengths. Experiments on summarization and biography tasks show our training-free approach significantly improves precision in achieving target token, word, or sentence counts without compromising quality. Additionally, we demonstrate that further supervised fine-tuning allows our method to generalize effectively to broader text-generation tasks.

Can LLMs Track Their Output Length? A Dynamic Feedback Mechanism for Precise Length Regulation

TL;DR

Precise control of output length in LLMs remains challenging. The authors propose a dynamic length feedback mechanism that intermittently inserts a length counter during generation, enabling adaptive adjustments toward target lengths in tokens, words, or sentences without additional training. Empirically, training-free feedback improves length adherence while preserving quality across summarization, biographies, and long-form QA; supervised fine-tuning with feedback further enhances generalization and training efficiency. The approach outperforms prior multi-stage methods in both efficiency and versatility, and suggests a path toward robust controllability of LLM outputs across diverse length constraints.

Abstract

Precisely controlling the length of generated text is a common requirement in real-world applications. However, despite significant advancements in following human instructions, Large Language Models (LLMs) still struggle with this task. In this work, we demonstrate that LLMs often fail to accurately measure input text length, leading to poor adherence to length constraints. To address this issue, we propose a novel length regulation approach that incorporates dynamic length feedback during generation, enabling adaptive adjustments to meet target lengths. Experiments on summarization and biography tasks show our training-free approach significantly improves precision in achieving target token, word, or sentence counts without compromising quality. Additionally, we demonstrate that further supervised fine-tuning allows our method to generalize effectively to broader text-generation tasks.
Paper Structure (36 sections, 22 figures, 4 tables, 1 algorithm)

This paper contains 36 sections, 22 figures, 4 tables, 1 algorithm.

Figures (22)

  • Figure 1: A comparison between the conventional prompt-based approach and our feedback-guided approach for controlling text generation length.
  • Figure 2: Mean Absolute Error (MAE) between (1) the estimated and actual generated length, and (2) the generated and user-specified length, across token ranges for (a) Qwen3-4B, (b) Qwen3-8B, or (c) LLaMA-3.1-8B-Instruct.
  • Figure 3: Generated length distributions under varying target lengths on GovReport using Qwen3-8B, comparing Baseline and Feedback at (a) token-level, (b) word-level, and (c) sentence-level granularities. Due to space constraints, please refer to the Appendix \ref{['appendix:train-free']} and \ref{['appendix:train-based']} for results on biographies and other models.
  • Figure 4: Generated length distributions of SFT and SFT+Feedback over varying target lengths on the ELI5 test set.
  • Figure 5: Training dynamics of token-length control performance on the ELI5 task using Qwen3-8B.
  • ...and 17 more figures