Learning Syntax Without Planting Trees: Understanding When and Why Transformers Generalize Hierarchically

  • 2024-04-25 08:10:29
  • Kabir Ahuja, Vidhisha Balachandran, Madhur Panwar, Tianxing He, Noah A. Smith, Navin Goyal, Yulia Tsvetkov
  • 0

Abstract

Transformers trained on natural language data have been shown to learn itshierarchical structure and generalize to sentences with unseen syntacticstructures without explicitly encoding any structural bias. In this work, weinvestigate sources of inductive bias in transformer models and their trainingthat could cause such generalization behavior to emerge. We extensivelyexperiment with transformer models trained on multiple synthetic datasets andwith different training objectives and show that while other objectives e.g.sequence-to-sequence modeling, prefix language modeling, often failed to leadto hierarchical generalization, models trained with the language modelingobjective consistently learned to generalize hierarchically. We then conductpruning experiments to study how transformers trained with the languagemodeling objective encode hierarchical structure. When pruned, we find jointexistence of subnetworks within the model with different generalizationbehaviors (subnetworks corresponding to hierarchical structure and linearorder). Finally, we take a Bayesian perspective to further uncovertransformers' preference for hierarchical generalization: We establish acorrelation between whether transformers generalize hierarchically on a datasetand whether the simplest explanation of that dataset is provided by ahierarchical grammar compared to regular grammars exhibiting lineargeneralization.

 

Quick Read (beta)

loading the full paper ...