Papers
Topics
Authors
Recent
Search
2000 character limit reached

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

Published 31 Jul 2026 in cs.CL and cs.LG | (2607.29378v1)

Abstract: 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--and requiring 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, without auxiliary aids. We train an explicit inverse LLM 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, 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 generalises across datasets and exhibits transferability in reconstructing prompts from responses generated by different LLMs. Further, across the set of token based evaluation metrics for prompt and response reconstructions, our approach outperforms prior work.

Summary

  • The paper introduces the PTP framework, which uses previous-token prediction on synthetically reversed data to achieve near-exact prompt reconstruction without accessing model internals.
  • The authors employ a novel synthetic pretraining strategy that generates reversed token sequences, resulting in high token-level fidelity and strong semantic retention across models.
  • The approach advances LLM security and interpretability, enabling effective prompt auditing and adversarial prompt recovery in nearly strict black-box scenarios.

PTP: Previous-Token Prediction-Based Inversion for LLMs

Motivation and Prior Work

The task of inverting LLMs—that is, reconstructing an input prompt given only a generated response—directly interrogates the one-to-many, non-injective mapping inherent to autoregressive generation. Traditional approaches to LLM inversion, often framed as semantic text reconstruction, hinge on access to model internals such as next-token logits, hidden states, or extensive external datasets for fine-tuning pretrained encoder–decoder architectures. Notably, methods like Logit-to-Text (L2T) and Prompt Inversion from Logprob Sequences (PILS) leverage low-level signal from logits, achieving high fidelity but violating strict black-box constraints. Black-box techniques such as Output-to-Prompt (O2P) and Reverse Prompt Engineering (RPE) have shown promising results by operating solely on observed text, but they face scalability and fidelity limitations, especially for exact prompt recovery.

Previous-Token Prediction (PTP) Framework

This work introduces a methodologically distinct paradigm for LLM inversion based on previous-token prediction (PTP). Rather than leveraging pretrained sequence-to-sequence architectures, PTP explicitly trains a decoder-only inverse LLM from scratch. Critically, it employs a synthetic data generation protocol: every token from the model’s vocabulary is used as a seed for stochastic forward generation, producing a diverse synthetic corpus via top-kk/top-pp/temperature sampling. Each synthetic sequence is then reversed at the token level to construct the training data for the inverse model.

The inverse model—architected for left-to-right autoregressive generation on reversed sequences—predicts the preceding token conditioned on future context, functionally mirroring the forward model’s operation but in reverse. Fine-tuning on a small set of forward-generated, real prompt-response pairs ensures alignment with natural linguistic distributions despite initial data-free training, a critical step for formatting robustness. Figure 1

Figure 1: The PTP approach to LLM inversion uses previous-token prediction to infer prompts that yield observed responses when fed to the forward model.

Empirical Evaluation

Model Performance and Architecture Analysis

Empirical results demonstrate robust superiority of PTP over contemporary black-box inversion baselines, especially on token-level metrics such as Exact Match and Token F1. For instance, on Qwen3-0.6B Chat, PTP achieves an Exact Match rate of 64.77%, compared to 25.44% for O2P (with extensive pretraining/fine-tuning) and 0.64% for RPEGA, with corresponding gains on BLEU, ROUGE-L, and Token F1. Semantic metrics (BERT F1, cosine similarity) also remain competitive, indicating preservation of functional model behavior rather than superficial lexical overlap.

PTP’s forward–inverse generative link reliably produces multiple distinct prompts yielding similar downstream responses, with response-level reconstructions tightly concentrated near the upper end of semantic metrics—supporting the claim that many diverse prompts can induce almost-indistinguishable generations. Figure 2

Figure 2: Distributions of prompt- and response-level ROUGE-L, Token F1, and BERT F1 scores show that reconstructed prompts induce consistent, semantically-similar responses despite their diversity.

Cross-architecture evaluation reveals that strict prompt reconstruction is sensitive to vocabulary/tokenizer mismatch, with token-level metrics degrading when the forward and inverse models are not matched (e.g., inverting LLaMA-2 7B Chat using a Qwen-based inverse model). Semantic-level measures (CS, BERT F1), however, remain robust, suggesting that intent and meaning are preserved even under architectural heterogeneity.

Generalization and Transferability

PTP exhibits significant transferability: an inverse model trained on one LLM reliably reconstructs semantically-aligned prompts (and functionally equivalent responses) when applied to outputs from entirely different LLMs, including closed models like GPT-4o. Cross-dataset experiments confirm this robustness—the main condition for successful inversion being the alignment between tokenization schemes for exact token-level matches, while looser semantic goals are achieved even under cross-domain or cross-model settings.

