Inference-Aware Prompt Optimization for Aligning Black-Box Large Language Models

Saaduddin Mahmud, Mason Nakamura, Kyle Hollins Wray, Shlomo Zilberstein

TL;DR

Prompt optimization and inference-time scaling (like Best-of-N sampling or Majority Voting) are typically treated as completely separate ways to improve LLM performance. This paper shows they are deeply interdependent—the best prompt changes depending on your compute budget—and introduces a framework (IAPO) and algorithm (PSST) to optimize both simultaneously.

What Problem Does This Paper Address?

When working with state-of-the-art Large Language Models (LLMs), researchers and engineers are often restricted to black-box APIs where model weights cannot be altered. To align these models to specific tasks, practitioners rely on two main paradigms:

  1. Prompt Optimization: Rewording or adding instructions to the input prompt to get better outputs.
  2. Inference Scaling: Generating multiple candidate responses for a single query and aggregating them using strategies like Best-of-N (BON) sampling or Majority Voting (MV).

Crucially, existing prompt optimization techniques are inference-agnostic—they optimize prompts assuming single-shot decoding ($N=1$) or a fixed, predetermined inference setup. The authors identify a major methodological gap here: prompt quality cannot be decoupled from the inference strategy. A prompt that excels when generating a single response might perform poorly when paired with Majority Voting, and vice versa.

Inference-agnostic vs. inference-aware prompt optimization framework overview.

Methods

The authors introduce IAPO (Inference-Aware Prompt Optimization), a framework that jointly optimizes prompt design and inference scale ($N$) while conditioning on user preferences (e.g., trade-offs between helpfulness and harmlessness) and computational budgets.

They formulate this as a contextual Best-Arm Identification (BAI) problem, where an "arm" represents a unique combination of a prompt and an inference scale. To solve it efficiently under a strict training budget, they propose:

  • PSST (Prompt Scaling via Sequential Trimming): An arm-elimination algorithm inspired by Sequential Halving. Unlike standard bandit algorithms, PSST is customized for LLM inference properties:
  • Asymmetric pull costs: Sampling an arm with $N=16$ costs sixteen times more budget than $N=1$.
  • Cross-context and nested sample reuse: A single batch of $N=16$ completions can be reused to simulate and evaluate smaller scales (like $N=4$ or $N=8$) across different user preference contexts, drastically saving training compute.
  • Top-K Screening: A warm-up heuristic that filters out clearly suboptimal prompts at a single-shot scale ($N=1$) using a small fraction of the budget before running the full PSST algorithm.

Datasets

The framework was evaluated across six diverse environments using Llama-3.3-70B-Instruct as the underlying black-box model:

  • Synthetic Benchmarks: Synth-Bernoulli (evaluated via MV) and Synth-Categorical (evaluated via BON) to validate theoretical guarantees.
  • Reasoning Tasks (using MV): The MATH benchmark and CommonsenseQA.
  • Multi-Objective Alignment (using BON): Helpful-Harmless (balancing helpfulness vs. harmlessness) and Summarization (balancing preference vs. faithfulness).

Key Insights and Ideas

  • The Prompt-Inference Crossover: The most striking insight is that prompt dominance shifts with the compute budget. As shown in their motivating case study, a "green" prompt might yield the highest accuracy at $N=1$, but as more compute is allocated ($N > 4$), a "blue" prompt completely overtakes it. Optimizing prompts purely on single-shot performance is short-sighted and leads to suboptimal deployment.
Prompt-Inference Interdependence on MATH and Helpful-Harmless datasets.
  • The Non-Affine Trap: Standard prompt optimization implicitly assumes that the average utility scales linearly. However, aggregation strategies like Majority Voting and Best-of-N introduce sharp, non-linear mathematical transformations. For instance, Majority Voting exhibits a steep performance drop-off when the base success probability dips below 0.5, making joint optimization mathematically necessary.

Key Results

The empirical evaluation demonstrated that PSST reliably discovers well-aligned prompt and scaling configurations using as few as 5,000 inference calls.

  • Vs. Standard Exploration: PSST and its Top-K screening variants consistently outperformed traditional bandit baselines like UCB, Softmax, and $\epsilon$-greedy across all six datasets, especially under tight training budgets.
  • Vs. Disjoint Optimization: IAPO methods significantly beat inference-agnostic baselines (like TRIPLE). Overall, the inference-aware approach outperformed disjoint optimization by up to 25% and prompt-only optimization by up to 50%.

Limitations and Future Work

While highly effective, the paper notes a few areas for expansion:

  • Fixed Inference Strategies: The current framework focuses on standard Best-of-N and Majority Voting. The authors plan to extend it to richer, more complex test-time compute strategies like tree search and "parallel thinking" architectures.
  • Latency Constraints: The cost function currently optimizes for token count/budget, but future iterations will explicitly factor in hard latency constraints.
  • Distribution Shift: Investigating how these jointly optimized policies hold up under long-horizon deployments where the query distribution shifts over time remains an open question.

Summary updated

BibTeX
@inproceedings{mahmud2026inference,
  author = {Saaduddin Mahmud and Mason Nakamura and Kyle Hollins Wray and Shlomo Zilberstein},
  title = {{Inference-Aware Prompt Optimization for Aligning Black-Box Large Language Models}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2026},
  doi = {10.1609/aaai.v40i38.40521},
}
Figure