Geometric Prompt-Trajectory Planning for Test-Time Scaling

Zhengqi Pei, Anran Zhang, Qingming Huang, Shuhui WangNeurIPS 2026

TL;DR

When we want a Large Language Model (LLM) to solve a genuinely tough problem, the current playbook is to give it a bigger compute budget at test time—usually by asking it to generate dozens of answers and taking a majority vote. Maze flips this script: instead of burning expensive generation tokens on brute-force trial and error, it spends a tiny fraction of compute upfront to map out the optimal sequence of few-shot examples before the LLM utters a single word. The result? Better reasoning accuracy with half the LLM calls.

What Problem Does This Paper Address?

Test-time scaling (TTS)—giving models more "thinking" compute during inference—has become a cornerstone of modern LLM reasoning. However, standard approaches like self-consistency (repeated sampling and majority voting) or Tree of Thoughts are "width-heavy" or generation-heavy: they rely on invoking the target LLM over and over again. Not only does this rack up massive decoding latency and API bills, it can also backfire if the model’s most common failure mode dominates the vote.

Meanwhile, we know that in-context learning is weirdly fragile. What few-shot examples ("exemplars") you put in a prompt—and the exact order you put them in—can make or break an LLM's reasoning. Previous methods tried to pick examples based on simple similarity to the user's question. The authors ask a sharp, economical question: Can a little bit of compute spent planning the exact trajectory of the prompt save us from making dozens of expensive reasoning attempts later?

Methods

The authors introduce Maze, a framework that treats an ordered sequence of $K$ few-shot examples not as a static bag of text, but as a prompt trajectory—a directed path through a latent geometric space leading from the system instruction ($e_0$), through the ordered exemplars, right up to the test query ($q$).

Figure 1: Maze plans the prompt before target-model generation. (a) Cached encoder views represent ordered exemplar trajectories from the system instruction e0 to the query q. (b) Directed transitions, node contributions, and query-conditioned cross-layer fusion produce a whole-path score. (c) The highest-scoring trajectory becomes a complete prompt for the black-box target. Correctness feedback supervises the scorer offline; online ranking uses only input-side features. MultiMaze allocates N generation calls to selected trajectories and aggregates their answers by majority vote.

Here is how the machinery works without needing access to the target LLM's weights:

  • Decoupled Black-Box Setup: A separate, frozen encoder (Qwen3-4B by default) extracts multi-layer representations ("views") of all candidate exemplars offline and caches them. At test time, only the new query needs to be encoded once.
  • Geometric Path Scorer: Maze uses a tiny, 0.35M-parameter learnable network to score candidate prompt paths (typically a pool of 100 random paths) before calling the target LLM. Crucially, this scorer models directed transitions between consecutive examples both within and across encoder layers, weights each node's contribution, and fuses them conditioned on the query. Reversing the order of two examples changes the directed edges, making the score genuinely order-sensitive.
  • Offline Contrastive Learning: How does the scorer know what a "good" path looks like? Offline, the authors train it on pairs of prompts—often created by small local edits like swapping two examples' positions—that flip the target LLM's answer from wrong to right.
  • Single-Call and MultiMaze: At inference, single-call Maze picks the highest-scoring path and makes just one LLM call. MultiMaze scales this up to $N$ calls by picking winning paths from $N$ candidate pools and taking a majority vote over the answers.

Datasets

No new datasets are introduced, though AIME problems from 2021–2024 are specifically curated and reserved for testing. Training pairs and exemplar banks are drawn from training splits, and evaluation spans five diverse reasoning benchmarks:

  • MMLU-Pro (professional-level multi-task knowledge)
  • GPQA (graduate-level "Google-proof" science QA)
  • GSM8K & MATH500 (grade-school to competition-level math)
  • AIME 2021–2024 (elite high-school math olympiad problems)

Key Insights and Ideas

  • It’s the route, not just the destination: Simply picking relevant examples isn't enough. Taking the exact set of examples chosen by Maze and merely shuffling their order drops accuracy by an average of 2.8 percentage points. Furthermore, Maze beats a parameter-matched Transformer ranker trained on the exact same data, proving that explicitly modeling directed, cross-layer transitions captures something special about how prompts steer an LLM.
  • Beating the "Oracle" without cheating: Surprisingly, 16-call MultiMaze outperforms a 16-call Random-Proposal Oracle (which peeks at the ground truth and succeeds if at least one of 16 random prompts yields the right answer). How? The oracle is stuck choosing among mediocre, unfiltered prompts; Maze changes the input distribution entirely, steering the LLM into higher-probability reasoning territory before generation begins.
  • Cross-Model Black-Box Transfer: Because the frozen Qwen3-4B encoder is completely detached from the target generator, a Maze scorer trained on open-weight models transfers zero-shot to proprietary giants like GPT-5.1 and Gemini 2.5 Pro, boosting their accuracy without collecting a single label from them.

