GeDi Posterior
When to use
Use this skill when implementing or checking GeDi-style controlled generation or training and you have class-conditional sequence log probabilities for desired and undesired control codes. Do not use it for ordinary discriminative classifiers that do not compare generative likelihoods.
Inputs
- Per-class sequence or token log probabilities.
- Sequence length for length normalization.
- Optional class biases/log priors.
alphanormalization scale.
Outputs
- Stable posterior probabilities over classes.
- Desired-class probability and diagnostic logits.
Workflow
- Sum token log probabilities per class if token-level values are provided.
- Normalize each class log-likelihood by
alpha / length. - Add class bias terms.
- Apply stable log-softmax; for binary cases, sigmoid of the logit difference is equivalent.
- Use the returned posterior as input to decoding or discriminative training.
Validation
Run:
python tests/test_posterior.py
Limitations
This skill computes the GeDi posterior only. It does not run a language model, tokenize text, or select next tokens.