diff --git a/default/settings.json b/default/settings.json
index 4383798ff..c351ab04e 100644
--- a/default/settings.json
+++ b/default/settings.json
@@ -61,6 +61,14 @@
"min_p",
"mirostat"
],
+ "samplers": [
+ "top_k",
+ "tfs_z",
+ "typical_p",
+ "top_p",
+ "min_p",
+ "temperature"
+ ],
"mirostat_mode": 0,
"mirostat_tau": 5,
"mirostat_eta": 0.1,
diff --git a/public/index.html b/public/index.html
index c2920d1dd..9b4e86234 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1550,6 +1550,27 @@
Load default order
+
+
+
+ Samplers Order
+
+
+
+ llama.cpp only. Determines the order of samplers. If Mirostat mode is not 0, sampler order is ignored.
+
+
+
Temperature
+
Top K
+
Top P
+
Typical P
+
Tail Free Sampling
+
Min P
+
+
+
diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js
index ec0ba468e..70a797710 100644
--- a/public/scripts/textgen-settings.js
+++ b/public/scripts/textgen-settings.js
@@ -35,6 +35,15 @@ export const textgen_types = {
};
const { MANCER, APHRODITE, TABBY, TOGETHERAI, OOBA, OLLAMA, LLAMACPP, INFERMATICAI } = textgen_types;
+
+const LLAMACPP_DEFAULT_ORDER = [
+ 'top_k',
+ 'tfs_z',
+ 'typical_p',
+ 'top_p',
+ 'min_p',
+ 'temperature',
+];
const OOBA_DEFAULT_ORDER = [
'temperature',
'dynamic_temperature',
@@ -113,6 +122,7 @@ const settings = {
grammar_string: '',
banned_tokens: '',
sampler_priority: OOBA_DEFAULT_ORDER,
+ samplers: LLAMACPP_DEFAULT_ORDER,
//n_aphrodite: 1,
//best_of_aphrodite: 1,
ignore_eos_token_aphrodite: false,
@@ -189,6 +199,7 @@ const setting_names = [
//'prompt_log_probs_aphrodite'
'sampler_order',
'sampler_priority',
+ 'samplers',
'n',
'logit_bias',
'custom_model',
@@ -456,6 +467,16 @@ function sortKoboldItemsByOrder(orderArray) {
}
}
+function sortLlamacppItemsByOrder(orderArray) {
+ console.debug('Preset samplers order: ', orderArray);
+ const $container = $('#llamacpp_samplers_sortable');
+
+ orderArray.forEach((name) => {
+ const $item = $container.find(`[data-name="${name}"]`).detach();
+ $container.append($item);
+ });
+}
+
function sortOobaItemsByOrder(orderArray) {
console.debug('Preset samplers order: ', orderArray);
const $container = $('#sampler_priority_container');
@@ -486,6 +507,26 @@ jQuery(function () {
saveSettingsDebounced();
});
+ $('#llamacpp_samplers_sortable').sortable({
+ delay: getSortableDelay(),
+ stop: function () {
+ const order = [];
+ $('#llamacpp_samplers_sortable').children().each(function () {
+ order.push($(this).data('name'));
+ });
+ settings.samplers = order;
+ console.log('Samplers reordered:', settings.samplers);
+ saveSettingsDebounced();
+ },
+ });
+
+ $('#llamacpp_samplers_default_order').on('click', function () {
+ sortLlamacppItemsByOrder(LLAMACPP_DEFAULT_ORDER);
+ settings.samplers = LLAMACPP_DEFAULT_ORDER;
+ console.log('Default samplers order loaded:', settings.samplers);
+ saveSettingsDebounced();
+ });
+
$('#sampler_priority_container').sortable({
delay: getSortableDelay(),
stop: function () {
@@ -595,7 +636,7 @@ jQuery(function () {
for (const [id, value] of Object.entries(inputs)) {
const inputElement = $(`#${id}`);
if (inputElement.prop('type') === 'checkbox') {
- inputElement.prop('checked', value);
+ inputElement.prop('checked', value).trigger('input');
} else if (inputElement.prop('type') === 'number') {
inputElement.val(value).trigger('input');
} else {
@@ -681,6 +722,13 @@ function setSettingByName(setting, value, trigger) {
return;
}
+ if ('samplers' === setting) {
+ value = Array.isArray(value) ? value : LLAMACPP_DEFAULT_ORDER;
+ sortLlamacppItemsByOrder(value);
+ settings.samplers = value;
+ return;
+ }
+
if ('logit_bias' === setting) {
settings.logit_bias = Array.isArray(value) ? value : [];
return;
@@ -901,6 +949,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
'dynatemp_exponent': settings.dynatemp ? settings.dynatemp_exponent : 1,
'smoothing_factor': settings.smoothing_factor,
'sampler_priority': settings.type === OOBA ? settings.sampler_priority : undefined,
+ 'samplers': settings.type === LLAMACPP ? settings.samplers : undefined,
'stopping_strings': getStoppingStrings(isImpersonate, isContinue),
'stop': getStoppingStrings(isImpersonate, isContinue),
'truncation_length': max_context,