TL;DR
Training multiple machine learning tasks together can often hurt performance due to "negative transfer," but finding the perfect task groupings usually requires an impossibly expensive search. This paper introduces Task Affinity Grouping (TAG), a method that identifies optimal task clusters in a single training run by measuring how the gradient of one task affects the loss of others, achieving a 10% performance boost and up to a 22x speedup over previous state-of-the-art methods.
What Problem Does This Paper Address?
Multi-Task Learning (MTL) is a powerful paradigm where a single model learns to solve several problems at once (e.g., an autonomous car detecting pedestrians, signs, and lane lines simultaneously). In theory, tasks should help each other by sharing features. In practice, tasks often "compete" for model capacity or have conflicting gradients, leading to worse performance than if they were trained separately.
The "holy grail" of MTL is knowing which tasks to group together in shared networks and which to keep separate. However, for $N$ tasks, there are $2^N - 1$ possible groupings—an exponential search space that is computationally prohibitive for large-scale problems. Most researchers currently rely on human intuition or expensive "trial and error" searches that require training hundreds of models.
Methods
The authors propose Task Affinity Grouping (TAG). The core idea is to measure Inter-Task Affinity during a single "discovery" training run where all tasks are trained together.
- Lookahead Affinity: At each training step, the algorithm calculates what would happen to Task B's loss if the model's shared parameters were updated using only the gradient from Task A.
- If Task B's loss decreases, Task A has a positive affinity for Task B.
- If the loss increases, they are antagonistic.
- Efficiency through Sampling: Instead of calculating this for every single step (which would be slow), they found that calculating affinity every 10 steps provides a 319% speedup with no loss in grouping quality.
- Network Selection: Once they have a matrix of pairwise affinities, they use a branch-and-bound algorithm to select the set of task groupings that maximizes the total affinity across all tasks, subject to a user-defined memory or latency budget.
Unlike previous methods that require training many partial combinations of tasks to see how they perform, TAG extracts this information "for free" during the standard training process.
Datasets
The researchers evaluated TAG on two major computer vision benchmarks:
- CelebA: A large-scale face attributes dataset. They used a subset of 9 tasks (e.g., detecting eyeglasses, baldness, or wearing a hat).
- Taskonomy: A massive dataset of indoor scenes. They focused on 5 complex tasks: Semantic Segmentation, Depth Estimation, Keypoint Detection, Edge Detection, and Surface Normal Prediction. This dataset is particularly challenging because the tasks are diverse and computationally heavy.
Key Insights and Ideas
- Grouping > Optimization: The authors compared task grouping against popular MTL optimization tricks (like GradNorm or PCGrad) that try to balance gradients. They found that choosing the right tasks to train together is more impactful than trying to fix a bad grouping with clever optimization.
- Affinity is Dynamic: Task relationships aren't static; they change throughout the training process. However, certain tasks consistently show high affinity for each other, and averaging these scores over the entire training run yields robust groupings.
- Training vs. Validation: Surprisingly, measuring affinity on the training set is just as effective as measuring it on a held-out validation set. This simplifies the pipeline significantly.
- Hyperparameter Sensitivity: The "optimal" grouping isn't just about the tasks themselves—it also depends on the batch size and learning rate. This highlights why automated methods like TAG are necessary; human intuition cannot account for these low-level training dynamics.
Key Results
- Performance: On Taskonomy, TAG decreased test loss by 10.0% compared to training all tasks together in one model.
- Speed: TAG was 11.6x faster than the state-of-the-art HOA method on Taskonomy and 22x faster on CelebA.
- Scalability: While previous methods might take thousands of GPU hours to find groupings for large datasets, TAG identifies them in the time it takes to perform a single training run plus a small overhead for affinity calculations.
- Complementary Benefits: TAG can be combined with other methods. For example, using TAG to find groups and then using PCGrad to train those groups led to even further performance gains.
Limitations and Future Work
- Selection Complexity: While the discovery of affinity is fast, the selection step (deciding the final groups from the affinity matrix) is technically NP-hard. For a very large number of tasks (e.g., 50+), the branch-and-bound solver might become a bottleneck, though it works fine for the scales tested.
- Architecture Fixed: The current method assumes a "hard-parameter sharing" architecture (a shared backbone with task-specific heads). It does not explore more complex branching architectures where tasks might split off at different layers.
- Future Direction: The authors suggest that future work could involve "online" task grouping, where the model dynamically re-groups tasks during a single training run rather than requiring a separate discovery and final training phase.
Summary updated