Generative Prompt Internalization

Haebin Shin, Lei Ji, Yeyun Gong, Sungdong Kim, Eunbi Choi, Minjoon Seo

Abstract

Generative Prompt Internalization (GenPI) addresses the "computational tax" associated with long system prompts in Large Language Model (LLM) applications. By training models to internalize complex instructions directly into their weights, GenPI eliminates the need to include lengthy prompts in every API call. This method employs a dual-loss objective—Supervised Fine-Tuning (SFT) and a novel Prompt Generation (PG) loss—allowing models to retain up to 100% of the performance of prompted models while reducing computational overhead by approximately 40%.

1. Introduction

In modern LLM deployments, system prompts containing detailed instructions and few-shot examples are essential for guiding model behavior. However, because LLMs must process the entire context for every turn in a conversation, these prompts lead to significant latency and increased operational costs. Existing solutions like prompt compression often sacrifice vital details, while traditional distillation methods struggle to capture the underlying logic of complex instructions. GenPI bridges this gap by treating the prompt itself as a target for learning, effectively moving information from the context window into the model's parameters.

2. Methodology

2.1 Joint-Loss Training

The core of GenPI is a joint-loss training approach that ensures the model not only mimics the desired behavior but also understands the reasoning behind it:

  1. Supervised Fine-Tuning (SFT) Loss: The student model is trained to replicate the outputs of a teacher model that has access to the full system prompt.
  2. Prompt Generation (PG) Loss: The student model is trained to take a user input and a generic response, then generate the target system prompt along with a "reason" for the behavioral change. This forcing of the model to generate the "why" helps it internalize the underlying logic rather than just surface-level patterns.
Overview of the GenPI framework, illustrating the joint training objective of Prompt Generation (PG) Loss and Supervised Fine-Tuning (SFT) Loss.

2.2 Self Role-Playing for Data Generation

To generate high-quality training data without expensive real-world environment interactions, the authors utilize a "Self Role-Playing Conversation" technique. The model is prompted to play both the "Agent" (e.g., an OS assistant) and the "Environment" (e.g., an Ubuntu terminal). By autonomously simulating multi-turn interactions, the model creates its own synthetic dataset for fine-tuning. The process is computationally efficient, utilizing QLoRA to update only 0.5% of the model's parameters.

3. Evaluation and Results

3.1 Experimental Setup

The researchers evaluated GenPI using the AgentBench framework across three challenging scenarios: OS Interaction (Ubuntu Docker), Web Browsing (HTML navigation), and Web Shopping (simulated e-commerce). These tasks featured prompts ranging from 474 to over 1,400 tokens.

3.2 Performance and Efficiency

GenPI demonstrated remarkable performance retention, achieving 100% of the teacher model's success rate on OS tasks and over 82% on complex web-based tasks. Crucially, this performance was achieved with significantly lower resource consumption. GenPI showed a 39% improvement in computational efficiency (measured in MACs and FLOPs) and a 17% reduction in latency compared to standard prompting.

Comparison of computational cost (MACs) across conversation turns, showing GenPI's efficiency relative to standard prompting and compression methods.

4. Conclusion

GenPI represents a significant step toward more efficient LLM agents. By internalizing prompt logic into model weights via generative supervision, it avoids the trade-offs between performance and context length inherent in prompt compression. Future work will focus on developing universal internalization methods that do not require prompt-specific adapters and expanding the technique to domains such as long-form Retrieval-Augmented Generation (RAG) and multi-modal applications.

Summary updated

BibTeX
@inproceedings{shin2025generative,
  author = {Haebin Shin and Lei Ji and Yeyun Gong and Sungdong Kim and Eunbi Choi and Minjoon Seo},
  title = {{Generative Prompt Internalization}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.naacl-long.376},
}
Figure