Abstract
Fine-tuning large Pretrained Language Models (PLMs) like BERT on small datasets often leads to overfitting due to a lack of task-specific focus. This paper proposes a method to integrate label information directly into the self-attention mechanism, guiding the model to prioritize task-relevant features. Experimental results show significant improvements on low-resource benchmarks and real-world clinical data without compromising performance on large-scale datasets.
Introduction
While models like BERT excel at general language understanding, they remain task-agnostic during pretraining. In low-resource scenarios—where labeled data is scarce—these models often overfit to noise, as the [CLS] token may attend to irrelevant tokens rather than task-critical keywords. Existing solutions, such as auxiliary pretraining, are often computationally expensive or data-dependent. This work introduces a "plug-and-play" modification to the self-attention module that treats labels as priors to focus the model's attention.
Methodology
The proposed approach modifies the standard Transformer architecture by incorporating task-specific label information into the self-attention layers.
Label Embeddings and Modified Attention
Each class label is represented as a vector (embedding) within the same space as the input tokens. During the self-attention process, the [CLS] token's attention scores are influenced by these label embeddings. Specifically, the authors employ a "Max Trick": the attention score for a token is updated by taking the maximum value between its original attention score and the attention score derived from the labels. This mechanism effectively boosts the signal of words highly relevant to the target classes.
Joint Loss Function
To ensure the label embeddings remain meaningful, a secondary loss function, $L_{label}$, is introduced. This joint loss forces the label embeddings to be easily classifiable by the model's final layer, maintaining their semantic relevance throughout the training process.
Experimental Evaluation
The method was evaluated on nine standard text classification tasks from the GLUE benchmark (including WNLI, RTE, MRPC, and CoLA) and two real-world clinical datasets:
- Message-urgency (1.7k samples): Categorizing patient messages into Non-urgent, Medium, or Urgent.
- Acknowledgment (1.6k samples): Identifying substantive queries versus simple acknowledgments.
Results and Analysis
The proposed method consistently outperformed standard BERT and BioBERT on low-resource tasks.
Key improvements include a jump from 55.11% to 57.75% accuracy on WNLI and from 63.90% to 66.43% on RTE. On the clinical Message-urgency dataset, the F1 score improved from 0.761 to 0.789. Notably, the model maintains stable performance on large datasets like MNLI (393k samples), suggesting that the task-specific prior is most beneficial when data is insufficient for the model to discover relevant features autonomously.
Conclusion
Integrating label information as a prior within the self-attention mechanism provides a robust solution for fine-tuning PLMs in low-resource environments. By filtering noise and highlighting "trigger words," the method improves classification performance and stability. Future work includes extending this framework to multi-label classification and other Transformer-based architectures.
Summary updated