‹ All demos
3 Dec 2026 · AI

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.

Xujun Che, Xi Niu, Haopeng Zhang, Depeng Xu

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:

bi,j = ui⊤ ΔQ ki,j

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:

Δ̂Q = argminrank Δ ≤ r Σi,j ( ui⊤ Δ ki,j − bi,j )²

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.

Victim arithmetic:
Heads H:
–
rank of left probes U (need d)
–
measurements mH vs unknowns r(2d−r)
–
fit residual (what the attacker sees)
–
true error ε (hidden from the attacker)

Recovery error vs number of prompts (log scale)
true error εfit residualm = d (Proposition 1)mH = 2·r(2d−r) (paper's rule of thumb)

The secret ΔQ, the attacker's Δ̂Q, and their difference

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 interfacePromptsParameter error εOutcome
GPT-2 small, rank 1, full distribution, fp645,000≤ 2.3×10−810 of 10 adapters to rounding level
GPT-2 small, rank 4 / rank 8, fp645,000 / 23,000≤ 2.5×10−73 of 3 each
Llama-3.2-1B, rank 1, fp648,5001.2×10−53 of 3
GPT-2 small, top-20 log-probs only, fp6410,5009.6×10−13direct fit, 16-token prompts
GPT-2 small, top-5 log-probs only, fp6440,5005.3×10−13direct fit, 16-token prompts
GPT-2 small, full distribution, bf1610,5000.12clone 1.06× as far from victim as a redeployment
GPT-2 served by vLLM, bf1610,5000.155clone 1.06× a redeployment

Values from the paper's Table 2 (worst case over the adapters in each row).

How to use it

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.