mirror of
https://github.com/open-webui/open-webui
synced 2025-03-10 06:33:19 +00:00
feat: scaffolding for logit_bias
This commit is contained in:
parent
82189066e8
commit
4a2a12fd21
@ -61,6 +61,7 @@ def apply_model_params_to_body_openai(params: dict, form_data: dict) -> dict:
|
|||||||
"reasoning_effort": str,
|
"reasoning_effort": str,
|
||||||
"seed": lambda x: x,
|
"seed": lambda x: x,
|
||||||
"stop": lambda x: [bytes(s, "utf-8").decode("unicode_escape") for s in x],
|
"stop": lambda x: [bytes(s, "utf-8").decode("unicode_escape") for s in x],
|
||||||
|
"logit_bias": lambda x: x,
|
||||||
}
|
}
|
||||||
return apply_model_params_to_body(params, form_data, mappings)
|
return apply_model_params_to_body(params, form_data, mappings)
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
stop: null,
|
stop: null,
|
||||||
temperature: null,
|
temperature: null,
|
||||||
reasoning_effort: null,
|
reasoning_effort: null,
|
||||||
|
logit_bias: null,
|
||||||
frequency_penalty: null,
|
frequency_penalty: null,
|
||||||
repeat_last_n: null,
|
repeat_last_n: null,
|
||||||
mirostat: null,
|
mirostat: null,
|
||||||
@ -298,6 +299,49 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class=" py-0.5 w-full justify-between">
|
||||||
|
<Tooltip
|
||||||
|
content={$i18n.t(
|
||||||
|
'Boosting or penalizing specific tokens for constrained responses. Bias values will be normalized to be between -100 and 100 (inclusive). (Default: none)'
|
||||||
|
)}
|
||||||
|
placement="top-start"
|
||||||
|
className="inline-tooltip"
|
||||||
|
>
|
||||||
|
<div class="flex w-full justify-between">
|
||||||
|
<div class=" self-center text-xs font-medium">
|
||||||
|
{$i18n.t('Logit Bias')}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
|
||||||
|
type="button"
|
||||||
|
on:click={() => {
|
||||||
|
params.logit_bias = (params?.logit_bias ?? null) === null ? '' : null;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{#if (params?.logit_bias ?? null) === null}
|
||||||
|
<span class="ml-2 self-center"> {$i18n.t('Default')} </span>
|
||||||
|
{:else}
|
||||||
|
<span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
{#if (params?.logit_bias ?? null) !== null}
|
||||||
|
<div class="flex mt-0.5 space-x-2">
|
||||||
|
<div class=" flex-1">
|
||||||
|
<input
|
||||||
|
class="w-full rounded-lg py-2 px-1 text-sm dark:text-gray-300 dark:bg-gray-850 outline-hidden"
|
||||||
|
type="text"
|
||||||
|
placeholder={$i18n.t('Enter logit bias as comma-seperated "token_id:bias_value" pairs')}
|
||||||
|
bind:value={params.logit_bias}
|
||||||
|
autocomplete="off"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class=" py-0.5 w-full justify-between">
|
<div class=" py-0.5 w-full justify-between">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={$i18n.t(
|
content={$i18n.t(
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
seed: null,
|
seed: null,
|
||||||
temperature: null,
|
temperature: null,
|
||||||
reasoning_effort: null,
|
reasoning_effort: null,
|
||||||
|
logit_bias: null,
|
||||||
frequency_penalty: null,
|
frequency_penalty: null,
|
||||||
presence_penalty: null,
|
presence_penalty: null,
|
||||||
repeat_penalty: null,
|
repeat_penalty: null,
|
||||||
@ -348,6 +349,8 @@
|
|||||||
temperature: params.temperature !== null ? params.temperature : undefined,
|
temperature: params.temperature !== null ? params.temperature : undefined,
|
||||||
reasoning_effort:
|
reasoning_effort:
|
||||||
params.reasoning_effort !== null ? params.reasoning_effort : undefined,
|
params.reasoning_effort !== null ? params.reasoning_effort : undefined,
|
||||||
|
logit_bias:
|
||||||
|
params.logit_bias !== null ? params.logit_bias : undefined,
|
||||||
frequency_penalty:
|
frequency_penalty:
|
||||||
params.frequency_penalty !== null ? params.frequency_penalty : undefined,
|
params.frequency_penalty !== null ? params.frequency_penalty : undefined,
|
||||||
presence_penalty: params.frequency_penalty !== null ? params.frequency_penalty : undefined,
|
presence_penalty: params.frequency_penalty !== null ? params.frequency_penalty : undefined,
|
||||||
|
Loading…
Reference in New Issue
Block a user