Sometimes an LLM produces generally good text but makes one narrow decoding choice too often. Perhaps a domain-specific abbreviation should be preferred, a deprecated product name should be discouraged, or a particular token must not appear in generated text.
Changing temperature is a poor fit for this problem because temperature affects the whole next-token distribution. Retraining a model is usually excessive when the desired change is local. Token and sequence biases provide a narrower tool: modify selected prediction scores during decoding while leaving the model parameters unchanged.
This article builds a practical mental model for these biases, shows why tokenization is the main source of surprises, and explains when targeted score editing is useful—and when a prompt, grammar, or application-level rule is a better solution.
Think of bias as an edit between prediction and selection
An autoregressive language model generates one token at a time. At each step it produces a score, commonly called a logit, for every token in its vocabulary. The decoder then processes those scores and chooses or samples the next token.
A simplified pipeline looks like this:
prompt + generated tokens
|
v
model
|
logits
|
targeted bias
|
adjusted scores
|
sampling / selectionSuppose the model produces these illustrative logits:
Token Original logit
stable 4.1
reliable 3.8
robust 3.2
fragile 1.4If an application adds +1.0 to the score for reliable, the adjusted scores become:
Token Original Bias Adjusted
stable 4.1 0.0 4.1
reliable 3.8 +1.0 4.8
robust 3.2 0.0 3.2
fragile 1.4 0.0 1.4The model has not learned a new fact. The decoder has simply made one token more competitive at this generation step.
A negative bias does the opposite. A sufficiently strong negative value can make a token effectively unavailable in implementations that support hard suppression. For example, some generation systems suppress a token by assigning it negative infinity before selection, which gives it zero probability after normalization.
The exact API, numeric range, and processing order are implementation details. The durable concept is the same: a targeted transformation changes selected scores before the decoder chooses the next token.
A finite bias changes odds rather than guaranteeing output
A useful way to understand additive logit bias is through probability ratios.
For two tokens a and b, softmax gives an odds ratio proportional to:
P(a) / P(b) = exp(logit(a) - logit(b))If the decoder adds a bias delta only to token a, the new ratio is:
P'(a) / P'(b)
= exp(logit(a) + delta - logit(b))
= exp(delta) * P(a) / P(b)So an additive bias changes relative odds multiplicatively. A positive finite bias does not mean “emit this token.” It means “make this token more competitive relative to tokens whose scores were not changed.”
That distinction matters in production. The model can still choose another token because its original score is higher, because sampling is stochastic, or because another decoding rule filters candidates later in the pipeline.
Likewise, a moderate negative bias discourages a token but does not necessarily prohibit it. If prohibition is a correctness requirement, use a mechanism whose contract actually enforces exclusion rather than relying on a merely unfavorable finite score.
Tokenization is the first thing to inspect
Bias controls usually operate on token IDs, not on human-visible words. That makes tokenization the most common source of mistakes.
Imagine that you want to discourage the visible string:
MegaCloudA tokenizer might represent it as one token, but it might instead produce pieces such as:
[Mega] [Cloud]or different pieces depending on preceding whitespace or capitalization. Biasing only the token for Mega may also affect unrelated text such as Megabyte. Biasing only Cloud can influence many sentences that have nothing to do with the product name.
The practical rule is simple: inspect the tokenizer output for the exact contexts you care about before assigning token-level biases.
Do not assume that:
- one visible word equals one token;
- the same word has the same token ID with and without leading whitespace;
- capitalization shares the same tokenization;
- punctuation around a term leaves its token sequence unchanged.
These properties depend on the tokenizer and vocabulary used by the model.
Single-token bias cannot express every string rule
Suppose a support assistant should avoid the phrase:
legacy modeIf legacy and mode are separate tokens, suppressing either token globally is broader than the requirement. The word mode may be perfectly valid in safe mode, and legacy may be appropriate when discussing a legacy API.
What you really want is conditional behavior:
if generated suffix == "legacy":
discourage " mode"That is a sequence bias rather than a global single-token bias. The decoder considers the generated prefix and applies an adjustment when a particular token sequence is about to be completed.
Conceptually:
history does not match prefix -> no sequence adjustment
history matches prefix -> bias candidate completion tokenSequence-aware processing can express narrower preferences than globally modifying every occurrence of a component token. Exact behavior still depends on the inference engine: some runtimes expose sequence-bias features directly, while others require a custom logits processor or do not expose this level of decoding control at all.
Positive sequence bias has a prefix problem
Encouraging a multi-token phrase has an important complication. Suppose the desired phrase tokenizes as:
[vector] [ database]If a system applies a positive bias only when the first token has already appeared, it can encourage database after vector, but it does nothing to make vector itself appear in the first place.
This means a sequence-completion bias is not automatically a phrase-insertion mechanism.
Forcing a phrase is harder still. The decoder must know when the phrase should begin, and once it begins, it may need to restrict subsequent choices until the required sequence is complete. That is closer to constrained decoding than to a simple preference adjustment.
Use sequence bias when the goal is to influence plausible continuations. If the output must contain an exact phrase, enforce that requirement with a mechanism designed to guarantee it or validate and retry at the application layer.
Bias interacts with the rest of the decoding pipeline
A targeted score edit does not operate in isolation. Generation systems may also apply temperature scaling, top-k or top-p filtering, repetition controls, grammar constraints, forced tokens, or other logits processors.
Order can matter.
Consider a token that receives a positive bias but is later removed by a hard grammar constraint. The bias cannot restore a token that the grammar declares invalid. Conversely, if filtering happens before a custom bias, a candidate that was already discarded may no longer be available to promote.
Because runtimes differ, do not infer processing order from parameter names. Treat the inference engine’s documentation and implementation contract as authoritative.
For debugging, reason about the complete pipeline:
model scores
-> targeted processors
-> structural constraints
-> sampling filters
-> token selectionThe actual order may differ, but writing down the real order for your runtime makes unexpected behavior much easier to diagnose.
Use the smallest bias that changes the measured behavior
A common mistake is to choose a large value immediately because it produces an obvious effect in one example. Strong biases can create secondary failures.
If a preferred token receives too much positive bias, generation can become unnaturally attracted to it whenever it is available. A strong negative bias can force awkward synonyms, broken names, or strange sentence structure because the decoder must route around a token that would normally be appropriate.
A better tuning process is:
- Build a small evaluation set containing cases where the target behavior should change and cases where it should not.
- Record a baseline with no bias.
- Apply a modest adjustment to one token or sequence.
- Measure both the intended effect and collateral changes.
- Increase the magnitude only if the target behavior remains too weak.
For stochastic decoding, run enough samples to distinguish a consistent shift from ordinary sampling variation.
The goal is not to maximize the bias. The goal is to produce the smallest intervention that reliably improves the behavior you actually care about.
Test negative examples, not only target examples
Suppose you bias a model toward the abbreviation SLO because your application frequently discusses service-level objectives. Testing only prompts about reliability may look successful.
But the same token pieces may occur in other contexts, or the bias may cause the abbreviation to appear where the full phrase would be clearer. Your evaluation therefore needs negative examples: prompts where the preferred token should not receive special treatment in the final output.
A useful test matrix includes:
Target cases -> preference should become more likely
Neutral cases -> output should remain essentially unchanged
Conflict cases -> correctness should override the preference
Formatting cases -> structured output should remain valid
Long outputs -> bias should not cause repeated attractionThis is especially important for global token biases because they apply whenever the relevant token is a candidate, not only in the semantic situation you had in mind.
Do not use token bias as a safety boundary
A token blacklist is a weak way to enforce a semantic policy.
A prohibited concept can often be expressed with different words, spellings, token sequences, languages, Unicode forms, or indirect descriptions. Blocking one token sequence therefore does not imply that the underlying meaning is blocked.
The reverse problem also occurs: suppressing common token pieces can damage harmless output that happens to share those pieces.
For safety, authorization, or compliance requirements, use controls designed around the actual requirement, such as input and output policy checks, constrained actions, permission boundaries, or application validation. Token bias can support presentation preferences, but it should not be treated as a semantic security mechanism.
Know when another control matches the problem better
Targeted bias is useful when the model’s behavior is broadly acceptable and you want a narrow preference at decoding time. Good candidates include mildly preferring established terminology, discouraging an obsolete label, or suppressing a known special token that should never be emitted in a particular generation mode.
Use a different mechanism when the requirement is structural or semantic:
- Prompting is often better when the model needs to understand why a terminology preference applies.
- Grammar-guided decoding is better when output must conform to a formal structure such as a schema.
- Stopping rules are better when generation should end at a known boundary.
- Application validation is better when a requirement must be checked after generation regardless of how the model produced the text.
- Fine-tuning may be appropriate when the desired behavior is broad, repeated across many contexts, and worth changing in the model rather than in one decoder configuration.
Choosing the narrowest mechanism that matches the requirement keeps behavior easier to reason about.
Conclusion
Token and sequence biases are targeted edits to an LLM’s prediction scores during decoding. Finite additive biases shift relative odds; hard suppression can make particular tokens unavailable when the runtime explicitly supports that behavior. Neither operation changes the model’s learned parameters.
The difficult part is rarely the arithmetic. It is defining the target correctly in token space and understanding how the bias interacts with the rest of the decoding pipeline. A visible word may span several tokens, a multi-token phrase requires prefix-aware handling, and a global token preference can affect contexts you did not intend.
Inspect tokenization first, tune against both positive and negative examples, and keep the intervention as small as practical. When the requirement is a hard structural or semantic rule, use a control that can actually enforce that rule rather than asking a token-level bias to do more than it can guarantee.