Interpreting and Exploiting Functional Specialization in Multi-Head Attention under Multi-task Learning

Chong Li, Shaonan Wang, Yunhao Zhang, Jiajun Zhang, Chengqing Zong

Abstract

Transformer models often suffer from negative transfer in multi-task learning (MTL), where gradient updates from different tasks interfere with one another. This research demonstrates that multi-head attention modules naturally develop task-specific "expert" heads, a phenomenon termed functional specialization. We introduce Important Attention-head Pruning (IAP) to quantify this specialization and Important Attention-head Training (IAT) to exploit it. By updating only task-relevant heads during fine-tuning, IAT reduces interference and improves performance by an average of 0.76% on the GLUE benchmark without adding any new parameters.

Introduction

Despite the dominance of Transformer-based architectures, they are frequently treated as monolithic "black boxes." In Multi-Task Learning (MTL), a common hurdle is negative transfer, where learning a new task inadvertently overwrites knowledge required for another. This study looks to the human brain for a solution, investigating whether artificial neural networks naturally develop "functional specialization"—where specific regions handle specific tasks.

Methods: Quantifying and Exploiting Specialization

The researchers developed two primary techniques to identify and leverage task-specific modularity within the attention mechanism.

Important Attention-head Pruning (IAP)

IAP serves as an analytical tool to measure specialization. It calculates an "importance score" for every attention head based on the sensitivity of the task's loss function to that head. By pruning the most important heads for Task A and observing the impact on Task B, the authors calculate a Dissociation Score. A high score indicates that the tasks rely on distinct sets of heads, confirming high functional specialization.

Visualization of task-specific attention head specialization.

Important Attention-head Training (IAT)

IAT is the practical application of these findings. During the final stages of multi-task training, the model updates only the most important heads for each specific task while keeping others frozen. This segregation prevents gradient updates from one task from interfering with the specialized knowledge needed for another, effectively mitigating negative transfer.

Conceptual diagram of Important Attention-head Training (IAT).

Key Insights

  • Specialization is Task-Dependent: The degree of specialization is negatively correlated with task similarity. Dissimilar tasks (e.g., grammar checking vs. sentiment analysis) evolve distinct sets of heads, while similar tasks share more resources.
  • Input Complexity Matters: Tasks requiring the comparison of two sequences (e.g., Natural Language Inference) show much higher dependence on specific attention heads than simpler, single-sequence tasks.
  • Brain-Like Architecture: These findings provide empirical evidence that artificial neural networks naturally trend toward the modular organization seen in biological brains when pushed to solve multiple problems.

Key Results

  • Performance Boost: IAT improved the average performance of five major Transformer models (including BERT and RoBERTa) on the GLUE benchmark by 0.76%.
  • Mitigating Negative Transfer: On the CoLA dataset, IAT led to a significant +3.6% improvement, rescuing the model from the interference typically seen in multi-task settings.
  • Superior Generalization: In few-shot transfer learning tests, models pre-trained with IAT consistently outperformed standard MTL models. For example, on the SciTail task with only 4 samples, the IAT-enhanced model achieved 75.66% accuracy compared to the baseline's 69.44%.
  • Zero Parameter Overhead: All improvements were achieved without adding additional parameters or adapters.

Conclusion

By interpreting and exploiting the natural functional specialization of attention heads, IAT provides a parameter-efficient way to improve multi-task learning and generalization. Future research will investigate whether similar specialization occurs in feed-forward layers and extend these methods to computer vision and multi-modal domains.

Summary updated

BibTeX
@inproceedings{li2023interpreting,
  author = {Chong Li and Shaonan Wang and Yunhao Zhang and Jiajun Zhang and Chengqing Zong},
  title = {{Interpreting and Exploiting Functional Specialization in Multi-Head Attention under Multi-task Learning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.1026},
}
Figure