Synthetic Pretraining: Data Efficiency

Ablations conclusively demonstrate that synthetic pretraining is essential for learning the inverse generative mapping. Direct fine-tuning on small real datasets leads to poor inversion performance, while synthetic corpus pretraining—using only the black-box forward model—enables stable convergence and high token-level fidelity. Figure 3

Figure 3

Figure 3: Training with synthetic pre-training (purple) demonstrates stable convergence and superior validation accuracy compared to using real data alone (yellow).

Methodological and Practical Considerations

PTP operates in a nearly-strict black-box regime: its only requirement is query access to the forward model and, for high-fidelity reconstruction, shared access to the tokenizer. The synthetic pretraining approach results in a manageable query budget (on the order of tens of millions of tokens for common vocabularies), which is parallelizable and computationally feasible in practice. Fine-tuning on a small human-generated dataset (≤400 samples) suffices to capture prompt formatting and idiomatic language.

PTP’s framing as functional inverse modeling, along with diverse stochastic probing, supports exploration of the entire equivalence class of prompts yielding a given response—a property with significant implications for prompt security and the control of undesirable behaviors in LLM-driven systems. Figure 4

Figure 4: Prompt-level score distributions are broad, but responses generated from reconstructed prompts nearly always match the originals semantically, reinforcing the model’s functional fidelity.

Implications and Future Directions

The PTP methodology marks a significant shift toward principled generative inversion, establishing a reusable, forward-agnostic inverse model that requires no pretrained linguistic priors, real-world datasets, or model-internal signal. This directly facilitates prompt auditing, adversarial prompt elicitation, and systematic analysis of LLM input–output mappings in security or interpretability contexts.

However, several challenges persist: strict token-level fidelity is only achievable with tokenizer access and under architectural compatibility; query-efficiency for very large models remains an open question; and the extent to which this inversion process is robust to complex prompt templating or noisy system outputs deserves further study. Future work may leverage more sophisticated synthetic corpus generation strategies or introduce iterative refinement for hard-to-invert outputs, providing scalability to even larger LLMs and highly structured inputs.

Conclusion

The PTP framework offers a robust, data-efficient, black-box method for LLM inversion. Through previous-token prediction on synthetically reversed forward generations, PTP achieves both strong exact prompt reconstruction and preservation of underlying semantic behavior. Its architectural agnosticism, generative rigor, and transferability establish it as a benchmark for black-box LLM auditing and interpretability, with clear implications for prompt security and functional understanding of deployed LLMs.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

Explain it Like I'm 14

Simple Summary of the Paper: “PTP: Previous-Token Prediction based LLM Inversion for Near-Exact Prompt Reconstruction”

What is this paper about?

This paper tries to do something that sounds tricky: given an answer written by a LLM, can we figure out a prompt that would make the model produce that answer? Think of it like hearing the punchline to a joke and trying to guess what the setup was. The authors introduce a new way to “invert” an LLM—work backwards from its output to a matching input—using a method they call Previous-Token Prediction (PTP).

What questions are the authors trying to answer?

  • Can we rebuild a prompt from only the text output of an LLM, without peeking inside the model?
  • Can we make this work reliably enough to recover the original words, not just the general meaning?
  • Can one inverse model work across different datasets and even on outputs made by other LLMs?
  • Can we get not just one, but multiple different prompts that still make the LLM give the same kind of answer?

How does their method work (in everyday terms)?

LLMs normally write text left-to-right by guessing the next word. The authors flip this idea.

Here’s the big idea, step by step:

  • Guessing the question from the answer: Instead of predicting the next word, the “inverse” model learns to predict the previous word—like rewinding a video one frame at a time.
  • Black-box only: They treat the target LLM like a sealed box. They can only give it text and read its replies—no access to internal info like probabilities or hidden layers.
  • Make their own training data: Since they can’t use the LLM’s insides or big outside datasets, they create synthetic text by asking the target LLM to continue short, simple starts (like starting from each token/word in its vocabulary). This shows how the LLM tends to continue text.
  • Reverse the sequences: They take those generated sequences and reverse them at the token level. Now a normal left-to-right model trained on these reversed sequences is, in effect, learning to predict previous tokens.
  • Train an “inverse” model from scratch: Using those reversed sequences, they train a small LLM that is good at reconstructing what came before a given piece of text.
  • Light fine-tuning for formatting: They briefly fine-tune this inverse model on a small set of real prompt–response pairs from the target LLM so it learns typical prompt styles (like how instructions are phrased).
  • Use it to recover prompts: To invert a new answer, they reverse the answer, run the inverse model to “decode backwards,” then reverse the result to get a prompt. They can do this greedily (for a best guess) or with sampling (for multiple valid prompts).

