From d1a654f41f3021b117321bcdbef046daa7f85084 Mon Sep 17 00:00:00 2001 From: AlpinDale Date: Sun, 1 Dec 2024 02:37:11 +0000 Subject: [PATCH 1/5] add to index.html --- public/index.html | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/public/index.html b/public/index.html index c00ab84f7..e28179009 100644 --- a/public/index.html +++ b/public/index.html @@ -1718,6 +1718,73 @@ Load default order +
+
+
+ Sampler Order +
+
+ Aphrodite only. Samplers will be applied in a top-down order. Use with caution. +
+
+
+ Top P & Top K + 0 +
+
+ Top A + 1 +
+
+ Min P + 2 +
+
+ Tail Free Sampling + 3 +
+
+ Typical P + 4 +
+
+ Dynatemp & Temperature + 5 +
+
+ Penalties + 6 +
+
+ DRY + 7 +
+
+ No Repeat Ngram + 8 +
+
+ Top Nsigma + 9 +
+
+ Eta Cutoff + 10 +
+
+ Epsilon Cutoff + 11 +
+
+ Cubic & Quadratic Sampling + 12 +
+
+ XTC + 13 +
+
+

From 80c8e83f09e9d2a743cb5e5e10d3285f1a93a1ef Mon Sep 17 00:00:00 2001 From: AlpinDale Date: Tue, 3 Dec 2024 01:46:51 +0000 Subject: [PATCH 2/5] use strings instead of IDs --- public/index.html | 96 +++++++++--------------------- public/scripts/samplerSelect.js | 13 ++++ public/scripts/textgen-settings.js | 34 +++++++++++ 3 files changed, 76 insertions(+), 67 deletions(-) diff --git a/public/index.html b/public/index.html index 5d1e54aec..c85ffc237 100644 --- a/public/index.html +++ b/public/index.html @@ -1718,73 +1718,6 @@ Load default order

-
-
-
- Sampler Order -
-
- Aphrodite only. Samplers will be applied in a top-down order. Use with caution. -
-
-
- Top P & Top K - 0 -
-
- Top A - 1 -
-
- Min P - 2 -
-
- Tail Free Sampling - 3 -
-
- Typical P - 4 -
-
- Dynatemp & Temperature - 5 -
-
- Penalties - 6 -
-
- DRY - 7 -
-
- No Repeat Ngram - 8 -
-
- Top Nsigma - 9 -
-
- Eta Cutoff - 10 -
-
- Epsilon Cutoff - 11 -
-
- Cubic & Quadratic Sampling - 12 -
-
- XTC - 13 -
-
-

@@ -1841,6 +1774,35 @@ Load default order

+
+
+

+ Sampler Order +
+

