Concise One-Layer Transformers Can Perform Dictionary Lookup
Organizations: Ume˚a University · Yale University
Abstract
While transformers have proven enormously successful in a range of tasks, their fundamental properties as models of computation are not well understood. This paper contributes to the study of the expressive capacity of transformers, focusing on their ability to perform the fundamental computational task of looking up a key in a dictionary. We prove that concise 1-layer transformers (i.e., with a polylog bound on the product of the number of heads, the embedding dimension, and precision) can perform this task when the key and value are represented in the same input position, but, under the -bit rational precision assumption, cannot perform it when the keys and values are represented in different input positions. Concise 2-layer transformers can perform the task in the second case. Experimentally, we find an alignment between what we have proven can be computed by concise transformers and what can be practically learned.
Figures & tables
| Initialization | ||||||||
|---|---|---|---|---|---|---|---|---|
| random | 1.25 | 0.37 | 61.73 | 1.05 | 99.77 | 0.04 | 99.94 | 0.03 |
| custom | 1.84 | 1.46 | 99.86 | 0.10 | 99.99 | 0.00 | 99.99 | 0.02 |
| 10 | 20 | 13.64 | 0.30 | 18.07 | 0.55 | 21.25 | 0.17 | 21.71 | 0.09 |
|---|---|---|---|---|---|---|---|---|---|
| 20 | 200 | 3.97 | 0.30 | 3.43 | 0.25 | 3.62 | 0.12 | 4.92 | 0.16 |
| 100 | 1000 | 0.45 | 0.04 | 0.57 | 0.04 | 0.58 | 0.03 | 0.47 | 0.03 |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
Transformer
Transformers are neural architectures that use attention to model relationships among sequence elements in language, vision, and scientific data.
See all 544 papers