acceptodds
Under review as a conference paper at ICLR 2027

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

Abstract

Large language models (LLMs) generate text by auto-regressively sampling the next token. This inherently leads to a many-to-many mapping between prompts and responses, complicating the task of inferring prompts from observed outputs. Prior work on LLM inversion frames prompt recovery as a semantic reconstruction task. They rely on fine-tuning pretrained sequence-to-sequence models on large external datasets with access to model weights or logits to generate semantically plausible prompts. In contrast, we present a functional approach to inverting a given LLM in a black-box setting by training an explicit inverse language model entirely from scratch on data synthetically generated from the target LLM itself. Analogous to forward next-token prediction, our inverse model is trained using previous-token prediction (PTP), establishing a generative link between the forward and inverse processes that enables faithful prompt reconstruction. Moreover, it naturally supports diverse prompt reconstructions through sampling, whereby all such prompts induce similar responses under the forward, target LLM. Our approach generalizes across datasets and exhibits semantic transferability in reconstructing prompts from responses generated by different LLMs. PTP substantially outperforms prior work on exact prompt recovery with tokenizer access while remaining competitive on semantic reconstruction metrics in fully black-box setup.

Primary area:
foundation or frontier models, including LLMs
Keywords:
LLM Inversion, Prompt Reconstruction, AI Safety, Previous-Token Prediction

Reviews

Among:
Shape:
1234this paper, Bottom 27%
Figure 1. Mean review rating of the reviewed papers at ICLR 2027. This paper averages 2.00 over 3 reviews, above 27% of the others.
Reviewer_kSAnOpenReview ↗
Rating
2
Confidence
3
Informativeness
2
Presentation
3
Soundness
2
Read review
Paper summary

This paper proposes Previous-Token Prediction (PTP) for prompt reconstruction. First training an inverse language model from scratch on token-reversed sequences generated through vocabulary-level probing of a target LLM, followed by fine-tuning on a small prompt–response dataset. The method reconstructs prompts from individual responses and evaluates both prompt recovery and response consistency through forward-model re-querying.

Critical strengths
  1. The method is conceptually simple and implementable using standard autoregressive training, without requiring access to the target model’s weights, logits, or hidden representations.

  2. Target-model-generated synthetic pretraining reduces reliance on external prompt–response datasets, with the main setting using only 400 external prompts for subsequent fine-tuning.

  3. Evaluating regenerated responses alongside recovered prompts is valuable because it examines whether reconstruction preserves the target model’s behavior beyond surface-level prompt similarity.

  4. The reported results show substantial improvements over the evaluated baselines on lexical reconstruction metrics in the main setting, while additional experiments explore transferability and the importance of synthetic pretraining.

Critical weaknesses
  1. The central exact-recovery claim is difficult to assess. Appendix C defines Exact Match after truncating predictions to the ground-truth prompt length, which does not measure full-sequence recovery. Moreover, Figure 4 contains intermediate “Exact Match” scores, requiring clarification of how this metric is computed and aggregated.

  2. The novelty relative to Pfau et al. (2023), which already uses reverse language modeling to generate prefixes conditioned on target suffixes, is insufficiently established. The paper cites this closely related work but provides neither a detailed distinction nor a direct experimental comparison.

  3. The ablations do not adequately isolate the benefit of reverse-token modeling from that of substantial synthetic pretraining. Comparing synthetic pretraining against training on only 400 examples does not establish whether PTP outperforms a forward-order alternative under matched data and computational budgets.

Questions for authors
  1. Could you provide the Exact Match implementation, explain the intermediate values in Figure 4, and report full-sequence EM without ground-truth-length truncation? Please also specify what the reported error bars represent.

  2. What are the substantive methodological differences from Pfau et al. (2023), beyond the synthetic-data construction and application setting? Could you provide a controlled comparison with that reverse-LM approach?

  3. Does PTP retain its advantage over forward-order synthetic pretraining followed by response-to-prompt fine-tuning when backbone, initialization, training data, and computational budget are matched?

  4. How is prompt generation terminated without knowing the original prompt length, and how much does fine-tuning improve free-running prompt reconstruction rather than teacher-forced validation accuracy?

