Unhide advanced parameters for Novel

This commit is contained in:
Cohee 2023-07-23 02:09:03 +03:00
parent dd69fd3934
commit 1b9ca4c9d9
10 changed files with 220 additions and 74 deletions

View File

@ -14,7 +14,10 @@
"repetition_penalty_range": 8192,
"repetition_penalty_frequency": 0.03,
"repetition_penalty_presence": 0.005,
"repetition_penalty_slope": 0,
"top_a": 0.075,
"top_k": 79,
"top_p": 0.95
"top_p": 0.95,
"typical_p": 1,
"max_context": 8192
}

View File

@ -5,6 +5,8 @@
"min_length": 1,
"top_k": 25,
"top_p": 1,
"top_a": 0,
"typical_p": 1,
"tail_free_sampling": 0.925,
"repetition_penalty": 1.9,
"repetition_penalty_range": 768,

View File

@ -4,6 +4,8 @@
"max_length": 40,
"min_length": 1,
"top_a": 0.022,
"top_k": 0,
"top_p": 1,
"typical_p": 0.9,
"tail_free_sampling": 0.956,
"repetition_penalty": 1.25,

View File

@ -5,6 +5,7 @@
"min_length": 1,
"top_k": 25,
"top_a": 0.3,
"top_p": 1,
"typical_p": 0.96,
"tail_free_sampling": 0.895,
"repetition_penalty": 1.0125,

View File

@ -6,6 +6,7 @@
"top_k": 79,
"top_p": 0.95,
"top_a": 0.075,
"typical_p": 1,
"tail_free_sampling": 0.989,
"repetition_penalty": 1.5,
"repetition_penalty_range": 8192,

View File

@ -5,6 +5,7 @@
"min_length": 1,
"top_k": 0,
"top_p": 0.912,
"top_a": 1,
"typical_p": 0.912,
"tail_free_sampling": 0.921,
"repetition_penalty": 1.21,

View File

@ -137,7 +137,7 @@
<span class="note-link-span">?</span>
</a>
</h3>
<select id="settings_perset">
<select id="settings_perset" data-preset-manager-for="kobold,koboldhorde">
<option value="gui" data-i18n="guikoboldaisettings">GUI KoboldAI Settings</option>
</select>
</div>
@ -148,7 +148,7 @@
<span class="note-link-span">?</span>
</a>
</h3>
<select id="settings_perset_novel">
<select id="settings_perset_novel" data-preset-manager-for="novel">
<option value="gui" data-i18n="default">Default</option>
</select>
</div>
@ -171,7 +171,7 @@
<div id="textgenerationwebui_api-presets">
<h3><span data-i18n="text gen webio(ooba)preset">Text Gen WebUI (ooba) presets</span>
</h3>
<select id="settings_preset_textgenerationwebui">
<select id="settings_preset_textgenerationwebui" data-preset-manager-for="textgenerationwebui">
</select>
</div>
<hr>
@ -777,6 +777,81 @@
</div>
</div>
<div id="novel_api-settings">
<div class="range-block">
<div class="range-block-title" data-i18n="Top P">
Top P
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="top_p_novel" name="volume" min="0" max="1" step="0.01">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="top_p_novel" id="top_p_counter_novel">
select
</div>
</div>
</div>
</div>
<div class="range-block">
<div class="range-block-title" data-i18n="Top A">
Top A
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="top_a_novel" name="volume" min="0" max="1" step="0.01">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="top_a_novel" id="top_a_counter_novel">
select
</div>
</div>
</div>
</div>
<div class="range-block">
<div class="range-block-title" data-i18n="Top K">
Top K
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="top_k_novel" name="volume" min="0" max="300" step="1">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="top_k_novel" id="top_k_counter_novel">
select
</div>
</div>
</div>
</div>
<div class="range-block">
<div class="range-block-title" data-i18n="Typical P">
Typical P
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="typical_p_novel" name="volume" min="0" max="1" step="0.01">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="typical_p_novel" id="typical_p_counter_novel">
select
</div>
</div>
</div>
</div>
<div class="range-block">
<div class="range-block-title" data-i18n="Min Length">
Min Length
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="min_length_novel" name="volume" min="0" max="1024" step="1">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="min_length_novel" id="min_length_counter_novel">
select
</div>
</div>
</div>
</div>
</div>
<div id="textgenerationwebui_api-settings">
<div class="range-block">

