Add support for logit_bias
and logit_bias_type
parameters
#351
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was inspired by the way simpleaichat works and I wanted to try running it on my own hardware with my own API server. This code relies on the
logit_bias
parameter to work, so I needed to add it.The way OpenAI's API works is that the
logit_bias
is a mapping frominput_ids
(as a string) to a bias (as a float). Because of the need to use IDs instead of just the token strings themselves, then it means this parameter and its functionality is tied to ChatGPT's tokenizer. This is a problem for other models, obviously.So in addition to implementing the API as OpenAI intended, I also added another parameter that changes the meaning of
logit_bias
to be a mapping from token strings (as a string) to a bias (as a float).I tested this with the following pair of requests:
The
jq
commands correspond to the following JSON objects.