2 comments
AuthorsOpenReview ↗

Gentle Reminder

Dear Reviewer,

As the discussion period is nearing its end, we would greatly appreciate it if you could acknowledge our response. Please let us know whether we have adequately addressed your concerns and if there is anything that remains unclear or requires further clarification.

We would be happy to provide any additional details that may be helpful. We look forward to hearing from you.

Thank you for your time.

Dear Reviewer kSAn,

As the authors' response deadline is fast approaching, please read through their rebuttal and let them know whether your concerns have been addressed or further clarification is still required.

Thank you.

AC

Reviewer_VtmrOpenReview ↗
Rating
3(+1)
Confidence
3
Informativeness
3
Presentation
2
Soundness
3(+1)
Read review
Paper summary

This paper proposes a previous-token prediction approach to reconstructing prompts from LLM responses. An inverse language model is trained from scratch on token-reversed synthetic sequences generated by the target model, followed by fine-tuning on prompt–response pairs. At inference, the model generates a reversed prompt conditioned on a reversed response. Experiments compare prompt reconstruction and closed-loop response reconstruction against existing methods, with additional evaluations across target models and datasets.

Critical strengths
  1. Reverse autoregressive modeling provides an interesting approach to prompt reconstruction.

  2. Closed-loop response evaluation is a useful complement to prompt similarity.

Critical weaknesses
  1. The definition and presentation of Exact Match are inconsistent. Appendix C defines a binary equality check after truncating the reconstruction to the reference lengths but Figure 4 shows intermediate values between zero and one. The paper does not explain whether these are averages over repeated generations or a different token-level metric.

  2. The organization obscures the connection between methods, experiments, and claims. The methodology mixes definitions, remarks, and numbered procedural steps without clear subsection boundaries.

Questions for authors
  1. Could you provide the precise formula or evaluation code for Exact Match? What are the results under strict full-sequence equality without reference-length truncation?

  2. Why do the Exact Match histograms in Figure 4 contain values between zero and one? If these represent averages over repeated generations or another score, please explain the statistical unit and how it corresponds to the definition in Appendix C and the reported table values.

3 comments
AuthorsOpenReview ↗

Gentle Reminder

Dear Reviewer,

As the discussion period is nearing its end, we would greatly appreciate it if you could acknowledge our response. Please let us know whether we have adequately addressed your concerns and if there is anything that remains unclear or requires further clarification.

We would be happy to provide any additional details that may be helpful. We look forward to hearing from you.

Thank you for your time.

Dear authors,

I have carefully read your response, and I am happy to raise my rating from 2 to 3 as Weak Acceptance.

Dear Reviewer, Thanks a lot for responding to our rebuttal.

Reviewer_oh8zOpenReview ↗
Rating
1
Confidence
3
Informativeness
1
Presentation
2
Soundness
1
Read review
Paper summary

This paper studies black-box LLM prompt inversion: given a single textual response y = f(x) from a target causal LLM f, the goal is to recover a prompt x_hat that matches the original prompt x or induces a similar response f(x_hat) ≈ y. The authors propose Previous-Token Prediction (PTP), which probes the target LLM f from every single vocabulary token v in V (|V| ≈ 150K for Qwen3-0.6B) to generate synthetic continuations of length L = 256 (~38.4M tokens per epoch), reverses each sequence at the token ID level, and pretrains a randomly initialized Qwen3-0.6B causal LM f_inv from scratch on the reversed sequences. Next, f_inv is fine-tuned on reversed concatenations Reverse(x, y) of 400 ShareGPT prompts and their target-model responses. At inference, f_inv conditions on Reverse(y), generates a reversed prompt x_tilde, and outputs x_hat = Reverse(x_tilde). Experiments on 100 held-out ShareGPT prompts compare PTP against O2P and RPE on Qwen3-0.6B Chat, and evaluate base vs. chat models, LLaMA-2-7B, zero-shot transfer to GPT-4o, cross-dataset transfer from Instructions-2M (30K), and cross-backbone ablations.

