mlsanityData to 7 Oct 2026

Improving Length-Generalization in Transformers via Task Hinting

arXiv 2310.00726 ↗First posted 1 Oct 2023cs.LG cs.AI stat.MLcited by 12

Not on the map. Why?

Abstract (arXiv)

It has been observed in recent years that transformers have problems with length generalization for certain types of reasoning and arithmetic tasks. In particular, the performance of a transformer model trained on tasks (say addition) up to a certain length (e.g., 5 digit numbers) drops sharply when applied to longer instances of the same problem. This work proposes an approach based on task hinting towards addressing length generalization. Our key idea is that while training the model on task-specific data, it is helpful to simultaneously train the model to solve a simpler but related auxiliary task as well. We study the classical sorting problem as a canonical example to evaluate our approach. We design a multitask training framework and show that task hinting significantly improve length generalization. For sorting we show that it is possible to train models on data consisting of sequences having length at most 20, and improve the test accuracy on sequences of length 100 from less than 1% (for standard training) to more than 92% (via task hinting). Our study uncovers several interesting aspects of length generalization. We observe that while several auxiliary tasks may seem natural a priori, their effectiveness in improving length generalization differs dramatically. We further use probing and visualization-based techniques to understand the internal mechanisms via which the model performs the task, and propose a theoretical construction consistent with the observed learning behaviors of the model. Based on our construction, we show that introducing a small number of length dependent parameters into the training procedure can further boost the performance on unseen lengths. Finally, we also show the efficacy of our task hinting based approach beyond sorting, giving hope that these techniques will be applicable in broader contexts.

Key facts. Cited by 12 papers in the map (data through 7 Oct 2026). Builds on 25 of its 32 references that are in the map. First posted on arXiv 1 Oct 2023.

Builds on

25 of 32 references.

References · 25

  1. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  2. 2014Adam: A Method for Stochastic Optimizationcited by 36,960
  3. 2020Language Models are Few-Shot Learnerscited by 32,199
  4. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
  5. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  6. 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
  7. 2016SGDR: Stochastic Gradient Descent with Warm Restartscited by 4,993
  8. 2019ALBERT: A Lite BERT for Self-supervised Learning of Language Representationscited by 2,772
  9. 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,085
  10. 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
  11. 2023Progress measures for grokking via mechanistic interpretabilitycited by 822
  12. 2022PaLI: A Jointly-Scaled Multilingual Language-Image Modelcited by 762
13 more
  1. 2022Emergent World Representations: Exploring a Sequence Model Trained on a Synthetic Taskcited by 417
  2. 2020Multi-Task Learning with Deep Neural Networks: A Surveycited by 374
  3. 2023Emergent Linear Representations in World Models of Self-Supervised Sequence Modelscited by 313
  4. 2023Towards Generalist Biomedical AIcited by 286
  5. 2022Exploring Length Generalization in Large Language Modelscited by 204
  6. 2021Saturated Transformers are Constant-Depth Threshold Circuitscited by 137
  7. 2022Unveiling Transformers with LEGO: a synthetic reasoning taskcited by 105
  8. 2023Goat: Fine-tuned LLaMA Outperforms GPT-4 on Arithmetic Taskscited by 84
  9. 2023Generalization on the Unseen, Logic Reasoning and Degree Curriculumcited by 73
  10. 2023Auto-Regressive Next-Token Predictors are Universal Learnerscited by 65
  11. 2023Length Generalization in Arithmetic Transformerscited by 64
  12. 2020The EOS Decision and Length Extrapolationcited by 46
  13. 2019Location Attention for Extrapolation to Longer Sequencescited by 33

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2023: 3; 2024: 4; 2025: 4; 2026: 1.

12 papers.