Reverse Prompt Engineering

Hanqing Li,Diego Klabjan
2024-11-11
Abstract:This paper explores a new black-box, zero-shot language model inversion problem and proposes an innovative framework for prompt reconstruction using only text outputs from a language model. Leveraging a large language model alongside an optimization algorithm, the proposed method effectively recovers prompts with minimal resources. Experimental results on several datasets derived from public sources indicate that the proposed approach achieves high-quality prompt recovery and generates prompts more similar to the originals than current state-of-the-art methods. Additionally, the use-case study demonstrates the method's strong potential for generating high-quality text data.
Computation and Language
What problem does this paper attempt to address?
The problem that this paper attempts to solve is to reverse - engineer and recover the original input prompt from the text output generated by large - language models (LLMs) under black - box and zero - sample conditions. Specifically, the researchers proposed a new method - Reverse Prompt Engineering (RPE), which can infer the original prompt by using the reasoning ability of the target LLM and combining an iterative optimization algorithm when only a small amount of text output is provided. Compared with previous methods, RPE does not require access to the internal parameters of the model or a large amount of output data, nor does it require an additional training process. This makes RPE particularly suitable for dealing with closed - source LLMs such as GPT - 3.5. In addition, RPE shows higher accuracy and efficiency in prompt recovery, and its average cosine similarity on different embedding models is 5.2% higher than that of the current state - of - the - art method. The main contributions of the paper are: - Providing the first research on the reverse problem of language models under black - box and zero - sample conditions. - Proposing an innovative method to recover prompts from text output using only LLMs. - Designing a novel optimization algorithm that uses the LLM itself as an optimizer to improve the accuracy of prompt recovery. Verified by experiments, RPE not only has technological breakthroughs but also shows great potential in practical applications, such as being used to generate high - quality text data, such as marketing plans, video game designs, and lyric writing.