Abstract
In-Context Learning (ICL) has revolutionized the use of large pre-trained language models (PLMs) by enabling task adaptation through few-shot demonstrations. However, ICL performance is highly sensitive to the selection and quality of these demonstrations, often requiring external labeled datasets. This paper introduces Self-Generated In-Context Learning (SG-ICL), a framework where the model generates its own synthetic demonstrations conditioned on the test input. Experimental results across multiple NLU benchmarks demonstrate that SG-ICL consistently outperforms zero-shot learning and provides more stable performance than random human-labeled examples, effectively bridging the gap between zero-shot and few-shot learning without external data.
Introduction
The standard paradigm for utilizing large language models involves providing a few labeled examples within the prompt to guide the model's output. While effective, this approach suffers from a significant dependency on external training data and high sensitivity to demonstration selection. Finding the "right" examples often requires extensive prompt engineering or access to a representative labeled corpus, which may not always be available.
The authors propose a novel alternative: instead of retrieving demonstrations, the model should generate them. By leveraging the generative capabilities of auto-regressive models, SG-ICL allows a model to "prime" itself for a specific task by creating contextually relevant examples on the fly.
Methodology: The SG-ICL Framework
SG-ICL operates through a two-step process designed to maximize the relevance of generated demonstrations to the target task.
1. Self-Generation Step
In this phase, the model is presented with the test input and a target label. Using a predefined template, the model is prompted to generate a new input that corresponds to that label. For instance, given a movie review and the label "Negative," the model might be asked to "Generate a 'Negative' review." Crucially, because the model sees the test input first, the generated synthetic example is often semantically or stylistically similar to the problem at hand, providing a more effective context than generic examples.
2. Inference Step
The generated input-label pairs are then prepended to the original test input as standard ICL demonstrations. The model processes this augmented prompt to produce the final prediction. This method utilizes a "verbalizer" to map internal labels to natural language words (e.g., mapping '0' to 'negative'), ensuring the model can interpret the synthetic demonstrations correctly.
Experimental Setup
The framework was evaluated using GPT-J (6B) on four diverse Natural Language Understanding (NLU) benchmarks:
- SST-2 & SST-5: Sentiment analysis tasks involving binary and fine-grained movie reviews.
- RTE (Recognizing Textual Entailment): Logical entailment tasks.
- CB (CommitmentBank): Real-world utterances involving entailment, contradiction, or neutrality.
Key Results and Discussion
The primary finding is that SG-ICL consistently improves upon zero-shot performance across all tested benchmarks.
Performance and Stability
As shown in the results, SG-ICL consistently sits between zero-shot and 8-shot performance. Notably, the authors observed that generating examples based on the specific test input is significantly more effective than generating class-conditional examples in isolation. This "input conditioning" ensures that the demonstrations are semantically close to the test case, leading to a performance jump.
Furthermore, SG-ICL exhibits lower variance compared to randomly selected human-labeled examples. While human-labeled "gold" data is generally superior, its performance can fluctuate wildly depending on the specific examples chosen. SG-ICL provides a more stable and predictable baseline.
The "0.6 Rule"
A quantitative analysis revealed that one self-generated demonstration is approximately equivalent to 0.6 human-labeled training samples. While not a total replacement for high-quality human data, this represents a significant capability for models to improve their own performance in data-scarce environments.
Conclusion
Self-Generated In-Context Learning demonstrates that the internal knowledge of large language models can be harnessed to create effective task contexts without external supervision. By conditioning demonstration generation on the test input, SG-ICL provides a robust, low-variance alternative to traditional ICL. Future work will explore the scalability of this approach to larger models and more complex reasoning tasks, such as mathematical problem-solving and code generation.
Summary updated