Conic Certification of Transformer Attention
Organizations: Department of Mathematical and Computational Sciences University of Toronto, Canada.
Abstract
Attention is the computational core of large language models, yet the verifiers that bound how far an attention head's output can move under input perturbations give no guarantee on how loose their bounds are. A weak certificate therefore cannot be told apart from a fragile model. We develop a conic programming theory of attention certification that supplies this guarantee. We prove that the difficulty lies not in the softmax but in the bilinear interaction of a varying query with the keys. This interaction makes certification NP-hard over boxes and inapproximable once the attention logits can move by a constant amount. A fixed query or listed token substitutions, by contrast, make the exact worst case efficiently computable. An exponential cone moment relaxation then certifies a head with an error bounded quadratically in the perturbation radius by computable quantities, an order that cannot be improved. We also show that relaxations that treat a network one operation at a time, linear bound propagation among them, pay on second-order terms a sum of per-operation maxima instead of one coupled maximum. Computational results on GPT-2 indicate that the theory carries over to a trained model. Against exact worst cases with the query fixed, the certificate attains the predicted second-order accuracy. It is tighter than linear bound propagation on every head, and the looseness of bound propagation tracks the predicted per-operation excess.
Figures & tables
| symbol | meaning | order |
|---|---|---|
| score width, | ||
| secant width, | ||
| dispersion of the midpoint pattern, margin of the dominant key | ||
| attention intervals | ||
| weighted secant slack, exact secant gap ( 16 ) | ||
| directional value radius and width | , |
| setting | status | result |
|---|---|---|
| scores in a box, values fixed | exact, | Remark 1 |
| fixed query, boxes, zonotopes, point hulls | exact, polynomial | Thm. 7 (ii) |
| fixed query, ellipsoids | exact, polynomial | Thm. 7 (iii) |
| listed candidates, any query | exact, polynomial | Remark 3 |
| varying query, two tokens in boxes | NP-hard | Thm. 5 |
| same, score range in | inapproximable within of the range | Thm. 6 |
| method | random | ambiguous | margin | rank-one |
|---|---|---|---|---|
| interval pattern bounds | ||||
| first order, | ||||
| level one, unit diagonal | ||||
| level one, |
| units | median | median relative gap | range-norm. gap | share of units | |||
|---|---|---|---|---|---|---|---|
| certificate | first order | certificate | |||||
| certificate | first order | share of units | ||
|---|---|---|---|---|
| median [IQR] | max | median | within | |
| slope | ||||
| query | IBP | CROWN | -CROWN | first | certifi- | ratio to cert. | ||
|---|---|---|---|---|---|---|---|---|
| order | cate | CROWN | ||||||
| fixed | ||||||||
| varying | ||||||||
Transformer Attention
Transformer attention lets models relate tokens by weighting information from other positions, enabling context-dependent sequence and multimodal processing.
See all 331 papers