LibMTL: A Python Library for Multi-Task Learning

Baijiong Lin, Yu ZhangarXiv 2022 · DOI

Abstract

Multi-Task Learning (MTL) is a powerful machine learning paradigm that enables a single model to learn multiple related tasks simultaneously, enhancing generalization while optimizing computational efficiency. Despite its advantages, the field has been hindered by a reproducibility crisis caused by fragmented implementations and inconsistent experimental setups. This paper introduces LibMTL, an open-source Python library built on PyTorch designed to address these challenges. By decoupling model architectures from loss-weighting strategies, LibMTL provides a modular and extensible framework that allows researchers to fairly compare and combine over 80 state-of-the-art MTL configurations.

1. Introduction

Multi-Task Learning (MTL) aims to leverage shared information across tasks to improve the performance of individual tasks compared to learning them in isolation. While theoretically promising, the practical application of MTL is often complicated by the "reproducibility crisis." Most state-of-the-art (SOTA) models are developed in isolated frameworks with varying hyperparameters and data processing pipelines. This fragmentation makes it difficult to discern whether a performance improvement stems from a novel architecture, a specific optimization trick, or simply superior hyperparameter tuning.

Furthermore, existing libraries are often domain-specific (e.g., focused solely on Natural Language Processing) or restricted to "single-input" scenarios where all tasks share the same input data. LibMTL was developed to bridge these gaps, providing a general-purpose tool that supports diverse data structures and provides a level playing field for benchmarking.

2. The LibMTL Framework

The core philosophy of LibMTL is the formal separation of the two primary pillars of MTL research: Architectures and Loss Weighting Strategies.

2.1 Modular Design

Because parameter-sharing mechanisms (architectures) and objective-balancing methods (weighting strategies) are largely orthogonal, LibMTL allows users to "plug and play" different components. For instance, a researcher can pair a classic architecture like Cross-stitch Networks with a modern optimization strategy like CAGrad using only a few lines of configuration. This modularity is achieved through three primary components:

  • LibMTL.architecture: Contains implementations of various parameter-sharing mechanisms.
  • LibMTL.weighting: Contains strategies for balancing task losses or gradients during training.
  • LibMTL.Trainer: A unified training engine that manages the interaction between the architecture, weighting strategy, and data pipeline.

2.2 Data Versatility

LibMTL is designed to handle two distinct data scenarios commonly found in MTL:

  • Single-input case: All tasks share the same input features (e.g., performing depth estimation and semantic segmentation on the same image).
  • Multi-input case: Each task utilizes its own unique dataset and input features, requiring the framework to manage disparate data streams simultaneously.

3. Supported Methods

LibMTL provides out-of-the-box support for a wide array of SOTA methods, eliminating the need for researchers to re-implement complex algorithms from scratch.

3.1 Architectures

The library currently supports 7 major MTL architectures:

  • Hard Parameter Sharing (HPS)
  • Cross-stitch Networks
  • Multi-gate Mixture-of-Experts (MMoE)
  • Multi-Task Attention Network (MTAN)
  • Customized Gate Control (CGC)
  • Progressive Layered Extraction (PLE)
  • DSelect-k

3.2 Loss Weighting Strategies

To prevent dominant tasks from overwhelming the learning process, LibMTL includes 12 weighting strategies:

  • Basic: Equal Weighting (EW), Uncertainty Weighting (UW), Dynamic Weight Average (DWA).
  • Gradient-based: GradNorm, MGDA, PCGrad, GradDrop, GradVac, CAGrad, IMTL.
  • Others: GLS and RLW.

4. Key Insights and Impact

The primary contribution of LibMTL is the enablement of fair benchmarking. By re-implementing diverse SOTA methods within a single, unified framework, the library ensures that comparisons are made under identical conditions. This transparency allows the research community to identify which combinations of architecture and optimization truly drive progress in the field.

Additionally, the library's extensibility is a significant boon for researchers. Developing a new weighting strategy only requires modifying the weighting module; the underlying training loops, data loaders, and architectural configurations remain consistent, significantly reducing the overhead for innovation.

5. Conclusion and Future Work

LibMTL represents a significant step toward standardized and reproducible research in Multi-Task Learning. By providing a comprehensive, modular, and easy-to-use library, the authors empower researchers to explore the vast landscape of MTL combinations efficiently. Future developments will focus on integrating emerging SOTA models, expanding documentation, and applying the framework to a broader range of domains beyond computer vision and NLP.

The source code and documentation are available on GitHub at https://github.com/median-research-group/LibMTL.

Summary updated

BibTeX
@misc{lin2022libmtl,
  author = {Baijiong Lin and Yu Zhang},
  title = {{LibMTL: A Python Library for Multi-Task Learning}},
  year = {2022},
  eprint = {2203.14338},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.14338},
}
Figure