ForkMerge: Mitigating Negative Transfer in Auxiliary-Task Learning

Junguang Jiang, Baixu Chen, Junwei Pan, Ximei Wang, Dapeng Liu, jie jiang, Mingsheng Long

Introduction

In machine learning, Auxiliary-Task Learning (ATL) is frequently used to help a model learn a "target" task by simultaneously training it on related "auxiliary" tasks. For example, predicting if a user will click an item (a common event) can serve as an auxiliary task for predicting if they will actually buy it (a rare event).

Ideally, the auxiliary task provides a hint that helps the model generalize. However, practitioners often encounter negative transfer: the auxiliary task confuses the model, leading to lower accuracy than if it had been trained on the target task alone. While previous research largely blames "gradient conflicts"—where tasks pull weights in opposite directions—this paper reveals that gradient conflicts aren't always detrimental. Instead, the authors identify distribution shift as a primary culprit and introduce ForkMerge, a novel training strategy that dynamically filters out harmful parameter updates.

Rethinking Gradient Conflict

Most optimization-based methods attempt to mathematically align conflicting gradients to smooth out the training process. However, the authors provide a surprising insight: gradient conflicts do not necessarily cause negative transfer.

Scatter plot showing Target Generalization vs Gradient Cosine Similarity for L2 regularization

As shown in the analysis of gradient cosine similarity, even standard $L_2$ regularization (weight decay) creates "conflicting" gradients while still improving overall performance. The real issue is whether the conflict helps or hurts generalization. When auxiliary data pulls the model too far from the target task's specific data distribution, negative transfer occurs. Therefore, focusing on validation error rather than just smoothing the optimization process is key.

The ForkMerge Method

To address this, the authors propose ForkMerge, a dynamic training pipeline that operates in the parameter space rather than the loss space. Instead of trying to find a single perfect balance between task losses at the start, ForkMerge treats the problem as a mixture of hypotheses.

Flowchart illustrating the ForkMerge algorithm's fork, optimize, and merge steps

The algorithm follows a periodic cycle:

  1. Fork: Every few epochs (an interval called $\Delta t$), the model is cloned into two branches. Branch 0 is trained only on the target task, while Branch 1 is trained on both the target and auxiliary tasks.
  2. Search: After training both branches independently for $\Delta t$ steps, the algorithm uses a small validation set to find an optimal mixing coefficient ($\lambda^*$). This determines how much auxiliary-task "knowledge" should be kept.
  3. Merge: The parameters of the two branches are linearly combined: $\theta_{new} = (1-\lambda^*)\theta_0 + \lambda^*\theta_1$. If the auxiliary task was harmful, $\lambda^*$ will be close to 0, effectively filtering out the bad updates.
  4. Synchronize: Both branches are updated to this new merged state, and the process repeats.

For scenarios with many auxiliary tasks, the method extends to $K+1$ branches, allowing the model to automatically prune irrelevant or harmful tasks during training.

Key Results

The authors evaluated ForkMerge across several diverse domains, including NYUv2 (scene understanding), DomainNet (multi-domain image recognition), and AliExpress (industrial recommendation).

  • Mitigating Negative Transfer: On DomainNet, where standard multi-task methods often fail miserably (sometimes dropping accuracy by 10-15% compared to single-task learning), ForkMerge consistently stayed above the baseline, achieving a +2.00% gain.
  • State-of-the-Art Performance: On the NYUv2 benchmark, ForkMerge achieved a 4.03% relative improvement over single-task learning, outperforming complex gradient-surgery methods like NashMTL and CAGrad.
  • Industrial Scale: On the AliExpress dataset, which contains over 100 million records, it achieved a 1.30% improvement. In high-traffic recommendation systems, a 1% gain is considered highly significant.
  • Efficiency: Because the branches can be trained in parallel and the merge step is a simple linear combination, ForkMerge avoids the exponential compute time of traditional hyperparameter grid searches.

Limitations and Future Work

ForkMerge relies heavily on having a high-quality, representative validation set to determine the merging weights. If the validation set is too small or biased, the search step might choose poor weights. Additionally, the interval between forks and merges ($\Delta t$) is a new hyperparameter that requires some initial tuning.

Looking forward, the authors suggest that this "fork-merge" philosophy could be applied to other areas, such as asynchronous optimization in distributed training or combining models trained on different data privacy tiers.

Summary updated

BibTeX
@inproceedings{jiang2023forkmerge,
  author = {Junguang Jiang and Baixu Chen and Junwei Pan and Ximei Wang and Dapeng Liu and jie jiang and Mingsheng Long},
  title = {{ForkMerge: Mitigating Negative Transfer in Auxiliary-Task Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=vZHk1QlBQW},
}
Figure