Analogy: It’s like tasting a cake (the answer), training a chef who specializes in reverse-engineering recipes (the inverse model), and then asking that chef to write down one or more recipes (prompts) that would bake a cake with the same taste.

What did they find, and why does it matter?

Here are the key results, explained simply:

  • Near-exact prompt recovery in many cases: When inverting answers from the same model family (e.g., Qwen chat), the method often recovers the original prompt almost word-for-word—about two-thirds of the time in their tests. That’s a strong result for a black-box method.
  • Works better on instruction-tuned chat models: Chat versions (trained to follow instructions) were easier to invert than base models. Instruction tuning seems to make prompts more “recoverable.”
  • Multiple prompts can work: Because many different prompts can lead to similar answers, their method can generate diverse prompts that still cause the original LLM to respond similarly. That’s useful for both understanding behavior and controlling it.
  • Outperforms prior black-box baselines on exact wording: Compared to earlier black-box methods that mainly match the meaning, PTP does better at matching the exact tokens (the literal words).
  • Transfers across datasets and models (with caveats): Even when the answer comes from a different model (like GPT-4o), their inverse model can still find prompts that lead to similar answers, though exact word matches drop because different models split words differently (tokenizers differ).

Why this matters:

  • Security and safety: If you can find many prompts that produce an unsafe or undesirable answer, you can block or filter those prompts more effectively.
  • Transparency: It gives a way to study how an LLM might have been prompted (e.g., hidden system prompts) without opening the model.
  • Practicality: It needs only text inputs/outputs—no privileged access to the model’s internals.

What are the limitations?

  • Exact matches depend on tokenization: If the forward model (the one you’re inverting) uses a different way of splitting text into tokens than your inverse model, exact word-for-word recovery becomes harder.
  • Query cost: Generating synthetic training data by probing the model across its whole vocabulary can be expensive in terms of the number of queries.
  • Small fine-tuning still needed: A brief fine-tune step on a small set of prompt–response pairs helps the inverse model get the style and formatting right.

What could this change in the future?

  • Better safety tools: Finding many different prompts that cause unsafe outputs could help companies build stronger defenses.
  • More reliable auditing: Teams might reconstruct hidden or internal prompts to check how systems behave and why.
  • Stronger, more efficient inversion: Future work could lower the number of queries needed, improve exact recovery across different tokenizers, and add light, smart refinement steps without losing the black-box simplicity.

In short: The paper shows a practical, black-box way to “rewind” an LLM’s output back to a prompt that likely produced it. It often gets very close to the original wording, beats previous black-box methods on exact matches, and can generate multiple valid prompts that lead to the same kind of answer.

Knowledge Gaps

