CCPrefix: Counterfactual Contrastive Prefix-Tuning for Many-Class Classification

Yang Li, Canran Xu, Guodong Long, Tao Shen, Chongyang Tao, Jing Jiang

TL;DR

Standard prefix-tuning struggles with many-class classification because semantically similar labels lead to ambiguous verbalizers. To fix this, the authors introduce CCPrefix, a novel method that generates instance-dependent soft prefixes based on counterfactual contrastive pairs ("Why A not B?"), significantly boosting performance in both fully supervised and few-shot settings.

What Problem Does This Paper Address?

Prompt- and prefix-tuning have bridged the gap between pre-training and fine-tuning by framing classification as cloze-style tasks. However, when dealing with a large number of classes (many-class classification), the "verbalizer" tokens representing these classes often become semantically blurred.

For example, in fine-grained entity typing, distinguishing between "Person-Actor" and "Person-Employee" is difficult because both share the overarching "Person" attribute. Standard prompt methods ask "Why is this text class A?", which highlights redundant features common to both classes. This paper addresses this verbalizer ambiguity problem by mimicking human decision-making: focusing on why an instance belongs to class A instead of class B.

Methods

The authors propose Counterfactual Contrastive Prefix-tuning (CCPrefix). The pipeline consists of three main stages:

  1. Contrastive Attribute Generation: For each instance, the model constructs all possible fact-counterfactual label pairs. It projects the sentence representation onto the subspaces spanned by these pairs ($u_{i,j} = v_i - v_j$) to extract fine-grained contrastive attributes.
  2. Prototype Constraint & Selection: Since assuming every non-gold label is a counterfactual introduces noise, the model uses a set of global prototypes to learn common features of valid fact-counterfactual pairs. It uses a self-contrastive learning loss ($\mathcal{L}_{\text{con}}$) to filter and select the top-$m$ most similar contrastive attributes ($C_{\text{sel}}$) to serve as additional soft prefix tokens.
  3. Siamese Prefix Tuning Objective: To ensure the Pre-trained Language Model (PLM) focuses on valid contrastive attributes and remains stable, a Siamese representation learning framework minimizes the negative cosine similarity between the template with selected attributes and the template with all positive attributes.
Figure 2: Our proposed model, CCPrefix. For easy comprehension, we zoom out contrastive prefix construction and contrastive attributes generation in Section 2.2. The losses Lcls, Ls and Lcon are defined in Equation (9), Equation (8) and Equation (5). The black line is the forward path for both training and inference, while the green line is the training path with supervised signal.

Datasets

The method was evaluated across three many-class classification tasks using six benchmark datasets:

  • Relation Classification (RC): TACRED, TACREV, ReTACRED, and SemEval 2010 Task 8.
  • Topic Classification (TC): DBPedia (14 classes).
  • Entity Typing (ET): FewNERD (66 fine-grained classes).

Key Insights and Ideas

  • "Why A not B?" beats "Why A?": Instead of highlighting all attributes associated with a class (which leads to redundancy), contrastive projection filters out shared similarities and isolates the exact discriminative features needed for classification.
  • Instance-Aware Soft Prefixes: Unlike static or shared prefixes, CCPrefix dynamically adjusts the prefix tokens based on the specific context of the input instance and its potential counterfactuals.
  • Global Prototypes as Noise Filters: By training global prototypes to recognize valid fact-counterfactual relationships across the entire dataset, the model successfully filters out the noisy attributes generated by invalid label pairs during inference.

Key Results

  • Fully Supervised Setting: CCPrefix achieved state-of-the-art or highly competitive results, scoring 72.6% on TACRED, 82.9% on TACREV, and 91.2% on ReTACRED in $F_1$ score. It outperformed strong baselines like PTR and LUKE without requiring external knowledge bases or manual logic rules.
  • Few-Shot Scenarios: In few-shot settings ($K=8, 16, 32$), CCPrefix consistently outperformed PTR, showing an average improvement of 6.6% on ReTACRED.
  • Extreme Data Scarcity: For topic classification (DBPedia) with $K=1$, CCPrefix outperformed ProtoVerb by 11.17% (84.02% vs 72.85%), demonstrating its power when class labels are semantically diverse.

Limitations and Future Work

  • The All-Labels-Are-Counterfactuals Assumption: The model assumes every non-gold label acts as a valid counterfactual. This assumption breaks down in hierarchical label spaces where classes naturally overlap semantically.
  • Extreme Scarcity with Subtle Labels: On the FewNERD dataset for entity typing, CCPrefix underperformed baselines at $K=1,2$. When labels have highly subtle differences (e.g., "building-theater" vs "building-library"), the model struggles to isolate contrastive attributes without more training data.
  • Multi-Entity Mismatch: In entity-centric tasks with multiple entities in a single sentence, the selected contrastive attributes can sometimes mismatch with the target entity, leading to mispredictions.
  • Future Directions: The authors plan to adapt this approach to Causal Language Models (CLMs) and extend it to relation extraction tasks.

Summary updated

Abstract

Recently, prefix-tuning was proposed to efficiently adapt pre-trained language models to a broad spectrum of natural language classification tasks. It leverages soft prefix as task-specific indicators and language verbalizers as categorical-label mentions to narrow the formulation gap from pre-training language models. However, when the label space increases considerably (i.e., many-class classification), such a tuning technique suffers from a verbalizer ambiguity problem since the many-class labels are represented by semantic-similar verbalizers in short language phrases. To overcome this, inspired by the human-decision process that the most ambiguous classes would be mulled over for each instance, we propose a brand-new prefix-tuning method, Counterfactual Contrastive Prefix-tuning (CCPrefix), for many-class classification. Basically, an instance-dependent soft prefix, derived from fact-counterfactual pairs in the label space, is leveraged to complement the language verbalizers in many-class classification. We conduct experiments on many-class benchmark datasets in both the fully supervised setting and the few-shot setting, which indicates that our model outperforms former baselines.
BibTeX
@inproceedings{li2024ccprefix,
  author = {Yang Li and Canran Xu and Guodong Long and Tao Shen and Chongyang Tao and Jing Jiang},
  title = {{CCPrefix: Counterfactual Contrastive Prefix-Tuning for Many-Class Classification}},
  booktitle = {EACL},
  year = {2024},
  url = {https://openreview.net/forum?id=19kun7SQu8},
}
Figure