about
Counting and Algorithmic Generalization with Transformers (arxiv.org)
1 point by PaulHoule on Oct 23, 2023 | hide | past | pdf | discuss on HN

In plain words: Transformers often fail at counting when numbers get bigger than those seen in training. The study finds two culprits: rescaling each layer's outputs and turning attention scores into percentages; removing both lets a simple transformer count correctly on unseen sizes.

Abstract

Algorithmic generalization in machine learning refers to the ability to learn the underlying algorithm that generates data in a way that generalizes out-of-distribution. This is generally considered a difficult task for most machine learning algorithms. Here, we analyze algorithmic generalization when counting is required, either implicitly or explicitly. We show that standard Transformers are based on architectural decisions that hinder out-of-distribution performance for such tasks. In particular, we discuss the consequences of using layer normalization and of normalizing the attention weights via softmax. With ablation of the problematic operations, we demonstrate that a modified transformer can exhibit a good algorithmic generalization performance on counting while using a very lightweight architecture.

Simon Ouellette, Rolf Pfister, Hansueli Jud
arXiv:2310.08661 · cs.LG · submitted Oct 12, 2023 · updated Jan 12, 2024
abstract · pdf · html · Applied AAAI 2024 reviewer comments. We clarified notation in the main algorithm pseudo-code (alg. 1). Removed superfluous experiments on Universal Transformers which did not yield interesting results and added confusion to the main insights of the paper. The paper is now more concise and straight to the point. Clarified our main contributions

add comment on HN