Reproduce “Hansel: Output Length Controlling Framework for Large Language Models” on OpenResearch
Turn your favorite coding agents into research agents that review literature, develop hypotheses, and run experiments.
Universal app for Apple silicon and Intel. Requires macOS 11 or later.
About this paper
Seoha Song, Junhyun Lee, Hyeonmok Ko
Samsung Research developed Hansel, a finetuning framework that enables Large Language Models to precisely control output length by augmenting training data with special tokens indicating remaining word count. This approach significantly reduces Mean Absolute Error in length control and demonstrates strong generalization to arbitrary, unseen target lengths while preserving output quality across various LLM architectures.
Key insights
- LLMs, not being intrinsic counters, can effectively gain precise length control by explicitly feeding them real-time remaining length information via periodically injected special tokens during finetuning.
- A simple dataset augmentation strategy with these special tokens enables LLMs to generalize length control to arbitrary target lengths, including those far outside the training distribution.
- Careful handling of the end-of-length token (`|0⟩`) through residual word training and label masking is critical to prevent abrupt and incomplete sentence termination.
Summary by alphaXiv.
Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.