Part 1: Multitask Learning (MTL)
1. Conceptual Definition
- Core Idea: A single neural network is trained to jointly solve related tasks simultaneously using shared internal representations.
- Inductive Transfer: According to Rich Caruana (1997), Multitask Learning acts as a form of inductive transfer. It improves generalization by leveraging the domain-specific information contained in the supervisory signals of related tasks:
2. Architectural Paradigm (Hard Parameter Sharing)
As illustrated in Caruana’s architecture:
- Shared Representation (Trunk): The lower hidden layers are shared across all tasks. They map raw inputs into a generic feature space.
- Task-Specific Heads: The upper layers split into specialized output heads, each mapped to a specific task.
Task 1 Task 2 Task 3 Task 4
↑ ↑ ↑ ↑
[Head 1] [Head 2] [Head 3] [Head 4]
\ \ / /
-----------------------------------------
↑
[ Shared Hidden Layers ]
↑
[ Input: x ]
3. Mathematical Formulation
Given a dataset of samples, each with inputs and target labels for different tasks:
- : The task-specific loss function (e.g., Cross-Entropy for classification, MSE for regression).
- : Task weight/importance coefficient balancing competing gradient updates.
- : Parameters updated by gradient contributions from all tasks:
4. Why Multitask Learning Works (Key Benefits)
- Implicit Data Augmentation: Effectively increases sample size because diverse training signals average out task-specific noise.
- Regularization: Prevents overfitting to a single task because the shared representation must satisfy multiple constraints simultaneously.
- Representation Learning: Encourages the shared layers to extract robust, invariant, and transferable features.
Part 2: Contrastive Learning
1. Conceptual Definition
- Core Goal: Learn an embedding space where semantically similar pairs (positive pairs) are pulled close together, while dissimilar pairs (negative pairs) are pushed far apart.
- Key Difference from Standard ML: Unlike traditional supervised learning that maps an input to a fixed target label, contrastive loss is defined relatively—an input’s representation is judged entirely in relation to other inputs.
- Feature Extraction: Once trained, the classification/projection head is discarded, and the activations of the intermediate latent space (the unit hypersphere) are used for downstream tasks (linear probing, zero-shot transfer, retrieval).
2. Anchors, Positive Pairs, and Negative Pairs
For an arbitrary reference data point (called the Anchor):
- Positive Sample (): A point semantically similar to .
- Unimodal (e.g., SimCLR): Two differently augmented views of the same image (crops, color jitters).
- Multimodal (e.g., CLIP): An image and its paired text caption.
- Negative Samples (): Dissimilar points (e.g., other unrelated images or mismatched captions in a mini-batch).
3. The InfoNCE Loss Function (Single Modality)
Let be an encoder mapping input to a latent embedding. Embeddings are -normalized onto the unit hypersphere:
The similarity between any two points is measured by cosine similarity (which equals the dot product for unit vectors):
For an anchor , one positive sample , and negative samples , the InfoNCE Loss is defined as:
- : Temperature hyperparameter.
- A smaller penalizes hard negative samples more aggressively.
- Interpretation: InfoNCE is mathematically identical to a multi-class cross-entropy loss, where the network is tasked with classifying the single positive pair among total candidate pairs.
4. Multimodal Contrastive Learning: CLIP (Radford et al., 2021)
(Referring directly to the second slide: Cat image paired with text vs. negative text )
In multimodal learning, inputs come from different domains (e.g., Image and Text):
- Image Encoder: (e.g., Vision Transformer or ResNet), normalized such that .
- Text Encoder: (e.g., Transformer), normalized such that .
The Mini-Batch Formulation:
Consider a mini-batch of paired samples :
- forms a positive pair (an image and its true caption).
- For a given image , all other texts in the batch serve as negative captions.
- For a given text , all other images serve as negative images.
Symmetric CLIP Loss Function:
The overall objective optimizes both image-to-text and text-to-image classification:
Where:
Part 3: Quick Summary Table
| Dimension | Multitask Learning (MTL) | Contrastive Learning (e.g., CLIP, SimCLR) |
|---|---|---|
| Supervision Type | Typically Supervised (multiple task targets ) | Self-supervised or weakly supervised (pairs of inputs) |
| Objective | Optimize multiple task-specific prediction losses simultaneously | Maximize agreement of positive pairs while repelling negative pairs |
| Architecture | Shared trunk + multiple task-specific output heads | One or two encoder backbones projected onto a shared unit sphere |
| Loss Formulation | Weighted sum: | InfoNCE / Softmax cross-entropy over similarity logits |
| Downstream Usage | Run directly on the task output heads | Discard projection heads; reuse embeddings for zero-shot or retrieval |