Rep2Text Recovers Private Prompts From a Single AI Hidden Vector
A new framework called Rep2Text shows that a single hidden vector inside an LLM leaks about half the words of its input, raising privacy and interpretability questions.
Takeaways
- Rep2Text reconstructs text from a single last-token LLM representation using a trainable adapter plus a decoder LLM. Paper
- Recovers roughly half of tokens in 16-token Wikipedia inputs while keeping topic and structure intact.
- Tested on Llama-3.1-8B, Llama-3.2-3B, Mistral-7B-v0.1, Gemma-7B targets with Llama and Qwen decoders up to 32B.
- Cross-model decoding works: attacker does not need the same model family as the target.
- Beats Vec2Text decisively on out-of-distribution clinical notes, suggesting a general representation-to-text mapping.
- Decoder scale barely helps; recoverability is bounded by what the target representation itself encodes.
Researchers have shown that a single activation from a large language model can reveal substantial parts of the text that produced it. Rep2Text takes the hidden representation of a prompt’s final token, projects it through a trained adapter, and lets a second LLM reconstruct the input autoregressively. On held-out 16-token passages, the system reaches 0.45 to 0.52 ROUGE-1 and often preserves the original topic, entities, and sentence structure.
The result clarifies how much input information survives inside the compressed state used for next-token prediction. It also exposes a security risk for systems that transmit, cache, or share intermediate activations. Exact wording remains difficult to recover, especially for longer inputs, but one vector can still disclose meaning and structure.
- Input: One hidden vector from the final prompt token at a selected transformer layer.
- Attack: A trained adapter maps that vector into pseudo-token embeddings for a frozen decoder.
- Best results: Short inputs drawn from distributions similar to the training data.
- Primary risk: Topic, structure, and some wording can leak even when raw prompts are unavailable.
How much survives the bottleneck?
A transformer’s final-token representation summarizes the preceding context for next-token prediction. The model has no explicit reconstruction objective, so the unresolved question was how much of the original text remained accessible in that summary. Earlier inversion methods generally targeted sentence embeddings from encoder models such as BERT, consumed full hidden-state sequences, or relied on repeated optimization.
Rep2Text tests a narrower threat model: an attacker obtains one vector h from a known layer and trains a model to infer the source text. The reconstruction uses no iterative search, partial text span, or task-specific hint at inference time. Training still requires paired examples of source text and target-model activations, and the adapter is tied to the representation space it learned.
An activation becomes pseudo-tokens
Rep2Text follows the projection pattern used by vision-language systems such as LLaVA. A two-layer multilayer perceptron with a gated skip connection maps the target model’s activation into the decoder’s token-embedding space. The adapter reshapes its output into k pseudo-token embeddings, which are inserted alongside system and user instructions while bypassing the decoder’s normal embedding lookup.
The decoder then generates a candidate reconstruction token by token. Training uses teacher forcing, which supplies the correct preceding output token, and label smoothing, which reduces overconfidence in a single target token.
The main experiments freeze the decoder and train only the adapter. Fine-tuning the full system raises ROUGE-1 by 0.03, ROUGE-2 by 0.05, and ROUGE-L by 0.04, with similarly small changes in semantic and LLM-judge scores. Most of the required alignment therefore fits inside the comparatively small projection network.
Short prompts leak the most
The researchers extracted layer-10 representations from Llama-3.1-8B, Llama-3.2-3B, Mistral-7B-v0.1, and Gemma-7B. They trained the inversion system on 640,000 Wikipedia passages from The Pile and evaluated it on held-out 16-token sequences.
| Measure | Reported range | What it captures |
|---|---|---|
| ROUGE-1 | 0.45 to 0.52 | Overlap between individual words or subword units |
| ROUGE-2 | 0.25 to 0.32 | Recovery of adjacent token pairs and local phrasing |
| BERTScore | 0.75 to 0.81 | Semantic similarity between reconstruction and source |
| Topic preservation | 0.79 to 0.91 | Retention of the source topic |
ROUGE-1 measures unigram overlap, so a score near 0.5 does not mean that half of every prompt is reproduced exactly. The combined metrics show that many reconstructions recover substantial vocabulary while preserving more of the source meaning than its precise wording.
Mistral-7B-v0.1 was the easiest target to invert, while the tested Llama models exposed slightly less information under the same evaluation. Decoders from a different model family performed nearly as well as target-matched decoders. An attacker may therefore use a separate decoding LLM, although the adapter still needs training data from the target representation space.
Increasing decoder size produced little benefit. Qwen-2.5-32B, despite having more than twice the parameters, did not improve on Qwen-2.5-14B. Reconstruction quality appears constrained mainly by the information retained in the target activation.
Wording fades before meaning
Input length had the largest effect on lexical recovery. ROUGE-1 fell from roughly 0.60 for 8-token inputs to roughly 0.30 for 64-token inputs, with comparable declines in ROUGE-2 and ROUGE-L. Semantic scores decreased more slowly, showing that longer inputs continued to leak topic and broad structure after exact phrasing became difficult to recover.
Sequences shorter than 16 tokens sometimes yielded near-exact reconstructions. Longer sequences more often produced paraphrases, omitted details, or substituted attributes. This pattern limits verbatim extraction while leaving meaningful privacy exposure.
Layer selection also changed what the inverter recovered. In Llama-3.1-8B, structural information peaked around layers 10 to 15, lexical and entity details peaked somewhat deeper, and topic signals remained stable across middle and later layers. The results provide a layer-by-layer recoverability profile for information that interpretability tools often measure only indirectly.
Rep2Text travels beyond Wikipedia
The closest prior method, Vec2Text, combines a hypothesizer with an iterative corrector. The researchers adapted it to the final-token setting and trained both systems on the same Wikipedia corpus. Their semantic scores were similar on in-distribution text, while Rep2Text achieved stronger token-level recovery.
The difference widened on out-of-distribution clinical note summaries. Rep2Text reached 0.26 Token F1, 0.37 ROUGE-1, 0.64 Topic Score, and 0.10 BLEU. Vec2Text scored no higher than 0.10 on nearly all reported metrics.
Qualitative examples show both the capability and its limits. Rep2Text recovered that a female patient presented with abnormal bleeding and fatigue, but changed her age and the duration of her symptoms. Vec2Text generated unrelated material. The adapter therefore transferred broad semantic structure into an unseen domain while remaining unreliable for exact clinical attributes.
Where developers should look
Rep2Text offers several practical uses for model builders and researchers:
- Interpretability: Measure which layers preserve wording, entities, syntax, and topic alongside methods such as logit lenses and sparse autoencoders.
- Privacy testing: Audit collaborative inference, split learning, activation transport, shared caches, and research pipelines that persist intermediate states.
- Architecture comparison: Compare how much input information different model families retain under a common inversion setup.
- Retention policy design: Treat stored activations as potentially sensitive data and apply access controls, deletion schedules, and encryption accordingly.
The demonstrated attack also has clear boundaries:
- Lexical recovery declines quickly beyond 16 tokens, although topic information remains accessible.
- Specific ages, dates, quantities, and similar attributes are often incorrect.
- The experiments cover target models up to 8B parameters and decoders up to 32B, leaving larger systems untested.
- The adapter needs paired text and activations from the target representation space before it can decode intercepted vectors.
- The paper does not link public code or weights. The authors report roughly seven hours of adapter training on two A100 GPUs for each configuration.
Hidden states need data controls
Rep2Text shows that a final-token activation can preserve substantial lexical, structural, and semantic information about its source prompt. Exact wording disappears faster than meaning as inputs grow, and related representation spaces can be decoded with LLMs from other model families.
Systems that handle hidden states should account for that recoverability in their threat models. Intermediate activations warrant controls similar to other sensitive model inputs, particularly when they leave the inference process, persist in storage, or become available to third-party tools.