From d66be24518631a86046bb5228414c9b1c1463d91 Mon Sep 17 00:00:00 2001 From: Alexander Abushady Date: Fri, 5 Jan 2024 02:08:44 -0500 Subject: [PATCH] DynaTemp UI v2 With DynaTemp moving into main KCPP now ST can have DynaTemp too! --- public/index.html | 23 +++++++++++++++++++++++ public/scripts/kai-settings.js | 22 +++++++++++++++++++++- public/scripts/power-user.js | 8 +++++++- public/scripts/textgen-settings.js | 9 +++++++++ src/ai_horde/index.d.ts | 6 ++++++ 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index dfbdcf032..e7b2fbbc6 100644 --- a/public/index.html +++ b/public/index.html @@ -1315,6 +1315,29 @@ +
+

DynaTemp +
+

+
+
+ +
+
+ Min Temp + + +
+
+ Max Temp + + +
+
+

Contrast Search
diff --git a/public/scripts/kai-settings.js b/public/scripts/kai-settings.js index f2f295dc3..d2f321005 100644 --- a/public/scripts/kai-settings.js +++ b/public/scripts/kai-settings.js @@ -31,6 +31,9 @@ export const kai_settings = { use_default_badwordsids: false, grammar: '', seed: -1, + dynatemp: false, + min_temp: 0.1, + max_temp: 2.0, }; /** @@ -46,6 +49,7 @@ export const kai_flags = { can_use_mirostat: false, can_use_grammar: false, can_use_min_p: false, + can_use_dynatemp: false, }; const defaultValues = Object.freeze(structuredClone(kai_settings)); @@ -139,7 +143,9 @@ export function getKoboldGenerationData(finalPrompt, settings, maxLength, maxCon use_default_badwordsids: (kai_flags.can_use_default_badwordsids || isHorde) ? kai_settings.use_default_badwordsids : undefined, grammar: (kai_flags.can_use_grammar || isHorde) ? substituteParams(kai_settings.grammar) : undefined, sampler_seed: kai_settings.seed >= 0 ? kai_settings.seed : undefined, - + dynatemp: (kai_flags.can_use_dynatemp || isHorde) ? kai_settings.dynatemp : false, + min_temp: (kai_flags.can_use_dynatemp || isHorde) ? kai_settings.min_temp : undefined, + max_temp: (kai_flags.can_use_dynatemp || isHorde) ? kai_settings.max_temp : undefined, api_server, }; return generate_data; @@ -306,6 +312,20 @@ const sliders = [ format: (val) => val, setValue: (val) => { kai_settings.seed = Number(val); }, }, + { + name: 'min_temp', + sliderId: '#min_temp_kobold', + counterId: '#min_temp_counter_kobold', + format: (val) => val, + setValue: (val) => { kai_settings.min_temp = Number(val); }, + }, + { + name: 'max_temp', + sliderId: '#max_temp_kobold', + counterId: '#max_temp_counter_kobold', + format: (val) => val, + setValue: (val) => { kai_settings.max_temp = Number(val); }, + }, ]; export function setKoboldFlags(koboldUnitedVersion, koboldCppVersion) { diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 84fad8c65..02c210bbb 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -604,6 +604,10 @@ async function CreateZenSliders(elmnt) { sliderID == 'rep_pen_range') { decimals = 0; } + if (sliderID == 'min_temp_textgenerationwebui' || + sliderID == 'max_temp_textgenerationwebui') { + decimals = 2; + } if (sliderID == 'eta_cutoff_textgenerationwebui' || sliderID == 'epsilon_cutoff_textgenerationwebui') { numSteps = 50; @@ -633,7 +637,9 @@ async function CreateZenSliders(elmnt) { } if (sliderID == 'mirostat_eta_textgenerationwebui' || sliderID == 'penalty_alpha_textgenerationwebui' || - sliderID == 'length_penalty_textgenerationwebui') { + sliderID == 'length_penalty_textgenerationwebui' || + sliderID == 'min_temp_textgenerationwebui' || + sliderID == 'max_temp_textgenerationwebui') { numSteps = 50; } //customize off values diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index c5af0b583..2ac4ecf82 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -79,6 +79,9 @@ const settings = { presence_pen: 0, do_sample: true, early_stopping: false, + dynatemp: false, + min_temp: 0, + max_temp: 2.0, seed: -1, preset: 'Default', add_bos_token: true, @@ -135,6 +138,9 @@ const setting_names = [ 'num_beams', 'length_penalty', 'min_length', + 'dynatemp', + 'min_temp', + 'max_temp', 'encoder_rep_pen', 'freq_pen', 'presence_pen', @@ -698,6 +704,9 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, 'length_penalty': settings.length_penalty, 'early_stopping': settings.early_stopping, 'add_bos_token': settings.add_bos_token, + 'dynatemp': settings.dynatemp, + 'min_temp': settings.min_temp, + 'max_temp': settings.max_temp, 'stopping_strings': getStoppingStrings(isImpersonate, isContinue), 'stop': getStoppingStrings(isImpersonate, isContinue), 'truncation_length': max_context, diff --git a/src/ai_horde/index.d.ts b/src/ai_horde/index.d.ts index dda1c170f..9f6c4f756 100644 --- a/src/ai_horde/index.d.ts +++ b/src/ai_horde/index.d.ts @@ -901,6 +901,12 @@ export interface ModelGenerationInputKobold { min_p?: number; /** Typical sampling value. */ typical?: number; + /** DynaTemp sampling activataion. */ + dynatemp?: boolean; + /** DynaTemp minimum temperature value. */ + min_temp?: number; + /** DynaTemp maximum temperature value. */ + max_temp?: number; /** Array of integers representing the sampler order to be used */ sample_order?: number[]; }