Below is a single, concrete list of knowledge gaps, limitations, and open questions that remain unresolved in the paper and can guide future research.

  • Black-box assumption vs. tokenizer access: The method implicitly assumes access to, and reuse of, the target model’s tokenizer; how to perform inversion when the tokenizer/vocabulary is unknown, changed, or inaccessible (e.g., proprietary models) remains open.
  • Sensitivity to tokenizer mismatch: Exact-token recovery collapses across tokenizer families; develop tokenizer-agnostic inversion (e.g., byte-level, character-level, or detokenization-robust approaches) and quantify the trade-offs in fidelity and compute.
  • Formal guarantees: No theoretical conditions are provided under which PTP is identifiable or consistent; derive guarantees relating PTP training on reversed synthetic sequences to recovering P(x | y), including assumptions on injectivity, decoding stochasticity, and sequence length.
  • Stopping and length prediction: The paper does not specify principled criteria for predicting prompt length or termination; investigate calibrated stopping rules, EOS handling, and length priors to reduce over/under-generation.
  • Uncertainty quantification: The inversion is inherently many-to-many, yet no uncertainty estimates are reported; design calibrated confidence scores over reconstructed prompts and methods to enumerate diverse, high-probability candidates with controllable diversity.
  • Diversity measurement: Although sampling is said to yield multiple valid prompts, there is no analysis of diversity, coverage, or redundancy; create metrics and protocols to quantify diversity while preserving forward-behavioral equivalence.
  • Practical query budget: Synthetic probing “over the entire vocabulary” is potentially expensive; quantify the actual query cost and develop efficient/active probing strategies with budget–accuracy trade-off analyses.
  • Probing design: Probing starts from single-token seeds; evaluate multi-token seeds, structured templates, or adaptive/active learning schemes to better cover the forward model’s behavior space with fewer queries.
  • Synthetic–natural gap: Training primarily on synthetic continuations may induce distributional mismatch with real prompts; assess and reduce this gap (e.g., with small, unlabeled real outputs or self-conditioning) without violating black-box constraints.
  • Fine-tuning dependency: Despite “data-free” pretraining, performance still requires fine-tuning on prompt–response pairs; quantify minimal fine-tuning needs, scaling laws vs. number/length of pairs, and generalization outside the fine-tuning domain.
  • Scaling to longer contexts: The approach assumes response length ≤ inverse model context window; study strategies for very long responses (chunked inversion, memory-augmented decoding) and quantify degradation with increasing length.
  • Robustness to decoding settings: Inversion is trained/evaluated under specific temperature/top-k/p; analyze sensitivity to forward model decoding policies and whether PTP can invert outputs produced under unknown or varying settings.
  • Multi-turn and system prompts: The method concatenates single-turn prompt–response pairs; extend to multi-turn dialogs, hidden system prompts, and tool-call traces, and evaluate reconstruction fidelity for these structured contexts.
  • Cross-model transfer: Only limited cross-family testing (Qwen → GPT-4o) is shown; systematically map transfer across multiple families/sizes/tokenizers and identify conditions that predict successful semantic vs. token-level transfer.
  • Cross-lingual and code domains: Experiments are largely English, general text; evaluate multilingual settings, code/math prompts, and domain-specific styles to understand tokenization and structure impacts.
  • Architectural constraints: The claim that PTP “naturally” requires decoder-only backbones is empirical; investigate bidirectional or prefix-decoder variants, reversible architectures, or alignment objectives that better suit backward generation.
  • Computational footprint: The paper omits wall-clock, memory, and hardware requirements for training-from-scratch inverse LLMs; provide reproducible cost profiles and compare cost–quality trade-offs against fine-tuning-based baselines.
  • EOS and special token handling: Details about special tokens, role tags, and formatting tokens under reversal are not specified; study how special-token policies affect exact reconstruction and formatting fidelity.
  • Evaluation beyond overlap/semantic metrics: Closed-loop evaluation is limited; explore behavioral equivalence via multi-sample response distributions, task success rates, and human judgments of functional equivalence.
  • Adversarial robustness: Assess robustness when the forward model introduces paraphrasing, randomized styles, or noise to resist inversion; develop defensive transformations and evaluate their impact on PTP success.
  • Privacy and safety implications: The method can enable extraction of private or harmful prompts; propose and test mitigations (watermarking, output randomization, differential privacy, detection) and quantify their effectiveness against PTP.
  • Model drift and versioning: Examine how often an inverse model must be retrained as the target LLM is updated; measure brittleness to small forward-model changes and propose lightweight adaptation strategies.
  • Frequency bias in probing: Uniform per-token probing likely overrepresents rare tokens; compare frequency-weighted vs. uniform probing and analyze the effect on inversion accuracy and stability.
  • Partial/observational constraints: Real-world logs may contain truncated or partially-redacted responses; develop methods for inversion from partial outputs and characterize error vs. observability.
  • Failure analysis: Provide systematic categorization of PTP failures (e.g., formatting errors, lexical substitutions, content drift) and targeted remedies for each failure mode.

Practical Applications

Immediate Applications

