Meta-Learning of Prompt Generation for Lightweight Prompt Engineering on Language-Model-as-a-Service

Hyeonmin Ha, Jihye Lee, Wookje Han, Byung-Gon ChunEMNLP 2023

Abstract

MetaL-Prompt is a lightweight meta-learning framework designed to make automatic prompt engineering practical for Language-Model-as-a-Service (LMaaS). By replacing expensive, iterative optimization with a meta-trained Prompt Generation Model (PGM), MetaL-Prompt generates high-quality prompts for unseen tasks in a single forward pass. Experimental results demonstrate that MetaL-Prompt achieves up to a 19.4% performance boost over state-of-the-art baselines while reducing computational costs from hours to milliseconds.

Introduction

Large Language Models (LLMs) are increasingly delivered as a Service (LMaaS), where users interact with models via prompts. However, "prompt engineering"—the process of finding the optimal prompt—is notoriously difficult and unstable. While automatic prompt tuning methods like P-tuning exist, they are computationally "heavy," requiring thousands of forward and backward passes to optimize a single prompt. For LMaaS providers serving millions of unique tasks, this overhead is economically unsustainable, often forcing users to rely on manual trial-and-error.

Overview of the MetaL-Prompt framework within an LMaaS context.

Methodology

The authors introduce MetaL-Prompt, which shifts the paradigm from iterative optimization to direct generation.

  1. Meta-Learning for Prompt Generation: Instead of optimizing a prompt for a specific task, the framework trains a Prompt Generation Model (PGM). The PGM is meta-trained across a wide variety of tasks to learn the mapping between a few task examples and the optimal prompt.
  2. Trainable Padding: To avoid the slowness of standard autoregressive generation, MetaL-Prompt employs "trainable padding"—specialized embeddings processed by an LSTM—allowing the PGM to generate all prompt tokens simultaneously in a single forward pass.
  3. Continuous Prompt Designs: The study explores various prompt representations, finding that Prefix-tuning (generating "virtual" keys and values for the target LLM's attention layers) provides the best performance.
  4. Parameter Efficiency: The PGM is initialized from a target LM and adapted using LoRA (Low-Rank Adaptation), ensuring efficient training and deployment.

Experimental Setup

MetaL-Prompt was evaluated using 142 diverse datasets from benchmarks like CrossFIT and UNIFIEDQA. The model was tested in three zero-shot meta-learning settings where evaluation tasks were entirely unseen during training:

  • Classification to Classification (cls → cls)
  • Question Answering to Question Answering (QA → QA)
  • High Resource to Low Resource (HR → LR)

Key Results

MetaL-Prompt demonstrates a significant breakthrough in both performance and efficiency:

  • Performance: On QA datasets, MetaL-Prompt outperformed the state-of-the-art P-tuning baseline by 19.4% in mean F1 score.
  • Speed and Efficiency: The most dramatic result is the reduction in computation time. In a head-to-head comparison on a GPT2-XL model, MetaL-Prompt generated a prompt in just 76 milliseconds, whereas the original Prefix-tuning method required 26.4 hours.
Comparison of computation costs between MetaL-Prompt and traditional tuning methods.

Even under "constrained budget" scenarios (e.g., limiting baselines to 10 epochs), MetaL-Prompt maintained a significant accuracy lead while remaining orders of magnitude faster.

Discussion and Insights

  • The Single-Pass Breakthrough: Prompt engineering does not require iterative search; a meta-model can immediately produce high-performing prompts from a few examples.
  • Continuous vs. Discrete: Continuous vectors (soft prompts) consistently outperform natural language tokens because they can capture task nuances that human language cannot easily express.
  • Scalability: MetaL-Prompt showed improved relative performance on larger models like Llama-2 (7B), indicating its viability for the scaling era.
  • Hybrid Potential: The generated prompts can serve as a "warm start" for further gradient-based tuning if a larger computational budget is available.

Limitations and Future Work

Despite its success, MetaL-Prompt faces challenges in transferability when moving between settings with and without demonstrations. Additionally, the PGM is constrained by the context window of the underlying model, which limits the number of examples it can process. Future work may explore iterative refinement, where the PGM progressively improves a prompt by observing its own outputs.

Summary updated

BibTeX
@inproceedings{ha2023meta,
  author = {Hyeonmin Ha and Jihye Lee and Wookje Han and Byung-Gon Chun},
  title = {{Meta-Learning of Prompt Generation for Lightweight Prompt Engineering on Language-Model-as-a-Service}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.159},
}
Figure