Steering a model you refuse to retrain
A language model is controllable when we can sample from for a condition we care about: a sentiment, a topic, the absence of toxicity. Retraining a conditional model for every new is the brute-force answer, and CTRL-style training is exactly that. We wanted the opposite: take a frozen model and bolt the condition on at sampling time.
Bayes gives the recipe in one line: reweight each candidate token as , where the exponent sets how loudly the classifier speaks. The catch is cost. Scoring means running the classifier once per candidate token, and a GPT-2 vocabulary offers tens of thousands of candidates at every step.
Around that bottleneck the field grew workarounds. GeDi and DExperts distill the condition into small conditional language models that score the whole vocabulary in one pass, but those models must themselves be trained. PPLM instead nudges hidden states by gradient ascent at each step, which is slow and temperamental. Meanwhile, when we wrote this, Hugging Face hosted roughly ten thousand ready-made text classifiers and only about two dozen conditional language models. That asymmetry is the motivation: we asked whether the plain classifier is enough.
Classify only the tokens that could win
One observation unlocks it: sampling strategies throw almost every token away. If we sample from the top after reweighting, a token buried deep in cannot claw its way back with any realistic classifier score, so classifying it is wasted work. CAIF therefore scores only the most probable candidates, with ; across all our experiments was enough.
One CAIF step, end to end
Sampling mechanismConcretely, at each step the frozen model proposes its distribution, we keep the top candidates, append each one to the context, ask the classifier for , add to the token logits, and sample from the resulting top . Guidance becomes a drop-in replacement for the sampling loop.
Point the exponent the right way
For detoxification the classifier outputs a toxicity probability, and there are two ways to hold it against a token. The route earlier systems defaulted to weights tokens by with , the inverse-probability score. We found the restriction to positive exponents unnecessary: weighting by with is equally valid and behaves very differently.
The difference lives in the curve. The negative- score starts punishing the moment toxicity probability rises above noise, while barely moves until approaches one half. Head to head on a thousand prompts, negative detoxified significantly better while keeping lower perplexity, so every later experiment uses it.
Two ways to spend the same classifier output
score added to token logitsOne classifier against three specialist systems
Our main test follows the DExperts protocol: ten thousand non-toxic prompts from RealToxicityPrompts, twenty-five continuations each, GPT-2 Large as the base model. CAIF is guided by an off-the-shelf toxic-bert classifier with and judged by a different, independently trained offensive-language classifier, with perplexity measured under GPT-2 XL, so no model grades its own homework.
Perplexity against toxic-sample probability
toxic sample probability, percentThe result is not a tradeoff but a dominance. We reach the lowest toxic-sample probability, 3.3 percent against 6.4 for the strongest DExperts variant and 11.2 for GeDi, and simultaneously the lowest perplexity, 15.0, where every specialist pays fluency for control. Binned by prompt toxicity, we beat DExperts on every bin below 0.75; on the most hostile prompts DExperts edges ahead on toxicity only by giving up far more perplexity.
Toxicity avoidance, all metrics
| Sampling | PPL | Mean tox. | Max tox. | Tox. prob. | Dist-1 |
|---|---|---|---|---|---|
| GPT-2, no steering | 25.5 | 18.2 | 47.5 | 43.1 | 57.9 |
| PPLM | 32.6 | 17.7 | 45.9 | 40.0 | 58.4 |
| GeDi | 60.0 | 13.7 | 32.2 | 11.2 | 61.5 |
| DExperts | 32.4 | 13.9 | 29.7 | 7.5 | 58.0 |
| DExperts, top-k | 20.2 | 13.3 | 27.9 | 6.4 | 52.9 |
| CAIF, ours | 15.0 | 12.0 | 26.1 | 3.3 | 51.5 |
Sentiment control tells the same story. On both neutral and negative prompts from OpenWebText, guiding with a public sentiment classifier produced more positive continuations at lower perplexity than PPLM, GeDi, and DExperts, with the same recipe and no retraining. The honest fine print is the distinctness column above: top- sampling repeats slightly more unigrams than the top- baselines.
Guide only where the model hesitates
Guiding every step still costs classifier calls per token, so we asked when the calls actually matter. A periodic criterion guides every -th step and is obviously blind: with period two, a toxic token is free to appear on every unguided step. The entropy criterion is the interesting one. When the model's next-token entropy is low, the continuation is nearly forced, so we skip the classifier; we intervene only above a threshold , where the text can still fork.
Three ways to spend the classifier budget
Guidance criteriaThe empirical entropy distribution lets us match budgets exactly: a threshold of 3.2 guides about half the steps, like period two, and 5.0 guides about a fifth. At equal budget the entropy criterion wins on both perplexity and toxicity, and on sentiment control entropy-3.2 matched or beat plain CAIF while paying for half the classifier calls.
Speed is the one axis where distilled systems keep an edge. A free-form classifier re-reads the whole prefix, so each call grows quadratically with length, while GeDi and DExperts cache their way to linear cost; we measured CAIF faster up to twenty generated tokens, comparable to fifty, and slower beyond. For pipelines that otherwise sample many candidates and filter afterward, trading raw speed for far fewer rejected samples is the better bargain.
Controllable generation never needed a second language model: a plain classifier, pointed at the few tokens that matter, steers further at lower cost.