We present here a methodology for biasing model’s decoding with respect to a list of token ids. To preserve the written fluency, we use model uncertainty to scale the intervention strength on the model’s probability so that when the model is certain about what to produce the intervention is minimum. To do that, we employ Shannon’s Entropy to quantify the model uncertainty:

where is a vector of probability the size of the model’s vocabulary obtained by soft-maxing the last layer model’s logits , i.e.:

We use the entropy to define a smooth gating mechanism :

where acts as a threshold for the minimum entropy needed for the intervention to start, is a smoothing factor, and is the sigmoid function.

Then we identified two possible scenarios, one where we want to encourage (positive biasing) the production of a list of ids, and one where we want to discourage (negative biasing) the production of a list of ids.

Positive Biasing

Given a vocabulary of green tokens we want to bias towards, we employ a soft-mixture of probability gated by our entropy-gate :

where are the softmaxed logits produced at a certain decoding step by the model, is a biasing prior distribution that allocates probability to each , and represents the intervention strength calculates as the maximum allowed strength gated by the entropy gate :

Choosing a prior

Uniform

This spreads the steering mass equally across all the green tokens in the selected vocabulary . Works well if is small, otherwise each token in gets a tiny bump in mass, this has then little effect on the generation, especially if greedy decoding.

Re-normalizing model distribution on

This re-normalizes the distribution of probability that the model assigned to the set of green tokens in , over themselves. This is like if the model only had the green tokens to choose from.

This is “smarter” than uniform, because increases the of vocabulary tokens dynamically based on how likely the model already wanted to generate them. However, if no vocabulary tokens are in the high-probability region it can have very little effect in biasing.

Top-K Green Tokens

Here we want to extract the model’s probability for the green tokens, pick the top- candidates and create a prior with uniform distribution over just those .

This is similar to the uniform distribution method, but instead of steering all the green tokens in , we just steer the top- candidates. This reduces the number of tokens where is spreaded to.

Negative Biasing

To avoid normalization artifacts or negative probabilities, negative biasing is performed directly in logit space. Given the model’s logits , we apply a penalty:

where is a vector of size that shapes where the penalty is applied with respect to a red token vocabulary we want to discourage, and is a penalty term calculated as the maximum penalty gated by :

How to choose

Uniform

Unnormalized Uniform

Top-K

Unnormalized Top-K

Re-Normalizing model Distribution in

the effect is that the total penalty is conserved over and allocated more towards those red tokens that the model currently prefers.