AI / MLLLM FundamentalsDiagramAdvanced
Logit Bias
KO: 로짓 바이어스·EN: Logit Bias·JA: ロジットバイアス
A low-level decoding control that adds positive or negative bias values to specific token IDs' raw logits before Softmax to encourage or ban particular tokens
Table of Contents
Structure Diagram
Token Probabilities Before vs After Logit Bias
(75, 76)Bias +4 → Promoted (76%)
Quick Answer
What is Logit Bias?
A low-level decoding control that adds positive or negative bias values to specific token IDs' raw logits before Softmax to encourage or ban particular tokens. It is a core concept in LLM Fundamentals within AI / ML.
Core Principles
Logit Bias adds a developer-specified { token_id: bias } offset directly to an LLM's raw output logits right before the Softmax step. Typical APIs accept values from -100 to +100.
Setting -100 effectively bans a token completely, while modest positive values (+1 to +5) gently steer generation toward desired class labels or preferred vocabulary.
Practical Takeaways
- Account for tokenizer variants: In BPE tokenizers,
"yes"," yes", and"Yes"have distinct token IDs. Inspect the exact model tokenizer to cover leading spaces and casing. - Avoid large positive biases: Values above
+5can force the model to repeat the boosted token incoherently regardless of grammar. - Use Structured Output for complex schemas: Logit Bias shines for single-token classification or hard token bans, whereas JSON Schema constrained decoding is safer for multi-field payloads.
Notable Examples
- Single-Token Classifiers: Pair
max_tokens=1with positive bias on class token IDs (0,1,2) for ultra-low-latency classification. - Hard Vocabulary Bans: Apply
-100bias to competitor names or disallowed formatting tokens. - Repetition Penalties: Frequency and presence penalties work under the hood by dynamically applying negative logit bias to already-generated tokens.