Provably Learning Attention with Queries
Abstract
Lay Summary
Many modern AI models, including LLMs, are built using a neural network architecture called Transformers. These models are often accessed through APIs: users send inputs and receive outputs, without seeing the model’s internal parameters. These parameters determine how the model processes inputs and produces outputs. This raises a natural question: can those parameters be recovered by using the outputs obtained by asking carefully chosen input sequences? We study this question for attention, which is a core component of the Transformer architecture. We show that, for a simple attention model, the answer is yes: there is a direct method that recovers the model’s parameters using a manageable number of queries. We then show that even fewer queries are needed in a common setting where the attention mechanism has a lower-dimensional internal structure. We also prove that the recovery algorithm remains stable and useful when the model’s or API’s answers are slightly noisy. Overall, our results clarify which parts of Transformer models can be identified from behaviour alone, with implications for understanding and preventing model extraction or stealing.