mlsanityData to 14 Oct 2026

Precise Length Control in Large Language Models

arXiv 2412.11937 ↗First posted 16 Dec 2024cs.CLcited by 13

Not on the map. Why?

Abstract (arXiv)

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.

Key facts. Cited by 13 papers in the map (data through 14 Oct 2026). Builds on 4 of its 7 references that are in the map. First posted on arXiv 16 Dec 2024.

Builds on

4 of 7 references.

References · 4

  1. 2019BERTScore: Evaluating Text Generation with BERTcited by 5,512
  2. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
  3. 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,234
  4. 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 327

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 9; 2026: 4.

13 papers.

Sort:

By area: