Abstract
Large Language Models (LLMs) often rely on extensive prompt engineering, including complex instructions and few-shot examples, to perform specific tasks. While effective, this approach incurs significant costs in terms of latency and token usage. We present PromptIntern, a novel fine-tuning framework that enables LLMs to internalize prompt knowledge directly into their parameters. By employing a progressive internalization strategy, PromptIntern reduces input tokens by over 90%, achieves a 4.2x inference speedup, and cuts monetary costs by 88.3% while maintaining high accuracy.
Introduction
Prompt engineering has become the standard paradigm for adapting LLMs to specialized domains. Users typically provide lengthy templates, API documentation, and multiple "few-shot" examples to guide the model. However, this "context-heavy" approach is inherently inefficient. Every query requires re-sending the same static instructions, leading to high per-request costs and increased latency.
Existing solutions like prompt compression attempt to summarize these prompts. However, they often lose critical nuances and fail to leverage the model's capacity to learn through parameter updates. PromptIntern addresses this by shifting the burden of task-specific knowledge from the short-term context window to the model's long-term memory—its weights.
Methodology: The Progressive Internalization Strategy
PromptIntern is inspired by the learning process of a human intern. Initially, an intern requires detailed manuals and examples. Over time, they internalize this knowledge, eventually requiring only a brief query to complete the task.
The framework implements this through three primary pillars:
- Template Compression: Static elements like instructions and bulky API documentation are distilled to their essence.
- Example Absorption: The model is trained on relevant few-shot examples, allowing it to "absorb" the underlying patterns and logic.
- Progressive Fine-tuning Pipeline: This is the core innovation. During LoRA-based fine-tuning, the system follows a schedule (typically linear decay) to gradually reduce prompt complexity.
As training progresses, the model is forced to rely less on the input text and more on its updated parameters. By the end of the process, the model can perform the task using "query-only" prompts. Interestingly, because prompts shorten during training, the total training time is often lower than traditional fine-tuning with full prompts.
Experimental Setup
The researchers evaluated PromptIntern on several Natural Language to Code (NL2Code) tasks, which typically require long, detailed prompts:
- MBPP: Python programming tasks.
- NL2F: Natural language to Excel formulas.
- NL2Bash: Natural language to Bash commands.
- GSM8K: Grade-school math word problems to test arithmetic reasoning generalization.
Key Results and Discussion
PromptIntern demonstrates a superior balance between efficiency and effectiveness compared to traditional prompt compression methods like LLMLingua.
Efficiency Gains
The results across GPT-4, GPT-3.5, and Llama-2 variants were substantial:
- Token Reduction: Input tokens were reduced by more than 90% compared to standard few-shot prompting.
- Inference Speedup: Inference was accelerated by an average of 4.2x.
- Cost Savings: Monetary costs for inference dropped by 88.3% based on standard API pricing.
Accuracy and Internalization
Unlike standard compression, which merely shortens text, PromptIntern improves the model's intrinsic understanding. In several benchmarks, the internalized model outperformed models using compressed prompts. For instance, on the MBPP dataset with GPT-4, PromptIntern achieved 87.9% accuracy using only 43 tokens, whereas the full 5-shot prompt required 1,181 tokens for 91.6% accuracy.
The authors found that a linear decay schedule is critical. Slowly removing information provides a predictable learning path, allowing the model to bridge the gap between the query and the missing instructions more effectively than aggressive removal strategies.
Limitations and Future Work
While PromptIntern offers massive efficiency gains, a small "accuracy tax" remains compared to using fully-loaded original prompts. Future research will focus on closing this gap and extending the method to more complex, long-form tasks such as legal or medical Q&A. Additionally, the current implementation is optimized for single-task internalization; exploring multi-task internalization within a single model remains an open area for investigation.
Conclusion
PromptIntern represents a significant step toward more efficient LLM deployment. By teaching models to "remember" instructions rather than constantly reading them, it paves the way for high-performance, low-cost AI applications in production environments.
Summary updated