AdvancedParams.svelte 33 KB

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