← Lab /AI/ML

Multi-head attention can be exactly learned with O(H·d2) value queries

The authors assert they can recover all multi-head attention parameters up to permutation using a finite number of queries

AI/ML arXiv 4 Aug 2026 Method Theory

Published as “Provably Learning Multi-Head Attention with Queries”

Why it matters

The results imply that multi-head attention parameters can be extracted from black-box APIs in principle, but practical attacks require oracle outputs with far higher precision than standard 64-bit floating point.

Summary

The paper shows that the canonical parameters of a multi-head softmax attention layer can be recovered exactly (up to permutation) from scalar final-token outputs using a randomized non-adaptive query scheme that needs exactly 4Hd^2 - 2H + 1 value queries of length at most 2H + 1 when the head count H is known. The theoretical claim is supported by proofs and synthetic experiments that succeed with high-precision oracle responses, but the method is highly sensitive to floating-point rounding, failing on most runs with IEEE-754 double precision for larger models.

What they found 1

  1. Exact query complexity for known head count

    “When H is known, it uses exactly 4Hd2 -2H +1 value queries of maximum length 2H + 1.”

Caveats 4

  • The algorithm returns all H heads with Eparam < 10-2 in 99/100 runs for (d, H) = (3, 2), 1/100 for (3, 4), and 0/100 for (3, 8) and (8, 4).
  • For approximate outputs, we give conditions under which queries distinguish the heads and reconstruction is well conditioned. Sufficiently small output errors then yield proportional parameter errors with a model- and query-dependent constant.
  • A two-head construction rules out a uniform bound over all identifiable models.
  • Thus, the failures arise from oracle rounding and persist despite high-precision offline computation.

What’s new here 4

  • Eliminates the need for orthogonal-subspace assumptions or known subspace bases.
  • Recovers a canonical representation by merging heads with identical weight matrices.
  • Uses rational interpolation of repeated-token queries to separate head contributions.
  • Extends the recovery to a one-layer Transformer with a bias-free ReLU feed-forward network.