· via Hacker News – Front Page (native)
Researchers reconstruct near-exact LLM prompts from outputs with previous-token prediction
A new arXiv paper trains an inverse language model with previous-token prediction to recover near-exact prompts from an LLM's responses in a black-box setting, with privacy implications for anyone publishing model outputs.

A paper describing a new way to recover the prompt behind a large language model's response — often nearly exactly — has drawn attention after reaching the front page of Hacker News. The work, submitted to arXiv in July by Pirzada Suhail, is titled "PTP: Previous-Token Prediction based LLM Inversion for Near-Exact Prompt Reconstruction," and its central claim is uncomfortable for anyone who exposes model outputs: with only black-box access, an inverse model can be trained to map responses back to the prompts that produced them.
Why prompts are hard to recover
Language models generate text one token at a time, sampling each token based on everything that came before. As the paper's abstract on arXiv explains, this produces a many-to-many relationship between prompts and responses: different prompts can elicit similar answers, and the same prompt can produce different outputs across samples. Recovering a prompt from an output is therefore not a simple lookup.
According to the authors, earlier research on LLM inversion treated the problem as semantic reconstruction. Those systems fine-tuned pretrained sequence-to-sequence models on large external datasets, and in some cases needed access to the target model's weights or its raw logits. The result was prompts that read as plausible paraphrases rather than faithful recoveries of what was actually entered.
Training a model to run backwards
The new approach drops those requirements. Instead of fine-tuning an existing model, the authors train an explicit inverse language model from scratch, using synthetic data generated from the target LLM itself. No external dataset, model weights or logits are required.
The key idea is in the name. A forward language model is trained on next-token prediction: given a prefix, guess what comes next. The inverse model is trained on previous-token prediction — guessing what came before — which the authors argue creates a structural connection between the forward and inverse generation processes, and is what makes faithful reconstruction possible.
Because the prompt-response mapping is many-to-many, the inverse model supports sampling: given a single response, it can produce several candidate prompts. The authors report that these diverse reconstructions share a useful property — when fed back into the target model, they all induce similar responses.
What the abstract reports
Two findings stand out. First, the approach generalizes across datasets, meaning the inverse model is not tied to the data it was evaluated on. Second, it exhibits transferability: it can reconstruct prompts from responses generated by different LLMs. Across token-based evaluation metrics for both prompt and response reconstruction, the authors say the method outperforms prior work. The abstract does not provide exact figures, so the full paper is needed to judge the scale of the gains and the cost of training the inverse model.
What it means if you expose model outputs
The practical concern is straightforward. Prompts frequently contain the most sensitive material in an LLM pipeline: system prompts a company considers proprietary, retrieved documents, customer details pasted into a support tool, internal instructions. If the response side of that interaction is visible — public chatbot transcripts, shared logs, agent traces, published API outputs — this line of research suggests the input side may be recoverable too.
The black-box setting lowers the bar considerably. An attacker would need neither weights nor logits, only the ability to generate synthetic data from a model. And the reported transferability means outputs from models beyond the original target could be invertible as well, widening the potential exposure.
There are caveats. Near-exactness is measured with token-based metrics, and a reconstructed prompt may be a functional equivalent — one that produces the same response — rather than a verbatim copy. The abstract also does not address how the method handles prompts assembled at runtime from system messages, tool outputs and retrieved context, which is how most production systems actually work.
Why it matters
This work reframes prompt leakage as a tractable engineering problem rather than a theoretical worry. For teams building on LLMs, it is a reminder that model outputs are not a safe proxy to publish when the inputs are confidential: anything that meaningfully shapes a response may be extractable from it. Until defenses are better understood, treating logs, transcripts and shared responses with the same sensitivity as the prompts themselves is the prudent default. For researchers, it also offers a cleaner formulation of inversion — previous-token prediction trained on self-generated data — that others are likely to build on.
- #llm
- #privacy
- #machine-learning
- #research
- #security