potentialpaper

Towards a Theoretical Understanding of Prompt Engineering: Tractability, Existence, and Generalization

Lijia Yu, Shuaitong Liu, Xiao-Shan Gao, Lijun Zhang

ICLR 2026 submission

Edit this page

Or clone it with git

The page gets its repository with its first edit, so start in the web editor.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

Abstract. Prompt engineering has rapidly become an indispensable tool for the effective utilization of large language models (LLMs), turning LLMs into task-specific experts without changing their weights. Despite its significant practical achievements, the theoretical advancement in this area is relatively limited. To enhance its understanding and interpretability, this paper addresses three fundamental questions in prompt engineering: the computational tractability of finding optimal prompts, existence conditions for the required prompts, and the generalizability of prompts. Precisely, we consider the problem of finding a prompt for a given query-answer dataset and a fixed transformer. We prove that deciding the existence of a perfect prompt is NP-complete, and computing an optimal prompt is NP-hard. Furthermore, we establish sufficient conditions for the existence of perfect prompts based on the structural properties of the dataset, which are also necessary in a certain sense. Finally, we derive a generalization bound demonstrating that the effectiveness of a prompt on the dataset extends to the whole data distribution when the dataset size significantly exceeds the prompt’s length. In summary, our findings answer three crucial theoretical questions in prompt engineering, offering enhanced theoretical insights and some practical guidance.

Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.

Claim this paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

add · history

No versions are recorded yet: its preprint, the venues it went to and what they decided, the camera-ready. Missing a version?

We don't know of a submission of this paper to a venue with open reviews. Missing a submission?

Loading the discussion…