AdvancedParams.svelte 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. <script lang="ts">
  2. import Switch from '$lib/components/common/Switch.svelte';
  3. import Tooltip from '$lib/components/common/Tooltip.svelte';
  4. import { getContext, createEventDispatcher } from 'svelte';
  5. const dispatch = createEventDispatcher();
  6. const i18n = getContext('i18n');
  7. export let admin = false;
  8. export let params = {
  9. // Advanced
  10. stream_response: null, // Set stream responses for this model individually
  11. seed: null,
  12. stop: null,
  13. temperature: null,
  14. frequency_penalty: null,
  15. repeat_last_n: null,
  16. mirostat: null,
  17. mirostat_eta: null,
  18. mirostat_tau: null,
  19. top_k: null,
  20. top_p: null,
  21. min_p: null,
  22. tfs_z: null,
  23. num_ctx: null,
  24. num_batch: null,
  25. num_keep: null,
  26. max_tokens: null,
  27. use_mmap: null,
  28. use_mlock: null,
  29. num_thread: null,
  30. num_gpu: null,
  31. template: null
  32. };
  33. let customFieldName = '';
  34. let customFieldValue = '';
  35. $: if (params) {
  36. dispatch('change', params);
  37. }
  38. </script>
  39. <div class=" space-y-1 text-xs pb-safe-bottom">
  40. <div>
  41. <Tooltip
  42. content={$i18n.t(
  43. 'When enabled, the model will respond to each chat message in real-time, generating a response as soon as the user sends a message. This mode is useful for live chat applications, but may impact performance on slower hardware.'
  44. )}
  45. placement="top-start"
  46. className="inline-tooltip"
  47. >
  48. <div class=" py-0.5 flex w-full justify-between">
  49. <div class=" self-center text-xs font-medium">
  50. {$i18n.t('Stream Chat Response')}
  51. </div>
  52. <button
  53. class="p-1 px-3 text-xs flex rounded transition"
  54. on:click={() => {
  55. params.stream_response =
  56. (params?.stream_response ?? null) === null
  57. ? true
  58. : params.stream_response
  59. ? false
  60. : null;
  61. }}
  62. type="button"
  63. >
  64. {#if params.stream_response === true}
  65. <span class="ml-2 self-center">{$i18n.t('On')}</span>
  66. {:else if params.stream_response === false}
  67. <span class="ml-2 self-center">{$i18n.t('Off')}</span>
  68. {:else}
  69. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  70. {/if}
  71. </button>
  72. </div>
  73. </Tooltip>
  74. </div>
  75. <div class=" py-0.5 w-full justify-between">
  76. <Tooltip
  77. content={$i18n.t(
  78. 'Sets the random number seed to use for generation. Setting this to a specific number will make the model generate the same text for the same prompt. (Default: random)'
  79. )}
  80. placement="top-start"
  81. className="inline-tooltip"
  82. >
  83. <div class="flex w-full justify-between">
  84. <div class=" self-center text-xs font-medium">
  85. {$i18n.t('Seed')}
  86. </div>
  87. <button
  88. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  89. type="button"
  90. on:click={() => {
  91. params.seed = (params?.seed ?? null) === null ? 0 : null;
  92. }}
  93. >
  94. {#if (params?.seed ?? null) === null}
  95. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  96. {:else}
  97. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  98. {/if}
  99. </button>
  100. </div>
  101. </Tooltip>
  102. {#if (params?.seed ?? null) !== null}
  103. <div class="flex mt-0.5 space-x-2">
  104. <div class=" flex-1">
  105. <input
  106. class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
  107. type="number"
  108. placeholder={$i18n.t('Enter Seed')}
  109. bind:value={params.seed}
  110. autocomplete="off"
  111. min="0"
  112. />
  113. </div>
  114. </div>
  115. {/if}
  116. </div>
  117. <div class=" py-0.5 w-full justify-between">
  118. <Tooltip
  119. content={$i18n.t(
  120. 'Sets the stop sequences to use. When this pattern is encountered, the LLM will stop generating text and return. Multiple stop patterns may be set by specifying multiple separate stop parameters in a modelfile.'
  121. )}
  122. placement="top-start"
  123. className="inline-tooltip"
  124. >
  125. <div class="flex w-full justify-between">
  126. <div class=" self-center text-xs font-medium">
  127. {$i18n.t('Stop Sequence')}
  128. </div>
  129. <button
  130. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  131. type="button"
  132. on:click={() => {
  133. params.stop = (params?.stop ?? null) === null ? '' : null;
  134. }}
  135. >
  136. {#if (params?.stop ?? null) === null}
  137. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  138. {:else}
  139. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  140. {/if}
  141. </button>
  142. </div>
  143. </Tooltip>
  144. {#if (params?.stop ?? null) !== null}
  145. <div class="flex mt-0.5 space-x-2">
  146. <div class=" flex-1">
  147. <input
  148. class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
  149. type="text"
  150. placeholder={$i18n.t('Enter stop sequence')}
  151. bind:value={params.stop}
  152. autocomplete="off"
  153. />
  154. </div>
  155. </div>
  156. {/if}
  157. </div>
  158. <div class=" py-0.5 w-full justify-between">
  159. <Tooltip
  160. content={$i18n.t(
  161. 'The temperature of the model. Increasing the temperature will make the model answer more creatively. (Default: 0.8)'
  162. )}
  163. placement="top-start"
  164. className="inline-tooltip"
  165. >
  166. <div class="flex w-full justify-between">
  167. <div class=" self-center text-xs font-medium">
  168. {$i18n.t('Temperature')}
  169. </div>
  170. <button
  171. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  172. type="button"
  173. on:click={() => {
  174. params.temperature = (params?.temperature ?? null) === null ? 0.8 : null;
  175. }}
  176. >
  177. {#if (params?.temperature ?? null) === null}
  178. <span class="ml-2 self-center"> {$i18n.t('Default')} </span>
  179. {:else}
  180. <span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
  181. {/if}
  182. </button>
  183. </div>
  184. </Tooltip>
  185. {#if (params?.temperature ?? null) !== null}
  186. <div class="flex mt-0.5 space-x-2">
  187. <div class=" flex-1">
  188. <input
  189. id="steps-range"
  190. type="range"
  191. min="0"
  192. max="1"
  193. step="0.05"
  194. bind:value={params.temperature}
  195. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  196. />
  197. </div>
  198. <div>
  199. <input
  200. bind:value={params.temperature}
  201. type="number"
  202. class=" bg-transparent text-center w-14"
  203. min="0"
  204. max="1"
  205. step="any"
  206. />
  207. </div>
  208. </div>
  209. {/if}
  210. </div>
  211. <div class=" py-0.5 w-full justify-between">
  212. <Tooltip
  213. content={$i18n.t(
  214. 'Enable Mirostat sampling for controlling perplexity. (Default: 0, 0 = Disabled, 1 = Mirostat, 2 = Mirostat 2.0)'
  215. )}
  216. placement="top-start"
  217. className="inline-tooltip"
  218. >
  219. <div class="flex w-full justify-between">
  220. <div class=" self-center text-xs font-medium">
  221. {$i18n.t('Mirostat')}
  222. </div>
  223. <button
  224. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  225. type="button"
  226. on:click={() => {
  227. params.mirostat = (params?.mirostat ?? null) === null ? 0 : null;
  228. }}
  229. >
  230. {#if (params?.mirostat ?? null) === null}
  231. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  232. {:else}
  233. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  234. {/if}
  235. </button>
  236. </div>
  237. </Tooltip>
  238. {#if (params?.mirostat ?? null) !== null}
  239. <div class="flex mt-0.5 space-x-2">
  240. <div class=" flex-1">
  241. <input
  242. id="steps-range"
  243. type="range"
  244. min="0"
  245. max="2"
  246. step="1"
  247. bind:value={params.mirostat}
  248. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  249. />
  250. </div>
  251. <div>
  252. <input
  253. bind:value={params.mirostat}
  254. type="number"
  255. class=" bg-transparent text-center w-14"
  256. min="0"
  257. max="2"
  258. step="1"
  259. />
  260. </div>
  261. </div>
  262. {/if}
  263. </div>
  264. <div class=" py-0.5 w-full justify-between">
  265. <Tooltip
  266. content={$i18n.t(
  267. 'Influences how quickly the algorithm responds to feedback from the generated text. A lower learning rate will result in slower adjustments, while a higher learning rate will make the algorithm more responsive. (Default: 0.1)'
  268. )}
  269. placement="top-start"
  270. className="inline-tooltip"
  271. >
  272. <div class="flex w-full justify-between">
  273. <div class=" self-center text-xs font-medium">
  274. {$i18n.t('Mirostat Eta')}
  275. </div>
  276. <button
  277. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  278. type="button"
  279. on:click={() => {
  280. params.mirostat_eta = (params?.mirostat_eta ?? null) === null ? 0.1 : null;
  281. }}
  282. >
  283. {#if (params?.mirostat_eta ?? null) === null}
  284. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  285. {:else}
  286. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  287. {/if}
  288. </button>
  289. </div>
  290. </Tooltip>
  291. {#if (params?.mirostat_eta ?? null) !== null}
  292. <div class="flex mt-0.5 space-x-2">
  293. <div class=" flex-1">
  294. <input
  295. id="steps-range"
  296. type="range"
  297. min="0"
  298. max="1"
  299. step="0.05"
  300. bind:value={params.mirostat_eta}
  301. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  302. />
  303. </div>
  304. <div>
  305. <input
  306. bind:value={params.mirostat_eta}
  307. type="number"
  308. class=" bg-transparent text-center w-14"
  309. min="0"
  310. max="1"
  311. step="any"
  312. />
  313. </div>
  314. </div>
  315. {/if}
  316. </div>
  317. <div class=" py-0.5 w-full justify-between">
  318. <Tooltip
  319. content={$i18n.t(
  320. 'Controls the balance between coherence and diversity of the output. A lower value will result in more focused and coherent text. (Default: 5.0)'
  321. )}
  322. placement="top-start"
  323. className="inline-tooltip"
  324. >
  325. <div class="flex w-full justify-between">
  326. <div class=" self-center text-xs font-medium">
  327. {$i18n.t('Mirostat Tau')}
  328. </div>
  329. <button
  330. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  331. type="button"
  332. on:click={() => {
  333. params.mirostat_tau = (params?.mirostat_tau ?? null) === null ? 5.0 : null;
  334. }}
  335. >
  336. {#if (params?.mirostat_tau ?? null) === null}
  337. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  338. {:else}
  339. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  340. {/if}
  341. </button>
  342. </div>
  343. </Tooltip>
  344. {#if (params?.mirostat_tau ?? null) !== null}
  345. <div class="flex mt-0.5 space-x-2">
  346. <div class=" flex-1">
  347. <input
  348. id="steps-range"
  349. type="range"
  350. min="0"
  351. max="10"
  352. step="0.5"
  353. bind:value={params.mirostat_tau}
  354. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  355. />
  356. </div>
  357. <div>
  358. <input
  359. bind:value={params.mirostat_tau}
  360. type="number"
  361. class=" bg-transparent text-center w-14"
  362. min="0"
  363. max="10"
  364. step="any"
  365. />
  366. </div>
  367. </div>
  368. {/if}
  369. </div>
  370. <div class=" py-0.5 w-full justify-between">
  371. <Tooltip
  372. content={$i18n.t(
  373. 'Reduces the probability of generating nonsense. A higher value (e.g. 100) will give more diverse answers, while a lower value (e.g. 10) will be more conservative. (Default: 40)'
  374. )}
  375. placement="top-start"
  376. className="inline-tooltip"
  377. >
  378. <div class="flex w-full justify-between">
  379. <div class=" self-center text-xs font-medium">
  380. {$i18n.t('Top K')}
  381. </div>
  382. <button
  383. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  384. type="button"
  385. on:click={() => {
  386. params.top_k = (params?.top_k ?? null) === null ? 40 : null;
  387. }}
  388. >
  389. {#if (params?.top_k ?? null) === null}
  390. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  391. {:else}
  392. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  393. {/if}
  394. </button>
  395. </div>
  396. </Tooltip>
  397. {#if (params?.top_k ?? null) !== null}
  398. <div class="flex mt-0.5 space-x-2">
  399. <div class=" flex-1">
  400. <input
  401. id="steps-range"
  402. type="range"
  403. min="0"
  404. max="100"
  405. step="0.5"
  406. bind:value={params.top_k}
  407. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  408. />
  409. </div>
  410. <div>
  411. <input
  412. bind:value={params.top_k}
  413. type="number"
  414. class=" bg-transparent text-center w-14"
  415. min="0"
  416. max="100"
  417. step="any"
  418. />
  419. </div>
  420. </div>
  421. {/if}
  422. </div>
  423. <div class=" py-0.5 w-full justify-between">
  424. <Tooltip
  425. content={$i18n.t(
  426. 'Works together with top-k. A higher value (e.g., 0.95) will lead to more diverse text, while a lower value (e.g., 0.5) will generate more focused and conservative text. (Default: 0.9)'
  427. )}
  428. placement="top-start"
  429. className="inline-tooltip"
  430. >
  431. <div class="flex w-full justify-between">
  432. <div class=" self-center text-xs font-medium">
  433. {$i18n.t('Top P')}
  434. </div>
  435. <button
  436. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  437. type="button"
  438. on:click={() => {
  439. params.top_p = (params?.top_p ?? null) === null ? 0.9 : null;
  440. }}
  441. >
  442. {#if (params?.top_p ?? null) === null}
  443. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  444. {:else}
  445. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  446. {/if}
  447. </button>
  448. </div>
  449. </Tooltip>
  450. {#if (params?.top_p ?? null) !== null}
  451. <div class="flex mt-0.5 space-x-2">
  452. <div class=" flex-1">
  453. <input
  454. id="steps-range"
  455. type="range"
  456. min="0"
  457. max="1"
  458. step="0.05"
  459. bind:value={params.top_p}
  460. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  461. />
  462. </div>
  463. <div>
  464. <input
  465. bind:value={params.top_p}
  466. type="number"
  467. class=" bg-transparent text-center w-14"
  468. min="0"
  469. max="1"
  470. step="any"
  471. />
  472. </div>
  473. </div>
  474. {/if}
  475. </div>
  476. <div class=" py-0.5 w-full justify-between">
  477. <Tooltip
  478. content={$i18n.t(
  479. 'Alternative to the top_p, and aims to ensure a balance of quality and variety. The parameter p represents the minimum probability for a token to be considered, relative to the probability of the most likely token. For example, with p=0.05 and the most likely token having a probability of 0.9, logits with a value less than 0.045 are filtered out. (Default: 0.0)'
  480. )}
  481. placement="top-start"
  482. className="inline-tooltip"
  483. >
  484. <div class="flex w-full justify-between">
  485. <div class=" self-center text-xs font-medium">
  486. {$i18n.t('Min P')}
  487. </div>
  488. <button
  489. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  490. type="button"
  491. on:click={() => {
  492. params.min_p = (params?.min_p ?? null) === null ? 0.0 : null;
  493. }}
  494. >
  495. {#if (params?.min_p ?? null) === null}
  496. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  497. {:else}
  498. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  499. {/if}
  500. </button>
  501. </div>
  502. </Tooltip>
  503. {#if (params?.min_p ?? null) !== null}
  504. <div class="flex mt-0.5 space-x-2">
  505. <div class=" flex-1">
  506. <input
  507. id="steps-range"
  508. type="range"
  509. min="0"
  510. max="1"
  511. step="0.05"
  512. bind:value={params.min_p}
  513. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  514. />
  515. </div>
  516. <div>
  517. <input
  518. bind:value={params.min_p}
  519. type="number"
  520. class=" bg-transparent text-center w-14"
  521. min="0"
  522. max="1"
  523. step="any"
  524. />
  525. </div>
  526. </div>
  527. {/if}
  528. </div>
  529. <div class=" py-0.5 w-full justify-between">
  530. <Tooltip
  531. content={$i18n.t(
  532. 'Sets how strongly to penalize repetitions. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 0.9) will be more lenient. (Default: 1.1)'
  533. )}
  534. placement="top-start"
  535. className="inline-tooltip"
  536. >
  537. <div class="flex w-full justify-between">
  538. <div class=" self-center text-xs font-medium">
  539. {$i18n.t('Frequency Penalty')}
  540. </div>
  541. <button
  542. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  543. type="button"
  544. on:click={() => {
  545. params.frequency_penalty = (params?.frequency_penalty ?? null) === null ? 1.1 : null;
  546. }}
  547. >
  548. {#if (params?.frequency_penalty ?? null) === null}
  549. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  550. {:else}
  551. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  552. {/if}
  553. </button>
  554. </div>
  555. </Tooltip>
  556. {#if (params?.frequency_penalty ?? null) !== null}
  557. <div class="flex mt-0.5 space-x-2">
  558. <div class=" flex-1">
  559. <input
  560. id="steps-range"
  561. type="range"
  562. min="0"
  563. max="2"
  564. step="0.05"
  565. bind:value={params.frequency_penalty}
  566. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  567. />
  568. </div>
  569. <div>
  570. <input
  571. bind:value={params.frequency_penalty}
  572. type="number"
  573. class=" bg-transparent text-center w-14"
  574. min="0"
  575. max="2"
  576. step="any"
  577. />
  578. </div>
  579. </div>
  580. {/if}
  581. </div>
  582. <div class=" py-0.5 w-full justify-between">
  583. <Tooltip
  584. content={$i18n.t(
  585. 'Sets how far back for the model to look back to prevent repetition. (Default: 64, 0 = disabled, -1 = num_ctx)'
  586. )}
  587. placement="top-start"
  588. className="inline-tooltip"
  589. >
  590. <div class="flex w-full justify-between">
  591. <div class=" self-center text-xs font-medium">
  592. {$i18n.t('Repeat Last N')}
  593. </div>
  594. <button
  595. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  596. type="button"
  597. on:click={() => {
  598. params.repeat_last_n = (params?.repeat_last_n ?? null) === null ? 64 : null;
  599. }}
  600. >
  601. {#if (params?.repeat_last_n ?? null) === null}
  602. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  603. {:else}
  604. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  605. {/if}
  606. </button>
  607. </div>
  608. </Tooltip>
  609. {#if (params?.repeat_last_n ?? null) !== null}
  610. <div class="flex mt-0.5 space-x-2">
  611. <div class=" flex-1">
  612. <input
  613. id="steps-range"
  614. type="range"
  615. min="-1"
  616. max="128"
  617. step="1"
  618. bind:value={params.repeat_last_n}
  619. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  620. />
  621. </div>
  622. <div>
  623. <input
  624. bind:value={params.repeat_last_n}
  625. type="number"
  626. class=" bg-transparent text-center w-14"
  627. min="-1"
  628. max="128"
  629. step="1"
  630. />
  631. </div>
  632. </div>
  633. {/if}
  634. </div>
  635. <div class=" py-0.5 w-full justify-between">
  636. <Tooltip
  637. content={$i18n.t(
  638. 'Tail free sampling is used to reduce the impact of less probable tokens from the output. A higher value (e.g., 2.0) will reduce the impact more, while a value of 1.0 disables this setting. (default: 1)'
  639. )}
  640. placement="top-start"
  641. className="inline-tooltip"
  642. >
  643. <div class="flex w-full justify-between">
  644. <div class=" self-center text-xs font-medium">
  645. {$i18n.t('Tfs Z')}
  646. </div>
  647. <button
  648. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  649. type="button"
  650. on:click={() => {
  651. params.tfs_z = (params?.tfs_z ?? null) === null ? 1 : null;
  652. }}
  653. >
  654. {#if (params?.tfs_z ?? null) === null}
  655. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  656. {:else}
  657. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  658. {/if}
  659. </button>
  660. </div>
  661. </Tooltip>
  662. {#if (params?.tfs_z ?? null) !== null}
  663. <div class="flex mt-0.5 space-x-2">
  664. <div class=" flex-1">
  665. <input
  666. id="steps-range"
  667. type="range"
  668. min="0"
  669. max="2"
  670. step="0.05"
  671. bind:value={params.tfs_z}
  672. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  673. />
  674. </div>
  675. <div>
  676. <input
  677. bind:value={params.tfs_z}
  678. type="number"
  679. class=" bg-transparent text-center w-14"
  680. min="0"
  681. max="2"
  682. step="any"
  683. />
  684. </div>
  685. </div>
  686. {/if}
  687. </div>
  688. <div class=" py-0.5 w-full justify-between">
  689. <Tooltip
  690. content={$i18n.t(
  691. 'Sets the size of the context window used to generate the next token. (Default: 2048)'
  692. )}
  693. placement="top-start"
  694. className="inline-tooltip"
  695. >
  696. <div class="flex w-full justify-between">
  697. <div class=" self-center text-xs font-medium">
  698. {$i18n.t('Context Length')}
  699. </div>
  700. <button
  701. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  702. type="button"
  703. on:click={() => {
  704. params.num_ctx = (params?.num_ctx ?? null) === null ? 2048 : null;
  705. }}
  706. >
  707. {#if (params?.num_ctx ?? null) === null}
  708. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  709. {:else}
  710. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  711. {/if}
  712. </button>
  713. </div>
  714. </Tooltip>
  715. {#if (params?.num_ctx ?? null) !== null}
  716. <div class="flex mt-0.5 space-x-2">
  717. <div class=" flex-1">
  718. <input
  719. id="steps-range"
  720. type="range"
  721. min="-1"
  722. max="10240000"
  723. step="1"
  724. bind:value={params.num_ctx}
  725. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  726. />
  727. </div>
  728. <div class="">
  729. <input
  730. bind:value={params.num_ctx}
  731. type="number"
  732. class=" bg-transparent text-center w-14"
  733. min="-1"
  734. step="1"
  735. />
  736. </div>
  737. </div>
  738. {/if}
  739. </div>
  740. <div class=" py-0.5 w-full justify-between">
  741. <Tooltip
  742. content={$i18n.t(
  743. 'The batch size determines how many text requests are processed together at once. A higher batch size can increase the performance and speed of the model, but it also requires more memory. (Default: 512)'
  744. )}
  745. placement="top-start"
  746. className="inline-tooltip"
  747. >
  748. <div class="flex w-full justify-between">
  749. <div class=" self-center text-xs font-medium">
  750. {$i18n.t('Batch Size (num_batch)')}
  751. </div>
  752. <button
  753. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  754. type="button"
  755. on:click={() => {
  756. params.num_batch = (params?.num_batch ?? null) === null ? 512 : null;
  757. }}
  758. >
  759. {#if (params?.num_batch ?? null) === null}
  760. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  761. {:else}
  762. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  763. {/if}
  764. </button>
  765. </div>
  766. </Tooltip>
  767. {#if (params?.num_batch ?? null) !== null}
  768. <div class="flex mt-0.5 space-x-2">
  769. <div class=" flex-1">
  770. <input
  771. id="steps-range"
  772. type="range"
  773. min="256"
  774. max="8192"
  775. step="256"
  776. bind:value={params.num_batch}
  777. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  778. />
  779. </div>
  780. <div>
  781. <input
  782. bind:value={params.num_batch}
  783. type="number"
  784. class=" bg-transparent text-center w-14"
  785. min="256"
  786. step="256"
  787. />
  788. </div>
  789. </div>
  790. {/if}
  791. </div>
  792. <div class=" py-0.5 w-full justify-between">
  793. <Tooltip
  794. content={$i18n.t(
  795. 'This option controls how many tokens are preserved when refreshing the context. For example, if set to 2, the last 2 tokens of the conversation context will be retained. Preserving context can help maintain the continuity of a conversation, but it may reduce the ability to respond to new topics. (Default: 24)'
  796. )}
  797. placement="top-start"
  798. className="inline-tooltip"
  799. >
  800. <div class="flex w-full justify-between">
  801. <div class=" self-center text-xs font-medium">
  802. {$i18n.t('Tokens To Keep On Context Refresh (num_keep)')}
  803. </div>
  804. <button
  805. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  806. type="button"
  807. on:click={() => {
  808. params.num_keep = (params?.num_keep ?? null) === null ? 24 : null;
  809. }}
  810. >
  811. {#if (params?.num_keep ?? null) === null}
  812. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  813. {:else}
  814. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  815. {/if}
  816. </button>
  817. </div>
  818. </Tooltip>
  819. {#if (params?.num_keep ?? null) !== null}
  820. <div class="flex mt-0.5 space-x-2">
  821. <div class=" flex-1">
  822. <input
  823. id="steps-range"
  824. type="range"
  825. min="-1"
  826. max="10240000"
  827. step="1"
  828. bind:value={params.num_keep}
  829. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  830. />
  831. </div>
  832. <div class="">
  833. <input
  834. bind:value={params.num_keep}
  835. type="number"
  836. class=" bg-transparent text-center w-14"
  837. min="-1"
  838. step="1"
  839. />
  840. </div>
  841. </div>
  842. {/if}
  843. </div>
  844. <div class=" py-0.5 w-full justify-between">
  845. <Tooltip
  846. content={$i18n.t(
  847. 'This option sets the maximum number of tokens the model can generate in its response. Increasing this limit allows the model to provide longer answers, but it may also increase the likelihood of unhelpful or irrelevant content being generated. (Default: 128)'
  848. )}
  849. placement="top-start"
  850. className="inline-tooltip"
  851. >
  852. <div class="flex w-full justify-between">
  853. <div class=" self-center text-xs font-medium">
  854. {$i18n.t('Max Tokens (num_predict)')}
  855. </div>
  856. <button
  857. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  858. type="button"
  859. on:click={() => {
  860. params.max_tokens = (params?.max_tokens ?? null) === null ? 128 : null;
  861. }}
  862. >
  863. {#if (params?.max_tokens ?? null) === null}
  864. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  865. {:else}
  866. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  867. {/if}
  868. </button>
  869. </div>
  870. </Tooltip>
  871. {#if (params?.max_tokens ?? null) !== null}
  872. <div class="flex mt-0.5 space-x-2">
  873. <div class=" flex-1">
  874. <input
  875. id="steps-range"
  876. type="range"
  877. min="-2"
  878. max="131072"
  879. step="1"
  880. bind:value={params.max_tokens}
  881. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  882. />
  883. </div>
  884. <div>
  885. <input
  886. bind:value={params.max_tokens}
  887. type="number"
  888. class=" bg-transparent text-center w-14"
  889. min="-2"
  890. step="1"
  891. />
  892. </div>
  893. </div>
  894. {/if}
  895. </div>
  896. {#if admin}
  897. <div class=" py-0.5 w-full justify-between">
  898. <Tooltip
  899. content={$i18n.t(
  900. 'Enable Memory Mapping (mmap) to load model data. This option allows the system to use disk storage as an extension of RAM by treating disk files as if they were in RAM. This can improve model performance by allowing for faster data access. However, it may not work correctly with all systems and can consume a significant amount of disk space.'
  901. )}
  902. placement="top-start"
  903. className="inline-tooltip"
  904. >
  905. <div class="flex w-full justify-between">
  906. <div class=" self-center text-xs font-medium">
  907. {$i18n.t('use_mmap (Ollama)')}
  908. </div>
  909. <button
  910. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  911. type="button"
  912. on:click={() => {
  913. params.use_mmap = (params?.use_mmap ?? null) === null ? true : null;
  914. }}
  915. >
  916. {#if (params?.use_mmap ?? null) === null}
  917. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  918. {:else}
  919. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  920. {/if}
  921. </button>
  922. </div>
  923. </Tooltip>
  924. {#if (params?.use_mmap ?? null) !== null}
  925. <div class="flex justify-between items-center mt-1">
  926. <div class="text-xs text-gray-500">
  927. {params.use_mmap ? 'Enabled' : 'Disabled'}
  928. </div>
  929. <div class=" pr-2">
  930. <Switch bind:state={params.use_mmap} />
  931. </div>
  932. </div>
  933. {/if}
  934. </div>
  935. <div class=" py-0.5 w-full justify-between">
  936. <Tooltip
  937. content={$i18n.t(
  938. "Enable Memory Locking (mlock) to prevent model data from being swapped out of RAM. This option locks the model's working set of pages into RAM, ensuring that they will not be swapped out to disk. This can help maintain performance by avoiding page faults and ensuring fast data access."
  939. )}
  940. placement="top-start"
  941. className="inline-tooltip"
  942. >
  943. <div class="flex w-full justify-between">
  944. <div class=" self-center text-xs font-medium">
  945. {$i18n.t('use_mlock (Ollama)')}
  946. </div>
  947. <button
  948. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  949. type="button"
  950. on:click={() => {
  951. params.use_mlock = (params?.use_mlock ?? null) === null ? true : null;
  952. }}
  953. >
  954. {#if (params?.use_mlock ?? null) === null}
  955. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  956. {:else}
  957. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  958. {/if}
  959. </button>
  960. </div>
  961. </Tooltip>
  962. {#if (params?.use_mlock ?? null) !== null}
  963. <div class="flex justify-between items-center mt-1">
  964. <div class="text-xs text-gray-500">
  965. {params.use_mlock ? 'Enabled' : 'Disabled'}
  966. </div>
  967. <div class=" pr-2">
  968. <Switch bind:state={params.use_mlock} />
  969. </div>
  970. </div>
  971. {/if}
  972. </div>
  973. <div class=" py-0.5 w-full justify-between">
  974. <Tooltip
  975. content={$i18n.t(
  976. 'Set the number of worker threads used for computation. This option controls how many threads are used to process incoming requests concurrently. Increasing this value can improve performance under high concurrency workloads but may also consume more CPU resources.'
  977. )}
  978. placement="top-start"
  979. className="inline-tooltip"
  980. >
  981. <div class="flex w-full justify-between">
  982. <div class=" self-center text-xs font-medium">
  983. {$i18n.t('num_thread (Ollama)')}
  984. </div>
  985. <button
  986. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  987. type="button"
  988. on:click={() => {
  989. params.num_thread = (params?.num_thread ?? null) === null ? 2 : null;
  990. }}
  991. >
  992. {#if (params?.num_thread ?? null) === null}
  993. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  994. {:else}
  995. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  996. {/if}
  997. </button>
  998. </div>
  999. </Tooltip>
  1000. {#if (params?.num_thread ?? null) !== null}
  1001. <div class="flex mt-0.5 space-x-2">
  1002. <div class=" flex-1">
  1003. <input
  1004. id="steps-range"
  1005. type="range"
  1006. min="1"
  1007. max="256"
  1008. step="1"
  1009. bind:value={params.num_thread}
  1010. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  1011. />
  1012. </div>
  1013. <div class="">
  1014. <input
  1015. bind:value={params.num_thread}
  1016. type="number"
  1017. class=" bg-transparent text-center w-14"
  1018. min="1"
  1019. max="256"
  1020. step="1"
  1021. />
  1022. </div>
  1023. </div>
  1024. {/if}
  1025. </div>
  1026. <div class=" py-0.5 w-full justify-between">
  1027. <Tooltip
  1028. content={$i18n.t(
  1029. 'Set the number of layers, which will be off-loaded to GPU. Increasing this value can significantly improve performance for models that are optimized for GPU acceleration but may also consume more power and GPU resources.'
  1030. )}
  1031. placement="top-start"
  1032. className="inline-tooltip"
  1033. >
  1034. <div class="flex w-full justify-between">
  1035. <div class=" self-center text-xs font-medium">
  1036. {$i18n.t('num_gpu (Ollama)')}
  1037. </div>
  1038. <button
  1039. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  1040. type="button"
  1041. on:click={() => {
  1042. params.num_gpu = (params?.num_gpu ?? null) === null ? 0 : null;
  1043. }}
  1044. >
  1045. {#if (params?.num_gpu ?? null) === null}
  1046. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1047. {:else}
  1048. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  1049. {/if}
  1050. </button>
  1051. </div>
  1052. </Tooltip>
  1053. {#if (params?.num_gpu ?? null) !== null}
  1054. <div class="flex mt-0.5 space-x-2">
  1055. <div class=" flex-1">
  1056. <input
  1057. id="steps-range"
  1058. type="range"
  1059. min="0"
  1060. max="256"
  1061. step="1"
  1062. bind:value={params.num_gpu}
  1063. class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
  1064. />
  1065. </div>
  1066. <div class="">
  1067. <input
  1068. bind:value={params.num_gpu}
  1069. type="number"
  1070. class=" bg-transparent text-center w-14"
  1071. min="0"
  1072. max="256"
  1073. step="1"
  1074. />
  1075. </div>
  1076. </div>
  1077. {/if}
  1078. </div>
  1079. <!-- <div class=" py-0.5 w-full justify-between">
  1080. <div class="flex w-full justify-between">
  1081. <div class=" self-center text-xs font-medium">{$i18n.t('Template')}</div>
  1082. <button
  1083. class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none"
  1084. type="button"
  1085. on:click={() => {
  1086. params.template = (params?.template ?? null) === null ? '' : null;
  1087. }}
  1088. >
  1089. {#if (params?.template ?? null) === null}
  1090. <span class="ml-2 self-center">{$i18n.t('Default')}</span>
  1091. {:else}
  1092. <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
  1093. {/if}
  1094. </button>
  1095. </div>
  1096. {#if (params?.template ?? null) !== null}
  1097. <div class="flex mt-0.5 space-x-2">
  1098. <div class=" flex-1">
  1099. <textarea
  1100. class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg -mb-1"
  1101. placeholder={$i18n.t('Write your model template content here')}
  1102. rows="4"
  1103. bind:value={params.template}
  1104. />
  1105. </div>
  1106. </div>
  1107. {/if}
  1108. </div> -->
  1109. {/if}
  1110. </div>