NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Improving In-Context Few-Shot Learning via Self-Supervised Training

Mingda Chen, Jingfei Du, Ramakanth Pasunuru, Todor Mihaylov, Srini Iyer, Veselin Stoyanov, Zornitsa Kozareva

Abstract

While Large Language Models (LLMs) demonstrate remarkable in-context learning (ICL) capabilities, a significant gap remains between standard next-token pretraining and the specific requirements of few-shot inference. This paper explores an intermediate self-supervised training stage designed to bridge this gap. By fine-tuning models on four specialized, automatically generated tasks that mirror the "Input/Output" format of downstream benchmarks, we demonstrate significant improvements in the ability of 125M and 1.3B parameter models to follow instructions and leverage in-context examples without requiring additional weight updates during inference.

1. Introduction

Large Language Models like GPT-3 have popularized in-context learning (ICL), where a model performs a new task simply by processing a few examples within its prompt. However, standard pretraining—predicting the next word across massive web crawls—is not explicitly optimized for this behavior. This creates a "format mismatch" between the training objective and the few-shot testing environment.

Existing attempts to mitigate this often rely on "cross-task supervision," which involves fine-tuning models on large collections of human-annotated tasks. While effective, human labels are expensive and finite. This research investigates whether a model can be taught how to learn in-context using only raw, unlabeled text through a self-supervised intermediate training phase.

2. Methodology

The core of the proposed approach is an intermediate training stage utilizing four self-supervised objectives. To ensure alignment with downstream few-shot tasks, all objectives are formatted using a consistent "Input: [text] \n Output: [text]" template.

2.1 Self-Supervised Objectives

  1. Next Sentence Generation (NSG): The model is provided with several sentences and tasked with generating the subsequent one.
  2. Masked Word Prediction (MWP): A generative adaptation of the BERT objective where the model fills in 1–20 missing words replaced by a special symbol.
  3. Last Phrase Prediction (LPP): Inspired by the LAMBADA dataset, this task requires the model to predict the final phrase of a sentence, forcing it to rely on local context.
  4. Classification (CL): A meta-task where the model determines if a set of sentences are "original," "shuffled," or sourced from "different documents." This objective encourages the model to identify topical similarities across different examples in a single prompt.

2.2 Training and Evaluation

The researchers fine-tuned two dense Transformer models (125M and 1.3B parameters) on a subset of the RoBERTa training corpus, including Wikipedia and BookCorpus. Evaluation was conducted on the SuperGLUE benchmark (e.g., BoolQ, COPA, RTE) and Natural-Instructions (e.g., Question and Answer Generation).

3. Key Insights

3.1 Format as a Feature

A primary finding is that the specific "Input/Output" template used during intermediate training is crucial. This structure helps the model internalize the mechanics of few-shot prompts, effectively "learning to learn" from the provided context.

3.2 Data Saturation and Complementarity

The effectiveness of self-supervision increases with data volume but tends to plateau at approximately 1 million instances. This suggests that the intermediate stage serves more as a "reformatting" of existing knowledge rather than the acquisition of new facts. Furthermore, self-supervision and human-annotated supervision (CrossTask) were found to be complementary. Combining both methods yielded the highest performance, suggesting that self-supervision teaches the mechanics of ICL while human labels refine task-specific nuances.

3.3 Task-Specific Trade-offs

The Classification (CL) task highlighted a trade-off between task types: while it significantly boosted performance on discriminative benchmarks like SuperGLUE, it hindered performance on generative tasks like Natural-Instructions. This indicates that the style of the intermediate task must align with the intended downstream application.

4. Results

  • Performance Gains: The 1.3B model’s average SuperGLUE score rose from 51.8 (baseline) to 55.6 following self-supervised training.
  • Instruction Following: Qualitative analysis indicated that self-supervised models were significantly more adept at maintaining the requested format. For instance, in question construction tasks, the baseline model often produced irrelevant text, whereas the self-supervised model remained on-task.
  • Few-Shot vs. Zero-Shot: The benefits were primarily observed in few-shot settings. In zero-shot scenarios, the gains were negligible, confirming that the method specifically enhances the model's ability to utilize in-context demonstrations.

5. Limitations and Future Work

Despite the improvements, several challenges remain. Task interference—where certain objectives hurt specific downstream tasks—suggests that a "universal" self-supervised objective is yet to be found. Additionally, while the 1.3B model showed clear gains, it remains to be seen if these benefits persist for massive models (175B+ parameters) that may already exhibit these capabilities through scale. Finally, the models remain sensitive to specific prompt templates, highlighting a need for increased robustness in future iterations.

Summary updated

BibTeX
@inproceedings{chen2022improving,
  author = {Mingda Chen and Jingfei Du and Ramakanth Pasunuru and Todor Mihaylov and Srini Iyer and Veselin Stoyanov and Zornitsa Kozareva},
  title = {{Improving In-Context Few-Shot Learning via Self-Supervised Training}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.naacl-main.260},
}
Figure