Does logit_bias remove tokens from top_logprobs?

Is it possible to use logit_bias to remove tokens from appearing altogether in top_logprobs? I would like to sample tokens from top_logprobs after removing certain tokens. However, currently, when I specify a token in logit_bias, it still appears in top_logprobs. Would appreciate other suggestions for how to do this as well. Thank you!

1 Like

Yes it does. Although identification of those token numbers from just the bytes provided along with logprobs requires use of the tiktoken library for lookup, they can be demoted with a strong negative bias of -100 and you will get a different set of possibilities.

The key is “correct token number”. If the AI really wants to write “hello” and nothing else, it is inventive about finding different tokens to represent the concept.

Most words that the AI produces start with a leading space, and several alternates for how they can appear, ultimately down to spelling with individual letters if the AI is creative enough.

Also note that the remaining tokens cannot be joined with the probabilities of those already eliminated, as a new softmax operation to normalize total mass into a 100% probability space would be performed on the remaining logits.


I think that as of March 4 logit_bias does NOT remove tokens from top_logprobs. In addition, it’s possible to get the top 20 logprobs rather than just the top 5.

I’m curious, is anyone still able to remove tokens from top_logprobs?

OpenAI changed the API before publication of this paper:

Because logit_bias promotion is part of obtaining full logits and then revealing model softmax head size. Like was published for GPT-3 before “turbo” made the production minimization no longer a bragging point.

1 Like

Hmm… but that paper was published on the 28th of November 2023, and they made the API change about 4 March 2024…

What do you mean by, “Like was published for GPT-3 before “turbo” made the production minimization no longer a bragging point.”?

Oops, I pasta’d an article with a similar title…here you go.

GPT-3 davinci had 12288 dimensions, 175B parameters. gpt-3.5-turbo…less, but the paper doesn’t reveal.