Stealing part of a production-grade language model
Stealing Part of a Production Language Model
Translation in progress — untranslated text is omitted.
Researchers propose a model-stealing attack against production-grade language models that, using only regular API access, recovers the transformer's embedding projection layer up to symmetry, extracting the full projection matrices of OpenAI ada and babbage for less than $20. The authors claim this is the first attack that can exactly extract information from black-box production models such as ChatGPT and PaLM-2; it exploits the low-rank nature of the model's last layer projecting from the hidden dimension to a higher-dimensional logit space, recovering the hidden dimension and weight matrix through the logprobs and logit bias interfaces. On five OpenAI models, the extracted weights differ from the true weights by less than 7×10⁻⁴; the authors confirm that the hidden dimensions of ada and babbage are 1024 and 2048, respectively, and recover the hidden dimension size of gpt-3.5-turbo for less than $200, estimating that fully extracting its projection matrix would cost less than $2000.
- The architectures and weights of production language models such as GPT-4 and PaLM-2 are secret, but the models themselves are exposed through APIs. The authors ask: how much exact information about a production model can an attacker learn solely through API queries.
- Exploits the low-rank structure of the transformer's final layer, which projects from a low-dimensional hidden space to high-dimensional logits: first reconstruct the full logit vector via the top-K logprobs plus logit bias API, then perform SVD on the query result matrix to recover the hidden dimension h and the embedding projection matrix W (up to an h×h transformation).
- Nearly perfect recovery of hidden dimensions and projection matrices on 6 open-source models; for five OpenAI production models, extracted the full projection matrices of ada and babbage for less than 20 USD (RMS error 5·10⁻⁴ and 7·10⁻⁴), and confirmed the hidden dimension of gpt-3.5-turbo. After responsible disclosure, OpenAI and Google have implemented defenses.
- The authors note that the attack can only recover a single layer, since due to the model's nonlinearity they see no obvious way to extend it to more layers; all attacks rely on the logit bias capability; the weights can only be recovered up to an h×h transformation rather than bit-for-bit exactly. Experiments were validated only on five OpenAI production models, and full matrix extraction was not achieved for babbage-002 and gpt-3.5.
The authors extracted complete projection matrices from OpenAI production models at a cost of less than $20; API providers that expose logit bias and logprobs can use this to check their own interfaces for leakage risk.
Related events and news
1 events · 2 news mentions
- The reports cite this paper
Mindgard 博客解析模型抽取与蒸馏攻击
News that mentions this paper
Mindgard 博客解析模型抽取与蒸馏攻击
- Mindgard Blogcites the paper's id or link什么是模型提取攻击?蒸馏攻击如何通过 API 窃取 AI 模型
In Stealing Part of a Production Language Model (Carlini et al., 2024), researchers from Google DeepMind, ETH Zurich and partner institutions recovered the full embedding projection layer of OpenAI’s
- Nicholas Carlini Writingcites the paper's id or linkNicholas Carlini 撰文《我为何发动攻击》:从可修补漏洞到不可修补漏洞
For example, earlier this year, at IEEE S&P, I presented a recent paper of ours that shows how to “poison” machine learning models in a way that is practical and costs under a hundred dollars.