diff --git a/public/index.html b/public/index.html index b74baf671..3a2f7a0f3 100644 --- a/public/index.html +++ b/public/index.html @@ -506,8 +506,11 @@
-

Preset settings ?

+

Preset settings + + ? + +

@@ -545,7 +548,11 @@
-

Advanced Settings

+

Advanced Settings + + ? + +

diff --git a/public/notes/kai_advanced.html b/public/notes/kai_advanced.html new file mode 100644 index 000000000..7d8a728c9 --- /dev/null +++ b/public/notes/kai_advanced.html @@ -0,0 +1,78 @@ + + + + Advanced Settings + + + + + + + + + +
+
+

Advanced Settings

+

+ The settings provided in this section offer a more detailed level of control over the text generation + process. It is important to be careful when making changes to these settings without proper + consideration, as doing so may result in degraded quality of responses. +

+

Top P Sampling

+

+ This setting controls how much of the text generated is based on the most likely options. + The top P words with the highest probabilities are considered. A word is then chosen at random, with a + higher chance of selecting words with higher probabilities. +

+

+ Set value to 1 to disable its effect. +

+

Top K Sampling

+

+ This setting limits the number of words to choose from to the top K most likely options. Can be used + together with Top P sampling. +

+

+ Set value to 0 to disable its effect. +

+

Top A Sampling

+

+ This setting allows for a more flexible version of sampling, where the number of words chosen from + the most likely options is automatically determined based on the likelihood distribution of the options, + but instead of choosing the top P or K words, it chooses all words with probabilities above a certain + threshold. +

+

+ Set value to 0 to disable its effect. +

+

Typical Sampling

+

+ This setting selects words randomly from the list of possible words, with each word having an equal + chance of being selected. This method can produce text that is more diverse but may also be less + coherent. +

+

+ Set value to 1 to disable its effect. +

+

Tail Free Sampling

+

+ This setting removes the least probable words from consideration during text generation, which can + improve the quality and coherence of the generated text. +

+

+ Set value to 1 to disable its effect. +

+

Repetition Penalty Slope

+

+ If both this and Repetition Penalty Range are below 0, then repetition penalty will have more effect + closer to the end of the prompt. The higher the value, the stronger the effect. +

+

Set value to 1 for linear interpolation or 0 to disable interpolation.

+
+
+ + + \ No newline at end of file diff --git a/public/scripts/kai-settings.js b/public/scripts/kai-settings.js new file mode 100644 index 000000000..7ad390cc2 --- /dev/null +++ b/public/scripts/kai-settings.js @@ -0,0 +1,83 @@ +import { + saveSettingsDebounced, +} from "../script.js"; + +export { + kai_settings, + loadKoboldSettings, +}; + +const kai_settings = { + top_p: 1, + top_a: 1, + top_k: 0, + typical: 1, + tfs: 1, + rep_pen_slope: 0.9, +}; + +function loadKoboldSettings(preset) { + for (const name of Object.keys(kai_settings)) { + kai_settings[name] = preset[name]; + $(`#${name}`).val(kai_settings[name]); + $(`#${name}_counter`).text(kai_settings[name]); + } +} + +// Cohee's TODO: Merge with sliders block in script.js +const sliders = [ + { + sliderId: "#top_p", + counterId: "#top_p_counter", + format: (val) => val, + setValue: (val) => { kai_settings.top_p = Number(val); }, + }, + { + sliderId: "#top_a", + counterId: "#top_a_counter", + format: (val) => val, + setValue: (val) => { kai_settings.top_a = Number(val); }, + }, + { + sliderId: "#top_k", + counterId: "#top_k_counter", + format: (val) => val, + setValue: (val) => { kai_settings.top_k = Number(val); }, + }, + { + sliderId: "#typical", + counterId: "#typical_counter", + format: (val) => val, + setValue: (val) => { kai_settings.typical = Number(val); }, + }, + { + sliderId: "#tfs", + counterId: "#tfs_counter", + format: (val) => val, + setValue: (val) => { kai_settings.tfs = Number(val); }, + }, + { + sliderId: "#rep_pen_slope", + counterId: "#rep_pen_slope_counter", + format: (val) => val, + setValue: (val) => { kai_settings.rep_pen_slope = Number(val); }, + }, +]; + +$(document).ready(function () { + $('.drawer-toggle').click(function () { + var icon = $(this).find('.drawer-icon'); + icon.toggleClass('down up'); + $(this).closest('.drawer').find('.drawer-content').slideToggle(); + }); + + sliders.forEach(slider => { + $(document).on("input", slider.sliderId, function () { + const value = $(this).val(); + const formattedValue = slider.format(value); + slider.setValue(value); + $(slider.counterId).html(formattedValue); + saveSettingsDebounced(); + }); + }); +}); \ No newline at end of file