Controlling GPT-3 with Logit Bias

How AI Dungeon uses logit bias to help control GPT-3.

GPT-3 Tokens

openai.Completion.create(engine=’davinci’, prompt=”q: What is the capital of france?\na:”, logprobs = 5, stop = “\n”, temperature=0)
{
“ France”: -3.9549413,
“ Paris”: -0.88349044,
“ The”: -3.9709404,
“ fr”: -4.021952,
“par”: -2.0355594
}
{
‘ France’: ‘1%’,
‘ Paris’: ‘41%’,
‘ The’: ‘1%’,
‘ fr’: ‘1%’,
‘par’: ‘13%’
}

Logit Bias

openai.Completion.create(engine=’davinci’, prompt=”q: What is the capital of france?\na:”, logprobs = 5, stop = “\n”, temperature=0, logit_bias={6342:-1})
{
“ France”: -3.6606863,
“ Paris”: -1.6055677,
“ The”: -3.6641173,
“ fr”: -3.757301,
“ par”: -1.7221524
}
openai.Completion.create(engine=’davinci’, prompt=”q: What is the capital of france?\na:”, logprobs = 5, stop = “\n”, temperature=0, logit_bias={6342:-10})
openai.Completion.create(engine=’davinci’, prompt=”q: What is the capital of france?\na:”, logprobs = 5, stop = “\n”, temperature=0, logit_bias={6342:-1, 1582:-10})

How We Use Logit Bias to Avoid User Banned Words

Users can add words which they don’t want to appear in their adventures (e.g. the dreaded ‘suddenly’).
openai.Completion.create(engine=’davinci’, prompt=”q: What is the capital of france?\na:”, logprobs = 5, stop = “\n”, temperature=0, logit_bias=banned_word_biases)

--

--

Making AI a tool of creativity and freedom for everyone. https://play.aidungeon.io

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store