Transformers Handle Endogeneity in In-Context Linear Regression

Haodong Liang, Krishnakumar Balasubramanian, Lifeng Lai
10/1/2024

No official code found. Best implementation: harris-liang/IVTransformer (1 star, MIT, last commit 2025-03-21).

Abstract

We explore the capability of transformers to address endogeneity in in-context linear regression. Our main finding is that transformers inherently possess a mechanism to handle endogeneity effectively using instrumental variables (IV). First, we demonstrate that the transformer architecture can emulate a gradient-based bi-level optimization procedure that converges to the widely used two-stage least squares $(\textsf{2SLS})$ solution at an exponential rate. Next, we propose an in-context pretraining scheme and provide theoretical guarantees showing that the global minimizer of the pre-training loss achieves a small excess loss. Our extensive experiments validate these theoretical findings, showing that the trained transformer provides more robust and reliable in-context predictions and coefficient estimates than the $\textsf{2SLS}$ method, in the presence of endogeneity.

View on arXivView PDF

Code Implementations(1)

MIT

Official implementations of experiments in paper "Transformers Handle Endogeneity in In-Context Linear Regression"

11Python, Jupyter NotebookMar 19, 20251 years agoMIT

Similar Papers

Cite this paper

@article{liang2024transformers,
  title  = {Transformers Handle Endogeneity in In-Context Linear Regression},
  author = {Haodong Liang and Krishnakumar Balasubramanian and Lifeng Lai},
  year   = {2024},
  eprint = {2410.01265},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2410.01265},
  journal = {ICLR 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.01265.svg)](https://codeofpaper.com/paper/2410.01265)

Discussion