Home Knowledge Base GeDi (Generative Discriminator)

GeDi (Generative Discriminator) is the controllable generation technique that uses class-conditional language models as discriminators to guide text generation toward or away from specified attributes — developed by Salesforce Research as a method to steer any language model's output in real-time by using smaller "guide" models that score candidate tokens for their alignment with desired properties like topic relevance, safety, or sentiment.

What Is GeDi?

Why GeDi Matters

How GeDi Works

Training: Train small class-conditional LMs on text labeled by attribute (e.g., "toxic" vs. "non-toxic"). Each class-conditional model learns language patterns specific to that attribute.

Inference: At each generation step: 1. Compute next-token probabilities from the base model. 2. Compute next-token probabilities from the desired-class guide model. 3. Compute next-token probabilities from the anti-class guide model. 4. Use Bayes' rule to weight base model probabilities toward desired class.

Guidance Strength: A control parameter adjusts how strongly the guide influences base model generation — from subtle bias to strong enforcement.

Applications

ApplicationDesired ClassAnti-ClassEffect
DetoxificationNon-toxicToxicSafe generation
Topic ControlOn-topicOff-topicRelevant content
SentimentPositiveNegativeUpbeat text
FormalityFormalInformalProfessional tone

Comparison with Alternatives

MethodBase Model ChangeControl GranularityOverhead
GeDiNone (frozen)Per-tokenSmall guide model
PPLMGradient updates during generationPer-stepBackpropagation per step
RLHFFull fine-tuningGlobal behaviorTraining cost
PromptingNoneInstructions onlyNo overhead

GeDi is an elegant solution for real-time attribute control in text generation — proving that small, specialized guide models can effectively steer any base model's output through Bayesian per-token weighting without requiring base model modification.

gedi (generative discriminator)gedigenerative discriminatortext generation

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.