TL;DR
When an LLM reads a prompt, its final token's hidden state is solely optimized to predict the next word—seemingly discarding the exact wording that came before. Yet, the authors of Rep2Text show that by treating this single vector like an "image" in a vision-language model, we can reverse-engineer roughly half of the original prompt's exact words and nearly all of its core meaning. Beyond peeking inside the LLM black box, this reveals a stark privacy warning: sharing raw model activations leaks far more text than previously assumed.
What Problem Does This Paper Address?
As text flows through a decoder-only LLM, all the context from preceding words gets funneled into the internal representation (hidden state) of the very last token so the model can guess what comes next. Because it is trained to look forward rather than backward, this single vector acts as a fierce information bottleneck.
Prior attempts to invert model activations back into readable text either needed the hidden states of every token in the sequence, relied on slow, iterative search algorithms, or only extracted vague, high-level explanations. This paper asks a crisp, fundamental question: How much of the exact original text is actually trapped inside that single, compressed last-token vector, and can we decode it directly?
Methods
Inspired by Large Vision-Language Models (like LLaVA)—which translate image vectors into token embeddings an LLM can "read"—the authors treat an internal hidden state as a foreign modality that simply needs a translator.
Their Rep2Text framework pairs two components:
- A Trainable Adapter (The Novel Bridge): A lightweight, two-layer MLP with a gated skip connection. It takes a single last-token representation ($h^\ell$) from a specific layer of a target LLM and expands/projects it into $k$ pseudo-token embeddings.
- A Decoding LLM: These $k$ projected embeddings, alongside standard prompt embeddings, are fed directly into a decoding LLM (bypassing its normal text tokenizer). The decoder then autoregressively writes out the reconstructed input text in a single forward pass—no iterative optimization required.
Notably, the target model and decoding model don't even have to be the same LLM, and keeping the decoding LLM completely frozen (training only the adapter with smoothed cross-entropy loss) works nearly as well as fine-tuning the whole decoder via LoRA.
Datasets
- In-Distribution (Wikipedia): Passages randomly truncated from Wikipedia articles in The Pile (ranging from 8 to 256 tokens; 16 tokens for main experiments). Adapters were trained on 640K sequences and tested on 1,000 held-out sequences.
- Out-of-Distribution (Clinical): LLM-generated clinical summaries of a public dataset containing patient names, ages, and symptoms (up to 25 tokens long) to test zero-shot domain transfer and privacy leakage. No new standalone benchmarks were introduced.
Key Insights and Ideas
- The bottleneck leaks: Even though next-token prediction doesn't explicitly require memorizing exact phrasing, a single vector retains massive lexical and structural footprints.
- Latent spaces align across model families: You can take a hidden state from Mistral-7B or Gemma-7B and decode it using Llama-3.1-8B. A simple MLP adapter bridges their internal spaces, proving different LLMs organize information in surprisingly compatible ways.
- Decoder family beats decoder scale: Scaling up a Qwen-2.5 decoder from 14B to 32B or 72B parameters didn't beat a much smaller 3B or 8B Llama decoder when inverting Mistral representations. Architectural compatibility matters more than raw parameter count.
- Wording fades with length, gist survives: As input sequences grow longer, exact word recovery drops steadily, while topic and entity preservation stay stubbornly high—visualizing the exact mechanics of semantic compression.
- Layers specialize by depth: Early-to-middle layers (around layer 10 in Llama-3.1-8B) best preserve sentence grammar and structure, whereas deeper layers (15–20) better capture specific named entities and overarching topics.
Key Results
Examples of structural and entity preservation scores
- High Single-Vector Recovery: On 16-token Wikipedia sequences, Rep2Text achieves ROUGE-1 scores between 0.45 and 0.64 (recovering roughly half of the exact unigrams), 0.76–0.81 BERTScore, and 0.86–0.92 Topic relevance (rated via GPT-4.1-mini and sanity-checked against human raters).
- Model Vulnerability Varies: Using a fixed Llama-3.1-8B decoder, Gemma-7B (Layer 26) was the most invertible target (0.64 ROUGE-1), outperforming Mistral-7B (0.55) and Llama-3.1-8B itself (0.48).
- Length Bottleneck: When scaling Llama-3.1-8B inputs from 8 to 64 tokens, ROUGE-1 drops from ~0.60 to ~0.36. Pushing Llama-3.2-3B out to 256 tokens drops ROUGE-1 to 0.30, yet Topic score holds above 0.68.
- Strong OOD Generalization: Compared against an adapted Vec2Text baseline (even with 50 iterative correction steps), Rep2Text generalizes far better zero-shot to clinical summaries—achieving 0.37 ROUGE-1 and 0.64 Topic Score versus Vec2Text's 0.14 and 0.21.
Limitations and Future Work
- Short-sequence sweet spot: Reliable word-for-word recovery degrades noticeably once inputs exceed 16 tokens.
- Attribute hallucinations: On out-of-distribution clinical text, while Rep2Text captures the medical context (e.g., reconstructing "A 35-year-old woman..." from "A 35-year-old female..."), it still hallucinates critical details like exact symptoms or implausible BMI numbers.
- Security implications: Because a single intermediate activation can expose sensitive user prompts, deployed distributed systems cannot treat hidden states as safe, obfuscated math. Developing defensive safeguards against representation inversion is highlighted as vital future work.
Summary updated