Contextual Counting: A Mechanistic Study of Transformers on a Quantitative Task

Siavash Golkar, Alberto Bietti, Mariel Pettee, Michael Eickenberg, Miles Cranmer +10 more
5/30/2024
cs.LGcs.AIstat.ML

No confident code implementation found for this paper.

Abstract

Transformers have revolutionized machine learning across diverse domains, yet understanding their behavior remains crucial, particularly in high-stakes applications. This paper introduces the contextual counting task, a novel toy problem aimed at enhancing our understanding of Transformers in quantitative and scientific contexts. This task requires precise localization and computation within datasets, akin to object detection or region-based scientific analysis. We present theoretical and empirical analysis using both causal and non-causal Transformer architectures, investigating the influence of various positional encodings on performance and interpretability. In particular, we find that causal attention is much better suited for the task, and that no positional embeddings lead to the best accuracy, though rotary embeddings are competitive and easier to train. We also show that out of distribution performance is tightly linked to which tokens it uses as a bias term.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{golkar2024contextual,
  title  = {Contextual Counting: A Mechanistic Study of Transformers on a Quantitative Task},
  author = {Siavash Golkar and Alberto Bietti and Mariel Pettee and Michael Eickenberg and Miles Cranmer and Keiya Hirashima and Geraud Krawezik and Nicholas Lourie and Michael McCabe and Rudy Morel and Ruben Ohana and Liam Holden Parker and Bruno Régaldo-Saint Blancard and Kyunghyun Cho and Shirley Ho},
  year   = {2024},
  eprint = {2406.02585},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2406.02585v1}
}

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/2406.02585.svg)](https://codeofpaper.com/paper/2406.02585)

Discussion