AdvancedParams.svelte 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <script lang="ts">
  2. import { getContext } from 'svelte';
  3. const i18n = getContext('i18n');
  4. export let options = {
  5. // Advanced
  6. seed: 0,
  7. stop: '',
  8. temperature: '',
  9. repeat_penalty: '',
  10. repeat_last_n: '',
  11. mirostat: '',
  12. mirostat_eta: '',
  13. mirostat_tau: '',
  14. top_k: '',
  15. top_p: '',
  16. tfs_z: '',
  17. num_ctx: '',
  18. num_predict: ''
  19. };
  20. </script>
  21. <div class=" space-y-3 text-xs">
  22. <div>
  23. <div class=" py-0.5 flex w-full justify-between">
  24. <div class=" w-20 text-xs font-medium self-center">{$i18n.t('Seed')}</div>
  25. <div class=" flex-1 self-center">
  26. <input
  27. class="w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
  28. type="number"
  29. placeholder="Enter Seed"
  30. bind:value={options.seed}
  31. autocomplete="off"
  32. min="0"
  33. />
  34. </div>
  35. </div>
  36. </div>
  37. <div>
  38. <div class=" py-0.5 flex w-full justify-between">
  39. <div class=" w-20 text-xs font-medium self-center">{$i18n.t('Stop Sequence')}</div>
  40. <div class=" flex-1 self-center">
  41. <input
  42. class="w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
  43. type="text"
  44. placeholder={$i18n.t('Enter stop sequence')}
  45. bind:value={options.stop}
  46. autocomplete="off"
  47. />
  48. </div>
  49. </div>
  50. </div>
  51. <div class=" py-0.5 w-full justify-between">
  52. <div class="flex w-full justify-between">
  53. <div class=" self-center text-xs font-medium">{$i18n.t('Temperature')}</div>
  54. <button
  55. class="p-1 px-3 text-xs flex rounded transition"
  56. type="button"
  57. on:click={() => {
  58. options.temperature = options.temperature === '' ? 0.8 : '';
  59. }}
  60. >
  61. {#if options.temperature === ''}
  62. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  63. {:else}
  64. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  65. {/if}
  66. </button>
  67. </div>
  68. {#if options.temperature !== ''}
  69. <div class="flex mt-0.5 space-x-2">
  70. <div class=" flex-1">
  71. <input
  72. id="steps-range"
  73. type="range"
  74. min="0"
  75. max="1"
  76. step="0.05"
  77. bind:value={options.temperature}
  78. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  79. />
  80. </div>
  81. <div>
  82. <input
  83. bind:value={options.temperature}
  84. type="number"
  85. class=" bg-transparent text-center w-14"
  86. min="0"
  87. max="1"
  88. step="0.05"
  89. />
  90. </div>
  91. </div>
  92. {/if}
  93. </div>
  94. <div class=" py-0.5 w-full justify-between">
  95. <div class="flex w-full justify-between">
  96. <div class=" self-center text-xs font-medium">{$i18n.t('Mirostat')}</div>
  97. <button
  98. class="p-1 px-3 text-xs flex rounded transition"
  99. type="button"
  100. on:click={() => {
  101. options.mirostat = options.mirostat === '' ? 0 : '';
  102. }}
  103. >
  104. {#if options.mirostat === ''}
  105. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  106. {:else}
  107. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  108. {/if}
  109. </button>
  110. </div>
  111. {#if options.mirostat !== ''}
  112. <div class="flex mt-0.5 space-x-2">
  113. <div class=" flex-1">
  114. <input
  115. id="steps-range"
  116. type="range"
  117. min="0"
  118. max="2"
  119. step="1"
  120. bind:value={options.mirostat}
  121. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  122. />
  123. </div>
  124. <div>
  125. <input
  126. bind:value={options.mirostat}
  127. type="number"
  128. class=" bg-transparent text-center w-14"
  129. min="0"
  130. max="2"
  131. step="1"
  132. />
  133. </div>
  134. </div>
  135. {/if}
  136. </div>
  137. <div class=" py-0.5 w-full justify-between">
  138. <div class="flex w-full justify-between">
  139. <div class=" self-center text-xs font-medium">{$i18n.t('Mirostat Eta')}</div>
  140. <button
  141. class="p-1 px-3 text-xs flex rounded transition"
  142. type="button"
  143. on:click={() => {
  144. options.mirostat_eta = options.mirostat_eta === '' ? 0.1 : '';
  145. }}
  146. >
  147. {#if options.mirostat_eta === ''}
  148. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  149. {:else}
  150. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  151. {/if}
  152. </button>
  153. </div>
  154. {#if options.mirostat_eta !== ''}
  155. <div class="flex mt-0.5 space-x-2">
  156. <div class=" flex-1">
  157. <input
  158. id="steps-range"
  159. type="range"
  160. min="0"
  161. max="1"
  162. step="0.05"
  163. bind:value={options.mirostat_eta}
  164. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  165. />
  166. </div>
  167. <div>
  168. <input
  169. bind:value={options.mirostat_eta}
  170. type="number"
  171. class=" bg-transparent text-center w-14"
  172. min="0"
  173. max="1"
  174. step="0.05"
  175. />
  176. </div>
  177. </div>
  178. {/if}
  179. </div>
  180. <div class=" py-0.5 w-full justify-between">
  181. <div class="flex w-full justify-between">
  182. <div class=" self-center text-xs font-medium">{$i18n.t('Mirostat Tau')}</div>
  183. <button
  184. class="p-1 px-3 text-xs flex rounded transition"
  185. type="button"
  186. on:click={() => {
  187. options.mirostat_tau = options.mirostat_tau === '' ? 5.0 : '';
  188. }}
  189. >
  190. {#if options.mirostat_tau === ''}
  191. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  192. {:else}
  193. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  194. {/if}
  195. </button>
  196. </div>
  197. {#if options.mirostat_tau !== ''}
  198. <div class="flex mt-0.5 space-x-2">
  199. <div class=" flex-1">
  200. <input
  201. id="steps-range"
  202. type="range"
  203. min="0"
  204. max="10"
  205. step="0.5"
  206. bind:value={options.mirostat_tau}
  207. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  208. />
  209. </div>
  210. <div>
  211. <input
  212. bind:value={options.mirostat_tau}
  213. type="number"
  214. class=" bg-transparent text-center w-14"
  215. min="0"
  216. max="10"
  217. step="0.5"
  218. />
  219. </div>
  220. </div>
  221. {/if}
  222. </div>
  223. <div class=" py-0.5 w-full justify-between">
  224. <div class="flex w-full justify-between">
  225. <div class=" self-center text-xs font-medium">{$i18n.t('Top K')}</div>
  226. <button
  227. class="p-1 px-3 text-xs flex rounded transition"
  228. type="button"
  229. on:click={() => {
  230. options.top_k = options.top_k === '' ? 40 : '';
  231. }}
  232. >
  233. {#if options.top_k === ''}
  234. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  235. {:else}
  236. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  237. {/if}
  238. </button>
  239. </div>
  240. {#if options.top_k !== ''}
  241. <div class="flex mt-0.5 space-x-2">
  242. <div class=" flex-1">
  243. <input
  244. id="steps-range"
  245. type="range"
  246. min="0"
  247. max="100"
  248. step="0.5"
  249. bind:value={options.top_k}
  250. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  251. />
  252. </div>
  253. <div>
  254. <input
  255. bind:value={options.top_k}
  256. type="number"
  257. class=" bg-transparent text-center w-14"
  258. min="0"
  259. max="100"
  260. step="0.5"
  261. />
  262. </div>
  263. </div>
  264. {/if}
  265. </div>
  266. <div class=" py-0.5 w-full justify-between">
  267. <div class="flex w-full justify-between">
  268. <div class=" self-center text-xs font-medium">{$i18n.t('Top P')}</div>
  269. <button
  270. class="p-1 px-3 text-xs flex rounded transition"
  271. type="button"
  272. on:click={() => {
  273. options.top_p = options.top_p === '' ? 0.9 : '';
  274. }}
  275. >
  276. {#if options.top_p === ''}
  277. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  278. {:else}
  279. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  280. {/if}
  281. </button>
  282. </div>
  283. {#if options.top_p !== ''}
  284. <div class="flex mt-0.5 space-x-2">
  285. <div class=" flex-1">
  286. <input
  287. id="steps-range"
  288. type="range"
  289. min="0"
  290. max="1"
  291. step="0.05"
  292. bind:value={options.top_p}
  293. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  294. />
  295. </div>
  296. <div>
  297. <input
  298. bind:value={options.top_p}
  299. type="number"
  300. class=" bg-transparent text-center w-14"
  301. min="0"
  302. max="1"
  303. step="0.05"
  304. />
  305. </div>
  306. </div>
  307. {/if}
  308. </div>
  309. <div class=" py-0.5 w-full justify-between">
  310. <div class="flex w-full justify-between">
  311. <div class=" self-center text-xs font-medium">{$i18n.t('Repeat Penalty')}</div>
  312. <button
  313. class="p-1 px-3 text-xs flex rounded transition"
  314. type="button"
  315. on:click={() => {
  316. options.repeat_penalty = options.repeat_penalty === '' ? 1.1 : '';
  317. }}
  318. >
  319. {#if options.repeat_penalty === ''}
  320. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  321. {:else}
  322. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  323. {/if}
  324. </button>
  325. </div>
  326. {#if options.repeat_penalty !== ''}
  327. <div class="flex mt-0.5 space-x-2">
  328. <div class=" flex-1">
  329. <input
  330. id="steps-range"
  331. type="range"
  332. min="0"
  333. max="2"
  334. step="0.05"
  335. bind:value={options.repeat_penalty}
  336. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  337. />
  338. </div>
  339. <div>
  340. <input
  341. bind:value={options.repeat_penalty}
  342. type="number"
  343. class=" bg-transparent text-center w-14"
  344. min="0"
  345. max="2"
  346. step="0.05"
  347. />
  348. </div>
  349. </div>
  350. {/if}
  351. </div>
  352. <div class=" py-0.5 w-full justify-between">
  353. <div class="flex w-full justify-between">
  354. <div class=" self-center text-xs font-medium">{$i18n.t('Repeat Last N')}</div>
  355. <button
  356. class="p-1 px-3 text-xs flex rounded transition"
  357. type="button"
  358. on:click={() => {
  359. options.repeat_last_n = options.repeat_last_n === '' ? 64 : '';
  360. }}
  361. >
  362. {#if options.repeat_last_n === ''}
  363. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  364. {:else}
  365. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  366. {/if}
  367. </button>
  368. </div>
  369. {#if options.repeat_last_n !== ''}
  370. <div class="flex mt-0.5 space-x-2">
  371. <div class=" flex-1">
  372. <input
  373. id="steps-range"
  374. type="range"
  375. min="-1"
  376. max="128"
  377. step="1"
  378. bind:value={options.repeat_last_n}
  379. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  380. />
  381. </div>
  382. <div>
  383. <input
  384. bind:value={options.repeat_last_n}
  385. type="number"
  386. class=" bg-transparent text-center w-14"
  387. min="-1"
  388. max="128"
  389. step="1"
  390. />
  391. </div>
  392. </div>
  393. {/if}
  394. </div>
  395. <div class=" py-0.5 w-full justify-between">
  396. <div class="flex w-full justify-between">
  397. <div class=" self-center text-xs font-medium">{$i18n.t('Tfs Z')}</div>
  398. <button
  399. class="p-1 px-3 text-xs flex rounded transition"
  400. type="button"
  401. on:click={() => {
  402. options.tfs_z = options.tfs_z === '' ? 1 : '';
  403. }}
  404. >
  405. {#if options.tfs_z === ''}
  406. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  407. {:else}
  408. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  409. {/if}
  410. </button>
  411. </div>
  412. {#if options.tfs_z !== ''}
  413. <div class="flex mt-0.5 space-x-2">
  414. <div class=" flex-1">
  415. <input
  416. id="steps-range"
  417. type="range"
  418. min="0"
  419. max="2"
  420. step="0.05"
  421. bind:value={options.tfs_z}
  422. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  423. />
  424. </div>
  425. <div>
  426. <input
  427. bind:value={options.tfs_z}
  428. type="number"
  429. class=" bg-transparent text-center w-14"
  430. min="0"
  431. max="2"
  432. step="0.05"
  433. />
  434. </div>
  435. </div>
  436. {/if}
  437. </div>
  438. <div class=" py-0.5 w-full justify-between">
  439. <div class="flex w-full justify-between">
  440. <div class=" self-center text-xs font-medium">{$i18n.t('Context Length')}</div>
  441. <button
  442. class="p-1 px-3 text-xs flex rounded transition"
  443. type="button"
  444. on:click={() => {
  445. options.num_ctx = options.num_ctx === '' ? 2048 : '';
  446. }}
  447. >
  448. {#if options.num_ctx === ''}
  449. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  450. {:else}
  451. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  452. {/if}
  453. </button>
  454. </div>
  455. {#if options.num_ctx !== ''}
  456. <div class="flex mt-0.5 space-x-2">
  457. <div class=" flex-1">
  458. <input
  459. id="steps-range"
  460. type="range"
  461. min="1"
  462. max="16000"
  463. step="1"
  464. bind:value={options.num_ctx}
  465. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  466. />
  467. </div>
  468. <div class="">
  469. <input
  470. bind:value={options.num_ctx}
  471. type="number"
  472. class=" bg-transparent text-center w-14"
  473. min="1"
  474. max="16000"
  475. step="1"
  476. />
  477. </div>
  478. </div>
  479. {/if}
  480. </div>
  481. <div class=" py-0.5 w-full justify-between">
  482. <div class="flex w-full justify-between">
  483. <div class=" self-center text-xs font-medium">{$i18n.t('Max Tokens')}</div>
  484. <button
  485. class="p-1 px-3 text-xs flex rounded transition"
  486. type="button"
  487. on:click={() => {
  488. options.num_predict = options.num_predict === '' ? 128 : '';
  489. }}
  490. >
  491. {#if options.num_predict === ''}
  492. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  493. {:else}
  494. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  495. {/if}
  496. </button>
  497. </div>
  498. {#if options.num_predict !== ''}
  499. <div class="flex mt-0.5 space-x-2">
  500. <div class=" flex-1">
  501. <input
  502. id="steps-range"
  503. type="range"
  504. min="-2"
  505. max="16000"
  506. step="1"
  507. bind:value={options.num_predict}
  508. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  509. />
  510. </div>
  511. <div class="">
  512. <input
  513. bind:value={options.num_predict}
  514. type="number"
  515. class=" bg-transparent text-center w-14"
  516. min="-2"
  517. max="16000"
  518. step="1"
  519. />
  520. </div>
  521. </div>
  522. {/if}
  523. </div>
  524. </div>