Reverse Prompt Engineering: A Zero-Shot, Genetic Algorithm Approach to Language Model Inversion

Hanqing Li, Diego Klabjan


Abstract
We explore a new language model inversion problem under strict black-box, zero-shot, and limited data conditions. We propose a novel training-free framework that reconstructs prompts using only a limited number of text outputs from a language model. Existing methods rely on the availability of a large number of outputs for both training and inference, an assumption that is unrealistic in the real world, and they can sometimes produce garbled text. In contrast, our approach, which relies on limited resources, consistently yields coherent and semantically meaningful prompts. Our framework leverages a large language model together with an optimization process inspired by the genetic algorithm to effectively recover prompts. Experimental results on several datasets derived from public sources indicate that our approach achieves high-quality prompt recovery and generates prompts more semantically and functionally aligned with the originals than current state-of-the-art methods. Additionally, use-case studies introduced demonstrate the method’s strong potential for generating high-quality text data on perturbed prompts.
Anthology ID:
2025.emnlp-main.1333
Volume:
Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing
Month:
November
Year:
2025
Address:
Suzhou, China
Editors:
Christos Christodoulopoulos, Tanmoy Chakraborty, Carolyn Rose, Violet Peng
Venue:
EMNLP
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
26234–26256
Language:
URL:
https://preview.aclanthology.org/ingest-emnlp/2025.emnlp-main.1333/
DOI:
Bibkey:
Cite (ACL):
Hanqing Li and Diego Klabjan. 2025. Reverse Prompt Engineering: A Zero-Shot, Genetic Algorithm Approach to Language Model Inversion. In Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, pages 26234–26256, Suzhou, China. Association for Computational Linguistics.
Cite (Informal):
Reverse Prompt Engineering: A Zero-Shot, Genetic Algorithm Approach to Language Model Inversion (Li & Klabjan, EMNLP 2025)
Copy Citation:
PDF:
https://preview.aclanthology.org/ingest-emnlp/2025.emnlp-main.1333.pdf
Checklist:
 2025.emnlp-main.1333.checklist.pdf