Your fine-tune isn't secret: rebuilding a LoRA adapter from log-probabilities
Most custom chatbots are a public base model plus a small low-rank "LoRA" adapter. The adapter holds everything that took the company time and data to make, so it is treated as the secret part of the product. Xujun Che, Xi Niu, Haopeng Zhang and Depeng Xu at UNC Charlotte show that the next-token log-probabilities many inference APIs return are enough to rebuild the adapter's actual weights, not just copy how it behaves. Every response turns into linear equations in the secret, and the number of prompts needed is set by the model's width. The demo below solves the paper's per-layer equations live.
Why it matters
Companies that serve a fine-tuned model behind an API often treat the small adapter as their trade secret, but this paper shows the log-probabilities the API returns are enough to rebuild it weight for weight: 5,000 ordinary prompts recovered every layer of a GPT-2 adapter to a relative error of 10−8. It also tells providers what actually protects them: returning only the top 20 or top 5 log-probabilities just raises the attacker's prompt bill (to about 10,500 or 40,500), while bf16 arithmetic keeps the recovered weights 10–20% off even though the clone still behaves almost exactly like the real model.
The paper
Recovering LoRA Adapter Weights from Log-Probabilities
Xujun Che, Xi Niu, Haopeng Zhang and Depeng Xu (University of North Carolina at Charlotte). arXiv:2612.00549 [cs.LG], submitted 30 November 2026. Read on arXiv · PDF
In plain language: the attacker knows the public base model and can only send ordinary prompts and read back log-probabilities. The fine-tune adds a rank-r increment to each layer's query and value projections, ΔQ = AQBQ with A ∈ ℝd×r and B ∈ ℝr×d. The key trick is a two-token prompt. The last position then attends over only two positions, so each attention head has a single unknown weight. The attacker finds those weights by fitting its own copy of the base to the victim's response. Each recovered weight gives one equation that is bilinear in the secret:
Here ui is the layer's input at the last position of prompt i (the left probe), and ki,j is the difference of the two keys of head j (the right probe). The attacker can compute both. Collecting a layer's equations gives a low-rank least-squares problem, solved jointly over the heads because they share the input-side factor A:
Proposition 1 sets the price. All heads of a layer read the same input ui, so the equations only see ΔQ through the span of the left probes. ΔQ is identifiable only if the probe matrix U = [u1 … um] has rank d. That needs m ≥ d prompts, whatever the rank and however many heads there are. The attacker can check this rank before solving. Errors are relative Frobenius errors on the product, ε = ‖Δ̂ − Δ‖F / ‖Δ‖F.
Try it: recover one layer's secret ΔQ
A random rank-r adapter ΔQ = AB is hidden in a layer of width d split into H heads. Each prompt gives one measurement bi,j per head, exactly the equation above. Left probes are token embeddings, as in a first layer, drawn from a vocabulary of 8d tokens. Right probes are random and sit on head j's own coordinates. Arithmetic noise is added to every measurement at the relative size the paper measured for each number format. The solver is the paper's recipe: a spectral initialisation, then alternating least squares (A with all heads together, then each head's slice of B on its own). It runs on the first m prompts of a fixed pool.
Blue cells are positive and orange cells are negative. The first two maps share one colour scale. The difference map is rescaled to its own largest cell, and its label says by how much.
What the paper finds
| Victim and interface | Prompts | Parameter error ε | Outcome |
|---|---|---|---|
| GPT-2 small, rank 1, full distribution, fp64 | 5,000 | ≤ 2.3×10−8 | 10 of 10 adapters to rounding level |
| GPT-2 small, rank 4 / rank 8, fp64 | 5,000 / 23,000 | ≤ 2.5×10−7 | 3 of 3 each |
| Llama-3.2-1B, rank 1, fp64 | 8,500 | 1.2×10−5 | 3 of 3 |
| GPT-2 small, top-20 log-probs only, fp64 | 10,500 | 9.6×10−13 | direct fit, 16-token prompts |
| GPT-2 small, top-5 log-probs only, fp64 | 40,500 | 5.3×10−13 | direct fit, 16-token prompts |
| GPT-2 small, full distribution, bf16 | 10,500 | 0.12 | clone 1.06× as far from victim as a redeployment |
| GPT-2 served by vLLM, bf16 | 10,500 | 0.155 | clone 1.06× a redeployment |
Values from the paper's Table 2 (worst case over the adapters in each row).
- The prompt bound is tight. For GPT-2 (d = 768), recovery failed at m = 768 because the first layer's probes had rank only 759: its probe depends on the last token alone, and 768 prompts held only 759 distinct last tokens. At m = 784 every adapter was recovered. The fit residual did not reveal the failure, but the rank check did.
- Truncation costs prompts, not secrecy. With only the top-k log-probabilities, two-token prompts no longer carry enough numbers, so the attack switches to one big fit of all factors on 16-token prompts.
- Precision is what protects. bf16 adds noise of 2.4–3.5% to every response. The paper also finds that this noise lines up with the weakest directions of the problem, so it hurts far more than random noise of the same size would. Recovered weights stay 10–20% off, yet the clone behaves almost like the victim, because the error lies in directions the output barely shows.
- Both increments matter. Clones carrying only Δ̂Q stay close to the base model's behaviour (ρ = 0.77–0.84), and clones carrying only Δ̂V reach ρ = 0.21–0.26.
How to use it
- Start at the default (fp64, 4 heads, d = 32, rank 1) and drag prompts from low to high. The blue error curve drops from far off to near the rounding floor right at the orange line m = d. Just below that line the green fit residual is already tiny: the solver has found a Δ that matches every measurement and is still wrong.
- Switch heads between 1, 2, 4 and 8. More heads give more measurements per prompt but do not move the m = d wall, because every head of a layer reads the same input. With 1 head the counting rule (grey line) binds instead, so more prompts are needed.
- Tick Last tokens may repeat. At m = d the probe rank drops below d, as in the paper's GPT-2 first layer, and recovery fails until a few extra prompts restore full rank.
- Raise the rank to 2 or 3. The wall stays at m = d, but the solver needs more prompts past it. This is why the paper keeps measurements at twice the number of unknowns or more.
- Tap fp32, fp16 and bf16. The error floor rises with the arithmetic's noise and no longer falls to zero. This is the only interface choice in the paper that keeps the weights themselves out of reach.
- For providers, the practical lesson is to limit what log-probabilities are exposed and how precisely, and to treat any returned log-probabilities as leaking the adapter.
This is an educational simulation of one layer's measurement equations, not the paper's code or models. The demo hands the solver the bilinear measurements bi,j directly, skipping the per-prompt inversion from log-probabilities. It uses random probes and a random secret instead of a trained adapter, and white arithmetic noise, which is gentler than the coherent bf16 noise the paper describes. The equation, Proposition 1, the solver structure, the error metric and the noise levels follow the paper.