用连续优化方法从GPT-2隐藏状态中恢复输入文本,发现多数错误可修正。
Recovering Input Text from Hidden States: Study of Gradient-Based Inversion of Decoder-Only Language Models

- 全程在连续空间优化,不硬性投影词元,仅最后提交一次结果。
- 10词C4提示下精确匹配率从66.9%升至97.5%,近似成功率达99.4%。
- 功能词(如空格前高频词)易失败,内容词几乎完美还原。
本文研究解码器型语言模型最后一层隐藏状态的逆问题:从隐藏状态恢复原始输入词元序列。不同于一次性重建,本文将逆问题视为连续嵌入空间中的优化过程,软代理在搜索中持续向目标逼近,不进行硬性词元投影,仅在内循环结束时提交一个词元。该设计带来两大影响:其一,完全连续优化揭示了丰富的内部信号,包括真实词元的秩轨迹、逐位置损失曲线及提交时刻的离散损失;其二,离散损失可用于评估恢复正确性。进一步分析发现,失败主要源于嵌入矩阵密集区的高频率函数词(如空格前词),而内容词几乎全部成功恢复。在10词的C4提示下,随着候选窗口扩大,精确匹配率从66.9%提升至97.5%(平均相似度0.994),表明多数错误为可修正的近似误差而非本质歧义。与公开的SIPIT参考方案对比显示,每步硬投影虽更快,但连续形式使优化过程可观测、失败可检测。结果表明,GPT-2最后一层隐藏状态对原文敏感度极高。
原文摘要 · Abstract (English)
This work studies the hidden-state inversion problem: recovering the original input token sequence of a decoder-only language model from its last-layer hidden states. Rather than treating inversion as a one-shot reconstruction, we study it as a continuous embedding-space optimisation in which a soft proxy is driven towards the leaked target without any hard-token projection during the search, and a token is committed only once, at the end of the inner loop. This design choice has two consequences which are the main focus of this paper. First, keeping the optimisation entirely in continuous space exposes a rich set of internal signals: rank trajectories of the ground-truth token, per-position loss curves, and a discrete loss measured at commit time. Second, the discrete loss allows assessing the correctness of recovery via cumulative discrete loss. We further analyse which tokens break the reconstructions and find a sharp categorical asymmetry: space-prefixed, high-frequency function words in dense regions of the embedding matrix dominate the failures, while content-bearing tokens are recovered almost perfectly. On 10-token C4 prompts the exact-match rate rises from 66.9% to 97.5% (mean similarity 0.994) as the candidate window is widened, confirming that most errors are recoverable near-misses rather than genuine ambiguities. A comparison with the released SIPIT reference situates these findings: per-step hard projection is faster, but the continuous formulation is what makes the optimisation observable and its failures detectable. The results show that last-layer hidden states of GPT-2 are as sensitive as the original text.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。