NoisyICL: A Little Noise in Model Parameters Calibrates In-context Learning

Yufeng Zhao, Yoshihiro Sakai, Naoya InouearXiv 2024 · DOI

Introduction

In-context learning (ICL) has emerged as a powerful paradigm for Large Language Models (LLMs), enabling them to perform new tasks using only a few demonstrations in the prompt. Despite its success, ICL suffers from two significant drawbacks: prior bias and poor calibration. Models often rely too heavily on pre-training priors rather than the provided context and frequently exhibit "unfaithful confidence," assigning high probabilities to incorrect outputs.

To address these issues, we introduce NoisyICL, a simple yet effective technique that improves ICL performance and calibration by injecting a small amount of random noise into the model's parameters. Unlike traditional fine-tuning, NoisyICL requires zero gradient updates and minimal computational overhead.

Conceptual overview of NoisyICL and its impact on average accuracy across different numbers of demonstrations for GPT-J and GPT-2.

Methodology

NoisyICL modifies the pre-trained model parameters $\theta$ before inference. The perturbed weights $\theta'$ are calculated as an interpolation between the original weights and random noise:

$$\theta'_i = (1 - \lambda)\theta_i + \lambda \mathcal{N}(0, \sigma^2)$$

Where:

  • $\sigma$ (Noise Scale): Set to 0.02, corresponding to the standard deviation of the model's original initialization.
  • $\lambda$ (Intensity): A hyperparameter controlling the noise level, optimized via a small validation set.

This "jittering" of weights moves the model away from the sharp local minima of its pre-training state. We hypothesize that this perturbation helps the model "forget" rigid priors, making it more receptive to the patterns within the few-shot demonstrations.

Experimental Setup

We evaluated NoisyICL across 12 diverse classification datasets, including sentiment analysis (e.g., SST2, PS), hate speech detection (e.g., Ethos, HS), and natural language inference (e.g., RTE, MRPC). The method was tested on two architectures: GPT-2 (137M) and GPT-J (6B).

Results and Discussion

The experimental results demonstrate that NoisyICL consistently outperforms vanilla ICL across various metrics and models.

Detailed performance comparison (Accuracy, Macro-F1, and ECE) across 12 datasets for GPT-J and GPT-2 models with and without NoisyICL.

Performance and Calibration Gains

As shown in the results, NoisyICL achieved an average accuracy improvement of approximately 10%. More importantly, it significantly improved model calibration. The Expected Calibration Error (ECE) dropped by an average of 25% for GPT-J, indicating that the model's confidence levels became much more aligned with its actual predictive accuracy.

Noise as a Neutralizer

Analysis reveals that noise increases the entropy of the model's predictions, effectively neutralizing intrinsic token and label biases. By reducing the dominance of frequent pre-training tokens, the model becomes more balanced. Furthermore, NoisyICL helps resolve the "overconfidence" problem by shifting the confidence distribution of incorrect predictions toward lower values.

Scaling and Stability

Interestingly, NoisyICL can "rescue" cases where vanilla ICL performance degrades as more demonstrations are added (a form of prompt-based overfitting). The optimal noise intensity $\lambda$ remains relatively stable across different numbers of demonstrations ($k$), suggesting it is primarily a property of the task-model pairing.

Conclusion

NoisyICL provides a lightweight, training-free method to enhance the robustness and calibration of in-context learning. By simply shaking up the model parameters, we can overcome stubborn pre-training biases and achieve performance gains comparable to more expensive methods. Future work may explore layer-wise noise application and more sophisticated noise sampling techniques to further refine this approach.

Summary updated

BibTeX
@misc{zhao2024noisyicl,
  author = {Yufeng Zhao and Yoshihiro Sakai and Naoya Inoue},
  title = {{NoisyICL: A Little Noise in Model Parameters Calibrates In-context Learning}},
  year = {2024},
  eprint = {2402.05515},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.05515},
}
Figure