Distribution-Level Z-Free-Relative Reconstruction Rescaling
Distribution-Level Z-Free-Relative Reconstruction Rescaling
Back to reconstruction weighting and normalization
Implementation note: Current implementation: empirical z-free-relative reconstruction rescaling
This note describes a distribution-level reconstruction rescaling that uses the expected loss of the latent-free conditional distribution as its reference scale. Its role is to restore reconstruction scale in the entangled-initialized regime, where the z-conditioned model already predicts from accurately enough that plain reconstruction can be too weak relative to KL.
Standard ELBO Objective
For one supervised pair , the conditional ELBO is
With a beta-weighted KL:
Equivalently, the minimized loss is
where the first term is the reconstruction loss
and the second term is the KL divergence tethering the posterior to the prior/router:
In a standard VAE trained from scratch, is initially large, so reconstruction gradients dominate early. In the current project this is not the regime: is initialized from an already strong entangled model , so the initial y-region NLL is often already very small. The KL term therefore starts on a comparable or larger scale and can push toward before becomes informative.
The failure mode is that the reconstruction loss is already small (at initialization, model can predict from without ), so the encoder-side gradient that would make useful is weak from step 0.
Normalized Reconstruction Objective
Let denote the current model's per-example teacher-forced y-region reconstruction loss, averaged over supervised positions and over the posterior on :
Let denote the frozen z-free base-model y-region surprisal for that same example:
Here "z-free" means the latent-free conditional distribution , i.e. the model's prediction of from without conditioning on a latent variable .
In the current implementation, the compact notation
is implemented as the masked mean token NLL
where is the supervised y-region. Likewise,
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.
Let
denote the distribution-level mean z-free loss used as the global normalization constant. In methodology terms this is a data-distribution expectation. In the current implementation it is estimated empirically from validation data. In the entangled-run setting this scalar is loaded from run artifacts; in the pretrained-source setting it is recomputed by scoring the current validation rows with the source model.
Define the normalized reconstruction term
The optimized objective becomes
So rescaling does not alter the shape of the reconstruction objective; it changes only its global weight. When the entangled baseline loss is tiny, the effective reconstruction coefficient becomes large, restoring a better reconstruction-to-KL balance.
Code-Length Interpretation
If negative log-likelihood is read as code length, then
is the code-length reduction obtained by conditioning on in addition to . This is the natural absolute-improvement quantity in the problem: it measures how much shorter the description of becomes once the latent is provided.
The current distribution-level rescaling does not optimize this difference directly. Instead, it rescales reconstruction by the aggregate z-free loss. That converts the absolute code-length picture into a fractional one at the distribution level.
Relative-Excess Interpretation
The dataset-level normalized reconstruction objective can be rewritten as
Since , this equals
This is a relative-excess reconstruction objective at the level of distribution means:
- the numerator is the excess reconstruction loss over the base model;
- the denominator expresses that excess relative to the mean base-model surprisal.
This interpretation is close to, but importantly different from, an example-level relative-excess objective. The current global rescaling forms
not
So the current method rescales reconstruction globally; it does not reweight examples relative to one another.
Interpretation
The corresponding validation metric
has a direct interpretation:
- is the leftover fraction of aggregate baseline surprisal after conditioning on .
- is the fraction of aggregate residual surprise in given explained by .
- : the disentangled model matches the entangled baseline.
- \rho_\mathrm{recon} < 1: the latent-conditioned model improves on the baseline, so conditioning on explains a positive fraction of the aggregate residual surprise.
- : the factorized model is even worse than the baseline at predicting y from x, z.
This is useful both as an optimization rescaling and as a comparison metric, because it reports reconstruction quality relative to the actual entangled initializer rather than on an absolute NLL scale that varies by task.
The critical point is that this is a global rescaling, not an example reweighting. It does not change which examples matter more. It only changes the overall reconstruction-to-KL balance.
Another way to say this is that rescaling turns absolute information gain into fractional information gain at the distribution level. The metric does not ask which examples receive more emphasis; it asks what fraction of the aggregate z-free loss remains.
Rate-Distortion View
The normalized objective can be written as
So in rate-distortion language, baseline normalization changes the global slope of the reconstruction-vs-KL tradeoff. Equivalently, it changes the global latent budget available to reconstruction improvement, but it does not redistribute that budget across examples. This is why it is best understood as scale restoration rather than reweighting.
Current status in this repository
This distribution-level objective family is currently implemented through an empirical validation-based estimator of the z-free reference loss.
- Core configuration contract:
normalize_reconstruction_lossandreconstruction_loss_normalizerinpath:core/disentanglement/config.py - Reconstruction weight application:
path:core/disentanglement/shared_discrete_cvae.pypath:core/disentanglement/continuous_cvae.py
- Normalizer loading / computation:
path:experiments/synthetic_sequences/disentangled/train_disentangled.pypath:experiments/synthetic_sequences/disentangled/setup.py
- CLI flag:
--normalize-reconstruction-lossinpath:experiments/synthetic_sequences/disentangled/config.py - Validation metric emission:
loss/val/baseline_normalized_reconstruction_lossinpath:experiments/synthetic_sequences/disentangled/evaluation_runtime.py
Neighboring variants
- Example-level inverse-surprisal weighting Uses inverse per-example base-model surprisal. Unlike distribution-level rescaling, that variant reweights examples and induces an example-dependent effective .
- Token-level surprisal-share weighting Uses per-token base-model surprisal shares to emphasize strategy-sensitive positions inside each example.
Relationship to Other Interventions
Token-Weighted Reconstruction
Token-weighted reconstruction changes the distribution of the reconstruction gradient across token positions by upweighting positions where the z-free model has high residual surprisal. Baseline normalization changes only the global magnitude of the standard reconstruction term. These are complementary:
- normalization says "make reconstruction matter again at all,"
- token weighting says "within reconstruction, focus on strategy-sensitive tokens."
Both can be used simultaneously.
Inter-Latent JSD
Inter-latent JSD injects an exclusivity signal: different latent values should induce different token distributions. It does not by itself solve the weak-reconstruction problem. Normalization and JSD therefore address different bottlenecks:
- normalization encourages to become useful,
- JSD encourages the information in to be strategy-separating.
InfoVAE-Style Beta Reduction
Lowering weakens the KL pressure directly. Normalization strengthens reconstruction directly. Both rebalance the same competition, but in opposite ways:
- beta reduction rescales downward,
- normalization rescales upward.
Normalization is especially natural in the entangled-initialized regime because its scale is tied to the observed baseline loss rather than chosen manually.
Diagnostics to Watch
The main diagnostics are:
- raw
reconstruction_loss: did the conditional generator remain strong? baseline_normalized_reconstruction_loss: is the factorized model beating the entangled baseline?kl_prior_loss: is the posterior carrying information instead of collapsing?loss_contrib/fraction_abs/reconstruction_loss: did the optimization balance actually shift toward reconstruction?- downstream structure metrics such as alignment or probe accuracy: does the stronger reconstruction signal translate into more informative latents?