arXiv:2511.01807cs.CLcs.AI2025-11被引 5

不重训练就能精准控制大模型输出长度,靠的是提示词里的规划和计数设计。

Plan-and-Write: Structure-Guided Length Control for LLMs without Model Retraining

  • 在提示词中加入规划与字数跟踪机制,引导模型遵守长度限制。
  • 在6个主流模型上测试,短中等长度控制精度提升最高达37.6%。
  • 无需重训练,适合生产环境快速部署,保持输出质量不下降。

大语言模型的长度控制是一个关键但未被充分解决的问题,广泛应用于语音交互需简洁回复、研究摘要需详尽输出等场景。现有方法如正则化DPO、长度指令微调及工具增强法,通常需要昂贵的模型重训练或复杂的推理时工具链。本文提出一种无需重训练的提示工程方法,通过结构化引导实现精确长度控制。该方法在提示词中嵌入刻意规划与字数统计机制,促使模型主动追踪并遵守指定长度约束。在六个先进LLM上的全面评估显示,相比标准提示,该方法在文档摘要任务中显著提升了多个模型的长度保真度,尤其在短至中等长度约束下表现突出。不同模型架构效果各异,部分模型长度遵循度提升最高达37.6%。质量评估进一步表明,该方法在保持或提升输出质量方面优于标准提示技术。本方案为需要精确长度控制的应用提供了即插即用的解决方案,特别适用于因成本或流程限制无法重训练模型的生产环境。

原文摘要 · Abstract (English)

Length control in Large Language Models (LLMs) is a crucial but under-addressed challenge, with applications ranging from voice interfaces requiring concise responses to research summaries needing comprehensive outputs. Current approaches to length control, including Regularized DPO, Length-Instruction Fine Tuning, and tool-augmented methods, typically require expensive model retraining or complex inference-time tooling. This paper presents a prompt engineering methodology that enables precise length control without model retraining. Our structure-guided approach implements deliberate planning and word counting mechanisms within the prompt, encouraging the model to carefully track and adhere to specified length constraints. Comprehensive evaluations across six state-of-the-art LLMs demonstrate that our method significantly improves length fidelity for several models compared to standard prompting when applied to document summarization tasks, particularly for shorter-to-medium length constraints. The proposed technique shows varying benefits across different model architectures, with some models demonstrating up to 37.6% improvement in length adherence. Quality evaluations further reveal that our approach maintains or enhances overall output quality compared to standard prompting techniques. Our approach provides an immediately deployable solution for applications requiring precise length control, particularly valuable for production environments where model retraining is impractical or cost-prohibitive.

长度控制提示工程零样本

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