Critical strengths

None

Critical weaknesses

1: The paper has conflation of two tasks "output-to-input prompt recovery" and "generate input prompt given output". They are actually different tasks, and the paper seems to conflate between the tasks.

  • "Generating inversely" vs. "using output to predict input": Right-to-left continuation of a homogeneous text stream P(z_{t-1} | z_{>=t}) and predicting a hidden input prompt from a model's output P(x | y) are distinct tasks. Stages 1–3 train exclusively on unprompted 256-token continuations y^(v) where no prompt–response boundary exists. Even in Stage 4 fine-tuning (lines 231–240), the authors concatenate s = (x_1, ..., x_n, y_1, ..., y_T) with no delimiter token and minimize unmasked NLL over the entire reversed sequence s_tilde = (y_T, ..., y_1, x_n, ..., x_1), so most of the gradient (and the ~85% teacher-forced Val Accuracy in Figure 2) optimizes reverse response token prediction rather than P(x | y).
  • Oracle ground-truth length leakage at test time (Appendix C, lines 708–712): Because f_inv is trained as an unbounded reverse stream completer without a prompt-boundary or stopping criterion, it continues generating tokens past x_1. To evaluate Exact Match, Appendix C discloses that x_hat is first truncated to the exact ground-truth token length n = |x|. Using |x| at test time is direct oracle leakage (and it is unclear whether Table 7 also feeds the oracle-truncated x_hat_{1:n} into f).

2: Training an inverse token prediction model is not a novel idea, the paper's central conceptual claim—inverting an autoregressive LLM by reversing token sequences after tokenization and training a causal decoder via previous-token prediction P(y_{t-1} | y_{>=t}) to sample diverse prompts x_hat that elicit y—is already established in prior work. Specifically, Pfau et al. (2023) ("Eliciting Language Model Behaviors Using Reverse Language Models", cited at line 200) already introduced token-level reversal of forward LLM generations and reverse autoregressive training to recover prefixes/prompts that induce target outputs. More recently, LEDOM (Yin et al., ACL 2026, arXiv:2507.01335) scaled pure previous-token prediction to 2B and 7B open-source reverse foundation models trained on 435B tokens, explicitly demonstrating backward abductive reasoning, question/prompt synthesis from answers P(x | y), and noisy-channel scoring with forward likelihood P(y | x).

The paper just ignore these works and not even included them as baselines.

Questions for authors

1: How does the per-model method PTP compare with inverse language models like LEDOM?

2: What is the paper's actual target? Inverse token prediction, or inverse prompt prediction, which is actually different tasks?

2 comments
AuthorsOpenReview ↗

Gentle Reminder

Dear Reviewer,

As the discussion period is nearing its end, we would greatly appreciate it if you could acknowledge our response. Please let us know whether we have adequately addressed your concerns and if there is anything that remains unclear or requires further clarification.

We would be happy to provide any additional details that may be helpful. We look forward to hearing from you.

Thank you for your time.

AuthorsOpenReview ↗

Are Your Baseline Concerns Resolved?

Dear Reviewer,

As the discussion period is nearing its end, we wanted to check whether you have any remaining concerns regarding our clarification on the distinction between reverse language modelling and target-specific, black-box LLM inversion.

We hope our explanation clarifies why methods such as Pfau et al. and LEDOM are related prior work but not comparable baselines for our target-specific black-box inversion setting.

If our clarification has addressed your concern, we would greatly appreciate it if you could reassess our work.

Thank you again for your time and consideration.

