mishig HF staff commited on
Commit
0ffe6c3
1 Parent(s): 7e29a25

Max tokens

Browse files
src/lib/components/InferencePlayground/InferencePlayground.svelte CHANGED
@@ -365,10 +365,7 @@
365
  </select>
366
  </div>
367
 
368
- <PlaygroundOptions
369
- bind:config={conversations[0].config}
370
- bind:streaming={conversations[0].streaming}
371
- />
372
  <div class="mt-auto">
373
  <div class="mb-3 flex items-center justify-between gap-2">
374
  <label
 
365
  </select>
366
  </div>
367
 
368
+ <PlaygroundOptions bind:conversation={conversations[0]} />
 
 
 
369
  <div class="mt-auto">
370
  <div class="mb-3 flex items-center justify-between gap-2">
371
  <label
src/lib/components/InferencePlayground/InferencePlaygroundConversation.svelte CHANGED
@@ -4,9 +4,10 @@
4
  import Message from './InferencePlaygroundMessage.svelte';
5
  import PlaygroundOptions from './InferencePlaygroundGenerationConfig.svelte';
6
  import IconPlus from '../Icons/IconPlus.svelte';
 
7
 
8
  export let loading;
9
- export let conversation;
10
  export let index;
11
  export let viewCode;
12
  export let sideBySide = false;
@@ -65,8 +66,7 @@
65
  /></svg
66
  >
67
  <PlaygroundOptions
68
- bind:config={conversation.config}
69
- bind:streaming={conversation.streaming}
70
  classNames="absolute top-8 right-0 w-56 invisible group-focus:visible hover:visible border border-gray-200/80 bg-white z-10 px-4 py-6 text-sm shadow-sm dark:border-gray-800 dark:bg-gray-800 rounded-xl"
71
  />
72
  </button>
 
4
  import Message from './InferencePlaygroundMessage.svelte';
5
  import PlaygroundOptions from './InferencePlaygroundGenerationConfig.svelte';
6
  import IconPlus from '../Icons/IconPlus.svelte';
7
+ import type { Conversation } from '$lib/types';
8
 
9
  export let loading;
10
+ export let conversation: Conversation;
11
  export let index;
12
  export let viewCode;
13
  export let sideBySide = false;
 
66
  /></svg
67
  >
68
  <PlaygroundOptions
69
+ bind:conversation
 
70
  classNames="absolute top-8 right-0 w-56 invisible group-focus:visible hover:visible border border-gray-200/80 bg-white z-10 px-4 py-6 text-sm shadow-sm dark:border-gray-800 dark:bg-gray-800 rounded-xl"
71
  />
72
  </button>
src/lib/components/InferencePlayground/InferencePlaygroundGenerationConfig.svelte CHANGED
@@ -1,19 +1,22 @@
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
 
13
  <div class="flex flex-col gap-y-5 {classNames}">
14
  {#each GENERATION_CONFIG_KEYS as key}
15
  {@const { label, min, step } = GENERATION_CONFIG_SETTINGS[key]}
16
- {@const max = key === 'max_tokens' ? 1000 : GENERATION_CONFIG_SETTINGS[key].max}
17
  <div>
18
  <div class="flex items-center justify-between">
19
  <label
@@ -24,18 +27,18 @@
24
  type="number"
25
  class="w-16 rounded border bg-transparent px-1 py-0.5 text-right text-sm dark:border-gray-700"
26
  {min}
27
- max={key === 'max_tokens' ? 1000 : max}
28
  {step}
29
- bind:value={config[key]}
30
  />
31
  </div>
32
  <input
33
  id="temperature-range"
34
  type="range"
35
  {min}
36
- max={key === 'max_tokens' ? 1000 : max}
37
  {step}
38
- bind:value={config[key]}
39
  class="h-2 w-full cursor-pointer appearance-none rounded-lg bg-gray-200 accent-black dark:bg-gray-700 dark:accent-blue-500"
40
  />
41
  </div>
@@ -59,8 +62,8 @@
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
@@ -69,8 +72,8 @@
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>
@@ -80,7 +83,7 @@
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" />
84
  <span class="text-sm font-medium text-gray-900 dark:text-gray-300">Streaming</span>
85
  <div
86
  class="peer relative h-5 w-9 rounded-full bg-gray-200 after:absolute after:start-[2px] after:top-[2px] after:h-4 after:w-4 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:bg-black peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:peer-checked:bg-blue-600"
 
1
  <script lang="ts">
2
+ import type { Conversation } from '$lib/types';
3
  import {
4
  GENERATION_CONFIG_KEYS,
5
  GENERATION_CONFIG_KEYS_ADVANCED,
6
  GENERATION_CONFIG_SETTINGS
7
  } from './generationConfigSettings';
8
 
9
+ export let conversation: Conversation;
 
10
  export let classNames = '';
11
+
12
+ $: modelMaxLength = conversation.model.tokenizerConfig.model_max_length;
13
+ $: maxTokens = Math.min(modelMaxLength ?? GENERATION_CONFIG_SETTINGS['max_tokens'].max, 64_000);
14
  </script>
15
 
16
  <div class="flex flex-col gap-y-5 {classNames}">
17
  {#each GENERATION_CONFIG_KEYS as key}
18
  {@const { label, min, step } = GENERATION_CONFIG_SETTINGS[key]}
19
+ {@const max = key === 'max_tokens' ? maxTokens : GENERATION_CONFIG_SETTINGS[key].max}
20
  <div>
21
  <div class="flex items-center justify-between">
22
  <label
 
27
  type="number"
28
  class="w-16 rounded border bg-transparent px-1 py-0.5 text-right text-sm dark:border-gray-700"
29
  {min}
30
+ {max}
31
  {step}
32
+ bind:value={conversation.config[key]}
33
  />
34
  </div>
35
  <input
36
  id="temperature-range"
37
  type="range"
38
  {min}
39
+ {max}
40
  {step}
41
+ bind:value={conversation.config[key]}
42
  class="h-2 w-full cursor-pointer appearance-none rounded-lg bg-gray-200 accent-black dark:bg-gray-700 dark:accent-blue-500"
43
  />
44
  </div>
 
62
  min={settings.min}
63
  max={settings.max}
64
  step={settings.step}
65
+ value={conversation.config[key] ?? settings.default}
66
+ on:input={(e) => (conversation.config[key] = Number(e.currentTarget.value))}
67
  />
68
  </div>
69
  <input
 
72
  min={settings.min}
73
  max={settings.max}
74
  step={settings.step}
75
+ value={conversation.config[key] ?? settings.default}
76
+ on:input={(e) => (conversation.config[key] = Number(e.currentTarget.value))}
77
  class="h-2 w-full cursor-pointer appearance-none rounded-lg bg-gray-200 accent-black dark:bg-gray-700 dark:accent-blue-500"
78
  />
79
  </div>
 
83
 
84
  <div class="mt-2">
85
  <label class="flex cursor-pointer items-center justify-between">
86
+ <input type="checkbox" bind:checked={conversation.streaming} class="peer sr-only" />
87
  <span class="text-sm font-medium text-gray-900 dark:text-gray-300">Streaming</span>
88
  <div
89
  class="peer relative h-5 w-9 rounded-full bg-gray-200 after:absolute after:start-[2px] after:top-[2px] after:h-4 after:w-4 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:bg-black peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:peer-checked:bg-blue-600"