atlas

Research map / Large language models / Language, safety and interpretability

Hansel: Output Length Controlling Framework for Large Language Models

AAAI 2025 · Large language models › Language, safety and interpretability · approach: LLM pruning and scaling data · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes Hansel, which finetunes LLMs on data augmented with periodically inserted hidden special tokens that encode remaining output word count, giving precise and extrapolable output length control.

Problem

LLMs cannot precisely control output length; prior length-control methods need pretraining or architecture changes, and prompt-based finetuning generalizes poorly to target lengths unseen in training.

Approach

Augment finetuning targets with special tokens |x><y| inserted every Delta words that encode the remaining number of words, plus a residual delta with label masking to avoid abrupt termination; the method needs only finetuning and no architecture change.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
use periodic hidden length tokens instead of prompt-only length finetuningPhi-2 length control · DailyDialog, MultiWOZ, XSum, CNN/DMMAE: DailyDialog: 0.24 -> 0.09; MultiWOZ: 0.11 -> 0.05; XSum: 0.47 -> 0.26; CNN/DM: 1.56 -> 0.39Helped
use periodic hidden length tokens instead of prompt-only length finetuningPhi-2 length control · DailyDialogROUGE-L: 0.27 -> 0.33Helped
use periodic hidden length tokens instead of prompt-only length finetuningPhi-2 length control · MultiWOZROUGE-L: 0.34 -> 0.34No clear effect
use periodic hidden length tokens instead of prompt-only length finetuningPhi-2 length control · XSum, CNN/DMROUGE-L: XSum: 0.33 -> 0.34; CNN/DM: 0.30 -> 0.31Helped
use periodic hidden length tokens instead of prompt-only length finetuningPhi-2 length control · DailyDialog, MultiWOZ, XSum, CNN/DMG-Eval: DailyDialog: 3.41 -> 3.55; MultiWOZ: 3.55 -> 3.54; XSum: 3.22 -> 3.26; CNN/DM: 3.82 -> 3.86Mixed
use periodic hidden length tokens instead of prompt-only length finetuningPhi-2 length control · target length 130 words across four datasetsMAE: DailyDialog: 18.51 -> 2.07; MultiWOZ: 23.85 -> 7.47; XSum: 10.37 -> 1.02; CNN/DM: 7.38 -> 1.00Helped
set residual length δ to 0 rather than 1 (ablation)Hansel · DailyDialogMAE: 0.09 -> 0.08Helped
increase residual length δ (ablation)Hansel · DailyDialog, MultiWOZ, XSum, CNN/DMMAE: DailyDialog (Δ=20): 0.08, 0.09, 0.12, 0.16; MultiWOZ (Δ=20): 0.05, 0.05, 0.07, 0.09; XSum (Δ=20): 0.19, 0.26, 0.32, 0.38Hurt
use nonzero residual length δ to avoid ending immediately at the zero token (ablation)Hansel · dialogue generationabrupt terminationHelped
vary stride Δ and residual length δ (ablation)Hansel · DailyDialog, MultiWOZ, XSum, CNN/DMROUGE-L: DailyDialog: 0.32–0.33; MultiWOZ: 0.34; XSum: 0.34; CNN/DM: 0.33–0.34No clear effect
train for more than 2 epochs (ablation)Hansel · four datasetsMAE and ROUGE-LHurt
add 50 Hansel instruction samples for cross-task length control (ablation)Phi-2 cross-task models · summarization and dialogue (40-word targets)MAE: 13.53 to 2.62; 31.50 to 0.93Helped

Surprising findings

Limitations

Experimental setup

Datasets: CNN/DM XSum DailyDialog MultiWOZ WMT19 de-en

Benchmarks: CNN/DM XSum DailyDialog MultiWOZ

Metrics: MAE of output length ROUGE-L ROUGE-1 ROUGE-2 G-Eval

Baselines: vanilla finetuning Gretel (prompt-based length finetuning)

Builds on: Chain-of-thought prompting AdamW Rotary positional embedding

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy