TL;DR
Getting large language models (LLMs) to reliably follow length constraints (e.g., "summarize in less than 100 words") remains surprisingly difficult and error-prone. This paper proposes a framework combining a Standard Prompt Extractor (SPE), rule-based reward models, and PPO-based reinforcement learning to align LLM generation with flexible length constraints without degrading summary quality.
What Problem Does This Paper Address?
In real-world applications, users frequently request texts of specific lengths—such as concise summaries, fixed-length snippets, or minimum-length essays. Furthermore, controlling sequence length directly reins in the latency and computational cost of autoregressive generation.
Standard supervised fine-tuning (SFT) often causes length controllability to compromise downstream generation quality. Meanwhile, prompting alone or standard RLHF struggles with diverse, precise constraints (e.g., "equal to", "less than", "more than", or "between $L_L$ and $L_U$"). Previous non-prompt length control techniques (like length embeddings or modified attention heads) require custom architectures that do not naturally suit modern decoder-only LLMs.
Methods
The proposed framework introduces a modular pipeline to handle diverse user instructions and align generation length:
User Prompt ──┬──> [Standard Prompt Extractor (SPE)] ──> Standard Control Prompt (SCP) ──┬──> [Rule-Based Reward Model]
│ │ │
└──> [Autoregressive LLM (Actor)] ──> Generated Sequence ───────┴───────────────┴──> PPO / Re-ranking
- Standard Prompt Extractor (SPE): User inputs express constraints in varied natural language (e.g., "give me a summary with less than 80 tokens"). The authors train an SPE (comparing a generative GPT-2 small and a discriminative BERT model with classification heads) to parse inputs into a Standard Control Prompt (SCP) containing explicit boundary values ($L_t$, $L_L$, $L_U$).
- Rule-Based Reward Formulation: Rather than using a noisy, learned reward model for length, the authors construct closed-form, deterministic reward functions based on ReLU penalties:
- More than $L_t$: $-\text{ReLU}(L_t - L_g)$
- Less than $L_t$: $-\text{ReLU}(-L_t + L_g)$
- Equal to $L_t$: $-|L_t - L_g|$
- Between $L_L$ and $L_U$: $-(\text{ReLU}(L_L - L_g) + \text{ReLU}(L_g - L_U))$
- PPO Reinforcement Fine-Tuning: The generator policy is trained using Proximal Policy Optimization (PPO). Rewards are assigned at sequence termination. Crucially, the objective augments PPO with a supervised fine-tuning (SFT) loss term ($L_A(\theta) = L^{\text{CLIP}+S+KL}(\theta) + \lambda L_{\text{SFT}}(\theta)$) on labelled summarization data to prevent the policy from collapsing summary quality.
- Sample Filtering (Inference Re-ranking): During inference, $N$ candidate sequences are generated via beam sampling, and the candidate with the highest reward under the rule-based model is chosen as the final output.
Datasets
The authors evaluated their framework on two standard document summarization benchmarks:
- CNN/DailyMail (CNNDM): 287,226 training, 13,368 validation, and 11,490 test articles.
- New York Times (NYT): 100,834 training and 9,706 test articles.
To simulate natural control instructions, the authors designed templates across five constraint categories (equal to, less than, more than, between, and none) and augmented the datasets by randomly sampling target lengths between 50 and 150 tokens.
Key Insights and Ideas
- Rule-based rewards beat trained reward models: Deterministic reward calculations achieved zero scoring error and negligible latency, outperforming BERT-large and GPT-medium trainable reward models in length control precision during RL training.
- Discriminative parsing is near-perfect: The discriminative BERT extractor achieved 100.0% accuracy on extracting bounds and generalized completely (100.0% accuracy) to held-out, unseen prompt templates.
- Directional length asymmetry: Generating summaries longer than the dataset mean is significantly harder for LLMs than generating shorter ones. On CNNDM (average summary length: 71 tokens), baseline prompt error for "more than" was 41.9 tokens off-target, compared to only 0.5 tokens for "less than". RL with sample filtering slashed the "more than" error from 41.9 down to 6.0 tokens.
- SFT loss acts as an anchor: Preserving an SFT auxiliary loss ($\lambda > 0$) during PPO training prevented policy degradation on downstream summarization quality metrics (ROUGE and BERTScore).
Key Results
Across three base model sizes (GPT-Small 124M, GPT-Medium 355M, and GPT-Large 774M):
- Single-Type ("Equal to") Control:
- On CNNDM (GPT-Small), baseline prompt control error dropped from 11.62 tokens down to 7.81 with RL, and to 6.22 tokens when combining RL and sample filtering (
Prompt+RL+filter). - On NYT (GPT-Small), error decreased from 13.33 to 9.55 tokens (
Prompt+RL+filter). - Multi-Type Control:
- On CNNDM (GPT-Small), average error across all four constraint types fell from 18.16 (baseline) to 7.06 tokens (
Prompt+RL+filter). - On NYT (GPT-Medium), error dropped from 13.17 to 3.65 tokens.
- Summary Quality Retention: Across all experimental conditions, BERTScore dropped by less than 1.0 point, and ROUGE metrics remained essentially stable, proving that the length improvements did not come at the expense of summary content.
- Out-of-Sample Generalization: When evaluated on unseen prompt phrasing templates, the tuned GPT-S model maintained low error (8.0 vs. 7.8 in-sample error for single-type control on CNNDM).
Limitations and Future Work
- Parameter Updates Required: The approach updates base model weights, creating computational overhead during training and potential risks of catastrophic forgetting for general tasks.
- Exploration of Parameter-Efficient Alternatives: The authors suggest exploring parameter-efficient tuning (e.g., adapters or LoRA) and in-context learning to achieve similar control without modifying full model checkpoints.
- Extension to Other Format Constraints: The authors propose extending this architecture to other rule-evaluable generation constraints, such as poetic forms or specific rhyme schemes.
Summary updated