Generative Calibration for In-context Learning

Zhongtao Jiang, Yuanzhe Zhang, Cao Liu, Jun Zhao, Kang Liu
10/16/2023
cs.CL

No official code found. Best implementation: changmenseng/generative_calibration (5 stars, last commit 2024-05-27).

Abstract

As one of the most exciting features of large language models (LLMs), in-context learning is a mixed blessing. While it allows users to fast-prototype a task solver with only a few training examples, the performance is generally sensitive to various configurations of the prompt such as the choice or order of the training examples. In this paper, we for the first time theoretically and empirically identify that such a paradox is mainly due to the label shift of the in-context model to the data distribution, in which LLMs shift the label marginal $p(y)$ while having a good label conditional $p(x|y)$. With this understanding, we can simply calibrate the in-context predictive distribution by adjusting the label marginal, which is estimated via Monte-Carlo sampling over the in-context model, i.e., generation of LLMs. We call our approach as generative calibration. We conduct exhaustive experiments with 12 text classification tasks and 12 LLMs scaling from 774M to 33B, generally find that the proposed method greatly and consistently outperforms the ICL as well as state-of-the-art calibration methods, by up to 27% absolute in macro-F1. Meanwhile, the proposed method is also stable under different prompt configurations.

View on arXivView PDF

Code Implementations(1)

50PythonOct 12, 20232 years ago

Similar Papers

Cite this paper

@article{jiang2023generative,
  title  = {Generative Calibration for In-context Learning},
  author = {Zhongtao Jiang and Yuanzhe Zhang and Cao Liu and Jun Zhao and Kang Liu},
  year   = {2023},
  eprint = {2310.10266},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2310.10266v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2310.10266.svg)](https://codeofpaper.com/paper/2310.10266)

Discussion