Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default penalty params to null when unspecified #37

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

petermuller
Copy link
Contributor

The LangChain JS library sets some default values for presence and frequency penalties if we don't set them as part of the OpenAI client. As a result, we end up with a non-required numeric value (0) that we did not intend to put there, which heavily degrades the model responses on tgi containers. These changes override the defaults set by the client so that the values are either the numeric value we set, including 0, otherwise they will be null. I validated that this happens by setting and unsetting the values in the model kwargs of the Chat UI and checked the request data from the network tab of my browser. Now, by default, these values won't be set unless we want them to be.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@petermuller petermuller requested a review from estohlmann June 20, 2024 21:29
@petermuller petermuller self-assigned this Jun 20, 2024
// LangChain's JS OpenAI client sets default values that we do not want if we didn't set them.
// The following parameters are preferred to be null instead of having a numeric default value
// as they degrade the quality of the model response if set incorrectly by default.
if (!modelConfig?.frequency_penalty && modelConfig?.frequency_penalty !== 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sent you a patch file but what I would suggest doing is pulling the properties that we want to null out by defualt out into the modelKwargs property of the modelConfig. These properties will be defaulted to null when passed into modelKwargs and you will get the behavior you are replicating here in a much cleaner way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome suggestion- doing that for the next set of changes. I left the number of tokens alone because those are usually required at the client level, but this is a much nicer approach and we don't need any other custom logic.

@petermuller petermuller merged commit 018c14e into main Jun 21, 2024
2 checks passed
@petermuller petermuller deleted the feature/default-params branch June 21, 2024 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants