From 6f7e7b85ab866ed60b1e4b26868f9889e4917cbc Mon Sep 17 00:00:00 2001 From: 50h100a Date: Sun, 24 Mar 2024 14:45:37 -0400 Subject: [PATCH 1/4] For Mancer: - Allow logprobs (works) - Allow multiswipe (not yet) - Adjust visible samplers Fix: 0 logprob is 100% chance, handle accordingly. --- public/index.html | 34 ++++++++++++++++-------------- public/script.js | 3 ++- public/scripts/logprobs.js | 2 +- public/scripts/textgen-settings.js | 20 ++++++++++++++---- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/public/index.html b/public/index.html index 7c82d0b1b..fd08949a0 100644 --- a/public/index.html +++ b/public/index.html @@ -1167,7 +1167,7 @@
-
+
Multiple swipes per generation
@@ -1228,7 +1228,7 @@
-
+
Epsilon Cutoff
@@ -1236,7 +1236,7 @@
-
+
Eta Cutoff
@@ -1274,7 +1274,7 @@
-
+
Min Length @@ -1284,20 +1284,22 @@
-
+

-
- Smoothing Factor - - -
-
- Smoothing Curve - - +
+
+ Smoothing Factor + + +
+
+ Smoothing Curve + + +
-
+

@@ -1492,7 +1494,7 @@
-
+