+
+ Aphrodite only. Determines the order of samplers. +
+
+
DRY
+
Penalties
+
No Repeat Ngram
+
Dynatemp & Temperature
+
Top Nsigma
+
Top P & Top K
+
Top A
+
Min P
+
Tail-Free Sampling
+
Eta Cutoff
+
Epsilon Cutoff
+
Typical P
+
Cubic and Quadratic Sampling
+
XTC
+
+ +
diff --git a/public/scripts/samplerSelect.js b/public/scripts/samplerSelect.js index c949b8e91..35f5629ba 100644 --- a/public/scripts/samplerSelect.js +++ b/public/scripts/samplerSelect.js @@ -129,6 +129,10 @@ function setSamplerListListeners() { relatedDOMElement = $('#sampler_priority_block_ooba'); } + if (samplerName === 'samplers_priorities') { //this is for aphrodite's sampler priority + relatedDOMElement = $('#sampler_priority_block_aphrodite'); + } + if (samplerName === 'penalty_alpha') { //contrastive search only has one sampler, does it need its own block? relatedDOMElement = $('#contrastiveSearchBlock'); } @@ -237,6 +241,11 @@ async function listSamplers(main_api, arrayOnly = false) { displayname = 'Ooba Sampler Priority Block'; } + if (sampler === 'samplers_priorities') { //this is for aphrodite's sampler priority + targetDOMelement = $('#sampler_priority_block_aphrodite'); + displayname = 'Aphrodite Sampler Priority Block'; + } + if (sampler === 'penalty_alpha') { //contrastive search only has one sampler, does it need its own block? targetDOMelement = $('#contrastiveSearchBlock'); displayname = 'Contrast Search Block'; @@ -373,6 +382,10 @@ export async function validateDisabledSamplers(redraw = false) { relatedDOMElement = $('#sampler_priority_block_ooba'); } + if (sampler === 'samplers_priorities') { //this is for aphrodite's sampler priority + relatedDOMElement = $('#sampler_priority_block_aphrodite'); + } + if (sampler === 'dry_multiplier') { relatedDOMElement = $('#dryBlock'); targetDisplayType = 'block'; diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 0dfae364f..077bf6911 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -89,6 +89,22 @@ const OOBA_DEFAULT_ORDER = [ 'encoder_repetition_penalty', 'no_repeat_ngram', ]; +const APHRODITE_DEFAULT_ORDER = [ + 'dry', + 'penalties', + 'no_repeat_ngram', + 'temperature', + 'top_nsigma', + 'top_p_top_k', + 'top_a', + 'min_p', + 'tfs', + 'eta_cutoff', + 'epsilon_cutoff', + 'typical_p', + 'quadratic', + 'xtc' +]; const BIAS_KEY = '#textgenerationwebui_api-settings'; // Maybe let it be configurable in the future? @@ -170,6 +186,7 @@ const settings = { banned_tokens: '', sampler_priority: OOBA_DEFAULT_ORDER, samplers: LLAMACPP_DEFAULT_ORDER, + samplers_priorties: APHRODITE_DEFAULT_ORDER, ignore_eos_token: false, spaces_between_special_tokens: true, speculative_ngram: false, @@ -259,6 +276,7 @@ export const setting_names = [ 'sampler_order', 'sampler_priority', 'samplers', + 'samplers_priorities', 'n', 'logit_bias', 'custom_model', @@ -627,6 +645,13 @@ jQuery(function () { saveSettingsDebounced(); }); + $('#aphrodite_default_order').on('click', function () { + sortOobaItemsByOrder(APHRODITE_DEFAULT_ORDER); + settings.samplers_priorties = APHRODITE_DEFAULT_ORDER; + console.log('Default samplers order loaded:', settings.samplers_priorties); + saveSettingsDebounced(); + }); + $('#textgen_type').on('change', function () { const type = String($(this).val()); settings.type = type; @@ -835,6 +860,14 @@ function setSettingByName(setting, value, trigger) { return; } + if ('samplers_priority' === setting) { + value = Array.isArray(value) ? value : APHRODITE_DEFAULT_ORDER; + insertMissingArrayItems(APHRODITE_DEFAULT_ORDER, value); + sortOobaItemsByOrder(value); + settings.samplers_priorties = value; + return; + } + if ('samplers' === setting) { value = Array.isArray(value) ? value : LLAMACPP_DEFAULT_ORDER; insertMissingArrayItems(LLAMACPP_DEFAULT_ORDER, value); @@ -1259,6 +1292,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, 'nsigma': settings.nsigma, 'custom_token_bans': toIntArray(banned_tokens), 'no_repeat_ngram_size': settings.no_repeat_ngram_size, + 'sampler_priority': settings.samplers_priorties, }; if (settings.type === OPENROUTER) { From add108b8216820a38a49e89a04c055c17d77d088 Mon Sep 17 00:00:00 2001 From: AlpinDale Date: Sat, 7 Dec 2024 12:36:10 +0000 Subject: [PATCH 3/5] fix the JS issue where both ooba and aphro were using the same container ID --- public/index.html | 2 +- public/scripts/textgen-settings.js | 34 ++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/public/index.html b/public/index.html index 5d54b7d48..d8a679675 100644 --- a/public/index.html +++ b/public/index.html @@ -1783,7 +1783,7 @@
Aphrodite only. Determines the order of samplers.
-
+
DRY
Penalties
No Repeat Ngram
diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 21c4202a8..e5d018b74 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -571,6 +571,15 @@ function sortOobaItemsByOrder(orderArray) { }); } +function sortAphroditeItemsByOrder(orderArray) { + const $container = $('#sampler_priority_container_aphrodite'); + + orderArray.forEach((name) => { + const $item = $container.find(`[data-name="${name}"]`).detach(); + $container.append($item); + }); +} + jQuery(function () { $('#koboldcpp_order').sortable({ delay: getSortableDelay(), @@ -624,6 +633,19 @@ jQuery(function () { }, }); + $('#sampler_priority_container_aphrodite').sortable({ + delay: getSortableDelay(), + stop: function () { + const order = []; + $('#sampler_priority_container_aphrodite').children().each(function () { + order.push($(this).data('name')); + }); + settings.samplers_priorities = order; + console.log('Samplers reordered:', settings.samplers_priorities); + saveSettingsDebounced(); + }, + }); + $('#tabby_json_schema').on('input', function () { const json_schema_string = String($(this).val()); @@ -643,9 +665,9 @@ jQuery(function () { }); $('#aphrodite_default_order').on('click', function () { - sortOobaItemsByOrder(APHRODITE_DEFAULT_ORDER); - settings.samplers_priorties = APHRODITE_DEFAULT_ORDER; - console.log('Default samplers order loaded:', settings.samplers_priorties); + sortAphroditeItemsByOrder(APHRODITE_DEFAULT_ORDER); + settings.samplers_priorities = APHRODITE_DEFAULT_ORDER; + console.log('Default samplers order loaded:', settings.samplers_priorities); saveSettingsDebounced(); }); @@ -860,8 +882,8 @@ function setSettingByName(setting, value, trigger) { if ('samplers_priority' === setting) { value = Array.isArray(value) ? value : APHRODITE_DEFAULT_ORDER; insertMissingArrayItems(APHRODITE_DEFAULT_ORDER, value); - sortOobaItemsByOrder(value); - settings.samplers_priorties = value; + sortAphroditeItemsByOrder(value); + settings.samplers_priorities = value; return; } @@ -1289,7 +1311,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, 'nsigma': settings.nsigma, 'custom_token_bans': toIntArray(banned_tokens), 'no_repeat_ngram_size': settings.no_repeat_ngram_size, - 'sampler_priority': settings.samplers_priorties, + 'sampler_priority': settings.type === APHRODITE ? settings.samplers_priorities : undefined, }; if (settings.type === OPENROUTER) { From 3ed5d892f70448c209efe242d7f074968a0d8911 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:13:19 +0200 Subject: [PATCH 4/5] Fix bugs with the settings --- 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 e5d018b74..ccbdc91c6 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -96,7 +96,7 @@ const APHRODITE_DEFAULT_ORDER = [ 'epsilon_cutoff', 'typical_p', 'quadratic', - 'xtc' + 'xtc', ]; const BIAS_KEY = '#textgenerationwebui_api-settings'; @@ -179,7 +179,7 @@ const settings = { banned_tokens: '', sampler_priority: OOBA_DEFAULT_ORDER, samplers: LLAMACPP_DEFAULT_ORDER, - samplers_priorties: APHRODITE_DEFAULT_ORDER, + samplers_priorities: APHRODITE_DEFAULT_ORDER, ignore_eos_token: false, spaces_between_special_tokens: true, speculative_ngram: false, @@ -879,7 +879,7 @@ function setSettingByName(setting, value, trigger) { return; } - if ('samplers_priority' === setting) { + if ('samplers_priorities' === setting) { value = Array.isArray(value) ? value : APHRODITE_DEFAULT_ORDER; insertMissingArrayItems(APHRODITE_DEFAULT_ORDER, value); sortAphroditeItemsByOrder(value); From 323b9407df6433f4251a780bad549cb6ed2d640b Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:26:57 +0200 Subject: [PATCH 5/5] Small cosmetic fixes --- public/index.html | 2 +- public/scripts/textgen-settings.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index d8a679675..233ab710f 100644 --- a/public/index.html +++ b/public/index.html @@ -1780,7 +1780,7 @@ Sampler Order
-
+
Aphrodite only. Determines the order of samplers.
diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index ccbdc91c6..1a2306a72 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -571,7 +571,12 @@ function sortOobaItemsByOrder(orderArray) { }); } +/** + * Sorts the Aphrodite sampler items by the given order. + * @param {string[]} orderArray Sampler order array. + */ function sortAphroditeItemsByOrder(orderArray) { + console.debug('Preset samplers order: ', orderArray); const $container = $('#sampler_priority_container_aphrodite'); orderArray.forEach((name) => {