Promptimus:手動エンジニアリングなしで既存の優れた LLM プロンプトを改善する手法
Amazon Science が発表した「Promptimus」は、既存の高度なプロンプトをゼロから作り直すのではなく、失敗点の特定と部分的修正を通じて自動最適化する画期的な手法です。
キーポイント
既存プロンプトの自動最適化アプローチ
プロンプトをゼロから設計するのではなく、既に構築された複雑なビジネスロジックを含むプロンプトに対して、失敗点に基づいた手術的な修正を行う手法です。
メトリクス駆動型の自律的改善
ユーザー定義のパフォーマンス指標と Python コード関数を用いて AI エージェントが自動で分析・デバッグを行い、特定のタスクに特化した改善戦略を反復実行します。
モデル非依存性と編集モード
ソースモデルの最適化済みプロンプトをターゲットモデルへ迅速に適応させる「モデル非依存性」に加え、複雑なロジックを維持しつつ欠陥部分のみを修正する「編集モード」を搭載しています。
多様なエンタープライズタスクへの対応
分類、情報抽出、生成、要約、コード生成、ツール利用など、テキストおよびマルチモーダルな幅広いエンタープライズユースケースで機能することが実証されています。
影響分析・編集コメントを表示
影響分析
この手法は、LLM の導入におけるボトルネックである「ドメイン固有の複雑なロジックを含むプロンプトの維持と最適化」に対する現実的な解決策を提供します。特に、医療や金融など規制が厳しく、一度構築されたプロンプトを安易に書き換えることができない業界において、既存資産を活かしつつ性能を継続的に向上させるための重要な技術基盤となり得ます。
編集コメント
「プロンプトエンジニアリングはもう終わりだ」と言われる中で、既存の複雑なシステムをいかに効率的に維持・進化させるかという実務的な視点が示されており、現場のエンジニアにとって非常に示唆に富む内容です。
大規模言語モデル(LLM)は、業界を問わず企業アプリケーションに不可欠なものとなっています。その内部では、顧客からの入力には、複雑なビジネスロジック、規制要件、ドメイン専門知識をエンコードしたプロンプトが付加されています。例えば、医療システムは健康保険の携帯性と責任法(HIPAA)に準拠した言語を使用する必要があり、金融取引システムはリスク許容ルールに従う必要があります。これらのプロンプトは通常、ドメイン専門家によって数週間から数ヶ月かけて作成されます。しかし、ビジネス上の要求はさらに高いパフォーマンスを求め続けています。したがって、課題はゼロからプロンプトを設計することではなく、ドメイン要件を損なうことなく、微妙でタスク固有の改良点を見出すことで、すでに強力なパフォーマンスを向上させることです。本稿では、既存のプロンプトを自動的に最適化するための手法「Promptimus」を紹介します。この手法には、先行する手法に比べていくつかの利点があります。
モデル非依存性:ソースモデル用に既に最適化されたプロンプトを受け取り、ターゲットモデルに対して迅速に再最適化し、モデル間で最適化されたプロンプトを比較します。
パフォーマンス基準に基づく駆動:既存のプロンプトテンプレート、タスク固有のデータサンプル、ユーザー定義のパフォーマンス指標(メトリクス)を受け取り、ドメイン固有の最適化目標を達成するために反復的にターゲット型の改善戦略を生成します。
脆弱性の活用に焦点:メトリクス解析 AI エージェントを使用して失敗点を特定し、デバッグ支援エージェントを使用して根本原因を特定し、ランダムな次元ではなく失敗点に対して外科的かつ標的型にプロンプトを改良することで、 targeted なパフォーマンス向上を実現します。
完全自動化:ユーザー定義の指標を分析し、コードサニタイゼーション AI エージェントを使用してデバッグチェックポイントを自動的に生成します。メトリクス関数は Python コードとしてインポート可能で、パフォーマンス基準はいつでも追加または変更できます。
編集モード:複雑なビジネスロジックを持つ大規模で慎重に構造化されたプロンプトの場合、編集モードではプロンプト全体を書き換えるのではなく、外科的かつ標的型の修正を行います。これは、すでに機能している部分を維持しつつ、壊れている部分だけを正確に修正するものです。
Promptimus は、分類、抽出、生成、要約、コード生成、ツール使用など、テキストおよびマルチモーダル LLM タスクの幅広い範囲をサポートしています。以下のセクションでは、私たちの手法、システムアーキテクチャ、および複数の企業タスクにおける実験結果を紹介します。
なぜ良いプロンプトを改善するのが難しいのか
プロンプト最適化の自動化への試みは、プロンプトエンジニアリングそのものの歴史に遡りますが、ゼロからプロンプトを生成する際にはうまく機能するアプローチでも、よく設計されたプロンプトを改善するのは困難です。"より創造的に"や"例を追加する"といった一般的な方向性を用いたランダムな探索戦略は効果的ではありません。なぜなら、残りの改善点は非常に特定の戦略的方向性に存在するためです。スカラー値のスコアという形で得られる限られたフィードバックでは、なぜインスタンスが失敗するのか、どのように改善すべきかについての指針を提供できません。
ビジネスドメインからの要求による複雑さの増大に加え、モデルの急速な進化もプロンプト最適化の課題をさらに複雑にしています。Anthropic、OpenAI、Google、Meta、Alibaba などのプロバイダーが新しいモデルをリリースするにつれ、企業は繰り返されるプロンプト移行の課題に直面します。あるモデル用に最適化されたプロンプトは、異なる指示従順特性のために別のモデルではパフォーマンスが発揮されないことがよくあります。手動での再最適化はコストがかかり時間がかかるため、回帰リスクによりより良いモデルの採用が遅れることがあります。
手法とシステム設計
Promptimus は、以下の入力を持つ 4 つのステップからなる反復ループを中心とした手法によってこれらの課題に対処します:推論に使用する LLM、初期のプロンプトテンプレート、プロンプトテンプレートに対応する変数を含む小さな JSONL データセット(通常 20〜50 サンプル)、これはプロンプトチューニング用の開発セットと検証用の保持されたテストセットに分割されます。サンプルに正解が含まれていることは必須ではありません。ユーザー定義のパフォーマンス評価メトリクス関数(独自の Python コードを持参可能)。
4 つのステップからなる反復ループ
ステップ 1:評価:初期化中に、開発セットを使用してターゲット LLM で元のプロンプトを実行し、ベースラインの評価スコアを確立します。さらに、メトリクス解析エージェントがユーザー定義のメトリクス関数を分析し、評価を中間検証ステップに分解するチェックポイント関数を生成します。これらのチェックポイントは、最適化プロセス全体を通じて微細な失敗診断を可能にします。例えば、チェックポイントで出力の 98% が正しい JSON 形式を持ち、95% が有効なスキーマを持つが、有効な値を持つのは 88% しかないことが明らかになった場合、パフォーマンス発現不足の原因は値の検証に限定されます。
初期評価の後、Promptimus は標準モード(プロンプトの完全書き換えを実行)または編集モード(構造化された検索・置換編集でプロンプトを修正)のいずれかに分岐します。
ステップ 2:フィードバック生成:LLM ドライブ型のフィードバックジェネレーターは、メトリクス解析器によって事前に計算されたメトリクスチェックポイントを使用して、現在のプロンプト結果における失敗パターンを診断します。ボトルネックとなるチェックポイント(パス率が最も低いもの)を特定し、対比を提供するために失敗例と成功例の両方を含む代表的なインスタンスを集め、根本原因と一般的な失敗モードを分析します。最後に、プロンプトを修正するための実行可能な提案(例えば、「モデルが列挙コードではなく記述的なテキストを出力するため、明示的な制約を追加することを提案する」)を提供します。
分析+戦略+編集生成:標準モードと同じ失敗分析を実行した後、フィードバックジェネレーターは特定の失敗に責任を持つ正確な場所に修正を固定した、標的型の検索・置換編集を提案します。
ステップ 3:戦略+完全書き換え:前ステップからのフィードバック、メトリクス、データサンプルに基づき、メタオプティマイザーがタスク特性を分析し、元のプロンプトにエンコードされたすべてのドメイン固有の要件を維持したまま、タスク固有の探索戦略を生成します。その後、各戦略に対して、指示最適化器は特定された弱点と特定のエラーパターンに対処する改善されたプロンプト候補を提案します。この戦略と候補との 1 対 1 の結合により、最適化空間の多様な探索が保証されます。
プログラムによる編集適用:ステップ 2 で提案された各編集について、Promptimus は 3 つのマッチングレベル(完全一致、空白正規化ファジーマッチ、行参照付近の類似度マッチ)を使用して、編集を特定された失敗に決定論的にマッチさせます。このプロセスは LLM の呼び出しなしで 97.3% の成功率を誇ります。
ステップ 4:候補評価:各候補を開発セットで実行し、ユーザー定義のメトリクス関数を実行して最良の候補を選択します。最もパフォーマンスの高い候補が次のイテレーションの開始点となります。この探索に焦点を当てたプロセスは、ユーザーが指定した回数反復的に実行され、各イテレーションは前回の学習と成果に基づいて構築されます。
大幅な拡張が必要な短いプロンプトには標準モードをお勧めします。例えば、詳細な推論プロトコルへと成長させる必要がある 2 行の数学プロンプトなどです。編集モードは、API スキーマ、コンプライアンスルール、ドメイン分類法などの構造化コンテンツを含む長く、すでに良く作られたプロンプトにはより適しています。完全書き換えでは、慎重に作成されたセクションが黙って削除または再編成されるリスクがあるためです。
50,000〜100,000 トークンのプロンプスの場合、典型的なイテレーションで生成されるのは 3〜5 の編集で合計 500〜1,000 トークンであり、プロンプト全体を再生成するのと比較されます。より一般的に、Promptimus は最適化ループが未解決の失敗モードを表面化させた場合にのみコンテンツを追加するため、プロンプスの長さは最初の数回のイテレーションで頭打ちになります。これは、すでに長い生産用プロンプスでは相対的なサービング時間の影響が小さく、短いスターターテンプレートでは大きくなることを意味します。最適化されたプロンプスがキャッシュされたシステムプロンプトとして提供される場合、追加コストはキャッシュの有効期間中に 1 回の呼び出しのみとなり、スケール上では無視できるほどになります。
実証実験と分析
私たちは、推論、数学、質問応答、テキストから SQL へ、コーディング、関数呼び出し、指示従順、マルチモーダルタスクにわたる 20 の公開ベンチマークで、Promptimus を 6 つの主要な自動プロンプト最適化手法と比較評価しました。すべての手法は、ターゲットモデルとして Claude Sonnet 4.6 を使用し、5 つのランダムシードで平均化した同じオプティマイザーモデルと評価予算を使用しました。各ベンチマークでは、最適化に 20 の開発サンプル、評価に 100 の保持されたテスト例を使用しました。
以下の表に報告されている通り、Promptimus は 20 のベンチマーク中 16 で最良の結果を達成し、1 つで同率首位となり、6 つのベースライン平均を上回りました(ベスト・オブ・シックス・ベースラインは 0.765 に対し、Promptimus は 0.792)。最大の改善は、メトリクスが分解可能な構造を持つタスクで見られました。特に、編集モードを使用した Promptimus はすべての 4 つのマルチモーダルベンチマークで他社を上回り、視覚言語プロンプトは書き換えるのではなく既存の視覚分析構造を維持することで恩恵を受けることが示唆されます。
ベンチマーク | メトリック | 最適化なし | ベスト・オブ・シックス・ベースライン | Promptimus | モード
BBH-CausalJudgeAcc [0,1] | 0.538 | 0.726 (GEPA) | 0.718 | Standard
BBH-DisambigQAAcc [0,1] | 0.601 | 0.868 (GPO) | 0.908 | Standard
BBH-GeoShapesAcc [0,1] | 0.747 | 0.770 (OPRO) | 0.936 | Standard
BBH-RuinNamesAcc [0,1] | 0.918 | 0.926 (GEPA) | 0.928 | Standard
BBH-SnarksAcc [0,1] | 0.324 | 0.920 (OPRO) | 0.908 | Edit
GSM8KAcc [0,1] | 0.658 | 0.964 (MIPROv2) | 0.958 | Standard
DAPO-AIMEAcc [0,1] | 0.703 | 0.730 (ProTeGi) | 0.79 | Standard
HotPotQAF1 [0,1] | 0.16 | 0.832 (MIPROv2) | 0.839 | Standard
SpiderExAcc [0,1] | 0.68 | 0.846 (GEPA) | 0.85 | Edit
BIRDExAcc [0,1] | 0.626 | 0.684 (ProTeGi) | 0.684 | Standard
BigCodeBench-hardPass@1 [0,1] | 0.339 | 0.336 (ProTeGi) | 0.345 | Standard
CodeforcesPass@1 [0,1] | 0.589 | 0.808 (TextGrad) | 0.818 | Edit
BFCLAST [0,1] | 0.882 | 0.968 (MIPROv2) | 0.98 | Standard
NesT-FuLPMacc [0,1] | 0.375 | 0.429 (TextGrad) | 0.469 | Standard
IFBenchAcc [0,1] | 0.498 | 0.509 (GEPA) | 0.53 | Standard
IFEvalStrict [0,1] | 0.876 | 0.886 (GPO) | 0.892 | Standard
MathVistaAcc [0,1] | 0.433 | 0.606 (GPO) | 0.644 | Edit
ChartQARelaxed Acc [0,1] | 0.279 | 0.828 (ProTeGi) | 0.834 | Edit
AI2DAcc [0,1] | 0.834 | 0.824 (MIPROv2) | 0.868 | Edit
DeFactifyAcc [0,1] | 0.835 | 0.922 (MIPROv2) | 0.938 | Edit
Average | 0.595 | 0.765 | 0.792 |
下の図は、2 つの代表的なベンチマークにおけるイテレーションを通じた収束を示しています。Promptimus の編集モードは、最終的な開発スコアの 90% に到達するのに、メトリクス呼び出しで中央値約 300 回と、すべてのベースラインよりも速く達成します。両方のモードは通常 8 回のイテレーション内で頭打ちになり、改善の大部分が最初の 3〜5 回のイテレーションに集中しています。
重要なのは、開発セットでの向上が保持されたテストセットにも転移することです。時にはベースラインが開発セットでは Promptimus と同等かそれ以上であっても、テストセットでは後れを取る場合があります。これは過学習を示唆しています。私たちはこれを、編集モードの外科的修正による汎用可能なプロンプト構造の維持と、例にわたって転送する失敗信号を生成するメトリクスプロービング(dev セットのパターンの暗記とは対照的)によるものだと考えています。
また、公開ベンチマークと Amazon の企業ユースケースを使用して、分類、テキストから SQL へ、数学推論、コーディング、マルチモーダル理解、7 つのターゲットモデルにおける複雑な API 生成を含むタスクで、複数の LLM にわたって Promptimus を評価しました。Promptimus はすべての 9 タスクでベースラインプロンプスを改善し、改善幅は 3.18% から 90.27% の範囲でした。開発セットのサイズは 30〜160 サンプルで、タスクの大半が 100 未満のサンプルを使用しており、システムのサンプル効率性を示しています。
結果はまた、モデル非依存性の一般化を強調しています:同じ最適化フレームワークが、タスク固有のエンジニアリングなしに、独自およびオープンソースの両方のターゲットモデルで意味のある改善を生み出しました。
タスク | ターゲット LLM | パフォーマンスメトリック | 開発セットサイズ | 最適化なし | 最適化後
Complex API call generation | GPT-OSS-120B | API Acc (user-defined) [0,1] | 43 | 0.45 | 0.86
Classification_A | Nova Pro | F1 score and FPR score [0,1] | 210 | 0.64 | 0.78
Multimodal classification_B | Haiku-4.5 | Accuracy [0,1] | 160 | 0.51 | 0.76
Classification_C | Nova Lite | Accuracy [0,1] | 85 | 0.56 | 0.58
Text2sql_A | Nova-Micro | Execution Accuracy [0,1] | 50 | 0.72 | 0.83
Math reasoning_A | Qwen3-235B[WS12] (non-reasoning) | Accuracy (user-defined) [0,1] | 30 | 0.47 | 0.50
Math reasoning_B | Claude-4.5-Opus (non-reasoning) | Accuracy (user-defined) [0,1] | 30 | 0.60 | 0.73
Coding_A | GPT-OSS-120B | Pass@1 [0,1] | 100 | 0.26 | 0.33
Coding_B | GPT-OSS-120B | Pass@1 [0,1] | 31 | 0.56 | 0.64 |
以下は、Promptimus がすでに微細に調整されたプロンプトを改善し、さまざまなユースケースでアプリケーションのパフォーマンスをさらに向上させた例です。
例 1:CodeForces(LLM の推論能力を評価するために設計されたコーディングベンチマーク)
このユースケースは、ユーザーが提供した問題説明に基づいて LLM に Python 関数を生成させるものです。50 の開発サンプル(元の開発セットからサンプリング)と 148 のテストサンプルを使用し、ユーザー定義のスコアリングアプローチを採用しました。Promptimus(編集モード)による最適化は 5 回のイテレーションで収束しました。
元のプロンプト vs 最適化されたプロンプト(削除は斜体、追加は太字)
-When tackling complex reasoning tasks, you have access to the following -actions. Use them as needed to progress through your thought process.
-[ASSESS]
-[ADVANCE]
-[VERIFY]
-[SIMPLIFY]
-[SYNTHESIZE]
-[PIVOT]
-[OUTPUT]
-You should strictly follow the format below:
-[ACTION NAME]
Your action step 1
Your action step 2
...
Next action: [NEXT ACTION NAME]
+You are an expert competitive programmer. Solve the given programming +problem in Python using the strict 2-phase reasoning structure defined below.
+ ## ABSOLUTE RULE – ONE [OUTPUT] BLOCK ONLY – ZERO EXCEPTIONS
+ The first [OUTPUT] block encountered is the ONLY one evaluated. A second [OUTPUT] block causes + immediate evaluation failure and a score of 0.
+ ## CRITICAL CONSTRAINTS
+ Standard Library Only – Use ONLY Python standard library modules. No exceptions.
+ Forbidden: sortedcontainers, numpy, scipy, pandas. Allowed: bisect, heapq, collections, math, + itertools, functools, sys.
+ If you need a sorted structure: implement using bisect + a plain list.
+ Sorting Pitfall Warning:
+ Never use sort(reverse=True) when the secondary sort direction differs from the primary.
+ Descending by key A, ascending by key B: items.sort(key=lambda x: (-x[0], x[1]))
+ I /O Consistency Rule:
+ Use exactly ONE I/O method throughout – no mixing.
+ Strategy A: input = sys.stdin.readline at top, then use input() everywhere.
+ Strategy B: use sys.stdin.readline() directly everywhere.
+ Variable Initialization Rule:
+ Declare all variables that are conditionally assigned BEFORE their conditional block.
+ ## STRICT 2-PHASE STRUCTURE
+ ### PHASE 1 – [ASSESS] (ONE block only)
+ 5 mandatory gates (G1–G5). Each gate requires a one-line YES/NO + justification.
+ G1 – Brute force feasible? Is O(nˆ2) within time constraints?
+ G2 – All variables initialized before conditional use?
+ G3 – I/O strategy chosen and consistent? Declare exactly one strategy.
+ G4 – Demo output reproducible by hand? Perform explicit dry run on demo input.
+ G5 – Any mutable structure modified during iteration? Confirm index recomputation.
+ End with: Chosen approach: [algorithm name], O([complexity]) – Tier [1/2/3]
+ Tier 1 = Brute-force correct, Tier 2 = Optimized correct, Tier 3 = Optimal.
+ Fallback Rule: If you cannot confidently implement Tier 2+, commit to Tier 1. A slow, correct + solution scores higher than a fast, broken one.
+ ### PHASE 2 – [OUTPUT] (ONE block only, immediately after ASSESS)
+ First line inside [OUTPUT] must declare I/O strategy as a comment.
+ Produce the complete Python solution. No other action types permitted.
+ ## CRITICAL OUTPUT RULES
+ 1. Exactly ONE [OUTPUT] block. Fix mistakes inline – never open a second.
+ 2. Inside [OUTPUT], the ONLY content is the fenced Python code block.
+ 3. Reasoning word budget: entire [ASSESS] block must not exceed 250 words.
+ 4. No trailing empty lines in output.
+ 5. Never end your response with only reasoning – even brute-force is acceptable over no solution.
+ 6. Never output -1 or "no solution" if the problem guarantees a solution always exists.
+ [. . . mandatory code scaffold template with I/O strategy declaration, imports, solve() structure, sorting/mutation reminders, output + formatting rules . . . ]
Time Limit: {time_limit}
Memory Limit: {memory_limit}
Problem Description: {problem_description}
Output Specification: {output_specification}
Demo Input: {demo_input}
Demo Output: {demo_output}
Note: {demo_note}
-Write Python code to solve the problem. Present the code in "'python ... '" at the end.
+Solve the problem using the 2-phase structure: [ASSESS] block (5 mandatory gates G1–G5, ≤250 words), +then [OUTPUT] block (fenced Python solution)
例 2:マルチモーダル AI エージェント
この AI エージェントは、Amazon が建設欠陥を検出するために使用されます。元のプロンプトと最適化されたプロンプトを以下に示します。画像検査員が撮影した画像を確認し、建設欠陥のカテゴリとリスクレベルを特定するために、Amazon Bedrock 上のビジョン言語モデル qwen3-vl-235b-a22b を使用しました。最適化プロセスは 16 の開発サンプルで 3 回のイテレーションをループしました。
Promptimus で生成されたメトリクス解析器と指示最適化器の推奨事項(役割の提供、タスク目標、例付き欠陥カテゴリ、カテゴリ曖昧さ解消セクション、決定木を含む分析指示、出力形式要件、および重要な出力要件)により、画像分類精度は 0.438 から 0.812 に向上しました。最適化されたプロンプトをテストサンプルセット(17 サンプル)に適用したところ、精度は 0.471 から 0.529 に改善されました。
例 3:Defactify(マルチモーダル事実検証)
これは、LLM のマルチモーダル事実検証能力、誤情報検出、AI 生成コンテンツの特定を評価するための包括的なフレームワークです。Promptimus のメトリクス解析器は、モデルがフォトリアリスティックな AI 生成画像に対してデフォルトで"Real"と判断することを発見しました。オプティマイザーは、モデルを"AI-generated"にバイアスさせる非対称重み付けを持つ敵対的デュアル仮説フレームワークを導入します。例えば、元のプロンプトでは、時計の数字が乱れているのを"芸術的なデザイン選択"として却下し、フォトリアリスティックなテクスチャに騙されます。一方、最適化後、敵対的デュアル仮説プロトコルは体系的な信号列挙を強制し、ベースラインが却下した乱れた時計の数字を検出します。
結論と今後の課題
他のメトリクス駆動型プロンプト最適化アプローチと比較して、Promptimus は標的型かつ脆弱性活用 focused な改良を通じて悪用を防ぐことに優れています。これは完全に一般化可能で、手動エンジニアリングなしにユーザー定義のメトリクス関数やタスクドメインに適応します。
密なフィードバックループは、メトリクス関数のコードに対する自動分析を駆動し、デバッグチェックポイントを特定し、各プロンプトとタスクの組み合わせの特定の失敗モードを対象とした適応的かつタスク認識型の探索戦略を生成します。特に、私たちのアプローチはサンプル効率的で、大幅な改善を推進するためにわずか 20〜50 の開発例のみを必要とし、ラベル付きデータが希少または入手コストが高い企業シナリオに適しています。
さらに、モデル非依存性の設計により、プロンプトをターゲットモデルに迅速に適応させ、シームレスな企業レベルのモデル移行を可能にします。私たちは、このイノベーションを Amazon Bedrock を通じて提供し、ゼロの手動エンジニアリングと最小限のラベル付きデータセットで、エンタープライズ生成 AI アプリケーションのモデル移行を可能にしています。
原文を表示
Large language models (LLMs) have become integral to enterprise applications across industries. Under the hood, customers’ inputs to the models are usually augmented with prompts that encode intricate business logic, regulatory requirements, and domain expertise: a healthcare system must use language compliant with the Health Insurance Portability and Accountability Act, for instance, and a financial trading system must follow risk tolerance rules. These prompts are typically crafted by domain experts over weeks or months. Yet business demands continue to push for further performance gains. The challenge, therefore, is not engineering prompts from scratch but rather elevating already strong performance by discovering nuanced, task-specific refinements — without compromising domain requirements. In this post, we present Promptimus, a method for automatically optimizing well-developed prompts that has several advantages over its predecessors: It's model agnostic: It takes a prompt already optimized for a source model, rapidly reoptimizes it for a target model, and compares the optimized prompts across models. It's driven by performance criteria: It takes the existing prompt template, task-specific data samples, and user-defined performance metrics and generates targeted improvement strategies, iterating repeatedly to achieve domain-specific optimization objectives. It focuses on exploits: It uses a metric-analyzer AI agent to identify failure points and a debugging helper agent to identify root causes, and it surgically refines prompts relative to failures (rather than along random dimensions) for targeted performance improvement. It’s fully automated: It analyzes user-defined metrics and uses a code sanitization AI agent to generate debugging checkpoints automatically. Metric functions can be imported as Python code, and performance criteria can be added or modified at any time. It has an edit mode: For large, carefully structured prompts with complex business logic, the edit mode makes surgical, targeted modifications instead of rewriting the entire prompt — preserving the parts that already work while fixing exactly what’s broken. Promptimus supports a wide range of textual and multimodal LLM tasks, including classification, extraction, generation, summarization, code generation, and tool use. In the following sections, we’ll present our methodology, the system architecture, and experimental results on multiple enterprise tasks. Why good prompts are hard to improve Attempts to automate prompt optimization are as old as prompt engineering itself, but approaches that work well when generating prompts from scratch struggle to improve well-engineered prompts. Random exploration strategies using generic directions like "be more creative" or "add examples" are ineffective, because the remaining improvements lie in very specific strategic directions. Sparse feedback in the form of scalar scores provides no guidance on why instances fail or how to improve. On top of growing complexity from business domain demands, rapid model evolution further compounds the challenge of prompt optimization. As providers like Anthropic, OpenAI, Google, Meta, and Alibaba release new models, enterprises face recurring prompt migration challenges. Prompts optimized for one model often underperform on another due to different instruction-following characteristics. Manual reoptimization is costly and time consuming, and regression risks delay adoption of better models. Methodology and system design Promptimus addresses these challenges with a methodology built around a four-step iteration loop, with the following inputs: the LLM you aim to use for inference the initial prompt template a small JSONL dataset (typically 20–50 samples) with corresponding variables for prompt templates, split into a development set (for prompt tuning) and a held-out test set (for validation); it is not mandatory for the samples to contain the ground truth a user-defined performance-evaluation metric function (you can bring your own Python code) The four-step iteration loop Step 1 — evaluation: During initialization, the original prompt is executed on the target LLM using the development set (dev set) to establish baseline evaluation scores. Additionally, the metric-analyzer agent performs analysis of the user-defined metric function, generating checkpoint functions that decompose the evaluation into intermediate validation steps. These checkpoints enable fine-grained failure diagnosis throughout the optimization process. For example, when the checkpoints reveal that 98% of outputs have the correct JSON format, and 95% have valid schemas, but only 88% have valid values, the cause of underperformance is localized to value validation. After the initial evaluation, Promptimus branches into either standard mode, where it conducts full prompt rewrites, or edit mode, where it modifies prompts with structured find-and-replace edits. Standard modeEdit modeStep 2Feedback generation: The LLM-driven feedback generator uses the metric checkpoints precomputed by the metric analyzer to diagnose failure patterns in the current-prompt results. It identifies the bottleneck checkpoint (the one with the lowest pass rate) and collects representative instances — including both failing and passing examples, to provide contrast — then analyzes root causes and common failure modes. Finally, it provides actionable suggestions for fixing the prompt (such as "model outputs descriptive text instead of enum codes, suggest adding explicit constraint").Analysis + strategy + edit generation: After performing the same failure analysis as in the standard mode, the feedback generator proposes targeted find-and-replace edits, pinning changes to the exact locations responsible for specific failures. Step 3Strategy + full rewrite: Based on the feedback from the previous step, along with the metrics and data samples, the metaoptimizer analyzes task characteristics and generates task-specific exploration strategies, while maintaining all domain-specific requirements encoded in the original prompt. Then, for each strategy, the instruction optimizer proposes an improved prompt candidate that addresses the identified weaknesses and specific error patterns. This one-to-one coupling between strategies and candidates ensures diverse exploration of the optimization landscape. Programmatic edit application: For each proposed edit in step 2, Promptimus deterministically matches the edit to the identified failure with three match levels: exact match, whitespace-normalized fuzzy match, and similarity match near line reference. This process has a 97.3% success rate with zero LLM calls.Step 4Candidate evaluation: Each candidate is executed using the dev set, and the best candidate is selected by running the user-defined metric function. The best-performing candidate becomes the starting point for the next iteration. This exploration-focused process runs iteratively for a user-specified number of iterations, with each iteration building on what was learned and achieved in the previous one.We recommend standard mode for short prompts that need significant expansion — for example, a two-line math prompt that needs to grow into detailed reasoning protocols. Edit mode is a better choice for longer and already well-crafted prompts containing structured content like API schemas, compliance rules, or domain taxonomies, where full rewrites risk silently dropping or reorganizing carefully crafted sections. For a prompt with 50,000–100,000 tokens, a typical iteration produces three to five edits totaling 500–1,000 tokens, versus regeneration of the entire prompt. More generally, Promptimus adds content only when the optimization loop surfaces unaddressed failure modes, so prompt length plateaus within the first few iterations. This means that the relative serving-time impact is small for already long production prompts and larger for short starter templates. If the optimized prompt is served as a cached system prompt, the additional cost is one call during the cache's time to live, which becomes negligible at scale. Empirical experiments and analysis We evaluated Promptimus against six leading automatic prompt optimization methods across 20 public benchmarks spanning reasoning, math, question answering, text-to-SQL, coding, function calling, instruction following, and multimodal tasks. All methods used the same optimizer model and evaluation budgets with Claude Sonnet 4.6 as the target model, averaged over five random seeds. Each benchmark used 20 dev samples for optimization and 100 held-out test examples for evaluation. As reported in the table below, Promptimus achieves the best result on 16 of 20 benchmarks and ties on one, outperforming all six baselines on average (0.792 vs. 0.765 for the best-of-six baseline). The largest gains appear on tasks where the metric has a decomposable structure. Notably, Promptimus with edit mode outperforms all four multimodal benchmarks, suggesting that vision-language prompts benefit from preserving existing visual-analysis structure rather than rewriting it. BenchmarkMetricNo optimizationBest of six baselinesPromptimusModeBBH-CausalJudgeAcc [0,1]0.5380.726 (GEPA)0.718StandardBBH-DisambigQAAcc [0,1]0.6010.868 (GPO)0.908StandardBBH-GeoShapesAcc [0,1]0.7470.770 (OPRO)0.936StandardBBH-RuinNamesAcc [0,1]0.9180.926 (GEPA)0.928StandardBBH-SnarksAcc [0,1]0.3240.920 (OPRO)0.908EditGSM8KAcc [0,1]0.6580.964 (MIPROv2)0.958StandardDAPO-AIMEAcc [0,1]0.7030.730 (ProTeGi)0.79StandardHotPotQAF1 [0,1]0.160.832 (MIPROv2)0.839StandardSpiderExAcc [0,1]0.680.846 (GEPA)0.85EditBIRDExAcc [0,1]0.6260.684 (ProTeGi)0.684StandardBigCodeBench-hardPass@1 [0,1]0.3390.336 (ProTeGi)0.345StandardCodeforcesPass@1 [0,1]0.5890.808 (TextGrad)0.818EditBFCLAST [0,1]0.8820.968 (MIPROv2)0.98StandardNesT-FuLPMacc [0,1]0.3750.429 (TextGrad)0.469StandardIFBenchAcc [0,1]0.4980.509 (GEPA)0.53StandardIFEvalStrict [0,1]0.8760.886 (GPO)0.892StandardMathVistaAcc [0,1]0.4330.606 (GPO)0.644EditChartQARelaxed Acc [0,1]0.2790.828 (ProTeGi)0.834EditAI2DAcc [0,1]0.8340.824 (MIPROv2)0.868EditDeFactifyAcc [0,1]0.8350.922 (MIPROv2)0.938EditAverage0.5950.7650.792The figure below shows convergence through iterations on two representative benchmarks. Promptimus edit mode reaches 90% of its final development score in a median of about 300 metric calls, faster than all baselines. Both modes typically plateau within eight iterations, with the bulk of improvement concentrated in the first three to five iterations. Importantly, dev set gains transfer to the held-out test set. Sometimes baselines match or even exceed Promptimus on dev but fall behind on test, indicating overfitting. We attribute this to edit mode's surgical modifications, which preserve generalizable prompt structure, and metric probing, which produces failure signals that transfer across examples, as opposed to memorization of dev-set patterns. We also evaluated Promptimus across multiple LLMs using a public benchmark and Amazon enterprise use cases, spanning the tasks of classification, text-to-SQL, math reasoning, coding, multimodal understanding, and complex API generation on seven target models. Promptimus improved baseline prompts on all nine tasks, with gains ranging from 3.18% to 90.27%. Dev sets ranged from 30 to 160 examples, with the majority of tasks using fewer than 100, demonstrating the system's sample efficiency. The results also highlight model-agnostic generalizability: the same optimization framework produced meaningful gains across both proprietary and open-source target models without task-specific engineering. TaskTarget LLMPerformance metricDev set sizeNo optimizationOptimizedComplex API call generationGPT-OSS-120BAPI Acc (user-defined) [0,1]430.450.86Classification_ANova ProF1 score and FPR score [0,1]2100.640.78Multimodal classification_BHaiku-4.5Accuracy [0,1]1600.510.76Classification_CNova LiteAccuracy [0,1]850.560.58Text2sql_ANova-MicroExecution Accuracy [0,1]500.720.83Math reasoning_AQwen3-235B[WS12] (non-reasoning)Accuracy (user-defined) [0,1]300.470.50Math reasoning_BClaude-4.5-Opus (non-reasoning)Accuracy (user-defined) [0,1]300.600.73Coding_AGPT-OSS-120BPass@1 [0,1]1000.260.33Coding_BGPT-OSS-120BPass@1 [0,1]310.560.64Following are examples of how Promptimus improved already fine-grained prompts to further drive application performance for a variety of use cases. Example 1: CodeForces (coding benchmark designed to evaluate LLM reasoning) This use case is to use an LLM to generate a Python function based on a user-provided problem description. We used 50 dev samples (sampled from the original dev set) and 148 test samples with a user-defined scoring approach. The Promptimus (edit mode) optimization converged in five iterations. Original vs. optimized prompt (deletions in italic, additions in bold)-When tackling complex reasoning tasks, you have access to the following -actions. Use them as needed to progress through your thought process. -[ASSESS] -[ADVANCE] -[VERIFY] -[SIMPLIFY] -[SYNTHESIZE] -[PIVOT] -[OUTPUT] -You should strictly follow the format below: -[ACTION NAME] -# Your action step 1 -# Your action step 2 -... -Next action: [NEXT ACTION NAME] +You are an expert competitive programmer. Solve the given programming +problem in Python using the strict 2-phase reasoning structure defined below. + ## ABSOLUTE RULE – ONE [OUTPUT] BLOCK ONLY – ZERO EXCEPTIONS + The first [OUTPUT] block encountered is the ONLY one evaluated. A second [OUTPUT] block causes + immediate evaluation failure and a score of 0. + ## CRITICAL CONSTRAINTS + Standard Library Only – Use ONLY Python standard library modules. No exceptions. + Forbidden: sortedcontainers, numpy, scipy, pandas. Allowed: bisect, heapq, collections, math, + itertools, functools, sys. + If you need a sorted structure: implement using bisect + a plain list. + Sorting Pitfall Warning: + Never use sort(reverse=True) when the secondary sort direction differs from the primary. + Descending by key A, ascending by key B: items.sort(key=lambda x: (-x[0], x[1])) + I /O Consistency Rule: + Use exactly ONE I/O method throughout – no mixing. + Strategy A: input = sys.stdin.readline at top, then use input() everywhere. + Strategy B: use sys.stdin.readline() directly everywhere. + Variable Initialization Rule: + Declare all variables that are conditionally assigned BEFORE their conditional block. + ## STRICT 2-PHASE STRUCTURE + ### PHASE 1 – [ASSESS] (ONE block only) + 5 mandatory gates (G1–G5). Each gate requires a one-line YES/NO + justification. + G1 – Brute force feasible? Is O(nˆ2) within time constraints? + G2 – All variables initialized before conditional use? + G3 – I/O strategy chosen and consistent? Declare exactly one strategy. + G4 – Demo output reproducible by hand? Perform explicit dry run on demo input. + G5 – Any mutable structure modified during iteration? Confirm index recomputation. + End with: Chosen approach: [algorithm name], O([complexity]) – Tier [1/2/3] + Tier 1 = Brute-force correct, Tier 2 = Optimized correct, Tier 3 = Optimal. + Fallback Rule: If you cannot confidently implement Tier 2+, commit to Tier 1. A slow, correct + solution scores higher than a fast, broken one. + ### PHASE 2 – [OUTPUT] (ONE block only, immediately after ASSESS) + First line inside [OUTPUT] must declare I/O strategy as a comment. + Produce the complete Python solution. No other action types permitted. + ## CRITICAL OUTPUT RULES + 1. Exactly ONE [OUTPUT] block. Fix mistakes inline – never open a second. + 2. Inside [OUTPUT], the ONLY content is the fenced Python code block. + 3. Reasoning word budget: entire [ASSESS] block must not exceed 250 words. + 4. No trailing empty lines in output. + 5. Never end your response with only reasoning – even brute-force is acceptable over no solution. + 6. Never output -1 or “no solution” if the problem guarantees a solution always exists. + [. . . mandatory code scaffold template with I/O strategy declaration, imports, solve() structure, sorting/mutation reminders, output + formatting rules . . . ] Title: {problem_title} Time Limit: {time_limit} Memory Limit: {memory_limit} Problem Description: {problem_description} Output Specification: {output_specification} Demo Input: {demo_input} Demo Output: {demo_output} Note: {demo_note} -Write Python code to solve the problem. Present the code in “‘python ... “‘ at the end. +Solve the problem using the 2-phase structure: [ASSESS] block (5 mandatory gates G1–G5, ≤250 words), +then [OUTPUT] block (fenced Python solution)Example 2: Multimodal AI agent This AI agent is for Amazon to detect construction defects. The original and optimized prompts are shown below. We used the vision-language model qwen3-vl-235b-a22b on Amazon Bedrock to examine the images taken by inspectors and identify construction defect categories and risk levels. The optimization process looped in three iterations with 16 dev samples. The recommendations generated by the metric analyzer and instruction optimizer in Promptimus (including providing a role, a task objective, defect categories with examples, a category disambiguation section, analysis instructions with a decision tree, output format requirements, and critical output requirements) improved the image classification accuracy from 0.438 to 0.812. When we applied the optimized prompt to the test sample set (17 samples), accuracy improved from 0.471 to 0.529. Example 3: Defactify (multimodal fact verification) This is a comprehensive framework for evaluating an LLM’s ability to perform multimodal fact verification, detect misinformation, and identify AI-generated content. The Promptimus metric analyzer found that the model defaults to ''Real'' for photorealistic AI-generated images. The optimizer introduces an adversarial dual-hypothesis framework with asymmetric weighting that biases the model toward “AI-generated”. For example, with the original prompt, the model dismisses a clock with garbled numbers as an “artistic design choice” and is fooled by photorealistic textures. After optimization, by contrast, the adversarial dual-hypothesis protocol forces systematic signal enumeration, catching the garbled clock numerals that the baseline dismissed. Conclusion and future work Compared to other metric-driven prompt optimization approaches, Promptimus excels at preventing exploitation through targeted and exploitation-focused refinements. It is fully generalizable, adaptive to user-defined metric functions and task domains without manual engineering. The dense feedback loop drives automatic analysis on metric-function code, identifies debugging checkpoints, and generates adaptive, task-aware exploration strategies that target the specific failure modes of each prompt-and-task combination. Particularly, our approach is sample efficient, requiring only a small number of dev examples (typically 20–50) to drive significant improvements, fitting it for enterprise scenarios where labeled data is scarce or expensive to obtain. Furthermore, its model-agnostic design enables it to rapidly adapt prompts to target models for seamless enterprise-level model migration. We are making this innovation available through Amazon Bedrock to enable model migration for enterprise generative-AI applications with zero manual engineering and minimal labeled datasets.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み