🧿Parameter details
Frequency and presence penalties
The frequency and presence penalties found in the Completions API can be used to reduce the likelihood of sampling repetitive sequences of tokens. They work by directly modifying the logits (un-normalized log-probabilities) with an additive contribution.
Where:
mu[j]
is the logits of the j-th tokenc[j]
is how often that token was sampled prior to the current positionfloat(c[j] > 0)
is 1 ifc[j] > 0
and 0 otherwisealpha_frequency
is the frequency penalty coefficientalpha_presence
is the presence penalty coefficient
As we can see, the presence penalty is a one-off additive contribution that applies to all tokens that have been sampled at least once and the frequency penalty is a contribution that is proportional to how often a particular token has already been sampled.
Reasonable values for the penalty coefficients are around 0.1 to 1 if the aim is to just reduce repetitive samples somewhat. If the aim is to strongly suppress repetition, then one can increase the coefficients up to 2, but this can noticeably degrade the quality of samples. Negative values can be used to increase the likelihood of repetition.
Last updated