[Paper Review] Stealing Part of a Production Language Model
The authors introduce a black-box model-stealing attack that recovers the embedding projection layer of transformer language models, revealing hidden dimensions and the final projection matrix with low error, and demonstrate practicality on OpenAI models at modest costs.
We introduce the first model-stealing attack that extracts precise, nontrivial information from black-box production language models like OpenAI's ChatGPT or Google's PaLM-2. Specifically, our attack recovers the embedding projection layer (up to symmetries) of a transformer model, given typical API access. For under \$20 USD, our attack extracts the entire projection matrix of OpenAI's Ada and Babbage language models. We thereby confirm, for the first time, that these black-box models have a hidden dimension of 1024 and 2048, respectively. We also recover the exact hidden dimension size of the gpt-3.5-turbo model, and estimate it would cost under $2,000 in queries to recover the entire projection matrix. We conclude with potential defenses and mitigations, and discuss the implications of possible future work that could extend our attack.
Motivation & Objective
- Demonstrate that a black-box API can leak the embedding projection layer of a transformer language model.
- Show that the hidden dimensionality of several production models can be recovered through API queries.
- Reconstruct the final embedding projection matrix (up to symmetries) from logit-vector outputs.
- Quantify practical costs (in queries and dollars) for recovering model components.
- Discuss defenses and mitigations to reduce leakage and outline future directions.
Proposed method
- Top-down extraction of the final embedding projection layer by exploiting the low-rank structure of the final projection from hidden states to logits (W · gθ(p)).
- Use random prefix prompts and collect logit vectors to form a data matrix Q = W · H and apply SVD to identify the hidden dimension h via rank analysis.
- Recover the final projection matrix W up to a h×h transformation by analyzing the SVD factors (U, Σ) and aligning with the true W up to symmetries (G).
- Generalize the attack to logit-bias APIs where the attacker can add biases to specific tokens and observe top-k logits/log-probabilities; develop cost-optimized variants to recover multiple logits per query.
- Extend methods to logit-bias APIs with top-k and top-1 settings, including strategies to handle biases and recover full logit vectors under practical API constraints.
Experimental results
Research questions
- RQ1What is the extent of information leakage about production LLMs that can be gleaned through black-box API access?
- RQ2Can an adversary recover the hidden dimension and the final embedding projection matrix of transformer language models from logit outputs?
- RQ3How accurately can the final projection matrix W be reconstructed (up to symmetries), and what are the numerical costs (queries and dollars) to do so?
- RQ4How do practical API constraints (top-k logit biases, logit bias, and logprob access) affect the feasibility of full or partial model extraction?
- RQ5What defenses and mitigations can reduce leakage while preserving API utility?
Key findings
- The attack recovers the embedding projection layer for several models with mean squared error on the order of 10−4 (up to symmetries).
- The hidden dimension h is recovered exactly for multiple models (e.g., 1024 for OpenAI ada, 2048 for OpenAI babbage).
- Full extraction of the final projection matrix W is achieved up to an h×h transformation, with RMS errors around 10−4 to 10−3 across tested models.
- The attack works across both open-source models (GPT-2, Pythia, LLaMA) and production models (OpenAI ada, babbage, gpt-3.5-turbo variants), with practical query costs.
- For select models, full layer extraction was demonstrated with under 2×10^6 to under 4×10^7 queries and costs ranging from approximately $1 to $2000.
- The results prompted defenses in production APIs, including defenses against logit bias-based leakage and combined logit-bias/logprobs access.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.