[Paper Review] Exploring Length Generalization in Large Language Models
The paper analyzes how transformer-based LLMs generalize to longer problem instances and shows that finetuning alone struggles, while in-context scratchpad prompting dramatically improves length generalization. It also identifies failure modes and interaction effects among finetuning, prompting, and scratchpad strategies.
The ability to extrapolate from short problem instances to longer ones is an important form of out-of-distribution generalization in reasoning tasks, and is crucial when learning from datasets where longer problem instances are rare. These include theorem proving, solving quantitative mathematics problems, and reading/summarizing novels. In this paper, we run careful empirical studies exploring the length generalization capabilities of transformer-based language models. We first establish that naively finetuning transformers on length generalization tasks shows significant generalization deficiencies independent of model scale. We then show that combining pretrained large language models' in-context learning abilities with scratchpad prompting (asking the model to output solution steps before producing an answer) results in a dramatic improvement in length generalization. We run careful failure analyses on each of the learning modalities and identify common sources of mistakes that highlight opportunities in equipping language models with the ability to generalize to longer problems.
Motivation & Objective
- Define and characterize length generalization in transformer models using parity and variable assignment tasks.
- Assess how finetuning, prompting, and scratchpad methods perform on in-distribution vs. out-of-distribution lengths.
- Identify failure modes and contextual factors that hinder length generalization.
- Investigate whether scratchpad prompting or finetuning can enable extrapolation to longer problem lengths.
Proposed method
- Define length in the context of a deterministic Markov process and study two tasks (parity and boolean variable assignment) that require state tracking.
- Evaluate multiple learning modalities: full finetuning of pretrained decoders, in-context few-shot prompting, and scratchpad (chain-of-thought) reasoning.
- Test combinations (finetuning, prompting, scratchpad) to observe interactions and failure modes.
- Conduct failure analyses focusing on positional encodings, distractors, and end-of-sequence signaling.
- Experiment with scratchpad prompting to assess template-based length generalization on pretrained LLMs.
- Describe how different input length distributions affect in-distribution versus out-of-distribution performance.
Experimental results
Research questions
- RQ1Can transformer models learned via finetuning generalize to longer problem lengths beyond training length?
- RQ2Does in-context learning with scratchpad reasoning improve length generalization compared to finetuning alone?
- RQ3What are the main failure modes that hinder length extrapolation (e.g., positional biases, EOS handling, distractors)?
Key findings
- Finetuning on length generalization tasks yields poor out-of-distribution performance, even with scale.
- Scaling model size and data does not meaningfully improve length generalization under finetuning.
- Scratchpad finetuning shows failure to generalize to longer problems, with distractors identified as a key culprit.
- In-context learning with scratchpad prompts dramatically improves length generalization, enabling templates to extrapolate to longer lengths.
- Few-shot scratchpad prompting can substantially outperform zero-shot scratchpad when base models already perform well on the task (notably parity).
- The effectiveness of combining finetuning, prompting, and scratchpad strategies is task-dependent and can yield mixed results (strong for parity, weaker for variable assignment).
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.