diff --git a/public/index.html b/public/index.html index 99dd6a030..233ab710f 100644 --- a/public/index.html +++ b/public/index.html @@ -1774,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 19c270e49..1a2306a72 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -82,6 +82,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? @@ -163,6 +179,7 @@ const settings = { banned_tokens: '', sampler_priority: OOBA_DEFAULT_ORDER, samplers: LLAMACPP_DEFAULT_ORDER, + samplers_priorities: APHRODITE_DEFAULT_ORDER, ignore_eos_token: false, spaces_between_special_tokens: true, speculative_ngram: false, @@ -256,6 +273,7 @@ export const setting_names = [ 'sampler_order', 'sampler_priority', 'samplers', + 'samplers_priorities', 'n', 'logit_bias', 'custom_model', @@ -553,6 +571,20 @@ 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) => { + const $item = $container.find(`[data-name="${name}"]`).detach(); + $container.append($item); + }); +} + jQuery(function () { $('#koboldcpp_order').sortable({ delay: getSortableDelay(), @@ -606,6 +638,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()); @@ -624,6 +669,13 @@ jQuery(function () { saveSettingsDebounced(); }); + $('#aphrodite_default_order').on('click', function () { + sortAphroditeItemsByOrder(APHRODITE_DEFAULT_ORDER); + settings.samplers_priorities = APHRODITE_DEFAULT_ORDER; + console.log('Default samplers order loaded:', settings.samplers_priorities); + saveSettingsDebounced(); + }); + $('#textgen_type').on('change', function () { const type = String($(this).val()); settings.type = type; @@ -832,6 +884,14 @@ function setSettingByName(setting, value, trigger) { return; } + if ('samplers_priorities' === setting) { + value = Array.isArray(value) ? value : APHRODITE_DEFAULT_ORDER; + insertMissingArrayItems(APHRODITE_DEFAULT_ORDER, value); + sortAphroditeItemsByOrder(value); + settings.samplers_priorities = value; + return; + } + if ('samplers' === setting) { value = Array.isArray(value) ? value : LLAMACPP_DEFAULT_ORDER; insertMissingArrayItems(LLAMACPP_DEFAULT_ORDER, value); @@ -1256,6 +1316,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.type === APHRODITE ? settings.samplers_priorities : undefined, }; if (settings.type === OPENROUTER) {