Comments on the paper

3 comments
AuthorsOpenReview ↗

Remaining Concerns: Prompt Recovery and Directional Consistency

We are glad to have clarified some of your concerns. We address the remaining points below.

1. Exact Match and Full-Sequence Recovery

Under the requested full-sequence Exact Match evaluation, PTP achieves 58% exact prompt recovery, compared to 0% for both O2P and RPE, as these methods can reconstruct semantically equivalent prompts but do not recover the exact original token sequences. This is a strict metric that requires the entire reconstructed sequence, including its length, to match the ground truth exactly; any mismatch in token content or sequence length results in a score of zero. These results demonstrate substantial exact sequence-level recovery and further strengthen our near-exact reconstruction claim.

For the previously reported token-level metric, all methods (PTP, O2P, and RPE) are evaluated consistently using the clarified EM metric in the revised paper, which compares tokens over the common span and normalizes by the ground-truth prompt length. Using the reconstructed prompt length as the denominator would be inappropriate, as shorter reconstructions could receive artificially perfect scores. For instance, reconstructing just one token that matches the first ground-truth token would yield an EM of 1 under reconstructed-length normalization, despite the rest of the prompt being missing. Normalizing by the ground-truth length instead penalizes missing tokens and accounts for both correctly recovered and unrecovered content.

2. Directional Consistency and Ablations

PTP during both pre-training and fine-tuning is a deliberate architectural choice, analogous to using NTP consistently across both stages in conventional autoregressive LLMs. Furthermore, since our objective is black-box inversion without access to real-world pre-training data, we rely on synthetic data generated directly from the target LLM for pre-training. Switching from NTP during synthetic pre-training to PTP during fine-tuning would introduce a directional mismatch and an associated penalty that is difficult to overcome during fine-tuning. Directional consistency between pre-training and fine-tuning is therefore fundamental to our framework, and the proposed configuration violates this principle rather than representing an alternative training strategy.

To provide empirical support for this design choice, we refer you to Appendix E, which already reports relevant experimental evidence: a T5 model pre-trained with NTP and subsequently fine-tuned for reverse-direction generation using PTP exhibits substantial degradation across all the reported evaluation metrics. This provides the necessary empirical evidence of the directional penalty associated with forcing a model to generate in a direction that conflicts with its pre-trained autoregressive dependencies. We therefore believe that the existing experiments provide sufficient empirical support for our design choice.

We hope these clarifications address your remaining concerns and help you reassess our work.

Thank you for your time and constructive feedback.

AuthorsOpenReview ↗

Summary of Revisions Following Reviewer Feedback

Dear Reviewers,

We sincerely thank you for your time and valuable feedback. Based on the discussion, we have made several revisions to the uploaded manuscript, including:

  1. Clarified the Exact Match (EM) metric definition and evaluation protocol. (Page 15, Appendix C, Lines 762-772)
  2. In addition, we have now included strict full-sequence prompt recovery results, with PTP achieving 58% exact recovery, compared to 0% for both O2P and RPE. (Page 9, Section 5.5.1, Lines 459-469)
  3. Expanded the discussion of related works by including a section on Reverse Language Modelling and its distinction from target-specific, black-box LLM Inversion. (Page 3, Section 2, Lines 125-140)
  4. Improved the presentation by expanding on the Methodology and Experiments Section in the paper. (Pages 4,5 & 6)

We hope these revisions have addressed your concerns. We would greatly appreciate it if you would reassess our work in light of the revisions.

Thank you again for your time and constructive feedback.

AuthorsOpenReview ↗

Any Further Clarifications?

Dear Reviewer,

As the discussion period is nearing its end, we wanted to check whether you have any remaining concerns or you seek further clarification regarding our responses. We would be happy to address any outstanding questions.

If our responses have addressed your concerns, we would greatly appreciate it if you could reassess our work.

Thank you again for your time and consideration.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.