The following applications can be deployed with the method as described: training an inverse LLM from scratch using synthetic probing of a target black-box LLM, optional light fine-tuning on a small prompt–response set, and closed-loop verification by re-querying the forward model.

  • Safety forensics and incident response
    • Sectors: software platforms, trust & safety, social media, consumer AI apps
    • What: Given a harmful or policy-violating output, reconstruct likely prompts and enumerate diverse paraphrases that induce the same behavior to map the attack surface.
    • Tools/workflows: “PromptBack” forensic console that ingests offending outputs, produces preimage prompts via greedy + sampled decoding, re-validates them against the forward LLM, and exports blocklists/training data.
    • Assumptions/dependencies: Best fidelity with same-family tokenizer; requires a probing query budget to pretrain the inverse model; ethical-use and legal approval for prompt recovery.
  • Guardrail hardening and coverage expansion
    • Sectors: AI safety, content moderation
    • What: Use the inverse model’s sampling to generate families of prompts that reliably lead to known-bad outputs; add them to allow/deny-lists or use them to train/refine classifiers and safety-tuned LLMs.
    • Tools/workflows: Batch inverse-sampling → closed-loop validation → guardrail policy update; CI tests that fail if new model versions become more invertible to unsafe prompts.
    • Assumptions/dependencies: Closed-loop replay to confirm functional equivalence; instruction-tuned models are more invertible (paper finding), which improves coverage.
  • System-prompt and hidden-instruction leakage assessment
    • Sectors: platform engineering, red-teaming, security audits
    • What: Quantify risk of hidden/system prompt exposure in black-box deployments by attempting reconstruction from observed outputs; report token-level vs semantic recovery.
    • Tools/workflows: Red-team suite with inversion metrics (Exact Match, Token F1, ROUGE-L, cosine/BERT-F1), family/tokenizer-mismatch diagnostics.
    • Assumptions/dependencies: Strongest results when the inverse model uses the same tokenizer; cross-model transfer works semantically but degrades exact recovery.
  • Compliance and audit recovery for enterprise assistants
    • Sectors: finance, healthcare, legal, HR
    • What: When only responses were logged (e.g., due to PII minimization), reconstruct approximations of missing prompts for audit trails and root-cause analysis.
    • Tools/workflows: Audit dashboard that attaches reconstructed prompts and confidence scores to outputs; human-in-the-loop review.
    • Assumptions/dependencies: Legal basis for reconstruction; semantic—not always exact—recovery; organizational tokenizer parity preferred.
  • Prompt-injection triage for RAG and agents
    • Sectors: enterprise software, cybersecurity
    • What: Given a compromised or off-policy answer from an agent, invert to surface candidate injection strings/prompts that likely caused it; feed findings into SIEM/SOAR.
    • Tools/workflows: “Inverse scan” on suspicious outputs → enumerate candidate injections → check forward model reproducibility.
    • Assumptions/dependencies: Works best when the forward model (or a close proxy) is accessible for replay.
  • Response-only dataset labeling and curation
    • Sectors: academia, MLops, data engineering
    • What: Create prompt labels for response-only corpora (e.g., harvested chats) to enable supervised training or analysis.
    • Tools/workflows: Inversion pipeline that generates 1–N candidate prompts per response; deduping by closed-loop validation; export for instruction tuning.
    • Assumptions/dependencies: Semantic correctness prioritized over exact match; dataset licensing/compliance.
  • Behavioral regression testing across model versions
    • Sectors: model evaluation, platform reliability
    • What: Use reconstructed prompts to test if new model versions preserve functional behavior; compare re-generated responses for drift.
    • Tools/workflows: Build “preimage test suites” and run closed-loop diffs across versions.
    • Assumptions/dependencies: Access to both versions for replay; manage tokenizer/version mismatches.
  • Academic evaluation and teaching
    • Sectors: academia, education
    • What: Benchmarks for inversion difficulty, analyses of injectivity and tokenizer effects, coursework on reverse autoregression.
    • Tools/workflows: Public inversion leaderboards; standardized metrics; classroom demos and labs.
    • Assumptions/dependencies: Reproducible black-box access and tokenizers; compute for synthetic pretraining.
  • Customer support and CRM analytics
    • Sectors: customer service, contact centers
    • What: Infer likely customer queries from agent or bot replies when ingress logs are incomplete; improve topic attribution and analytics.
    • Tools/workflows: Batch inversion of resolved tickets; cluster analysis on reconstructed prompts.
    • Assumptions/dependencies: Domain shift may reduce exactness; human QA loop to validate reconstructions.
  • Data augmentation for instruction tuning
    • Sectors: NLP product teams, model training
    • What: Generate multiple semantically equivalent prompts per answer to diversify training and improve robustness.
    • Tools/workflows: Inverse sampling → dedup via closed-loop test → integrate into fine-tuning datasets.
    • Assumptions/dependencies: Monitor semantic drift; sampling temperature/top-k/p controls.

Long-Term Applications

