A Unified Evaluation-Instructed Framework for Query-Dependent Prompt Optimization

Ke Chen, Yifeng Wang, Hassan Almosapeeh, Haohan WangarXiv 2025 · DOI

Abstract

Current prompt optimization techniques often rely on static templates or expensive, black-box feedback loops. This paper introduces a unified framework for query-dependent prompt optimization that utilizes an execution-free evaluator. By training a model to predict multi-dimensional quality scores, the system can diagnose specific prompt failures for a given query and perform interpretable, performance-oriented rewrites without the high cost of repeated LLM executions.

Introduction

In Large Language Model (LLM) applications, the quality of a prompt often determines the boundary between accurate reasoning and hallucination. Existing optimization methods face two primary challenges: the use of static templates that ignore query-specific requirements and reliance on unstable, expensive feedback mechanisms like textual gradients or black-box reward models. This research addresses these issues by defining the core metrics of a "good" prompt and integrating them into an efficient, portable optimization loop.

Methodology: The Prompt Evaluation–Optimization Pipeline

The proposed framework consists of three integrated stages designed to move beyond "one-size-fits-all" prompting.

The Unified Evaluation-Instructed Framework architecture, illustrating the Evaluator and Optimizer components.

1. Training Dataset Generation

To build a robust evaluator, the authors curated a dataset of 11,530 prompts. This corpus includes static templates, LLM-generated prompts in diverse styles (e.g., Socratic, Expert Discussion), and "Evolutionary Recombination"—a genetic-algorithm-inspired method that merges segments of different prompts to create high-performing hybrids.

2. The Execution-Free Evaluator

A lightweight LLaMA-8B model was fine-tuned using Low-Rank Adaptation (LoRA). This evaluator performs two simultaneous tasks:

  • Classification: Predicting the likelihood of prompt success (accuracy > 50%).
  • Regression: Estimating four critical metrics: Negative Log-Likelihood (NLL), Semantic Stability, Mutual Information (MI), and Query Entropy.

3. Metric-Aware Optimization

When the evaluator identifies a low-quality prompt, it leverages the gradient of the classification loss to pinpoint the specific metric causing the deficit. A targeted "diagnoser" then provides actionable feedback, such as suggesting format constraints to improve stability or reducing stylistic noise to enhance mutual information.

Experimental Setup and Benchmarks

The framework was rigorously tested across eight benchmarks spanning diverse domains:

  • Reasoning and Logic: Big-Bench Hard (BBH) tasks including causal judgment and sports understanding.
  • Advanced Knowledge: GPQA Diamond (graduate-level science) and MedQA (medical board exams).
  • Specialized Domains: LegalBench for legal definition classification.
  • Mathematics: MATH500 for high-level mathematical reasoning.

Key Insights: The Four Pillars of Prompt Quality

Statistical analysis using XGBoost identified four key features that serve as the most reliable predictors of downstream LLM performance.

Distribution of feature weights for prompt quality metrics, highlighting the importance of Query Entropy and Stability.
  • Predictive Power: Query Entropy and Stability Score emerged as dominant factors in determining prompt efficacy.
  • Efficiency: By predicting these metrics directly from text, the system avoids the "token tax" associated with multiple LLM runs.
  • Model Capacity Limits: Optimization is most effective within a model's natural capacity. For instance, while optimization improves LLaMA-3-8B, it cannot bridge the gap to GPT-4o on extremely complex tasks like MATH500.
  • Portability: Signals derived from the LLaMA-3-trained evaluator successfully generalized to improve other models, including LLaMA-3.1 and GPT-4o.

Results and Performance

The framework demonstrates significant improvements over both static and query-dependent baselines:

  • Accuracy: The evaluator achieved 83.7% accuracy in predicting prompt success, a substantial increase over the 69% achieved by Prompt-OIRL.
  • Benchmark Gains: The system yielded a 10% improvement on LegalBench and a 5-6% gain on the unseen MedQA dataset.
  • Interpretability: Unlike black-box models, this framework provides explicit diagnostic feedback, identifying exactly why a prompt is failing (e.g., lack of clear output format).

Conclusion and Future Work

This unified framework represents a shift toward more interpretable and efficient prompt engineering. While highly effective, the authors note that prompt optimization cannot compensate for fundamental reasoning deficiencies in smaller models. Future research will expand the evaluation metrics to include safety, token efficiency, and readability, alongside exploring query-side augmentation to address high Query Entropy.

Summary updated

BibTeX
@misc{chen2025unified,
  author = {Ke Chen and Yifeng Wang and Hassan Almosapeeh and Haohan Wang},
  title = {{A Unified Evaluation-Instructed Framework for Query-Dependent Prompt Optimization}},
  year = {2025},
  eprint = {2511.19829},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.19829},
}
Figure