Logit bias steers generated text by adding an offset to selected token logits before they become probabilities. Negative values suppress tokens, while positive values favor them; values from -100 to 100 provide strong control. section 3.3.2
Apply logit bias by:
- Use tiktoken to identify every relevant token variant, including capitalization and preceding-space forms. section 3.3.2
- Pass a dictionary mapping token IDs to bias values in the completion request. section 3.3.2
- Use -100 to effectively ban a token or 100 to make it exclusive, recognizing that smaller changes produce softer steering. section 3.3.2
Constraining pet salon names
A completion request can assign -100 to token IDs representing “purr,” “purrs,” and “meow,” then add a positive bias of 5 to selected “furry” tokens. The resulting suggestions avoid the banned terms and favor the targeted vocabulary.
Figure 3.2 The logit_bias parameter
Use the figure to inspect how changing token bias alters the probability distribution available during generation. section 3.3.2