View File

@ -4918,11 +4918,6 @@ async function getSettings(type) {
novelai_setting_names = {};
novelai_setting_names = arr_holder;
nai_settings.preset_settings_novel = settings.preset_settings_novel;
$(
`#settings_perset_novel option[value=${novelai_setting_names[nai_settings.preset_settings_novel]}]`
).attr("selected", "true");
//Load AI model config settings
amount_gen = settings.amount_gen;
@ -4935,10 +4930,11 @@ async function getSettings(type) {
showSwipeButtons();
// Kobold
loadKoboldSettings(settings);
loadKoboldSettings(settings.kai_settings ?? settings);
// Novel
loadNovelSettings(settings);
loadNovelSettings(settings.nai_settings ?? settings);
$(`#settings_perset_novel option[value=${novelai_setting_names[nai_settings.preset_settings_novel]}]`).attr("selected", "true");
// TextGen
loadTextGenSettings(data, settings);
@ -5058,8 +5054,8 @@ async function saveSettings(type) {
context_settings: context_settings,
tags: tags,
tag_map: tag_map,
...nai_settings,
...kai_settings,
nai_settings: nai_settings,
kai_settings: kai_settings,
...oai_settings,
}, null, 4),
beforeSend: function () {

View File

@ -11,13 +11,18 @@ export {
};
const nai_settings = {
temp_novel: 0.5,
rep_pen_novel: 1,
rep_pen_size_novel: 100,
rep_pen_slope_novel: 0,
rep_pen_freq_novel: 0,
rep_pen_presence_novel: 0,
tail_free_sampling_novel: 0.68,
temperature: 0.5,
repetition_penalty: 1,
repetition_penalty_range: 100,
repetition_penalty_slope: 0,
repetition_penalty_frequency: 0,
repetition_penalty_presence: 0,
tail_free_sampling: 0.68,
top_k: 0,
top_p: 1,
top_a: 1,
typical_p: 1,
min_length: 0,
model_novel: "euterpe-v2",
preset_settings_novel: "Classic-Euterpe",
streaming_novel: false,
@ -45,13 +50,18 @@ function loadNovelPreset(preset) {
$("#max_context_counter").text(`${preset.max_context}`);
$("#rep_pen_size_novel").attr('max', preset.max_context);
nai_settings.temp_novel = preset.temperature;
nai_settings.rep_pen_novel = preset.repetition_penalty;
nai_settings.rep_pen_size_novel = preset.repetition_penalty_range;
nai_settings.rep_pen_slope_novel = preset.repetition_penalty_slope;
nai_settings.rep_pen_freq_novel = preset.repetition_penalty_frequency;
nai_settings.rep_pen_presence_novel = preset.repetition_penalty_presence;
nai_settings.tail_free_sampling_novel = preset.tail_free_sampling;
nai_settings.temperature = preset.temperature;
nai_settings.repetition_penalty = preset.repetition_penalty;
nai_settings.repetition_penalty_range = preset.repetition_penalty_range;
nai_settings.repetition_penalty_slope = preset.repetition_penalty_slope;
nai_settings.repetition_penalty_frequency = preset.repetition_penalty_frequency;
nai_settings.repetition_penalty_presence = preset.repetition_penalty_presence;
nai_settings.tail_free_sampling = preset.tail_free_sampling;
nai_settings.top_k = preset.top_k;
nai_settings.top_p = preset.top_p;
nai_settings.top_a = preset.top_a;
nai_settings.typical_p = preset.typical_p;
nai_settings.min_length = preset.min_length;
loadNovelSettingsUi(nai_settings);
}
@ -59,33 +69,58 @@ function loadNovelSettings(settings) {
//load the rest of the Novel settings without any checks
nai_settings.model_novel = settings.model_novel;
$(`#model_novel_select option[value=${nai_settings.model_novel}]`).attr("selected", true);
$('#model_novel_select').val(nai_settings.model_novel);
nai_settings.temp_novel = settings.temp_novel;
nai_settings.rep_pen_novel = settings.rep_pen_novel;
nai_settings.rep_pen_size_novel = settings.rep_pen_size_novel;
nai_settings.rep_pen_slope_novel = settings.rep_pen_slope_novel;
nai_settings.rep_pen_freq_novel = settings.rep_pen_freq_novel;
nai_settings.rep_pen_presence_novel = settings.rep_pen_presence_novel;
nai_settings.tail_free_sampling_novel = settings.tail_free_sampling_novel;
nai_settings.preset_settings_novel = settings.preset_settings_novel;
nai_settings.temperature = settings.temperature;
nai_settings.repetition_penalty = settings.repetition_penalty;
nai_settings.repetition_penalty_range = settings.repetition_penalty_range;
nai_settings.repetition_penalty_slope = settings.repetition_penalty_slope;
nai_settings.repetition_penalty_frequency = settings.repetition_penalty_frequency;
nai_settings.repetition_penalty_presence = settings.repetition_penalty_presence;
nai_settings.tail_free_sampling = settings.tail_free_sampling;
nai_settings.top_k = settings.top_k;
nai_settings.top_p = settings.top_p;
nai_settings.top_a = settings.top_a;
nai_settings.typical_p = settings.typical_p;
nai_settings.min_length = settings.min_length;
nai_settings.streaming_novel = !!settings.streaming_novel;
loadNovelSettingsUi(nai_settings);
// reload the preset to migrate any new settings
for (const key of Object.keys(nai_settings)) {
if (typeof nai_settings[key] === 'number' && Number.isNaN(nai_settings[key])) {
$("#settings_perset_novel").trigger("change");
}
}
}
function loadNovelSettingsUi(ui_settings) {
$("#temp_novel").val(ui_settings.temp_novel);
$("#temp_counter_novel").text(Number(ui_settings.temp_novel).toFixed(2));
$("#rep_pen_novel").val(ui_settings.rep_pen_novel);
$("#rep_pen_counter_novel").text(Number(ui_settings.rep_pen_novel).toFixed(2));
$("#rep_pen_size_novel").val(ui_settings.rep_pen_size_novel);
$("#rep_pen_size_counter_novel").text(Number(ui_settings.rep_pen_size_novel).toFixed(0));
$("#rep_pen_slope_novel").val(ui_settings.rep_pen_slope_novel);
$("#rep_pen_slope_counter_novel").text(Number(`${ui_settings.rep_pen_slope_novel}`).toFixed(2));
$("#rep_pen_freq_novel").val(ui_settings.rep_pen_freq_novel);
$("#rep_pen_freq_counter_novel").text(Number(ui_settings.rep_pen_freq_novel).toFixed(5));
$("#rep_pen_presence_novel").val(ui_settings.rep_pen_presence_novel);
$("#rep_pen_presence_counter_novel").text(Number(ui_settings.rep_pen_presence_novel).toFixed(3));
$("#tail_free_sampling_novel").val(ui_settings.tail_free_sampling_novel);
$("#tail_free_sampling_counter_novel").text(Number(ui_settings.tail_free_sampling_novel).toFixed(3));
$("#temp_novel").val(ui_settings.temperature);
$("#temp_counter_novel").text(Number(ui_settings.temperature).toFixed(2));
$("#rep_pen_novel").val(ui_settings.repetition_penalty);
$("#rep_pen_counter_novel").text(Number(ui_settings.repetition_penalty).toFixed(2));
$("#rep_pen_size_novel").val(ui_settings.repetition_penalty_range);
$("#rep_pen_size_counter_novel").text(Number(ui_settings.repetition_penalty_range).toFixed(0));
$("#rep_pen_slope_novel").val(ui_settings.repetition_penalty_slope);
$("#rep_pen_slope_counter_novel").text(Number(`${ui_settings.repetition_penalty_slope}`).toFixed(2));
$("#rep_pen_freq_novel").val(ui_settings.repetition_penalty_frequency);
$("#rep_pen_freq_counter_novel").text(Number(ui_settings.repetition_penalty_frequency).toFixed(5));
$("#rep_pen_presence_novel").val(ui_settings.repetition_penalty_presence);
$("#rep_pen_presence_counter_novel").text(Number(ui_settings.repetition_penalty_presence).toFixed(3));
$("#tail_free_sampling_novel").val(ui_settings.tail_free_sampling);
$("#tail_free_sampling_counter_novel").text(Number(ui_settings.tail_free_sampling).toFixed(3));
$("#top_k_novel").val(ui_settings.top_k);
$("#top_k_counter_novel").text(Number(ui_settings.top_k).toFixed(0));
$("#top_p_novel").val(ui_settings.top_p);
$("#top_p_counter_novel").text(Number(ui_settings.top_p).toFixed(2));
$("#top_a_novel").val(ui_settings.top_a);
$("#top_a_counter_novel").text(Number(ui_settings.top_a).toFixed(2));
$("#typical_p_novel").val(ui_settings.typical_p);
$("#typical_p_counter_novel").text(Number(ui_settings.typical_p).toFixed(2));
$("#min_length_novel").val(ui_settings.min_length);
$("#min_length_counter_novel").text(Number(ui_settings.min_length).toFixed(0));
$("#streaming_novel").prop('checked', ui_settings.streaming_novel);
}
@ -94,43 +129,73 @@ const sliders = [
sliderId: "#temp_novel",
counterId: "#temp_counter_novel",
format: (val) => Number(val).toFixed(2),
setValue: (val) => { nai_settings.temp_novel = Number(val).toFixed(2); },
setValue: (val) => { nai_settings.temperature = Number(val).toFixed(2); },
},
{
sliderId: "#rep_pen_novel",
counterId: "#rep_pen_counter_novel",
format: (val) => Number(val).toFixed(2),
setValue: (val) => { nai_settings.rep_pen_novel = Number(val).toFixed(2); },
setValue: (val) => { nai_settings.repetition_penalty = Number(val).toFixed(2); },
},
{
sliderId: "#rep_pen_size_novel",
counterId: "#rep_pen_size_counter_novel",
format: (val) => `${val}`,
setValue: (val) => { nai_settings.rep_pen_size_novel = Number(val).toFixed(0); },
setValue: (val) => { nai_settings.repetition_penalty_range = Number(val).toFixed(0); },
},
{
sliderId: "#rep_pen_slope_novel",
counterId: "#rep_pen_slope_counter_novel",
format: (val) => `${val}`,
setValue: (val) => { nai_settings.rep_pen_slope_novel = Number(val).toFixed(2); },
setValue: (val) => { nai_settings.repetition_penalty_slope = Number(val).toFixed(2); },
},
{
sliderId: "#rep_pen_freq_novel",
counterId: "#rep_pen_freq_counter_novel",
format: (val) => `${val}`,
setValue: (val) => { nai_settings.rep_pen_freq_novel = Number(val).toFixed(5); },
setValue: (val) => { nai_settings.repetition_penalty_frequency = Number(val).toFixed(5); },
},
{
sliderId: "#rep_pen_presence_novel",
counterId: "#rep_pen_presence_counter_novel",
format: (val) => `${val}`,
setValue: (val) => { nai_settings.rep_pen_presence_novel = Number(val).toFixed(3); },
setValue: (val) => { nai_settings.repetition_penalty_presence = Number(val).toFixed(3); },
},
{
sliderId: "#tail_free_sampling_novel",
counterId: "#tail_free_sampling_counter_novel",
format: (val) => `${val}`,
setValue: (val) => { nai_settings.tail_free_sampling_novel = Number(val).toFixed(3); },
setValue: (val) => { nai_settings.tail_free_sampling = Number(val).toFixed(3); },
},
{
sliderId: "#top_k_novel",
counterId: "#top_k_counter_novel",
format: (val) => `${val}`,
setValue: (val) => { nai_settings.top_k = Number(val).toFixed(0); },
},
{
sliderId: "#top_p_novel",
counterId: "#top_p_counter_novel",
format: (val) => Number(val).toFixed(2),
setValue: (val) => { nai_settings.top_p = Number(val).toFixed(2); },
},
{
sliderId: "#top_a_novel",
counterId: "#top_a_counter_novel",
format: (val) => Number(val).toFixed(2),
setValue: (val) => { nai_settings.top_a = Number(val).toFixed(2); },
},
{
sliderId: "#typical_p_novel",
counterId: "#typical_p_counter_novel",
format: (val) => Number(val).toFixed(2),
setValue: (val) => { nai_settings.typical_p = Number(val).toFixed(2); },
},
{
sliderId: "#min_length_novel",
counterId: "#min_length_counter_novel",
format: (val) => `${val}`,
setValue: (val) => { nai_settings.min_length = Number(val).toFixed(0); },
},
];
@ -139,19 +204,19 @@ export function getNovelGenerationData(finalPromt, this_settings, this_amount_ge
"input": finalPromt,
"model": nai_settings.model_novel,
"use_string": true,
"temperature": parseFloat(nai_settings.temp_novel),
"temperature": parseFloat(nai_settings.temperature),
"max_length": this_amount_gen, // this_settings.max_length, // <= why?
"min_length": this_settings.min_length,
"tail_free_sampling": parseFloat(nai_settings.tail_free_sampling_novel),
"repetition_penalty": parseFloat(nai_settings.rep_pen_novel),
"repetition_penalty_range": parseInt(nai_settings.rep_pen_size_novel),
"repetition_penalty_slope": parseFloat(nai_settings.rep_pen_slope_novel),
"repetition_penalty_frequency": parseFloat(nai_settings.rep_pen_freq_novel),
"repetition_penalty_presence": parseFloat(nai_settings.rep_pen_presence_novel),
"top_a": this_settings.top_a,
"top_p": this_settings.top_p,
"top_k": this_settings.top_k,
"typical_p": this_settings.typical_p,
"min_length": parseInt(nai_settings.min_length),
"tail_free_sampling": parseFloat(nai_settings.tail_free_sampling),
"repetition_penalty": parseFloat(nai_settings.repetition_penalty),
"repetition_penalty_range": parseInt(nai_settings.repetition_penalty_range),
"repetition_penalty_slope": parseFloat(nai_settings.repetition_penalty_slope),
"repetition_penalty_frequency": parseFloat(nai_settings.repetition_penalty_frequency),
"repetition_penalty_presence": parseFloat(nai_settings.repetition_penalty_presence),
"top_a": parseFloat(nai_settings.top_a),
"top_p": parseFloat(nai_settings.top_p),
"top_k": parseInt(nai_settings.top_k),
"typical_p": parseFloat(nai_settings.typical_p),
//"stop_sequences": {{187}},
//bad_words_ids = {{50256}, {0}, {1}};
"generate_until_sentence": true,
@ -212,7 +277,7 @@ $(document).ready(function () {
const value = $(this).val();
const formattedValue = slider.format(value);
slider.setValue(value);
$(slider.counterId).html(formattedValue);
$(slider.counterId).text(formattedValue);
console.log('saving');
saveSettingsDebounced();
});

View File

@ -11,7 +11,7 @@ export {
generateTextGenWithStreaming,
}
let textgenerationwebui_settings = {
const textgenerationwebui_settings = {
temp: 0.7,
top_p: 0.5,
top_k: 40,