Key Results

Scaling behavior of Maze across training pairs, pool size, and LLM calls

Figure 2: Scaling behavior of Maze. (a) Accuracy @ MMLU-Pro vs. number of contrastive pairs used to train the metric mappings. (b) Qwen3-4B’s Accuracy @ MMLU-Pro vs. path-pool size Mpool at inference. Darker hues indicate more training epochs (from 2 to 32) for the same configuration. (c) Multi-call Maze vs. Oracle-guided BoN and Majority Vote (Qwen3-4B): with the same or fewer calls, energy-ranked prompting improves the observed call–accuracy trade-off; the oracle curve uses random proposals.
  • Single-Call Gains: Across Mistral-7B, LLaMA3-8B, and Qwen3-8B, single-call Maze beats random prompting and prior exemplar-optimization baselines (pFLAT, EASE) across every benchmark. On GPQA with Qwen3-8B, Maze jumps 15.02 percentage points over random prompting (53.37% vs. 38.35%) and beats EASE by 5.07 points.
  • Halving the Multi-Call Budget: With 16 target LLM calls, MultiMaze outperforms 32-call Majority Vote in every tested setup—cutting end-to-end latency nearly in half (254.6s vs. 483.2s on Qwen3-8B/MMLU-Pro). On GPQA with Qwen3-14B, 16-call MultiMaze hits 70.98%, crushing 32-call Majority Vote (54.32%) by 16.66 points.
  • Negligible Online Overhead: Encoding the query and scoring 100 paths adds just 0.3 seconds to a single 15.5-second LLM call on an RTX 4090.
  • Proprietary APIs: With lightweight adaptation (512 completions), 1-call Maze boosts Gemini 2.5 Pro on AIME-24 from 87.1% to 91.5%, and 8-call MultiMaze reaches 94.5%.

Limitations and Future Work

Maze isn't a free lunch. Its theoretical and empirical bounds show that planner-side search relies on two things: coverage (your exemplar bank actually contains useful examples) and rankability (the scorer accurately orders them). Furthermore, generating the offline contrastive training data takes 10–20 hours of compute; you need enough test-time query traffic to amortize that upfront investment. Finally, mismatches between the small proxy encoder and a massive target LLM, as well as residual stochasticity during token decoding, can cap performance gains. Future directions are not explicitly proposed by the authors beyond establishing prompt-side planning as a complementary axis for test-time scaling.

Summary updated

Abstract

Test-time scaling (TTS) improves large language model (LLM) reasoning by allocating additional inference-time computation, often through repeated sampling and aggregation. This width-heavy strategy increases the generation cost and can reinforce common failure modes. We introduce Maze, a TTS framework that shifts part of this computation from repeated target-model calls to planning over ordered few-shot exemplars. The central idea is to treat an ordered exemplar sequence as a prompt trajectory embedded in a latent geometric space. Instead of asking the LLM for many independent attempts, Maze first ranks candidate prompt trajectories using cached encoder representations and a path scorer, i.e., a lightweight learnable metric, then spends one call (or a few calls) only on the most promising trajectories. Directed transitions, node contributions, and query-conditioned cross-layer fusion model how the complete path guides the target model. The selected trajectory is executed with one call, or with a small call budget in MultiMaze. A separate frozen encoder preserves black-box access to the target LLM. Across five reasoning benchmarks, single-call Maze outperforms the evaluated single-call prompt-optimization baselines, while MultiMaze improves on 32-call majority vote using 16 target-model calls. A theoretical analysis relates selection quality to candidate coverage and ranking error, explaining when planner-side computation can substitute for repeated sampling and when it cannot.
BibTeX
@inproceedings{pei2026geometric,
  author = {Zhengqi Pei and Anran Zhang and Qingming Huang and Shuhui Wang},
  title = {{Geometric Prompt-Trajectory Planning for Test-Time Scaling}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=e22Krci8Dn},
}
Figure