On the Capability and Limitation of Hard Prompt

📅 2026-09-26
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 AI Summary
This study addresses the lack of theoretical foundations for hard prompts in large language models (LLMs) by integrating computational complexity theory, formal analysis of Transformers, and statistical learning theory to conduct rigorous mathematical proofs. The research establishes, for the first time, the NP-completeness of hard prompt search, reveals the "prompt-dominates-answer" phenomenon alongside intrinsic trade-offs between prompt length and performance, and derives necessary and sufficient conditions for generalization together with the first tight bounds. By bridging this theoretical gap in hard prompting, this work lays a solid mathematical foundation for prompt engineering in practical LLM applications.
📝 Abstract
Prompt engineering has become an indispensable tool for using large language models (LLMs), turning LLMs into task-specific experts without changing their weights. Despite notable theoretical advances in prompt engineering, the theory for the more practical hard or discrete prompts is largely open. In this paper, we try to fill this gap either by providing a complete solution or by making substantial progress on the three core theoretical questions regarding hard prompts. First, we show that determining the existence of a hard prompt for a transformer to solve a downstream task is NP-complete and that finding an optimal hard prompt is NP-hard, which is the first computational complexity result for hard prompting, as far as we know. Second, we show that, unlike soft or continuous prompts, hard prompts have essential limitations: hard prompts are not complete; short hard prompts do not significantly enhance the ability of transformers; and long hard prompts exhibit the"prompt dominating answer phenomenon,"meaning that, with high probability, the same answer is given for all queries of the same length. On the other hand, linear hard prompts do not have the limitations of short or long prompts. Third, we provide a tight bound on the size of the task in terms of the prompt length for the performance of prompts on the finite task to generalize to the entire data distribution, leading to a necessary and sufficient condition for generalizability. This is the first result on generalization for prompting, as far as we know. Our findings not only offer the first theoretical insights into hard prompts but also provide provably reliable practical guidance for real-world LLM usage.
Problem

Research questions and friction points this paper is trying to address.

hard prompt
computational complexity
prompt limitation
generalization
large language models
Innovation

Methods, ideas, or system contributions that make the work stand out.

Hard Prompt
Computational Complexity
Prompt Dominating Answer Phenomenon
Generalization Bound
Prompt Engineering
🔎 Similar Papers
No similar papers found.
💼 Related Jobs
No related jobs found.
L
Lijia Yu
Institute of AI for Industries, Chinese Academy of Sciences
S
Shuaitong Liu
Southwest University
Gaojie Jin
Gaojie Jin
Lecturer (Assistant Professor), University of Exeter
Machine LearningStatistical LearningTrustworthy AIHuman-GenAI-Alignment
X
Xinyu Li
Department of Computer Science, University of Exeter
Xiao-Shan Gao
Xiao-Shan Gao
AMSS, CAS
Automated ReasoningSymbolic ComputationMachine Learning Theory