Language Model Inversion
John X. Morris, Wenting Zhao, Justin T. Chiu, Vitaly Shmatikov, Alexander M. Rush
Abstract
Language models produce a distribution over the next token; can we use this to recover the prompt tokens? We consider the problem of language model inversion and show that next-token probabilities contain a surprising amount of information about the preceding text. Often we can recover the text in cases where it is hidden from the user, motivating a method for recovering unknown prompts given only the model's current distribution output. We consider a variety of model access scenarios, and show how even without predictions for every token in the vocabulary one can recover the necessary probability vector through search. On Llama-2 7B, our inversion method reconstructs prompts with a BLEU of 59 and token-level F1 of 78 and recovers 27% of prompts exactly. 1
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
40 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Membership Inference Attacks Against Machine Learning Models cites Stealing Machine Learning Models via Prediction APIs
- Privacy Backdoors: Enhancing Membership Inference through Poisoning Pre-trained Models cites Membership Inference Attacks Against Machine Learning Models
- Stealing part of a production language model cites Query-Based Adversarial Prompt Generation
- Stealing part of a production language model cites Stealing Machine Learning Models via Prediction APIs
- In-Context Unlearning: Language Models as Few-Shot Unlearners cites Membership Inference Attacks Against Machine Learning Models
Cited by top-tier papers40
- In-Context Unlearning: Language Models as Few-Shot UnlearnersMartin Pawelczyk, Seth Neel, Himabindu LakkarajuICML 2024 · 217 citations
- Stealing part of a production language modelNicholas Carlini, Daniel Paleka, Krishnamurthy Dj Dvijotham, Thomas Steinke et al.ICML 2024 · 157 citations
- Query-Based Adversarial Prompt GenerationJonathan Hayase, Ema Borevkovic, Nicholas Carlini, Florian Tramèr et al.NeurIPS 2024 · 72 citations
- Privacy Backdoors: Enhancing Membership Inference through Poisoning Pre-trained ModelsYuxin Wen, Leo Marchyok, Sanghyun Hong, Jonas Geiping et al.NeurIPS 2024 · 39 citations
- DPIC: Decoupling Prompt and Intrinsic Characteristics for LLM Generated Text DetectionXiao Yu, Yuang Qi, Kejiang Chen, Guoqiang Chen et al.NeurIPS 2024 · 24 citations
Builds on16
- Membership Inference Attacks Against Machine Learning ModelsReza Shokri, Marco Stronati, Congzheng Song, Vitaly ShmatikovS&P 2017 · 5,137 citations
- The Curious Case of Neural Text DegenerationAri Holtzman, Jan Buys, Li Du, Maxwell Forbes et al.ICLR 2020 · 4,112 citations
- Stealing Machine Learning Models via Prediction APIsFlorian Tramèr, Fan Zhang, Ari Juels, Michael K. Reiter et al.USENIX Security 2016 · 2,088 citations
- WizardLM: Empowering Large Pre-Trained Language Models to Follow Complex InstructionsCan Xu, Qingfeng Sun, Kai Zheng, Xiubo Geng et al.ICLR 2024 · 1,206 citations
- WizardCoder: Empowering Code Large Language Models with Evol-InstructZiyang Luo, Can Xu, Pu Zhao, Qingfeng Sun et al.ICLR 2024 · 945 citations
Related papers
- Better Language Model Inversion by Compactly Representing Next-Token DistributionsMurtaza Nazir, Matthew Finlayson, John X. Morris, Xiang Ren et al.NeurIPS 2025 · 13 citations
- Extracting Prompts by Inverting LLM OutputsCollin Zhang, John X. Morris, Vitaly ShmatikovEMNLP 2024 · 10 citations
- Reverse Prompt Engineering: A Zero-Shot, Genetic Algorithm Approach to Language Model InversionHanqing Li, Diego KlabjanEMNLP 2025 · 1 citation
- An Invariant Latent Space Perspective on Language Model InversionWentao Ye, Jiaqi Hu, Haobo Wang, Xinpeng Ti et al.AAAI 2026 · 1 citation
- Distribution Prompting: Understanding the Expressivity of Language Models Through the Next-Token Distributions They Can ProduceHaojin Wang, Zining Zhu, Freda ShiEMNLP 2025
