Skip to content

Commit

Permalink
Set default penalty params to null when unspecified (#37)
Browse files Browse the repository at this point in the history
* Set default penalty params to null when unspecified

* Move model args to the client kwargs to avoid setting inintended default values
  • Loading branch information
petermuller authored Jun 21, 2024
1 parent 9c37751 commit 018c14e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
6 changes: 0 additions & 6 deletions lib/user-interface/react/src/components/chatbot/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,6 @@ export default function Chat({ sessionId }) {
},
streaming,
maxTokens: modelConfig?.max_tokens,
n: modelConfig?.n,
topP: modelConfig?.top_p,
frequencyPenalty: modelConfig?.frequency_penalty,
presencePenalty: modelConfig?.presence_penalty,
temperature: modelConfig?.temperature,
stop: modelConfig?.stop,
modelKwargs: modelConfig?.modelKwargs,
});
};
Expand Down
32 changes: 16 additions & 16 deletions lib/user-interface/react/src/components/chatbot/ModelKwargs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ export default function ModelKwargsEditor({ setModelConfig, visible, setVisible
useEffect(() => {
const modelConfig: ModelConfig = {
max_tokens: maxNewTokens,
n: n,
top_p: topP,
frequency_penalty: frequencyPenalty,
presence_penalty: presencePenalty,
temperature: temperature,
stop: stopSequences.map((elem) => {
try {
return unraw(elem);
} catch (error) {
return elem;
}
}),
modelKwargs: {
n: n,
top_p: topP,
frequency_penalty: frequencyPenalty,
presence_penalty: presencePenalty,
temperature: temperature,
stop: stopSequences.map((elem) => {
try {
return unraw(elem);
} catch (error) {
return elem;
}
}),
seed,
},
};
Expand Down Expand Up @@ -96,7 +96,7 @@ export default function ModelKwargsEditor({ setModelConfig, visible, setVisible
</FormField>
<FormField
label="n"
constraintText="Must be greater than or equal to 1 - Defaults to 1 if not specified."
constraintText="Must be greater than or equal to 1 - Defaults to null if not specified."
description="How many completions to generate for each prompt."
>
<Input
Expand Down Expand Up @@ -142,7 +142,7 @@ export default function ModelKwargsEditor({ setModelConfig, visible, setVisible
</FormField>
<FormField
label="frequency_penalty"
constraintText="Must be between -2.0 and 2.0 - Defaults to 0 if not specified."
constraintText="Must be between -2.0 and 2.0 - Defaults to null if not specified."
description="Number between -2.0 and 2.0. Positive values
penalize new tokens based on their existing
frequency in the text so far, decreasing the model's
Expand All @@ -166,7 +166,7 @@ export default function ModelKwargsEditor({ setModelConfig, visible, setVisible
</FormField>
<FormField
label="presence_penalty"
constraintText="Must be between -2.0 and 2.0 - Defaults to 0 if not specified."
constraintText="Must be between -2.0 and 2.0 - Defaults to null if not specified."
description="Number between -2.0 and 2.0. Positive values
penalize new tokens based on whether they appear
in the text so far, increasing the model's
Expand All @@ -190,7 +190,7 @@ export default function ModelKwargsEditor({ setModelConfig, visible, setVisible
</FormField>
<FormField
label="temperature"
constraintText="Must be between 0 and 2.0 - Defaults to 1 if not specified."
constraintText="Must be between 0 and 2.0 - Defaults to null if not specified."
description="What sampling temperature to use, between 0 and 2.
Higher values like 0.8 will make the output more random,
while lower values like 0.2 will make it more focused
Expand Down
12 changes: 6 additions & 6 deletions lib/user-interface/react/src/components/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ import { BaseMessage, BaseMessageFields, MessageContent, MessageType } from '@la
*/
export type ModelConfig = {
max_tokens?: number;
n?: number | null;
top_p?: number | null;
frequency_penalty?: number | null;
presence_penalty?: number | null;
temperature?: number | null;
stop: string[];
modelKwargs?: ModelArgs;
};

/**
* Used to specify additional parameters in how the LLM processes inputs
*/
export type ModelArgs = {
n?: number | null;
top_p?: number | null;
frequency_penalty?: number | null;
presence_penalty?: number | null;
temperature?: number | null;
stop: string[];
seed?: number | null;
};

Expand Down

0 comments on commit 018c14e

Please sign in to comment.