TLDR: GreenTEA is an agentic LLM workflow that automatically optimizes prompts for Large Language Models. It uses a collaborative team of agents: an analyzing agent identifies common error patterns via topic modeling, and a generation agent revises prompts using a gradient-guided genetic algorithm. This approach balances exploration and exploitation in the prompt search space, leading to superior performance compared to human-engineered prompts and other automatic optimization methods across various reasoning, commonsense, and ethical decision-making tasks.
Large Language Models (LLMs) have become incredibly powerful, but their performance heavily relies on the quality of the prompts they receive. Crafting these prompts manually, known as prompt engineering, is a time-consuming task that requires deep expertise. This manual approach makes it difficult to scale LLM applications across diverse tasks.
Existing automatic prompt optimization methods often face a dilemma: either they explore too many new prompt candidates, which is computationally expensive, or they focus too much on refining existing prompts, risking getting stuck in suboptimal solutions due to the complex nature of prompt design. This highlights a need for a more balanced and efficient approach.
Introducing GreenTEA: A Smart Approach to Prompt Optimization
Researchers Zheng Dong, Luming Shang, and Gabriela Olinto from Amazon Buyer Risk Prevention have introduced GreenTEA (Gradient Descent with Topic-modeling and Evolutionary Auto-prompting), an innovative agentic LLM workflow designed to automatically optimize prompts. GreenTEA strikes a crucial balance between exploring new prompt possibilities and exploiting existing knowledge to refine them effectively.
At its core, GreenTEA operates with a collaborative team of AI agents that work together to iteratively improve prompts. When an LLM makes an error, an ‘analyzing agent’ steps in. This agent uses a technique called topic modeling to identify common patterns in the errors. By clustering error samples based on their semantic similarity, it ensures that the feedback provided is coherent and focused on major deficiencies.
Once the error patterns are identified, a ‘generation agent’ takes over. This agent revises the prompt specifically to address these key shortcomings. The entire refinement process is guided by a genetic algorithm framework, which mimics natural selection. This means candidate prompts ‘evolve’ through operations like crossover (combining features from successful prompts) and mutation (introducing small changes) to progressively enhance the LLM’s performance.
How GreenTEA Works in Detail
The GreenTEA framework involves an iterative loop with two main stages: feedback collection and prompt generation. It starts with an initial set of generic prompts. In the feedback collection stage, each prompt is evaluated, and any incorrect predictions are gathered. The topic modeling mechanism then groups these errors into clusters, allowing the analyzing agent to focus on the most significant error types. The analyzing agent then summarizes these mistakes and provides actionable feedback on how to improve the prompt.
In the prompt generation stage, the generation agent uses a gradient-guided genetic algorithm. It selects two ‘parent’ prompts based on their performance, combines them through a ‘crossover’ operation, and then introduces ‘mutations’ guided by the feedback from the analyzing agent. This process creates new, improved ‘child’ prompts. This evolutionary approach helps GreenTEA explore the vast prompt space efficiently, avoiding local optima and leading to more robust prompt solutions.
Also Read:
- Type-Compliant Adaptation Cascades: A New Framework for Robust LLM Workflows
- Unlocking LLM Potential: A New Approach to Prompt Engineering with Smaller Models
Impressive Results Across Diverse Tasks
Extensive experiments were conducted on several public benchmark datasets, showcasing GreenTEA’s superior performance. These datasets covered a range of tasks including quantitative reasoning (GSM8K), ethical decision-making (ETHOS), commonsense reasoning (PIQA), and complex logical reasoning (Big-Bench Hard – BBH).
GreenTEA consistently outperformed human-engineered prompts and existing state-of-the-art methods for automatic prompt optimization. An ablation study further confirmed the importance of GreenTEA’s key components: the topic-modeling mechanism for efficient feedback and the gradient-guided genetic algorithm for robust prompt evolution. The study showed that removing these components led to lower accuracy and slower convergence.
The research paper also provides compelling examples of how prompts evolve. Starting from a simple instruction like “Decide if the comment is hateful,” GreenTEA progressively refines it into detailed, multi-step guidelines, directly correlating with significant accuracy gains.
GreenTEA represents a significant step forward in automating the creation of high-quality prompts for LLMs, making them more effective and efficient across a wide array of applications. For more technical details, you can read the full research paper here.


