Abstract
Prompt engineering is a critical yet labor-intensive aspect of working with Large Language Models (LLMs). We present the Hierarchical Multi-Agent Workflow (HMAW), a zero-shot, task-agnostic framework that automates prompt refinement using a "CEO-Manager-Worker" organizational structure. HMAW decomposes a single user query into high-level strategic goals and detailed execution instructions. Our evaluation across five diverse benchmarks demonstrates that HMAW provides a significant performance boost—averaging 30.7%—without the need for manual engineering or specialized training datasets.
Introduction
The effectiveness of LLMs is highly sensitive to the quality of the input prompt. However, current optimization strategies face significant hurdles: manual design (e.g., Chain-of-Thought) is time-consuming, while automated methods like APE often require extensive in-domain training data. HMAW bridges this gap by offering a query-specific optimization that is both zero-shot and task-agnostic.
The HMAW Framework
The core innovation of HMAW is its three-layer hierarchical structure, which mimics a corporate environment to refine task execution:
- CEO Layer: Analyzes the user query to establish a high-level "global strategy."
- Manager Layer: Receives the CEO's strategy and the original query to generate a detailed "local checklist" and specific output guidelines.
- Worker Layer: Uses the Manager’s detailed instructions and the original query to produce the final response.
Technical Design Choices
A pivotal component of this architecture is the use of skip connections. By providing the original user query to every layer, the system ensures that the specific intent of the user is not lost or distorted as instructions pass through the hierarchy. Additionally, assigning specific "corporate personas" to each agent helps maintain focus on their respective sub-tasks (strategy vs. execution).
Evaluation and Results
HMAW was evaluated using Mixtral-8x7B across five benchmarks: ATLAS (general), FED (dialogue), GSM8K (math), CodeNet (coding), and a new Education dataset.
- Performance Gains: HMAW achieved an average improvement of 30.7% over "No Prompting" baselines.
- Subjective Superiority: On the FED dialogue dataset, GPT-3.5 preferred HMAW’s outputs over baseline responses 86.2% of the time.
- Model Agnostic: The framework showed consistent benefits when using different base models, including GPT-3.5 and GPT-4o.
Key Insights
- Optimal Complexity: Testing hierarchies from 1 to 6 layers revealed that a 3-layer structure is the "sweet spot." Adding more layers (e.g., Senior Vice Presidents) led to over-complicated instructions that degraded output quality.
- Metaphor Effectiveness: The "Corporate" metaphor outperformed "Government" or "University" structures, suggesting that business-oriented task decomposition is particularly effective for LLM reasoning.
Limitations and Future Work
While HMAW significantly improves output quality, it introduces increased computational overhead. The three-layer process requires multiple LLM calls, increasing inference time by 200-700%. Future research will focus on "workflow pruning" to dynamically skip layers for simpler queries, optimizing both cost and performance.
Summary updated