These require further research, scaling, or integration work (e.g., robust cross-tokenizer inversion, lower query budgets, broader model transfer).

  • Cross-vendor, tokenizer-agnostic inversion service
    • Sectors: evaluation, auditing, enterprise SaaS
    • What: Reliable semantic and stronger token-level prompt reconstruction across heterogeneous LLM families without tokenizer parity.
    • Potential product: “Universal Inverse API” with automatic tokenizer bridging and alignment adapters.
    • Dependencies/assumptions: Improved cross-tokenizer alignment, calibration for exact vs semantic trade-offs, efficient probing strategies.
  • Standardized privacy and leakage risk quantification
    • Sectors: policy, governance, compliance
    • What: Regulatory audits that score models on prompt and system-prompt extractability from outputs; reporting frameworks for procurement and oversight.
    • Potential product: Certified “Inversion Risk Score” with thresholds and compliance badges.
    • Dependencies/assumptions: Industry consensus on metrics; legal/ethical frameworks for responsible testing.
  • Equivalence-class guardrails
    • Sectors: AI safety, platform infra
    • What: Real-time defenses that block entire classes of prompts that induce the same unsafe outputs, not just specific strings.
    • Potential product: Runtime moderation engine that uses inverse-model sampling + fast simulators to anticipate near-neighbor prompts.
    • Dependencies/assumptions: Low-latency inference; scalable sampling; continual learning of new unsafe classes.
  • Provenance, attribution, and model fingerprinting
    • Sectors: media platforms, IP protection, journalism
    • What: Use inversion plus closed-loop checks to assess whether an output likely originated from a specific model/config or from a prompt-injected session.
    • Potential product: “LLM fingerprinting” toolkit for forensics and IP disputes.
    • Dependencies/assumptions: Better cross-model calibration; careful error bounds to avoid false attribution.
  • Watermarking and traceability via invertible training
    • Sectors: platform integrity, compliance
    • What: Architect models and training regimes to make inversion more faithful and controllable, enabling traceable preimages and accountable generations.
    • Potential product: “Traceable LMs” with built-in reversible links between outputs and allowable prompt sets.
    • Dependencies/assumptions: Architectural/training changes; privacy-by-design safeguards.
  • Agent planning and credit assignment via reverse decoding
    • Sectors: autonomous agents, robotics, software automation
    • What: Use backward generative modeling to infer prior instructions/subgoals from outcomes, improving plan repair and policy learning.
    • Potential product: Backward-reasoning modules for multi-step agent frameworks.
    • Dependencies/assumptions: Longer-horizon inversion with memory and tool-use context; hybrid symbolic-neural support.
  • Sensitive-domain audit and e-discovery
    • Sectors: healthcare, finance, legal
    • What: Regulated audits that reconstruct user intents from AI-assisted decisions to ensure policy compliance and informed-consent adherence.
    • Potential product: E-discovery pipelines integrating inversion with protected-data access logs.
    • Dependencies/assumptions: Strong governance, consent, and redaction; validated accuracy thresholds to prevent misinterpretation.
  • Data loss prevention and exfiltration analysis
    • Sectors: cybersecurity
    • What: When outputs indicate possible leakage, enumerate preimage prompts to characterize how leaks could have been elicited and to patch policies/data exposure.
    • Potential product: DLP analyzers with inverse-driven “leak elicitation maps.”
    • Dependencies/assumptions: Access to the production model or high-fidelity proxy; robust semantic inversion.
  • Lossless/reversible LM pairs and editable generation
    • Sectors: creative tools, IDEs, education
    • What: Future architectures that allow near-lossless forward–inverse cycles, enabling granular editing by “backing out” to an inducing prompt and re-forwarding.
    • Potential product: Round-trip editors for text/code with provenance-preserving histories.
    • Dependencies/assumptions: Architectural innovation beyond current decoder-only designs; training objectives that encourage bidirectional fidelity.
  • Research: injectivity, identifiability, and theory
    • Sectors: academia
    • What: Rigorous studies of when LMs are injective/invertible; links to hidden-state recoverability and causal interpretability.
    • Potential product: Open benchmarks and theory toolkits connecting inversion quality to model design choices.
    • Dependencies/assumptions: Access to families of models and controlled training regimes.

Notes on Feasibility and Constraints

  • Black-box but tokenizer-sensitive: Exact token-level reconstruction is strongest when the inverse model shares the tokenizer and family with the target LLM; semantic reconstruction transfers better across families.
  • Query budget and compute: Synthetic probing over the vocabulary and training an inverse model (e.g., ~0.6B parameters) require measurable API and compute budgets; on-the-fly generation improves diversity and performance.
  • Data/ethics: Some uses are dual-use. Deploy only with explicit consent, legal review, and strict governance; avoid reconstructing sensitive user inputs without authorization.
  • Closed-loop verification: For high-stakes applications, always re-query the forward LLM to confirm that reconstructed prompts functionally reproduce the target response within predefined similarity thresholds.
  • Model choice: Instruction-tuned chat models were found more invertible than base models, which benefits safety and audit applications but also heightens leakage risk—balance with guardrails and monitoring.

