Labels Need Prompts Too: Mask Matching for Natural Language Understanding Tasks

Bo Li, Wei Ye, Quansen Wang, Wen Zhao, Shikun Zhang

Abstract

Traditional Natural Language Understanding (NLU) methods often treat labels as arbitrary indices, ignoring the rich semantic information inherent in label names. While prompt-tuning has attempted to bridge this gap via manual verbalizers, it struggles with scalability and complex label sets. We propose Mask Matching, a novel paradigm that applies prompting to both inputs and labels. By matching the hidden representations of [MASK] tokens from both sides, our approach leverages the full semantic power of pre-trained language models without manual engineering. Mask Matching demonstrates superior performance across 14 datasets, particularly in low-resource and high-cardinality classification tasks.

Introduction

In standard NLU classification, labels are typically treated as discrete numbers (0, 1, 2). However, label names like "Positive," "Organization," or "Place of Birth" carry significant semantic weight that can guide a model's understanding. Existing attempts to utilize this information generally fall into two categories:

  1. Semantic Matching: Directly comparing input text to label names, often using sub-optimal pooling methods (e.g., averaging word embeddings) that fail to capture context.
  2. Prompt-tuning: Mapping specific words (verbalizers) to labels. This requires intensive manual design and becomes impractical for tasks with numerous classes, such as fine-grained entity typing.

Mask Matching addresses these limitations by extracting the semantic "essence" of label names naturally and efficiently through a dual-prompting mechanism.

Methodology: The Mask Matching Paradigm

The core innovation of Mask Matching is the simultaneous prompting of both the input text and the candidate labels.

Comparison of Mask Matching with conventional classification, semantic matching, and prompt-tuning.

As illustrated in Figure 1, unlike conventional classification or standard prompt-tuning, Mask Matching utilizes two distinct templates:

  • Input-prompt ($P_I$): A template such as [Input Text]. It is [MASK].
  • Label-prompt ($P_L$): A novel template applied to every category name, e.g., [Label Name] is [MASK].

The model uses a single Pre-trained Language Model (PLM) to encode both prompts. It extracts the hidden representation of the [MASK] token from the input and the corresponding [MASK] token from each potential label. Prediction is then performed by calculating the dot-product similarity between the input mask and all label masks. During training, a cross-entropy loss is optimized to align the input mask with the correct label mask in the embedding space, removing the need for a traditional classification head or manual verbalizers.

Examples of input and label prompts across various NLU tasks.

Figure 2 demonstrates how this approach generalizes across diverse tasks, from entity typing to stance detection, by simply adapting the prompt templates.

Experimental Evaluation

The researchers evaluated Mask Matching across 8 NLU tasks using 14 datasets, including topic classification (R8, R52), sentiment analysis (MR, IMDb), entity typing (FEW-NERD, BBN), relation classification (TACRED), and natural language inference (QNLI, SNLI).

Key Results

  • Performance Gains: Mask Matching outperformed standard fine-tuning on 13 out of 14 datasets. Notable improvements include a +1.7% gain on the Word in Context (WiC) task.
  • Scalability: In complex tasks like BBN entity typing (47 classes), performance improved by +0.9% over fine-tuning, demonstrating its effectiveness in high-cardinality settings where prompt-tuning often fails.
  • Low-Resource Robustness: In scenarios with only 10% of training data, Mask Matching showed dramatic improvements over prompt-tuning in entity typing and relation extraction.
  • Label Enrichment: Manually adding synonyms to label names (e.g., "Person" $\rightarrow$ "Person, human, individual") further boosted performance, confirming that the model effectively leverages label semantics.

Discussion and Insights

Mask Matching treats labels as "first-class citizens," allowing the PLM to utilize its internal knowledge about semantic concepts. The [MASK] token representation serves as a more powerful feature extractor than traditional pooling methods. Furthermore, the method is robust to specific prompt wording, reducing the burden of prompt engineering.

Conclusion and Future Work

Mask Matching offers a scalable and semantically rich alternative to traditional fine-tuning and prompt-tuning. While highly effective for single-input tasks, its impact on sentence-pair tasks (like NLI) is currently more modest, suggesting a need for better joint encoding strategies. Future research may explore automatic label name extension using PLMs and the use of multiple mask tokens to further refine label representations.

Summary updated

BibTeX
@inproceedings{li2024labels,
  author = {Bo Li and Wei Ye and Quansen Wang and Wen Zhao and Shikun Zhang},
  title = {{Labels Need Prompts Too: Mask Matching for Natural Language Understanding Tasks}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i16.29806},
}
Figure