Example-Level Inverse-Surprisal Weighting
Example-Level Inverse-Surprisal Weighting
Back to reconstruction weighting and normalization
Implementation note: Current implementation: example-level inverse-surprisal weighting
This note records an under-consideration variant of baseline-normalized reconstruction that weights each example by the inverse of its own base-model surprisal rather than using one dataset-level constant.
Setup
Let denote the current model's per-example y-region reconstruction loss:
Let denote the z-free base-model surprisal on the same example:
In the current implementation, the compact notation
is implemented as the masked mean token NLL
and
is implemented as
So the compact notation suppresses two implementation details: the loss is masked to the supervised y-span, and it is averaged across those supervised tokens rather than summed.
Objective
The proposed example-level normalized reconstruction term is
with included explicitly to prevent low-surprisal examples from producing extreme ratios.
The empirical objective becomes
Fractional Interpretation
When is small relative to , this admits the decomposition
This is the mean relative excess reconstruction loss over the base model.
If negative log-likelihood is read as code length, then
is the code-length reduction from conditioning on in addition to . That is the natural absolute-improvement quantity.
The ratio form changes the interpretation from absolute improvement to fractional improvement:
- it asks what fraction of the residual surprise in given is explained by ;
- equivalently, minimizing means minimizing the leftover fraction of baseline surprisal after conditioning on .
This is the strongest user-facing interpretation of the objective:
- the numerator measures excess loss over the base model;
- the denominator expresses that excess relative to the base-model surprisal scale of that same example.
In this sense, normalization turns absolute information gain into fractional information gain at the example level.
Difference vs optimization effect
The code-length difference
has the cleanest information-theoretic interpretation, but if is frozen it does not change the reconstruction gradient.
The ratio
does change optimization:
So the optimization effect comes from inverse-surprisal reweighting, while the clean interpretation comes from the underlying code-length reduction.
Relation to dataset-level normalization
It is important to distinguish this mean of ratios from the current dataset-level ratio of means:
The dataset-level variant is a global rescaling of reconstruction. This example-level variant is example reweighting.
See Distribution-Level Z-Free-Relative Reconstruction Rescaling for the distribution-level form.
Example-dependent reconstruction-vs-KL balance
The per-example objective takes the form
Equivalently, after factoring out the reconstruction coefficient, the KL-to-reconstruction balance becomes example dependent:
So this objective does not merely normalize scale. It multiplies the effective KL pressure by an example-specific factor derived from the base-model surprisal.
This makes the objective naturally interpretable as a heterogeneous -VAE or a sample-dependent rate-distortion tradeoff: different examples face different effective prices on latent rate, or equivalently different effective latent budgets.
Interpretation and caution
The most important caveat is how to explain the weighting signal.
At the mechanism level, the objective does assign larger reconstruction gradients to examples with smaller . But the intended interpretation is not "give more latent budget to easy examples." The better interpretation is that the ratio acts as an equalization force: it normalizes away absolute difficulty so that high-surprisal examples do not dominate simply because they carry more raw reconstruction loss.
Equivalently, the objective prefers large fractional improvement rather than large absolute improvement.
Two cautions follow:
- this objective is not literally the conditional mutual information ; the direct information-theoretic quantity is the code-length difference , not the ratio;
- very small denominators can make the weighting unstable or overly aggressive, which is why the term is essential.
Current status in this repository
This variant is implemented as example_inverse_surprisal_weighted_reconstruction_loss, one explicit term in the current reconstruction stack.
The current code touchpoints are:
- the per-example reconstruction helper in
path:core/disentanglement/losses.py - the frozen-reference-model machinery in
path:core/disentanglement/token_weighting.py - the loss composition paths in:
path:core/disentanglement/shared_discrete_cvae.pypath:core/disentanglement/continuous_cvae.py
- CLI / trainer wiring in
path:experiments/synthetic_sequences/disentangled/config.pyandpath:experiments/synthetic_sequences/disentangled/train_disentangled.py
The implementation note is Current implementation: example-level inverse-surprisal weighting.
Neighboring variants
- Distribution-Level Z-Free-Relative Reconstruction Rescaling Global reconstruction rescaling by one distribution-level constant.
- Token-level surprisal-share weighting Within-example token weighting toward positions where the z-free model has high residual surprisal shares and has the most local room to help.