← Latest papers
🤖 AI

Recovering Input Text from Hidden States: Study of Gradient-Based Inversion of Decoder-Only Language Models

This paper demonstrates that decoder-only language models' last-layer hidden states are as sensitive as the original text, showing that a continuous embedding-space optimization approach effectively recovers input tokens while revealing that reconstruction failures are primarily caused by high-frequency function words rather than genuine ambiguities.

Original authors: Mikołaj Słowikowski, Maciej Witold Majewski

Published 2026-07-02
📖 5 min read🧠 Deep dive

Original authors: Mikołaj Słowikowski, Maciej Witold Majewski

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Big Idea: The "Digital Shadow" Can Be Shown to Be the Object Itself

Imagine you have a very complex, high-tech 3D printer. You put a piece of clay (the text) into the machine, and it prints out a perfect, glowing hologram of that clay (the hidden state).

For a long time, people thought that if you only saw the hologram, you couldn't figure out what the original clay looked like. They assumed the hologram was a "one-way street"—you could make the hologram from the clay, but you couldn't turn the hologram back into clay.

This paper proves that assumption is wrong. The authors show that if you have the hologram (the hidden state) and you know how the printer works (the model's internal code), you can reverse-engineer the process to recreate the original clay perfectly.

How They Did It: The "Smooth Slide" vs. The "Staircase"

The authors didn't just guess the words. They used a clever mathematical trick called gradient-based inversion. Here is how they explained their specific method compared to others:

  • The Old Way (The Staircase): Imagine trying to find a specific house in a city. The old method (like a previous study called SIPIT) is like jumping from one street corner to the next. You guess a house, check if it's right, and if not, you jump to the next closest house immediately. It's fast, but you lose the ability to see how close you were before you jumped.
  • The New Way (The Smooth Slide): The authors' method is like sliding down a smooth, invisible hill toward the target house. You don't jump to a specific house until you are absolutely sure you've reached the bottom of the hill.
    • Why this matters: Because they stay on the "smooth slide" (a continuous mathematical space) for a long time, they can watch exactly how the search is going. They can see if the search is getting stuck or if the "house" they are looking for is hiding in a crowded neighborhood where many houses look alike.

The Results: What Did They Find?

1. It Works Very Well
When they tried to recover short sentences (10 words long) from the "holograms" of a popular AI model (GPT-2), they were incredibly successful.

  • With a standard setting, they got the whole sentence right 67% of the time.
  • By giving the computer more time to search and checking more "neighborhoods," they got it right 97.5% of the time.
  • Even when they didn't get the exact word, the words they guessed were usually very similar (like saying "cat" instead of "kitten").

2. The "Crowded Neighborhood" Problem
The researchers noticed a funny pattern about which words were hard to recover.

  • The Easy Words: Unique, interesting words (like "astronaut," "pizza," or "quantum") were recovered almost perfectly. They live in "empty neighborhoods" in the computer's memory, so it's easy to find them.
  • The Hard Words: The most common, boring words (like "the," "and," "of," or spaces before words) were the hardest to get right. These words live in "super crowded neighborhoods" where thousands of similar-looking words are packed tightly together. It's like trying to find one specific "John Smith" in a stadium full of 10,000 John Smiths.

3. The "Self-Check" Feature
Because they used the "smooth slide" method, they created a built-in alarm system.

  • If the computer successfully recovers the text, the mathematical "distance" to the target stays tiny (near zero).
  • If the computer makes a mistake, that distance suddenly spikes.
  • This means the system can tell you, "I think I made a mistake here," without needing to know the original answer beforehand. It's like a GPS that says, "I'm lost," even if you don't know the destination.

Why Should We Care? (The Privacy Warning)

The paper concludes with a serious warning for anyone using AI:

If you send data to a cloud server to be processed, and the server sends back just the "hologram" (the hidden numbers) instead of the text, you are not safe.

The authors show that these "holograms" are just as sensitive as the original text. If a hacker (or even the server itself) intercepts these numbers, they can use this "smooth slide" method to reconstruct your private messages, passwords, or documents with very high accuracy.

Summary Analogy

Think of the AI model as a lock.

  • Old belief: The key (the text) turns the lock to open it, but once the door is open, you can't tell what the key looked like just by looking at the open door.
  • This paper's finding: If you look closely at the open door (the hidden state) and know how the lock works, you can actually mold a new key that fits perfectly. The "open door" contains all the information needed to rebuild the key.

The paper proves that for these specific types of AI models, hiding the text inside numbers does not actually hide the text.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →