paper-with-me

홈 › Papers

How Transformers Learn Causal Structure with Gradient Descent

2024-02-22 · Eshaan Nichani, Alex Damian, Jason D. Lee

The incredible success of transformers on sequence modeling tasks can be largely attributed to the self-attention mechanism, which allows information to be transferred between different parts of a sequence. Self-attention allows transformers to encode causal structure which makes them particularly suitable for sequence modeling. However, the process by which transformers learn such causal structure via gradient-based training algorithms remains poorly understood. To better understand this process, we introduce an in-context learning task that requires learning latent causal structure. We prove that gradient descent on a simplified two-layer transformer learns to solve this task by encoding the latent causal graph in the first attention layer. The key insight of our proof is that the gradient of the attention matrix encodes the mutual information between tokens. As a consequence of the data processing inequality, the largest entries of this gradient correspond to edges in the latent causal graph. As a special case, when the sequences are generated from in-context Markov chains, we prove that transformers learn an induction head (Olsson et al., 2022). We confirm our theoretical findings by showing that transformers trained on our in-context learning task are able to recover a wide variety of causal structures.

📄 PDF Abstract BibTeX arXiv:2402.14735

Code (1)

eshnich/transformers-learn-causal-structure 공식 구현 jax

Tasks

In-Context Learning

Similar Papers 제목 키워드 기반

Transformers Learn Latent Mixture Models In-Context via Mirror Descent

2026-04-12 · Francesco D'Angelo, Nicolas Flammarion arxiv

Sequence modelling requires determining which past tokens are causally relevant from the context and their importance: a process inherent to the attention layers in transformers, yet whose underlying learned mechanisms r…

Towards Understanding the Universality of Transformers for Next-Token Prediction

2024-10-03 · Michael E. Sander, Gabriel Peyré

Causal Transformers are trained to predict the next token for a given context. While it is widely accepted that self-attention is crucial for encoding the causal structure of sequences, the precise underlying mechanism b…

A Granger-Causal Perspective on Gradient Descent with Application to Pruning

2024-12-04 · Aditya Shah, Aditya Challa, Sravan Danda, Archana Mathur 외

Stochastic Gradient Descent (SGD) is the main approach to optimizing neural networks. Several generalization properties of deep networks, such as convergence to a flatter minima, are believed to arise from SGD. This arti…

Transformers learn to implement preconditioned gradient descent for in-context learning

2023-09-21 · NeurIPS 2023 11

Motivated by the striking ability of transformers for in-context learning, several works demonstrate that transformers can implement algorithms like gradient descent. By a careful construction of weights, these works sho…

Transformers learn in-context by gradient descent

2022-12-15 · Johannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento 외

At present, the mechanisms of in-context learning in Transformers are not well understood and remain mostly an intuition. In this paper, we suggest that training Transformers on auto-regressive objectives is closely rela…

In-Context LearningMeta-Learningregression