cs.LGAug 4, 2026

Attention-based representations for multi-task computation

Authors: Daniel HsuMingyue Xu

Organizations: Columbia University · Purdue University

Abstract

Multi-head attention layers produce vector representations that support multiple downstream tasks. We establish bounds on the number of heads required in two simple and concrete multi-task scenarios. In the first scenario, a vector representation is sought so that linear predictors can compute both the smallest and largest numbers in a given list. In this case, it is known two attention heads with small embedding dimension and bit precision level suffice. We prove that a single attention head requires exponentially higher embedding dimension or precision level. In the second scenario, a vector representation is sought so that a polynomial threshold function can compute the XOR of a given string of nn bits. This scenario is analogous to the first one for n=2n=2, since XOR is readily computed by a linear function using a vector representation that encodes both the AND and the OR of the two bits. We observe that nn-bit XOR requires the product of the number of heads and the polynomial degree to be at least nn, and we construct multi-head attention layers that match this lower bound. These results generalize to arbitrary (symmetric) Boolean functions, where the bound is given in terms of the threshold degree.

Explore similar work

Sep 3, 2026cs.CC

The Head Complexity of Boolean Functions in Single-Layer Attention

What can a single layer of self-attention compute? We study head complexity: the minimum number of attention heads required to compute a function in a one-layer attention-only model. We establish an exact hierarchy under this measure: kk heads compute kk-bit parity but cannot compute (k+1)(k+1)-bit parity. The lower bound is unconditional in the two resources a transformer might otherwise exploit; it holds at unbounded embedding dimension and unbounded numerical precision. The proof rests on an alternating-sum obstruction: after clearing the softmax denominators, every monomial in the resulting decision polynomial omits at least one of the k+1k+1 input bits, forcing its correlation with parity to vanish. The same obstruction yields lower bounds for related tasks, including the well-studied multi-hop induction-head task. We also establish compactness bounds for embedding dimension and numerical precision. Specifically, a compactness theorem shows that any function computable at all can be computed with embedding dimension and precision bounded by the discrete data of the task, namely, head count, alphabet size, and length. Thus, potentially unbounded dimension or precision provably cannot substitute for heads. Finally, we derive nearly matching universal bounds for general binary functions: 2n2^n heads suffice to compute every nn-bit binary function, with one head per monomial in its multilinear expansion, while a counting argument shows almost all such functions require Ω(2n/n2)Ω(2^n/n^2) heads. This lower bound matches the upper bound to within a poly(n)\operatorname{poly}(n) factor, even when dimension and precision are unbounded. Together, these results characterize head requirements for Boolean computation in this model.
Rajmohan Rajaraman, Ravi Sundaram, Amanuel Tesfaye
Aug 4, 2026cs.LG

Provably Learning Multi-Head Attention with Queries

We study the problem of learning multi-head softmax attention from black-box input-output access. The learner may query arbitrary real-valued token sequences and observe only the scalar output at the final token. Recent work gives an algorithm using O(d2)O(d^2) value queries to recover the single-head parameters (W,v)(W,v). For multiple heads, the same work establishes identifiability under the assumption that the heads occupy pairwise orthogonal subspaces. Applying the single-head recovery algorithm separately to the heads additionally requires bases for these subspaces to be known. We recover a canonical representation by merging heads with the same WhW_h, summing their corresponding vhv_h, and discarding a merged head when this sum is zero, without these subspace assumptions. By varying the number of copies of a token, our algorithm obtains samples of a rational function whose interpolation separates the canonical heads. Additional queries formed by adding selected token vectors then match the same head across different queries. When the oracle outputs and all subsequent computations are exact, the learner chooses its query vectors at random and recovers the canonical pairs {(Wh,vh):h[H]}\{(W_h,v_h):h\in[H]\} up to permutation with probability one. When HH is known, it uses exactly 4Hd22H+14Hd^2-2H+1 value queries of maximum length 2H+12H+1. If only a known upper bound H0H_0 is available, the algorithm uses 4H0d22H0+14H_0d^2-2H_0+1 value queries of maximum length 2H0+12H_0+1. For approximate oracle outputs, we give conditions under which the parameter error is at most a model- and query-dependent constant multiple of the output error. Finally, we extend our result to a one-layer Transformer with multi-head attention followed by a bias-free ReLU feed-forward network. Under additional conditions, we recover a functionally equivalent Transformer without relying on a separate algorithm for learning the feed-forward network.
Sunyeop Kim, Insung Kim, Jian Guo
May 12, 2026cs.LG

Lower bounds for one-layer transformers that compute parity

This note shows that no self-attention layer post-processed by a rational function can sign-represent the parity function unless the product of the number of heads and the degree of the post-processing function grows linearly with the input length. Combining this lower bound with rational approximation of ReLU networks yields a margin-dependent extension for self-attention layers post-processed by ReLU networks.
Daniel Hsu