Skip to content

Zero-shot prompt optimizer (Vertex AI)

The Vertex AI Zero-Shot Optimizer is a real-time, low-latency prompt rewriter that takes a single user-written prompt and outputs an improved version — clearer phrasing, better structure, more aligned with the target model’s conventions — without needing any labeled dataset. It supports two modes: instruction generation (describe a goal in plain language → get a structured system prompt) and prompt refinement (rewrite an existing prompt). Output includes the rewritten prompt plus a list of applicable_guidelines explaining which rules were applied (e.g. “add role definition”, “remove redundant instructions”). A dedicated gemini_nano mode rewrites prompts for small-model deployment characteristics.

  • The optimizer is dataset-free and synchronous: a single SDK call (client.prompt_optimizer.optimize_prompt(prompt=...)) returns an OptimizeResponse with a suggested_prompt, applicable_guidelines, and the original_prompt [§Optimize a prompt].
  • Two operating modes: instruction generation (goal → full system instruction from scratch) and prompt refinement (existing prompt → improved prompt) [§Use cases].
  • An explicit small-model mode (OPTIMIZATION_TARGET_GEMINI_NANO) rewrites prompts to match the instruction-following profile of small models like Gemma 3n E4B, which differ meaningfully from large models [§Optimizing for smaller models].
  • applicable_guidelines exposes the rewrite rules used (e.g. Structure: add role definition, RedundancyInstructions: remove redundant explanation) along with text_before_change / text_after_change deltas — so the optimizer doubles as a teaching tool for prompt patterns [§Optimize a prompt example output].
  • The zero-shot optimizer is model-independent and can improve prompts for any Google model, in contrast to the data-driven optimizer which only supports GA Gemini target models [overview page].
  • Supports all languages Gemini supports; available through the Vertex AI Python SDK [§Overview].

The user calls client.prompt_optimizer.optimize_prompt(prompt=...) (optionally with an OptimizeConfig that sets optimization_target for small-model mode). Internally the service runs a single LLM call (or short loop) that applies a curated set of prompt-engineering best practices — role definition, structure, redundancy removal, ambiguity resolution — and returns the rewritten prompt along with a structured trace of which guidelines fired. Because there’s no dataset and no evaluation loop, latency is on the order of a single LLM round-trip, which makes it usable as an inline request-rewriter sitting between the user and the target model — i.e. as one component of the “router + rewriter” pre-processing stack the Slack note describes Google apps using in production.

No benchmark numbers on the doc page. The output schema (applicable_guidelines with before/after deltas) is itself the primary “result” the page advertises — a transparent rewrite that the user can inspect and learn from.

This is the low-latency end of an emerging two-tier prompt-optimization pattern that Google appears to be standardizing: (1) a fast zero-shot rewriter sits in the request path, (2) a batch data-driven optimizer (Data-driven prompt optimizer (Vertex AI)) recompiles system prompts offline against labeled metrics, and (3) a tiny classifier/model router (mentioned in the Slack note but not documented in either page) decides which target model to forward to. For Luma, the per-model adaptation story matters most: prompts that worked on Gemini Pro often degrade on Flash because Flash needs more rigid templates and explicit examples, while Pro can absorb open-ended context — the optimizer’s gemini_nano mode makes this size-tier-aware behavior explicit. The applicable_guidelines output is also worth studying as a possible source of training signal for an in-house prompt critic.