ImageNet classification with deep convolutional neural networks
Alex Krizhevsky, Ilya Sutskever et al.
19
Citations
0
Influential Citations
Natural Language Processing Journal
Venue
2024
Year
Large Language Models (LLMs) are increasingly used in production systems, powering applications such as chatbots, summarization, and question answering. Despite their success, controlling the length of their response remains a significant challenge, particularly for tasks requiring structured outputs or specific levels of detail. In this work, we propose a method to adapt pre-trained decoder-only LLMs for precise control of response length. Our approach incorporates a secondary length-difference positional encoding (LDPE) into the input embeddings, which counts down to a user-set response termination length. Fine-tuning with LDPE allows the model to learn to terminate responses coherently at the desired length, achieving mean token errors of less than 3 tokens. We also introduce Max New Tokens++, an extension that enables flexible upper-bound length control, rather than an exact target. Experimental results on tasks such as question answering and document summarization demonstrate that our method enables precise length control without compromising response quality.
Controlling the length of LLM responses is a critical but under-addressed challenge in production AI systems. Applications like chatbots, summarization, and question answering often require outputs of a specific length—whether for readability, formatting constraints, or user preferences. Existing methods either rely on post-hoc truncation, which can cut off coherent responses, or require complex architectural changes. This paper tackles the problem head-on by introducing a simple yet effective fine-tuning approach that gives practitioners precise control over response length without degrading quality.
The significance lies in its practicality: the method works with pre-trained decoder-only LLMs, requires only fine-tuning, and achieves mean token errors under 3 tokens. This level of precision is a major step forward for deploying LLMs in real-world applications where output length is a hard requirement.
The paper reports mean token errors of less than 3 tokens for exact length control, which is a dramatic improvement over baseline methods that often deviate by tens of tokens. For upper-bound control via Max New Tokens++, the model successfully respects the maximum while maintaining response coherence. Importantly, the authors show that response quality—measured by standard metrics like ROUGE for summarization and accuracy for QA—does not degrade compared to models without length control. This suggests that LDPE enables length precision without forcing the model to sacrifice content quality.
This work addresses a practical bottleneck in LLM deployment: the inability to reliably control output length. By providing a lightweight fine-tuning method that works with existing models, it lowers the barrier for integrating length-controlled generation into production pipelines. The introduction of Max New Tokens++ further enhances flexibility, making the approach suitable for scenarios where exact length is less critical than an upper bound. As LLMs continue to be embedded in user-facing applications, precise length control will become increasingly important for user experience, system constraints, and regulatory compliance. This paper provides a solid foundation for future work on controllable generation.
Alex Krizhevsky, Ilya Sutskever et al.
Ashish Vaswani, Noam Shazeer et al.
Douglas M. Bates, Martin Mächler et al.
Diederik P. Kingma, Jimmy Ba