CCPrompt: Counterfactual Contrastive Prompt-Tuning for Many-Class Classification

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

Introduction

Adapting Pre-trained Language Models (PLMs) to downstream tasks via prompt-tuning or prefix-tuning has become a standard practice. By framing classification as a "cloze-style" completion task, these methods leverage the inherent knowledge of PLMs. However, a significant hurdle remains: many-class classification. When dealing with dozens or hundreds of categories, standard methods often falter due to semantic overlap between labels.

The Challenge of Many-Class Classification

The primary issue in large label spaces is verbalizer ambiguity. When classes are numerous, the words chosen to represent them (verbalizers) often share significant semantic meaning. For instance, in fine-grained entity typing, categories like "Person-Actor" and "Person-Employee" both fall under the "Person" umbrella. A standard model might focus on generic attributes—such as a location or the mention of a company—that apply to both classes, failing to capture the specific nuances required to distinguish between them.

An example of verbalizer ambiguity in entity typing, where 'Actor' and 'Employee' share overlapping semantic features.

Methodology: CCPrefix

To address this, the authors propose CCPrefix (Counterfactual Contrastive Prefix-tuning). Drawing inspiration from social science research, which posits that explanations are most effective when they are contrastive (answering "why A and not B"), CCPrefix generates instance-dependent soft prefixes that highlight the differences between the ground truth and its most confusing alternatives.

The overall architecture of CCPrefix, detailing the flow from input instance to contrastive attribute construction and final classification.

The CCPrefix pipeline consists of four key stages:

  1. Contrastive Generation: For each instance, the model constructs "fact-counterfactual" pairs. It projects sentence representations into a contrastive subspace defined by the difference between label embeddings ($v_{fact} - v_{counterfactual}$).
  2. Prototype Constraint: To filter noise, the model learns global "prototypes" for contrastive attributes. These prototypes help identify which attributes are truly discriminative across the dataset, ensuring the model isn't distracted by semantically distant or irrelevant labels.
  3. Prefix Construction: The top-$m$ most relevant contrastive attributes are selected to serve as "soft prefix" tokens, which are then prepended to the input to guide the PLM.
  4. Siamese Training: A Siamese representation learning objective is employed to align the generated prefix with an "ideal" prefix containing all positive attributes, ensuring training stability.

Evaluation and Results

CCPrefix was evaluated across several many-class benchmarks, including Relation Classification (TACRED, ReTACRED), Topic Classification (DBPedia), and Entity Typing (FewNERD).

The results demonstrate that CCPrefix consistently outperforms strong baselines like PTR and ProtoVerb. Notably, in few-shot settings ($K=1$ or $2$), the model showed substantial gains. For example, on DBPedia with $K=1$, CCPrefix achieved an F1 score of 84.02%, significantly higher than ProtoVerb's 72.85%. In fully supervised Relation Classification on ReTACRED, it reached a state-of-the-art F1 of 91.2%.

Qualitative analysis further reveals that CCPrefix produces more concentrated highlights within a sentence compared to standard methods. Instead of scattered attention, it focuses on determinant keywords—such as "native of" for birth locations—thereby reducing ambiguity.

Limitations and Future Work

While effective, CCPrefix currently assumes all non-gold labels are potential counterfactuals, which may include semantically unrelated noise. Additionally, in tasks with multiple entities, the model can occasionally associate attributes with the wrong entity. Future work aims to adapt this contrastive approach for Causal Language Models (CLMs) and more complex extraction tasks.

Summary updated

Abstract

With the success of the prompt-tuning paradigm in Natural Language Processing (NLP), various prompt templates have been proposed to further stimulate specific knowledge for serving downstream tasks, e.g., machine translation, text generation, relation extraction, and so on. Existing prompt templates are mainly shared among all training samples with the information of task description. However, training samples are quite diverse. The sharing task description is unable to stimulate the unique task-related information in each training sample, especially for tasks with the finite-label space. To exploit the unique task-related information, we imitate the human decision process which aims to find the contrastive attributes between the objective factual and their potential counterfactuals. Thus, we propose the \textbf{C}ounterfactual \textbf{C}ontrastive \textbf{Prompt}-Tuning (CCPrompt) approach for many-class classification, e.g., relation classification, topic classification, and entity typing. Compared with simple classification tasks, these tasks have more complex finite-label spaces and are more rigorous for prompts. First of all, we prune the finite label space to construct fact-counterfactual pairs. Then, we exploit the contrastive attributes by projecting training instances onto every fact-counterfactual pair. We further set up global prototypes corresponding with all contrastive attributes for selecting valid contrastive attributes as additional tokens in the prompt template. Finally, a simple Siamese representation learning is employed to enhance the robustness of the model. We conduct experiments on relation classification, topic classification, and entity typing tasks in both fully supervised setting and few-shot setting. The results indicate that our model outperforms former baselines.
BibTeX
@inproceedings{li2024ccprompt,
  author = {Yang Li and Canran Xu and Tao Shen and Jing Jiang and Guodong Long},
  title = {{CCPrompt: Counterfactual Contrastive Prompt-Tuning for Many-Class Classification}},
  booktitle = {EACL},
  year = {2024},
  url = {https://openreview.net/forum?id=19kun7SQu8},
}
Figure