Mutual information: how much two variables share
When you observe an image and predict its label, a fundamental question arises: how much information does the image contain about the label? And conversely, how much does the label tell us about the image? Mutual information answers this question precisely and symmetrically.
Definition
The formula
The mutual information between two random variables and is:
It's the KL divergence between the joint distribution and the product of marginals :
If and are independent, and . The more dependent the variables are, the higher the mutual information.
Equivalent formulas
Mutual information can be expressed in several ways, all instructive:
The first one says: mutual information is the reduction in uncertainty about when you know . It's the initial uncertainty minus the residual uncertainty.
Venn diagram analogy
Think of a Venn diagram:
- The left circle is (total uncertainty of )
- The right circle is (total uncertainty of )
- The intersection is (shared information)
- The union is (joint entropy)
- is the part of outside the intersection

Key properties
Symmetry
Unlike KL divergence, mutual information is symmetric. What tells about is exactly what tells about .
Non-negativity
with equality if and only if and are independent.
More general than correlation
Pearson correlation only captures linear dependencies. Mutual information captures any form of statistical dependence. Two variables can have zero correlation but high mutual information (for example, with symmetric around 0).
Bounds
The shared information cannot exceed the total information of each variable.
Feature selection
The principle
To choose the most informative features for predicting a target variable , you can rank features by decreasing mutual information:
A feature with high mutual information with the target is potentially useful. A feature with is independent of the target and can be eliminated.
Advantages over correlation
- Captures nonlinear relationships between features and target
- Doesn't assume any particular distribution
- Works for both discrete and continuous variables (with kernel or histogram estimation)
Limitations
- Estimating mutual information in high dimensions is difficult
- Doesn't account for redundancies between features: two highly correlated features can each have high with the target, but adding both doesn't bring much
Contrastive learning and InfoNCE
The idea of contrastive learning
Contrastive learning learns representations by bringing together representations of "similar" examples (positives) and pushing apart those of "different" examples (negatives). But what's the connection with mutual information?
InfoNCE loss
The InfoNCE loss (Information Noise Contrastive Estimation), at the heart of SimCLR, CLIP, and many others, is a lower bound on mutual information:
where is a similarity function between representations, is the positive example, and are the negative examples.
It can be shown that:
Minimizing the InfoNCE loss maximizes a lower bound on the mutual information between the representations of the two views. That's why contrastive learning is sometimes called "mutual information maximization."
CLIP: a flagship example
CLIP learns image-text representations by maximizing mutual information between image and text embeddings that correspond to each other. The image of a cat and the sentence "a photo of a cat" share information about the visual content. CLIP captures this shared information in a common embedding space.
The Information Bottleneck
The theoretical framework
The Information Bottleneck theory, proposed by Naftali Tishby in 1999, offers an original perspective on why deep neural networks work. The idea is that a good representation of an input for predicting an output must:
- Maximize : the representation should contain the maximum relevant information for prediction
- Minimize : the representation should forget the irrelevant details of the input
The parameter controls the tradeoff between compression and prediction.
Interpretation for deep networks
Each layer of a deep network can be seen as a transformation that compresses input information while preserving useful information for the output. The early layers extract many features (high ), and subsequent layers compress toward the essentials (low , high ).
The fitting phase and the compression phase
Experimental work has observed two phases during training:
- Fitting phase: the network learns to encode relevant information, increases rapidly
- Compression phase: the network forgets irrelevant details, decreases while remains stable
This interpretation remains debated in the scientific community, but it offers an intuitive framework for thinking about what deep networks do.

Estimating mutual information
The practical challenge
Computing exact mutual information requires knowing the joint distribution , which is rarely the case in practice. We need estimators.
Classic estimators
- Histogram: discretize the variables and count. Simple but imprecise in high dimensions.
- KNN (k-Nearest Neighbors): the Kraskov-Stogbauer-Grassberger estimator uses distances to neighbors to estimate densities. More robust than histograms.
Neural estimators
MINE (Mutual Information Neural Estimation) uses a neural network to estimate a lower bound on mutual information:
where is a neural network. This allows estimating mutual information between network layers, learned representations, or any pair of variables.
Mutual information in modern architectures
Attention and mutual information
The attention mechanism can be interpreted as a relevance computation: which input tokens are most informative for predicting an output token? It's an implicit form of mutual information maximization between the query and the keys.
Data augmentation
Data augmentations in contrastive learning (cropping, rotation, color changes) are chosen to preserve semantic information ( stays high) while modifying surface details ( is reduced). It's the Information Bottleneck put into practice.
Regularization and information forgetting
Dropout, weight decay, and data augmentation can all be seen as mechanisms that reduce (the information the representation keeps about the input), forcing the network to retain only information useful for the task.
Key takeaways
- Mutual information measures any form of statistical dependence between two variables
- : it's the reduction in uncertainty brought by knowledge of the other variable
- It's more general than correlation because it captures nonlinear dependencies
- InfoNCE in contrastive learning maximizes a lower bound on mutual information
- The Information Bottleneck proposes that a good network compresses the input while preserving relevant information for the output
- Estimating mutual information in high dimensions is a practical challenge, solved by neural estimators like MINE
Where this is used. The InfoNCE objective described here is what trains text embedding models.