Introduction
In the field of deep learning, a persistent "generalization gap" exists between statistical theory and empirical practice. Classical statistical tools often produce vacuous bounds—theoretical guarantees that a model’s error will be less than 100%—which offer little practical value. This disconnect has led many researchers to hypothesize that deep learning requires an entirely new theoretical framework to explain why massive models do not simply memorize their training data.
This paper challenges that assumption by focusing on prompt engineering. When using vision-language models like CLIP for zero-shot classification, practitioners provide text prompts (e.g., "a photo of a [CLASS]"). Often, researchers optimize these prompts on a training set to maximize performance. Surprisingly, even when prompts are explicitly tuned, the resulting models still perform exceptionally well on unseen test data, resisting the severe overfitting typically expected. The authors demonstrate that classical PAC-Bayes theory, when combined with a large language model (LLM) as a prior, provides remarkably tight generalization bounds that explain this success.
Methodology
The researchers reframe prompt engineering as a discrete optimization problem. Instead of updating millions of continuous network weights, the optimization process searches for a sequence of discrete text tokens.
- Greedy Search: They implement a simple algorithm that constructs a prompt one word at a time, iteratively choosing the token that most improves training accuracy.
- PAC-Bayes Framework: To derive generalization bounds, the authors utilize the PAC-Bayes framework. The critical innovation is their choice of prior: they use a pretrained Large Language Model (LLaMA-7B) to define the likelihood of specific word sequences.
- Structural Risk Minimization (SRM): They introduce a "Regularized Greedy" search. Rather than solely maximizing accuracy, this approach seeks prompts that minimize the PAC-Bayes bound, effectively balancing empirical accuracy with the "naturalness" or likelihood of the prompt according to the LLM prior.
Key Insights and Empirical Results
The authors evaluate their approach across diverse computer vision benchmarks, including standard classification tasks (CIFAR-10, CIFAR-100, ImageNet) and domain generalization datasets (fMoW, OfficeHome).
Why Discrete Optimization Helps Theory
Because prompts consist of discrete tokens, the hypothesis space (the total number of possible prompts) is significantly smaller and more structured than the infinite, continuous space of neural network weights. This discrete nature makes the underlying mathematics much more tractable. By using an LLM as a prior, the authors encode the intuition that "natural-sounding" prompts are more likely to generalize. If a nonsensical prompt achieves 100% training accuracy, the PAC-Bayes bound heavily penalizes it for being highly unlikely under the LLM prior.
Remarkably Tight Bounds
Unlike most generalization bounds in deep learning, the bounds derived in this work are non-vacuous and remarkably tight.
As shown above, the PAC-Bayes bounds for prompts generated via greedy search remain significantly tighter and closer to the true test error compared to standard uniform convergence bounds. For instance, on ImageNet, the authors achieved a generalization bound of 31.9% for a classifier with an actual test error of 25.6%. For context, previous state-of-the-art bounds for ImageNet were often above 90% or entirely vacuous. On CIFAR-10 using a ViT-L/14 CLIP model, they found a bound of 6.3% against a test error of 2.8%.
Effective Model Selection
The authors also demonstrate that the PAC-Bayes bound is an excellent tool for model selection.
When evaluating various hand-crafted prompts, there is a strong linear correlation between the theoretical PAC-Bayes bound and the actual test error. If a practitioner has multiple candidate prompts, selecting the one with the lowest theoretical bound reliably identifies the prompt that will perform best on unseen data. Furthermore, prompt engineering proves highly robust to noise; unlike standard neural networks, it is exceedingly difficult to find a text prompt that can "memorize" images with randomized labels.
Limitations and Future Work
While these findings bridge a significant gap between theory and practice, the authors note a few limitations:
- Frozen Encoders: These tight bounds rely on the image and text encoders of the vision-language model remaining frozen. Fine-tuning the continuous weights of the model would cause the complexity to explode, likely rendering the bounds vacuous once again.
- Data Contamination: Vision-language models undergo massive web-scale pre-training, raising the possibility that they have already seen the "test" images. The authors acknowledge this but argue their bounds remain valid relative to the prompt search process itself.
- Linguistic Coherence: While the Regularized Greedy search produces prompts that generalize well, the resulting text is not always human-readable. Future work could focus on constraining the search to produce more interpretable, natural language prompts without sacrificing performance or theoretical guarantees.
Summary updated