界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
效率与协作 · SKILL.md

gedi_posterior

gedi_posterior

【效率与协作】Compute GeDi generative-discriminator class posteriors from control and anti-control log probabilities using stable Bayes-rule normalization.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: gedi_posterior description: Compute GeDi generative-discriminator class posteriors from control and anti-control log probabilities using stable Bayes-rule normalization.

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.
  • alpha normalization scale.

Outputs

  • Stable posterior probabilities over classes.
  • Desired-class probability and diagnostic logits.

Workflow

  1. Sum token log probabilities per class if token-level values are provided.
  2. Normalize each class log-likelihood by alpha / length.
  3. Add class bias terms.
  4. Apply stable log-softmax; for binary cases, sigmoid of the logit difference is equivalent.
  5. 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.

我的收藏