Glossary

  • Adam Optimiser: An adaptive stochastic optimization algorithm that uses first and second moments of gradients to adjust learning rates. "using autoregressive NLL loss with Adam Optimiser and lr=1e-3."
  • alignment fine-tuning: Additional training to align a model’s behavior with human or task-specific preferences, often after pretraining or instruction tuning. "to assess the performance of our approach under instruction tuning and alignment fine-tuning."
  • auto-regressive: A generation or modeling process where each token is predicted conditioned only on previously generated tokens. "As a result, once trained, the model can generate a sequence auto-regressively from left to right, conditioned on the prompt xx."
  • BERT F1: A semantic similarity metric that computes F1 using contextual embeddings derived from BERT representations. "A combination of lexical and semantic similarity metrics, including Exact Match (EM), Token F1, BLEU, ROUGE-L, Cosine Similarity (CS), and BERT F1 defined in Appendix Sec~\ref{sec:eval-metrics} are used for evaluating the prompt reconstruction quality."
  • black-box setting: A regime where one can query a model’s inputs and observe outputs without access to its internal parameters, gradients, or logits. "In contrast, we present a functional approach to inverting a given LLM in a black-box setting, without auxiliary aids."
  • BLEU: A precision-oriented n-gram overlap metric commonly used to evaluate text generation quality. "A combination of lexical and semantic similarity metrics, including Exact Match (EM), Token F1, BLEU, ROUGE-L, Cosine Similarity (CS), and BERT F1 defined in Appendix Sec~\ref{sec:eval-metrics} are used for evaluating the prompt reconstruction quality."
  • causal LLM: A LLM that predicts the next token based only on tokens to its left (past context). "Given a prompt xx, a causal LLM ff learns to model the conditional probability of the next token at each position."
  • closed-loop response reconstruction: An evaluation setup where reconstructed prompts are fed back into the forward model to see if the original responses are reproduced. "PTP outperforms prior black-box baselines on lexical metrics and preserves semantic behavior under closed-loop response reconstruction."
  • conjunctive normal form: A standardized Boolean formula represented as a conjunction of disjunctions (AND of OR clauses). "Finally, deterministic formulations such as \cite{suhail2024network}, which encode networks into conjunctive normal form and apply SAT solvers and samplers to identify inverse solutions."
  • cosine similarity (CS): A similarity measure computing the cosine of the angle between two vectors, often used for semantic similarity. "A combination of lexical and semantic similarity metrics, including Exact Match (EM), Token F1, BLEU, ROUGE-L, Cosine Similarity (CS), and BERT F1 defined in Appendix Sec~\ref{sec:eval-metrics} are used for evaluating the prompt reconstruction quality."
  • decoder-based inverse LLM: A decoder-only LLM trained to map responses back to prompts (the inverse mapping). "Rather than fine-tuning a pretrained sequence-to-sequence model, we train an explicit decoder-based inverse LLM entirely from scratch using synthetically generated data obtained from the target model itself, without access to logits, gradients, embeddings, or original training data."
  • Exact Match (EM): A strict metric that checks whether two sequences are exactly identical at the token level. "A combination of lexical and semantic similarity metrics, including Exact Match (EM), Token F1, BLEU, ROUGE-L, Cosine Similarity (CS), and BERT F1 defined in Appendix Sec~\ref{sec:eval-metrics} are used for evaluating the prompt reconstruction quality."
  • greedy reverse decoding: Deterministically selecting the highest-probability tokens when generating the prompt in reverse order. "(3) The use of PTP-based inversion for faithful prompt reconstruction through greedy reverse decoding and subsequent response reconstruction by re-querying the forward model."
  • He initialization: A weight initialization strategy designed for deep networks with ReLU-like activations to maintain signal variance. "We use Qwen3-0.6B, as our inverse model, which is sufficiently expressive and lightweight enough to be trained from scratch, initialized using He~\cite{he2015delving} initialization."
  • injective: A one-to-one mapping property where each input maps to a unique output, enabling potential invertibility. "Recently, ~\cite{nikolaou2025languagemodelsinjectiveinvertible} introduced SipIt suggesting that transformer LLMs are injective, mapping discrete input sequences to continuous hidden representations enabling provable reconstruction of exact inputs from hidden activations."
  • instruction tuning: Supervised fine-tuning on instruction–response pairs to make models follow natural-language instructions. "We validate our proposed inversion approach across multiple LLMs, including Qwen3-0.6B and LLaMA-2 7B, with different model sizes and architectures on both the base and chat variants to assess the performance of our approach under instruction tuning and alignment fine-tuning."
  • inverse LLM: A model trained to predict previous tokens or reconstruct prompts from responses, effectively inverting a forward LLM. "We train an explicit inverse LLM entirely from scratch on data synthetically generated from the target LLM itself."
  • Logit-to-Text (L2T): A prompt inversion approach that reconstructs text from next-token probability vectors (logits). "Complementarily, \cite{morris2024language} proposes Logit-to-Text(L2T) for prompt inversion from next-token distributions, showing that a model’s probability vector over the vocabulary contains rich information about preceding text."
  • logits: The raw, pre-softmax scores output by a model for each token in the vocabulary. "They rely on fine-tuning pretrained sequence-to-sequence models on large external datasets—and requiring access to model weights or logits—to generate semantically plausible prompts."
  • negative log-likelihood (NLL): A loss function equal to the negative logarithm of the model-assigned probability of the observed sequence. "This corresponds to minimizing the negative log-likelihood loss"
  • next-token prediction (NTP): The standard language modeling objective of predicting the next token given the prior context. "LLMs are typically trained in a forward generative manner using the next-token prediction (NTP) objective."
  • Output-to-Prompt (O2P): A black-box method that learns to recover prompts from observed textual outputs. "Output-to-Prompt (O2P) by \cite{zhang-etal-2024-extracting} operates purely on textual outputs in a black-box setting by fine-tuning pretrained sequence-to-sequence models to recover prompts from responses."
  • preimage: The set of all inputs that a function maps to a given output. "such that x^\hat{x} belongs to the preimage of yy under ff, defined as"
  • Previous-Token Prediction (PTP): An inversion objective where the model predicts the prior token given future context, enabling reverse generation. "Our proposed approach to LLM Inversion using Previous-Token Prediction."
  • Prompt Inversion from Logprob Sequences (PILS): A method that aggregates log-probabilities across steps to reconstruct prompts efficiently. "Later, Nazir et al.~\cite{nazir2025betterlanguagemodelinversion} propose Prompt Inversion from Logprob Sequences (PILS), exploiting the low-dimensional structure of next-token distributions to compactly represent and aggregate log-probabilities across generation steps, yielding substantial gains in exact recovery."
  • Reverse Prompt Engineering (RPE): A training-free, search-based technique that iteratively refines candidate prompts to reproduce outputs. "propose reverse prompt engineering(RPE), a training-free black-box approach that queries the target LLM with its own responses and refines candidate prompts via search."
  • ROUGE-L: A recall-oriented text overlap metric based on the longest common subsequence. "A combination of lexical and semantic similarity metrics, including Exact Match (EM), Token F1, BLEU, ROUGE-L, Cosine Similarity (CS), and BERT F1 defined in Appendix Sec~\ref{sec:eval-metrics} are used for evaluating the prompt reconstruction quality."
  • SAT solvers: Algorithms that determine the satisfiability of Boolean formulas, often used in combinatorial search. "encode networks into conjunctive normal form and apply SAT solvers and samplers to identify inverse solutions."
  • sequence-to-sequence model: An encoder–decoder architecture that maps an input sequence to an output sequence. "They rely on fine-tuning pretrained sequence-to-sequence models on large external datasets—and requiring access to model weights or logits—to generate semantically plausible prompts."
  • SipIt: A method arguing that transformer LMs are injective and thus invertible via hidden states. "Recently, ~\cite{nikolaou2025languagemodelsinjectiveinvertible} introduced SipIt suggesting that transformer LLMs are injective, mapping discrete input sequences to continuous hidden representations enabling provable reconstruction of exact inputs from hidden activations."
  • stochastic decoding: A non-deterministic generation procedure that samples tokens according to a modified probability distribution. "using stochastic decoding with temperature τ\tau, top-kk, and top-pp filtering."
  • temperature: A scaling factor applied to logits to control randomness during sampling. "using stochastic decoding with temperature τ\tau, top-kk, and top-pp filtering."
  • tokenization: The process of converting text into a sequence of tokens as defined by a model’s vocabulary. "Reversal is applied after tokenization rather than at the raw text level."
  • Token F1: An F1 score computed over token matches, assessing token-level precision and recall. "A combination of lexical and semantic similarity metrics, including Exact Match (EM), Token F1, BLEU, ROUGE-L, Cosine Similarity (CS), and BERT F1 defined in Appendix Sec~\ref{sec:eval-metrics} are used for evaluating the prompt reconstruction quality."
  • top-kk: A sampling strategy that restricts choices to the kk most probable tokens. "using stochastic decoding with temperature τ\tau, top-kk, and top-pp filtering."
  • top-pp filtering: Also called nucleus sampling; selects from the smallest set of tokens whose cumulative probability exceeds pp. "using stochastic decoding with temperature τ\tau, top-kk, and top-pp filtering."
  • transferability: The ability of a learned inverse model to generalize to different models or datasets. "Our approach generalises across datasets and exhibits transferability in reconstructing prompts from responses generated by different LLMs."
  • vocabulary-level probing: Systematically seeding generations from each vocabulary token to synthesize training data. "(2) A synthetic data generation strategy based on vocabulary-level probing of the target LLM without access to model internals."
  • zero-shot: Performing a task without task-specific training or fine-tuning on that target domain. "and demonstrates strong zero-shot transferability across different LLMs, all within a strict black-box setting."

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.

Tweets

Sign up for free to view the 2 tweets with 426 likes about this paper.