CFG
diff --git a/public/script.js b/public/script.js index 5f2e92c4d..8d25226c7 100644 --- a/public/script.js +++ b/public/script.js @@ -4531,6 +4531,7 @@ function parseAndSaveLogprobs(data, continueFrom) { logprobs = data?.completion_probabilities?.map(x => parseTextgenLogprobs(x.content, [x])) || null; } break; case textgen_types.APHRODITE: + case textgen_types.MANCER: case textgen_types.TABBY: { logprobs = parseTabbyLogprobs(data) || null; } break; @@ -4585,7 +4586,7 @@ function extractMultiSwipes(data, type) { return swipes; } - if (main_api === 'openai' || (main_api === 'textgenerationwebui' && textgen_settings.type === textgen_types.APHRODITE)) { + if (main_api === 'openai' || main_api === 'mancer' || (main_api === 'textgenerationwebui' && textgen_settings.type === textgen_types.APHRODITE)) { if (!Array.isArray(data.choices)) { return swipes; } diff --git a/public/scripts/logprobs.js b/public/scripts/logprobs.js index 44884b898..2aef6e61b 100644 --- a/public/scripts/logprobs.js +++ b/public/scripts/logprobs.js @@ -139,7 +139,7 @@ function renderTopLogprobs() { const candidates = topLogprobs .sort(([, logA], [, logB]) => logB - logA) .map(([text, log]) => { - if (log < 0) { + if (log <= 0) { const probability = Math.exp(log); sum += probability; return [text, probability, log]; diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 7f22d0311..e12146f83 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -850,6 +850,7 @@ export function parseTextgenLogprobs(token, logprobs) { switch (settings.type) { case TABBY: case APHRODITE: + case MANCER: case OOBA: { /** @type {Record[]} */ const topLogprobs = logprobs.top_logprobs; @@ -971,6 +972,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, 'typical_p': settings.typical_p, 'typical': settings.typical_p, 'sampler_seed': settings.seed, + 'seed': settings.seed, 'min_p': settings.min_p, 'repetition_penalty': settings.rep_pen, 'frequency_penalty': settings.freq_pen, @@ -1000,12 +1002,12 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, 'skip_special_tokens': settings.skip_special_tokens, 'top_a': settings.top_a, 'tfs': settings.tfs, - 'epsilon_cutoff': settings.type === OOBA ? settings.epsilon_cutoff : undefined, - 'eta_cutoff': settings.type === OOBA ? settings.eta_cutoff : undefined, + 'epsilon_cutoff': [OOBA, MANCER].includes(settings.type) ? settings.epsilon_cutoff : undefined, + 'eta_cutoff': [OOBA, MANCER].includes(settings.type) ? settings.eta_cutoff : undefined, 'mirostat_mode': settings.mirostat_mode, 'mirostat_tau': settings.mirostat_tau, 'mirostat_eta': settings.mirostat_eta, - 'custom_token_bans': settings.type === textgen_types.APHRODITE ? + 'custom_token_bans': [APHRODITE, MANCER].includes(settings.type) ? toIntArray(getCustomTokenBans()) : getCustomTokenBans(), 'api_type': settings.type, @@ -1022,7 +1024,6 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, 'penalty_alpha': settings.type === OOBA ? settings.penalty_alpha : undefined, 'temperature_last': (settings.type === OOBA || settings.type === APHRODITE || settings.type == TABBY) ? settings.temperature_last : undefined, 'do_sample': settings.type === OOBA ? settings.do_sample : undefined, - 'seed': settings.seed, 'guidance_scale': cfgValues?.guidanceScale?.value ?? settings.guidance_scale ?? 1, 'negative_prompt': cfgValues?.negativePrompt ?? substituteParams(settings.negative_prompt) ?? '', 'grammar_string': settings.grammar_string, @@ -1045,6 +1046,17 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, //'logprobs': settings.log_probs_aphrodite, //'prompt_logprobs': settings.prompt_log_probs_aphrodite, }; + + if (settings.type === MANCER) { + params.n = canMultiSwipe ? settings.n : 1 + params.epsilon_cutoff /= 1000 + params.eta_cutoff /= 1000 + params.dynatemp_mode = + params.dynatemp_min = params.dynamic_temperature ? params.dynatemp_low : 0 + params.dynatemp_max = params.dynamic_temperature ? params.dynatemp_high : 0 + delete params.dynatemp_low, params.dynatemp_high + } + if (settings.type === APHRODITE) { params = Object.assign(params, aphroditeParams); } else { From df805d692b7c4db54cda87b99428251ade2f4d0a Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:42:27 +0200 Subject: [PATCH 2/4] Fix some code --- public/script.js | 2 +- public/scripts/textgen-settings.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/public/script.js b/public/script.js index 8d25226c7..9349097c8 100644 --- a/public/script.js +++ b/public/script.js @@ -4586,7 +4586,7 @@ function extractMultiSwipes(data, type) { return swipes; } - if (main_api === 'openai' || main_api === 'mancer' || (main_api === 'textgenerationwebui' && textgen_settings.type === textgen_types.APHRODITE)) { + if (main_api === 'openai' || (main_api === 'textgenerationwebui' && [MANCER, APHRODITE].includes(textgen_settings.type))) { if (!Array.isArray(data.choices)) { return swipes; } diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index e12146f83..4236762e6 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -1048,13 +1048,13 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, }; if (settings.type === MANCER) { - params.n = canMultiSwipe ? settings.n : 1 - params.epsilon_cutoff /= 1000 - params.eta_cutoff /= 1000 - params.dynatemp_mode = - params.dynatemp_min = params.dynamic_temperature ? params.dynatemp_low : 0 - params.dynatemp_max = params.dynamic_temperature ? params.dynatemp_high : 0 - delete params.dynatemp_low, params.dynatemp_high + params.n = canMultiSwipe ? settings.n : 1; + params.epsilon_cutoff /= 1000; + params.eta_cutoff /= 1000; + params.dynatemp_mode = params.dynamic_temperature ? true : false; + params.dynatemp_min = params.dynamic_temperature ? params.dynatemp_low : 0; + params.dynatemp_max = params.dynamic_temperature ? params.dynatemp_high : 0; + delete params.dynatemp_low, params.dynatemp_high; } if (settings.type === APHRODITE) { From 4caa3b4f208c45e8c7ea612f849410a3c4c66463 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:49:12 +0200 Subject: [PATCH 3/4] And then there were none --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index fd08949a0..66de9a383 100644 --- a/public/index.html +++ b/public/index.html @@ -1494,7 +1494,7 @@

-
+

CFG
From 8b092adc149f7c7875011a0752d558e673b663a4 Mon Sep 17 00:00:00 2001 From: 50h100a <136940546+50h100a@users.noreply.github.com> Date: Mon, 25 Mar 2024 12:25:03 -0400 Subject: [PATCH 4/4] Use mode enum to toggle dynatemp behavior. --- public/scripts/textgen-settings.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 4236762e6..b16b67173 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -1051,9 +1051,9 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, params.n = canMultiSwipe ? settings.n : 1; params.epsilon_cutoff /= 1000; params.eta_cutoff /= 1000; - params.dynatemp_mode = params.dynamic_temperature ? true : false; - params.dynatemp_min = params.dynamic_temperature ? params.dynatemp_low : 0; - params.dynatemp_max = params.dynamic_temperature ? params.dynatemp_high : 0; + params.dynatemp_mode = params.dynamic_temperature ? 1 : 0; + params.dynatemp_min = params.dynatemp_low; + params.dynatemp_max = params.dynatemp_high; delete params.dynatemp_low, params.dynatemp_high; }