Spaces:
Runtime error
Runtime error
Advanced generation options (#30)
Browse files
src/lib/components/InferencePlayground/InferencePlaygroundGenerationConfig.svelte
CHANGED
|
@@ -1,8 +1,12 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
export let config;
|
| 5 |
-
export let streaming;
|
| 6 |
export let classNames = '';
|
| 7 |
</script>
|
| 8 |
|
|
@@ -37,6 +41,43 @@
|
|
| 37 |
</div>
|
| 38 |
{/each}
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
<div class="mt-2">
|
| 41 |
<label class="flex cursor-pointer items-center justify-between">
|
| 42 |
<input type="checkbox" bind:checked={streaming} class="peer sr-only" />
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
+
import {
|
| 3 |
+
GENERATION_CONFIG_KEYS,
|
| 4 |
+
GENERATION_CONFIG_KEYS_ADVANCED,
|
| 5 |
+
GENERATION_CONFIG_SETTINGS
|
| 6 |
+
} from './generationConfigSettings';
|
| 7 |
|
| 8 |
export let config;
|
| 9 |
+
export let streaming: boolean;
|
| 10 |
export let classNames = '';
|
| 11 |
</script>
|
| 12 |
|
|
|
|
| 41 |
</div>
|
| 42 |
{/each}
|
| 43 |
|
| 44 |
+
<details>
|
| 45 |
+
<summary>Advanced Options</summary>
|
| 46 |
+
<div class="mt-4 flex flex-col gap-y-5">
|
| 47 |
+
{#each GENERATION_CONFIG_KEYS_ADVANCED as key}
|
| 48 |
+
{@const settings = GENERATION_CONFIG_SETTINGS[key]}
|
| 49 |
+
<div>
|
| 50 |
+
<div class="flex items-center justify-between">
|
| 51 |
+
<label
|
| 52 |
+
for="temperature-range"
|
| 53 |
+
class="mb-2 block text-sm font-medium text-gray-900 dark:text-white"
|
| 54 |
+
>{settings.label}</label
|
| 55 |
+
>
|
| 56 |
+
<input
|
| 57 |
+
type="number"
|
| 58 |
+
class="w-16 rounded border bg-transparent px-1 py-0.5 text-right text-sm dark:border-gray-700"
|
| 59 |
+
min={settings.min}
|
| 60 |
+
max={settings.max}
|
| 61 |
+
step={settings.step}
|
| 62 |
+
value={config[key] ?? settings.default}
|
| 63 |
+
on:input={(e) => (config[key] = e.currentTarget.value)}
|
| 64 |
+
/>
|
| 65 |
+
</div>
|
| 66 |
+
<input
|
| 67 |
+
id="temperature-range"
|
| 68 |
+
type="range"
|
| 69 |
+
min={settings.min}
|
| 70 |
+
max={settings.max}
|
| 71 |
+
step={settings.step}
|
| 72 |
+
value={config[key] ?? settings.default}
|
| 73 |
+
on:input={(e) => (config[key] = e.currentTarget.value)}
|
| 74 |
+
class="h-2 w-full cursor-pointer appearance-none rounded-lg bg-gray-200 accent-black dark:bg-gray-700 dark:accent-blue-500"
|
| 75 |
+
/>
|
| 76 |
+
</div>
|
| 77 |
+
{/each}
|
| 78 |
+
</div>
|
| 79 |
+
</details>
|
| 80 |
+
|
| 81 |
<div class="mt-2">
|
| 82 |
<label class="flex cursor-pointer items-center justify-between">
|
| 83 |
<input type="checkbox" bind:checked={streaming} class="peer sr-only" />
|
src/lib/components/InferencePlayground/generationConfigSettings.ts
CHANGED
|
@@ -46,16 +46,17 @@ export const GENERATION_CONFIG_SETTINGS: Record<string, GenerationKeySettings> =
|
|
| 46 |
|
| 47 |
export type GenerationConfigKey = keyof typeof GENERATION_CONFIG_SETTINGS;
|
| 48 |
|
| 49 |
-
export const GENERATION_CONFIG_KEYS: GenerationConfigKey[] =
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
export type GenerationConfig = Record<GenerationConfigKey, number>;
|
| 54 |
|
| 55 |
-
export const defaultGenerationConfig =
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
},
|
| 60 |
-
{} as GenerationConfig
|
| 61 |
-
);
|
|
|
|
| 46 |
|
| 47 |
export type GenerationConfigKey = keyof typeof GENERATION_CONFIG_SETTINGS;
|
| 48 |
|
| 49 |
+
export const GENERATION_CONFIG_KEYS: GenerationConfigKey[] = ['temperature', 'max_tokens'];
|
| 50 |
+
|
| 51 |
+
export const GENERATION_CONFIG_KEYS_ADVANCED: GenerationConfigKey[] = [
|
| 52 |
+
'top_p',
|
| 53 |
+
'top_k',
|
| 54 |
+
'repetition_penalty'
|
| 55 |
+
];
|
| 56 |
|
| 57 |
export type GenerationConfig = Record<GenerationConfigKey, number>;
|
| 58 |
|
| 59 |
+
export const defaultGenerationConfig = GENERATION_CONFIG_KEYS.reduce((acc, key) => {
|
| 60 |
+
acc[key] = GENERATION_CONFIG_SETTINGS[key].default;
|
| 61 |
+
return acc;
|
| 62 |
+
}, {} as GenerationConfig);
|
|
|
|
|
|
|
|
|