cs.LGJul 2, 2025

GPT, But Backwards: Exactly Inverting Language Model Outputs

Authors: Adrians Skapars, Edoardo Manino, Youcheng Sun, Lucas C. Cordeiro

Organizations: Department of Computer Science, University of Manchester, Manchester, United Kingdom · Mohamed bin Zayed University of Artificial Intelligence, United Arab Emirates · Federal University of Amazonas, Manaus, Brazil

Abstract

Recent work shows that distinct inputs produce distinct hidden representations in LLMs, so the input can in principle be recovered from them. Yet, no existing method can reliably do so from the model's output text or logits alone. We introduce Sparse One-hot Discrete Adam (SODA), a white-box search-based algorithm that reconstructs textual inputs from partial knowledge of the output. Given output logits, SODA recovers natural sequences of up to 17 tokens with zero false positives and achieves a 4x improvement in exact-match reconstruction over the strongest prior method. We further show that input length and vocabulary size matter more for inversion difficulty than parameter count, with SODA inverting models from 33M to 3B parameters. Finally, we demonstrate proof-of-concept security applications: SODA recovers 6 backdoor triggers from a poisoned LLM in under 1000 iterations, and 139 tokens of personally identifiable information from synthetic user-chatbot interactions. Our code is available at https://github.com/AdrSkapars/inversion_optimisation.

Figures & tables

Appendix figures & tables6 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. PTP: Previous-Token Prediction based LLM Inversion for Near-Exact Prompt Reconstruction

    Jul 31, 2026Pirzada Suhail, Nagasai Saketh Naidu, Atanu R Sinha +1LLM PromptingNext-Token Prediction

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

    Jul 1, 2026Mikołaj Słowikowski, Maciej Witold MajewskiDecoder-Only Language ModelsPrivacy Leakage in Language Models

  3. Rep2Text: Decoding Full Text from a Single LLM Token Representation

    Nov 9, 2025Haiyan Zhao, Zirui He, Yiming Tang +4LLM InterpretabilityLLM Information Extraction