DevTools Logo

Logit Bias Builder

Logit Bias Builder

Turn words into token IDs with a local encoder and assemble the exact logit_bias JSON for an API call.

Runs in your browsercl100k_baseloading encoder…
Try an example

Encoding

GPT-4, GPT-3.5-turbo

Text to encode

0 groups · 0 unique ids

Import / decode

building

Generated logit_bias

0 token ids
Working…

Examples

hello!

Input
cl100k_base · hello!
Output
two token ids with a multi-token warning

The exclamation mark is its own token; only the ids you choose are biased.

Ban digits

Input
Recipe: ban digits
Output
"15339": -100 style rows for digit ids

A quick way to stop numeric output in constrained formats.

Force JSON brace

Input
Recipe: Force JSON brace
Output
one id at +100

A strong nudge toward starting an answer with an opening brace.

Audit a map

Input
{"999999": 5}
Output
out-of-vocabulary error

Import validation flags ids that cannot exist in the selected encoding.

About this tool

The Logit Bias Builder resolves text to token IDs and emits the exact logit_bias object used by completions APIs. It runs a real BPE encoder locally, showing the id, rendered piece and byte length of every token so you can see what a bias will actually affect.

Words are grouped: when a single input word expands to three tokens, the tool marks the group and warns that bias operates on pieces rather than on the word. Per-token sliders and numeric fields accept values from -100 to +100, duplicates merge with the last value winning, neutral rows disappear and the emitted JSON is sorted numerically for stable diffs.

Switch between cl100k_base, o200k_base, p50k_base and r50k_base to match your model. Import an existing bias object to decode ids back to token text, flag ids outside the selected vocabulary, and reuse the result. Encoding happens in your browser — no text or keys are uploaded.

What this tool does not do

  • Only the four bundled OpenAI-family encodings are available; other model families need their own tokenizers.
  • Bias is applied at a single decoding step, not to every occurrence of a word in a response.
  • No API calls are made and no keys are accepted.

How to use this tool

  1. Match the encoding

    Choose cl100k_base for GPT-4/3.5, o200k_base for GPT-4o/o1, p50k_base for legacy Codex or r50k_base for GPT-2. The model-name hint suggests one automatically.

  2. Type the text

    Enter words or phrases. Each token piece appears with its id; multi-token words get a visible warning chip.

  3. Set biases

    Use the per-token field or quick actions: -100 bans, +100 strongly boosts, 0 removes the row. Values outside the range are clamped with a note.

  4. Copy or audit

    Copy or download the sorted JSON, switch to import mode to audit an existing map, or use decode mode to see what a list of ids means.

Use cases

Constrained generation

Suppress tokens that would violate an output format without changing the prompt.

Debugging completions

Check which ids an API example refers to before copying it into production code.

Encoding migration

Compare the same text across cl100k and o200k when moving between model generations.

Encoding map

EncodingTypical models
cl100k_baseGPT-4, GPT-3.5-turbo
o200k_baseGPT-4o, o1 and newer reasoning models
p50k_baseCodex and text-davinci-003
r50k_baseGPT-2 and older local models

Special-token spelling is encoded as plain text unless the opt-in toggle is enabled.

Common mistakes

Mistake:Biasing a whole word when it is several tokens.

Fix:Inspect the grouped rows and set the bias for each id you actually want to suppress or boost.

Mistake:Using ids from a different encoding.

Fix:The same text has different ids per encoding; import validation flags out-of-range ids and the encoding badge shows the active one.

Mistake:Enabling special tokens casually.

Fix:The toggle can resolve control tokens such as <|endoftext|>; leave it off unless you explicitly need that behavior.

Mistake:Expecting a hard guarantee from +100.

Fix:Bias shifts logits; it does not force a token. Use constrained decoding when correctness must be exact.

Frequently asked questions

Why does one word have multiple token IDs?

BPE tokenizers split text into frequent pieces, not dictionary words. 'unbelievably!' can become several ids. The tool groups pieces per input word and warns when a group has more than one token, because logit_bias affects individual ids only.

What do -100 and +100 do?

They add or subtract 100 from the logit of that token at the next decoding step. -100 effectively bans a token and +100 strongly favors it, but neither is an absolute guarantee — other tokens can still win if their logits are high enough.

Which encoding matches my model?

GPT-4 and GPT-3.5-turbo use cl100k_base; GPT-4o and o-series use o200k_base; legacy Codex/text-davinci models use p50k_base; GPT-2 uses r50k_base. The model-name hint suggests one, and you can override it at any time.

Does the bias apply to whole words?

No. It applies only to the token ids in the emitted map. If a word spans three pieces you need three ids to suppress it reliably; the grouped rows show exactly which ones.

Is my text sent anywhere?

No. Encodings are loaded locally and text is encoded in your browser. Nothing is uploaded, and the tool never asks for API keys — the output is inert JSON you copy into your own request.

What happens if the same token appears twice?

Duplicate ids are merged with the last value winning, and a note explains the merge. Imported maps are validated the same way, with an explicit error when an id is outside the selected vocabulary.

References & standards