webui : add backend sampling options
This commit is contained in:
parent
f1f3e68511
commit
a3eb847d24
Binary file not shown.
|
|
@ -152,6 +152,16 @@
|
||||||
key: 'samplers',
|
key: 'samplers',
|
||||||
label: 'Samplers',
|
label: 'Samplers',
|
||||||
type: 'input'
|
type: 'input'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'backend_sampling',
|
||||||
|
label: 'Backend sampling',
|
||||||
|
type: 'checkbox'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'backend_dist',
|
||||||
|
label: 'Backend dist sampling',
|
||||||
|
type: 'checkbox'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -277,6 +287,10 @@
|
||||||
|
|
||||||
function handleConfigChange(key: string, value: string | boolean) {
|
function handleConfigChange(key: string, value: string | boolean) {
|
||||||
localConfig[key] = value;
|
localConfig[key] = value;
|
||||||
|
|
||||||
|
if (key === 'backend_sampling' && value === false) {
|
||||||
|
localConfig.backend_dist = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,9 @@
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
{:else if field.type === 'checkbox'}
|
{:else if field.type === 'checkbox'}
|
||||||
{@const isDisabled = field.key === 'pdfAsImage' && !supportsVision()}
|
{@const pdfDisabled = field.key === 'pdfAsImage' && !supportsVision()}
|
||||||
|
{@const backendDistDisabled = field.key === 'backend_dist' && !localConfig.backend_sampling}
|
||||||
|
{@const isDisabled = pdfDisabled || backendDistDisabled}
|
||||||
|
|
||||||
<div class="flex items-start space-x-3">
|
<div class="flex items-start space-x-3">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
|
@ -223,11 +225,15 @@
|
||||||
<p class="text-xs text-muted-foreground">
|
<p class="text-xs text-muted-foreground">
|
||||||
{field.help || SETTING_CONFIG_INFO[field.key]}
|
{field.help || SETTING_CONFIG_INFO[field.key]}
|
||||||
</p>
|
</p>
|
||||||
{:else if field.key === 'pdfAsImage' && !supportsVision()}
|
{:else if pdfDisabled}
|
||||||
<p class="text-xs text-muted-foreground">
|
<p class="text-xs text-muted-foreground">
|
||||||
PDF-to-image processing requires a vision-capable model. PDFs will be processed as
|
PDF-to-image processing requires a vision-capable model. PDFs will be processed as
|
||||||
text.
|
text.
|
||||||
</p>
|
</p>
|
||||||
|
{:else if backendDistDisabled}
|
||||||
|
<p class="text-xs text-muted-foreground">
|
||||||
|
Enable GPU sampling to allow GPU dist sampling.
|
||||||
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ export const SETTING_CONFIG_DEFAULT: Record<string, string | number | boolean> =
|
||||||
modelSelectorEnabled: false,
|
modelSelectorEnabled: false,
|
||||||
// make sure these default values are in sync with `common.h`
|
// make sure these default values are in sync with `common.h`
|
||||||
samplers: 'top_k;typ_p;top_p;min_p;temperature',
|
samplers: 'top_k;typ_p;top_p;min_p;temperature',
|
||||||
|
backend_sampling: false,
|
||||||
|
backend_dist: false,
|
||||||
temperature: 0.8,
|
temperature: 0.8,
|
||||||
dynatemp_range: 0.0,
|
dynatemp_range: 0.0,
|
||||||
dynatemp_exponent: 1.0,
|
dynatemp_exponent: 1.0,
|
||||||
|
|
@ -50,6 +52,10 @@ export const SETTING_CONFIG_INFO: Record<string, string> = {
|
||||||
'On pasting long text, it will be converted to a file. You can control the file length by setting the value of this parameter. Value 0 means disable.',
|
'On pasting long text, it will be converted to a file. You can control the file length by setting the value of this parameter. Value 0 means disable.',
|
||||||
samplers:
|
samplers:
|
||||||
'The order at which samplers are applied, in simplified way. Default is "top_k;typ_p;top_p;min_p;temperature": top_k->typ_p->top_p->min_p->temperature',
|
'The order at which samplers are applied, in simplified way. Default is "top_k;typ_p;top_p;min_p;temperature": top_k->typ_p->top_p->min_p->temperature',
|
||||||
|
backend_sampling:
|
||||||
|
'Enable backend-based samplers. When enabled, supported samplers run on the accelerator backend for faster sampling.',
|
||||||
|
backend_dist:
|
||||||
|
'Perform the final distribution sampling step on the backend. Requires backend sampling to be enabled.',
|
||||||
temperature:
|
temperature:
|
||||||
'Controls the randomness of the generated text by affecting the probability distribution of the output tokens. Higher = more random, lower = more focused.',
|
'Controls the randomness of the generated text by affecting the probability distribution of the output tokens. Higher = more random, lower = more focused.',
|
||||||
dynatemp_range:
|
dynatemp_range:
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,8 @@ export class ChatService {
|
||||||
dry_penalty_last_n,
|
dry_penalty_last_n,
|
||||||
// Other parameters
|
// Other parameters
|
||||||
samplers,
|
samplers,
|
||||||
|
backend_sampling,
|
||||||
|
backend_dist,
|
||||||
custom,
|
custom,
|
||||||
timings_per_token
|
timings_per_token
|
||||||
} = options;
|
} = options;
|
||||||
|
|
@ -182,6 +184,9 @@ export class ChatService {
|
||||||
: samplers;
|
: samplers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (backend_sampling !== undefined) requestBody.backend_sampling = backend_sampling;
|
||||||
|
if (backend_dist !== undefined) requestBody.backend_dist = backend_dist;
|
||||||
|
|
||||||
if (timings_per_token !== undefined) requestBody.timings_per_token = timings_per_token;
|
if (timings_per_token !== undefined) requestBody.timings_per_token = timings_per_token;
|
||||||
|
|
||||||
if (custom) {
|
if (custom) {
|
||||||
|
|
|
||||||
|
|
@ -298,6 +298,12 @@ class ChatStore {
|
||||||
if (currentConfig.samplers) {
|
if (currentConfig.samplers) {
|
||||||
apiOptions.samplers = currentConfig.samplers;
|
apiOptions.samplers = currentConfig.samplers;
|
||||||
}
|
}
|
||||||
|
if (currentConfig.backend_sampling !== undefined) {
|
||||||
|
apiOptions.backend_sampling = Boolean(currentConfig.backend_sampling);
|
||||||
|
}
|
||||||
|
if (currentConfig.backend_dist !== undefined) {
|
||||||
|
apiOptions.backend_dist = Boolean(currentConfig.backend_dist);
|
||||||
|
}
|
||||||
if (currentConfig.custom) {
|
if (currentConfig.custom) {
|
||||||
apiOptions.custom = currentConfig.custom;
|
apiOptions.custom = currentConfig.custom;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,8 @@ export interface ApiChatCompletionRequest {
|
||||||
dry_penalty_last_n?: number;
|
dry_penalty_last_n?: number;
|
||||||
// Sampler configuration
|
// Sampler configuration
|
||||||
samplers?: string[];
|
samplers?: string[];
|
||||||
|
backend_sampling?: boolean;
|
||||||
|
backend_dist?: boolean;
|
||||||
// Custom parameters (JSON string)
|
// Custom parameters (JSON string)
|
||||||
custom?: Record<string, unknown>;
|
custom?: Record<string, unknown>;
|
||||||
timings_per_token?: boolean;
|
timings_per_token?: boolean;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ export interface SettingsChatServiceOptions {
|
||||||
dry_penalty_last_n?: number;
|
dry_penalty_last_n?: number;
|
||||||
// Sampler configuration
|
// Sampler configuration
|
||||||
samplers?: string | string[];
|
samplers?: string | string[];
|
||||||
|
backend_sampling?: boolean;
|
||||||
|
backend_dist?: boolean;
|
||||||
// Custom parameters
|
// Custom parameters
|
||||||
custom?: string;
|
custom?: string;
|
||||||
timings_per_token?: boolean;
|
timings_per_token?: boolean;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue