---
title: "Automatic Prompt Engineer (APE)"
source: "https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)"
wiki: "systems-analysis.info/eng"
article: "Automatic_Prompt_Engineer_(APE)"
language: "en"
categories:
  - "Category:English"
  - "Category:Large language models"
  - "Category:Machine learning"
  - "Category:Prompt engineering"
  - "Category:Technology"
revision_id: 69
wiki_created_at: 2026-09-06T22:16:59Z
wiki_modified_at: 2026-09-06T22:16:59Z
downloaded_at: 2026-09-07T22:20:47Z
---

# Automatic Prompt Engineer (APE)

**Automatic Prompt Engineer** (**APE**) is a method for the automated generation and optimization of textual instructions (prompts) to control the behavior of [large language models](https://systems-analysis.info/eng/Large_language_model "Large language model") (LLMs). The approach was proposed in 2022 by a group of researchers led by **Yongchao Zhou**<sup>[\[1\]](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_note-ape_zhou_2022-1)</sup>.

Instead of manual creation and iterative refinement of prompts, APE formalizes [prompt engineering](https://systems-analysis.info/eng/Prompt_engineering "Prompt engineering") as an optimization problem. In this framework, a prompt is treated as a natural language "program" that must be synthesized to maximize a specific scoring function (e.g., the accuracy or factuality of the model's responses)<sup>[\[2\]](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_note-survey_li_2025-2)</sup>.

## Core Concept and Method

The APE method uses two language models in tandem: a *proposal model* and a *target model*. The process is an iterative *search-and-select* cycle:

1.  **Proposal Generation**. The proposal model receives a few input-output examples for the target task and, based on them, creates a set of possible candidate prompts that could produce such results.
2.  **Scoring**. Each generated candidate prompt is passed to the target LLM. The target model executes the instruction on a new set of test data, and its responses are evaluated according to a predefined metric (e.g., accuracy, completeness, F1-score).
3.  **Selection**. The prompt that achieved the best score during the evaluation is selected.
4.  **Iteration (optional)**. The cycle can be repeated. The proposal model is instructed to refine the best-found prompt by creating variations of it, after which the scoring and selection process is repeated to achieve maximum effectiveness<sup>[\[1\]](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_note-ape_zhou_2022-1)</sup>.

This approach allows for the automatic replication of the manual prompt engineering process, using an LLM to generate hypotheses (prompts) and subsequently evaluate them.

## Key Methodologies

The automation of prompt engineering is implemented using various algorithmic approaches.

### LLM-Based Automation

This is the classic APE method described above, where one LLM is used to generate and evaluate prompts for another (or the same) LLM. This approach has proven very effective for discrete, text-based prompts<sup>[\[1\]](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_note-ape_zhou_2022-1)</sup>.

### Evolutionary Methods

Genetic algorithms or beam search are used to create and select prompts, especially long and complex ones. For example, the **APEX** (*Automatic Engineering of Long Prompts*) framework applies evolutionary algorithms to progressively "grow" and refine complex instructions<sup>[\[3\]](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_note-apex_hsieh_2024-3)</sup>.

### Gradient-Based Methods (Soft Prompts)

This approach works with *continuous* or *soft prompts*, which are trainable vectors ([embeddings](https://systems-analysis.info/eng/Embedding_(NLP) "Embedding (NLP)")) rather than textual instructions. These vectors are optimized using gradient descent directly on the target task. This category includes techniques like Prompt Tuning and Prefix-Tuning.

### Reinforcement Learning

In this paradigm, the LLM acts as an agent that generates a prompt (action), and the environment returns a score for the response quality (reward). The goal is to maximize the cumulative reward by finding an optimal prompt generation policy through reinforcement learning (RL) methods<sup>[\[2\]](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_note-survey_li_2025-2)</sup>.

## Results and Discoveries

Experiments in the original APE study showed that automatically generated instructions outperformed human-written prompts in most cases.

- In tests on 24 Natural Language Processing (NLP) tasks, APE generated prompts that were **more effective than human-written ones in 19 out of 24 cases**<sup>[\[1\]](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_note-ape_zhou_2022-1)</sup>.
- APE was able to automatically "discover" a more effective phrasing for [Chain-of-Thought](https://systems-analysis.info/eng/Chain-of-Thought_Prompting "Chain-of-Thought Prompting") style prompting. Instead of the standard phrase *"Let's think step by step,"* APE generated a more detailed and effective instruction: *"Let's work this out in a step by step way to be sure we have the right answer."* This phrasing improved accuracy on mathematical reasoning tasks on datasets like MultiArith and [GSM8K](https://systems-analysis.info/eng/GSM8K_(Grade_School_Math_8K) "GSM8K (Grade School Math 8K)")<sup>[\[1\]](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_note-ape_zhou_2022-1)</sup>.

## Applications and Advantages

### Applications

- **Improving [few-shot learning](https://systems-analysis.info/eng/Few-Shot_and_Zero-Shot_Learning "Few-Shot and Zero-Shot Learning")**: Automatically selecting optimal examples and instructions.
- **Enhancing model factuality**: APE can be configured to find prompts that minimize "[hallucinations](https://systems-analysis.info/eng/LLM_hallucinations "LLM hallucinations")" and maximize the truthfulness of responses on benchmarks like *[TruthfulQA](https://systems-analysis.info/eng/TruthfulQA_Benchmark "TruthfulQA Benchmark")*.
- **Development automation**: Accelerating the creation of chatbots, information extraction systems, and other LLM-based applications<sup>[\[4\]](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_note-mdpi_app-4)</sup>.

### Advantages

- **Scalability**: The ability to automatically generate and evaluate hundreds or thousands of prompts without human intervention.
- **Adaptability**: Easily [fine-tuning](https://systems-analysis.info/eng/Fine-tuning_(deep_learning) "Fine-tuning (deep learning)") LLMs for new, highly specialized domains.
- **Resource efficiency**: Significant reduction in the time and effort spent on manual prompt engineering.

## Evolution and Related Approaches

The APE concept continues to evolve. Fully autonomous systems have emerged, such as **APET** (*Automatic Prompt Engineering Toolbox*), which allow an LLM (e.g., [GPT](https://systems-analysis.info/eng/GPT_(OpenAI) "GPT (OpenAI)")-4) to independently apply complex prompting strategies (*Expert Prompting*, *Chain of Thought*, *[Tree of Thoughts](https://systems-analysis.info/eng/Tree_of_Thoughts_(ToT) "Tree of Thoughts (ToT)")*) and dynamically improve instructions without external intervention<sup>[\[5\]](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_note-apet_kepel_2024-5)</sup>.

APE is part of a broader trend toward automating interactions with LLMs, which also includes:

- **AutoPrompt**: An early method that used a gradient-based search to find discrete "trigger" [tokens](https://systems-analysis.info/eng/Token_(LLM) "Token (LLM)").
- **OPRO** (*Optimization by PROmpting*): An approach from DeepMind similar to APE, which also uses an LLM to optimize prompts.

## External links

- <a href="https://sites.google.com/view/automatic-prompt-engineer" class="external text" rel="nofollow">Official Website of the Automatic Prompt Engineer (APE) Project</a>
- <a href="https://arxiv.org/abs/2211.01910" class="external text" rel="nofollow">Research Paper: "Large Language Models Are Human-Level Prompt Engineers"</a>
- AutoPrompt (2020). *AutoPrompt – Official GitHub Repository*. <a href="https://github.com/ucinlp/autoprompt" class="external text" rel="nofollow">GitHub</a>.
- <a href="https://en.wikipedia.org/wiki/Prompt_engineering#Using_language_models_to_generate_prompts" class="external text" rel="nofollow">Using language models to generate prompts — Wikipedia</a>

## Literature

- Zhou, Y. et al. (2022). *Large Language Models Are Human-Level Prompt Engineers*. <a href="https://arxiv.org/abs/2211.01910" class="external text" rel="nofollow">arXiv:2211.01910</a>.
- Li, W. et al. (2025). *A Survey of Automatic Prompt Engineering: An Optimization Perspective*. <a href="https://arxiv.org/abs/2502.11560" class="external text" rel="nofollow">arXiv:2502.11560</a>.
- Hsieh, C.-J. et al. (2024). *Automatic Engineering of Long Prompts*. Findings of ACL 2024. <a href="https://aclanthology.org/2024.findings-acl.634" class="external text" rel="nofollow">2024.findings-acl.634</a>.
- Hsieh, C.-J. et al. (2023). *Automatic Long Prompt Engineering*. <a href="https://arxiv.org/abs/2311.10117" class="external text" rel="nofollow">arXiv:2311.10117</a>.
- Shin, T. et al. (2020). *AutoPrompt: Eliciting Knowledge from Language Models with Automatically Generated Prompts*. <a href="https://arxiv.org/abs/2010.15980" class="external text" rel="nofollow">arXiv:2010.15980</a>.
- Yang, C. et al. (2023). *Large Language Models as Optimizers (OPRO)*. <a href="https://arxiv.org/abs/2309.03409" class="external text" rel="nofollow">arXiv:2309.03409</a>.
- Liu, Y. et al. (2024). *Revisiting OPRO: The Limitations of Small-Scale LLMs as Optimizers*. <a href="https://arxiv.org/abs/2405.10276" class="external text" rel="nofollow">arXiv:2405.10276</a>.
- Kepel, D.; Valogianni, K. (2024). *Autonomous Prompt Engineering in Large Language Models (APET)*. <a href="https://arxiv.org/abs/2407.11000" class="external text" rel="nofollow">arXiv:2407.11000</a>.
- Yang, C. et al. (2024). *Optimizing Instructions and Demonstrations for Multi-Stage LM Programs*. <a href="https://arxiv.org/abs/2406.11695" class="external text" rel="nofollow">arXiv:2406.11695</a>.
- Hsieh, C.-J. et al. (2024). *APEX (code repository and results)*. <a href="https://aclanthology.org/2024.findings-acl.634.pdf" class="external text" rel="nofollow">PDF</a>.

## References

1.  <span id="cite_note-ape_zhou_2022-1">↑ <sup>[1.0](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_ref-ape_zhou_2022_1-0)</sup> <sup>[1.1](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_ref-ape_zhou_2022_1-1)</sup> <sup>[1.2](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_ref-ape_zhou_2022_1-2)</sup> <sup>[1.3](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_ref-ape_zhou_2022_1-3)</sup> <sup>[1.4](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_ref-ape_zhou_2022_1-4)</sup> Zhou, Y. et al. "Large Language Models Are Human-Level Prompt Engineers". *arXiv:2211.01910*, 2022. <a href="https://arxiv.org/abs/2211.01910" class="external autonumber" rel="nofollow">[1]</a></span>
2.  <span id="cite_note-survey_li_2025-2">↑ <sup>[2.0](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_ref-survey_li_2025_2-0)</sup> <sup>[2.1](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_ref-survey_li_2025_2-1)</sup> Li, W. et al. "A Survey of Automatic Prompt Engineering: An Optimization Perspective". *arXiv:2502.11560*, 2025. <a href="https://arxiv.org/abs/2502.11560" class="external autonumber" rel="nofollow">[2]</a></span>
3.  <span id="cite_note-apex_hsieh_2024-3">[↑](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_ref-apex_hsieh_2024_3-0) Hsieh, C.-J. et al. "Automatic Engineering of Long Prompts". *Findings of the Association for Computational Linguistics: ACL 2024*. <a href="https://aclanthology.org/2024.findings-acl.634/" class="external autonumber" rel="nofollow">[3]</a></span>
4.  <span id="cite_note-mdpi_app-4">[↑](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_ref-mdpi_app_4-0) Fernandez-garcia, A. et al. "Automatic Prompt Engineering for Foundation Models: A Survey". *MDPI Electronics*, 2025. <a href="https://www.mdpi.com/2079-9292/14/11/2145" class="external autonumber" rel="nofollow">[4]</a></span>
5.  <span id="cite_note-apet_kepel_2024-5">[↑](https://systems-analysis.info/eng/Automatic_Prompt_Engineer_(APE)#cite_ref-apet_kepel_2024_5-0) Kepel, D. & Valogianni, K. "Autonomous Prompt Engineering in Large Language Models". *arXiv:2407.11000*, 2024. <a href="https://arxiv.org/abs/2407.11000" class="external autonumber" rel="nofollow">[5]</a></span>
