Enhancing Input-Label Mapping in In-Context Learning with Contrastive Decoding

Keqin Peng, Liang Ding, Yuanxin Ouyang, Meng Fang, Yancheng Yuan +1 more
2/19/2025
cs.CL

Official code: Romainpkq/CD_ICL (2 stars, Apache-2.0, last commit 2025-05-30).

Abstract

Large language models (LLMs) excel at a range of tasks through in-context learning (ICL), where only a few task examples guide their predictions. However, prior research highlights that LLMs often overlook input-label mapping information in ICL, relying more on their pre-trained knowledge. To address this issue, we introduce In-Context Contrastive Decoding (ICCD), a novel method that emphasizes input-label mapping by contrasting the output distributions between positive and negative in-context examples. Experiments on 7 natural language understanding (NLU) tasks show that our ICCD method brings consistent and significant improvement (up to +1.8 improvement on average) upon 6 different scales of LLMs without requiring additional training. Our approach is versatile, enhancing performance with various demonstration selection methods, demonstrating its broad applicability and effectiveness. The code and scripts are released at https://github.com/Romainpkq/CD_ICL.

View on arXivView PDF

Code Implementations(1)

Romainpkq/CD_ICLOfficial100%
Apache-2.0
20Shell, PythonMay 30, 20251 years agoApache-2.0

Similar Papers

Cite this paper

@article{peng2025enhancing,
  title  = {Enhancing Input-Label Mapping in In-Context Learning with Contrastive Decoding},
  author = {Keqin Peng and Liang Ding and Yuanxin Ouyang and Meng Fang and Yancheng Yuan and Dacheng Tao},
  year   = {2025},
  eprint = {2502.13738},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.13738v2}
}

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/2502.13738.svg)](https://codeofpaper.com/paper/2502.13738)

Discussion