From 14ef5d9a6b88f092b2c74a0b5be7fd7b5e577f8f Mon Sep 17 00:00:00 2001 From: Mike Weldon Date: Wed, 2 Aug 2023 18:21:14 -0700 Subject: [PATCH 1/3] Add new NAI presets TeaTime and ProWriter --- .../Pro_Writer-Kayra.settings | 19 +++++++++++++++++++ .../NovelAI Settings/Tea_Time-Kayra.settings | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 public/NovelAI Settings/Pro_Writer-Kayra.settings create mode 100644 public/NovelAI Settings/Tea_Time-Kayra.settings diff --git a/public/NovelAI Settings/Pro_Writer-Kayra.settings b/public/NovelAI Settings/Pro_Writer-Kayra.settings new file mode 100644 index 000000000..99486aff5 --- /dev/null +++ b/public/NovelAI Settings/Pro_Writer-Kayra.settings @@ -0,0 +1,19 @@ +{ + "order": [3, 4, 0], + "temperature": 1.19, + "max_length": 300, + "min_length": 1, + "top_a": 0.116, + "tail_free_sampling": 0.958, + "repetition_penalty": 1.64, + "repetition_penalty_slope": 2.12, + "repetition_penalty_frequency": 0, + "repetition_penalty_presence": 0, + "repetition_penalty_range": 2048, + "use_cache": false, + "return_full_text": false, + "prefix": "vanilla", + "phrase_rep_pen": "medium", + "cfg_scale": 1.0, + "max_context": 7800 +} diff --git a/public/NovelAI Settings/Tea_Time-Kayra.settings b/public/NovelAI Settings/Tea_Time-Kayra.settings new file mode 100644 index 000000000..fb0c08f1b --- /dev/null +++ b/public/NovelAI Settings/Tea_Time-Kayra.settings @@ -0,0 +1,19 @@ +{ + "order": [5, 0, 4], + "temperature": 1, + "max_length": 300, + "min_length": 1, + "top_a": 0.017, + "typical_p": 0.975, + "repetition_penalty": 3, + "repetition_penalty_slope": 0.09, + "repetition_penalty_frequency": 0, + "repetition_penalty_presence": 0, + "repetition_penalty_range": 7680, + "use_cache": false, + "return_full_text": false, + "prefix": "vanilla", + "phrase_rep_pen": "aggressive", + "cfg_scale": 1.0, + "max_context": 7800 +} From 1d0f67c1440d9b5e9d0a852871dba405c648c5a4 Mon Sep 17 00:00:00 2001 From: Mike Weldon Date: Wed, 2 Aug 2023 18:22:06 -0700 Subject: [PATCH 2/3] Add NAI preamble to start of chat buffer --- public/index.html | 16 ++++++++++++++++ public/script.js | 10 +++++++++- public/scripts/nai-settings.js | 16 ++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index e3f0137ed..d15824738 100644 --- a/public/index.html +++ b/public/index.html @@ -807,6 +807,22 @@
+
+
+ Preamble +
+
+
+
+
+ Use style tags to improve the quality of the output +
+
+ +
+
Top P diff --git a/public/script.js b/public/script.js index 3f5f6ea58..67a375942 100644 --- a/public/script.js +++ b/public/script.js @@ -3142,7 +3142,15 @@ function parseTokenCounts(counts, thisPromptBits) { } function adjustChatsSeparator(mesSendString) { - if (power_user.custom_chat_separator && power_user.custom_chat_separator.length) { + if (main_api === 'novel') { + let preamble = "\n***\n" + nai_settings.nai_preamble; + if (!preamble.endsWith('\n')) { + preamble += '\n'; + } + mesSendString = preamble + mesSendString; + } + + else if (power_user.custom_chat_separator && power_user.custom_chat_separator.length) { mesSendString = power_user.custom_chat_separator + '\n' + mesSendString; } diff --git a/public/scripts/nai-settings.js b/public/scripts/nai-settings.js index fd7513b57..bd49687c0 100644 --- a/public/scripts/nai-settings.js +++ b/public/scripts/nai-settings.js @@ -13,6 +13,8 @@ export { getNovelTier, }; +const default_preamble = "[ Style: chat, complex, sensory, visceral ]"; + const nai_settings = { temperature: 0.5, repetition_penalty: 1, @@ -29,6 +31,7 @@ const nai_settings = { model_novel: "euterpe-v2", preset_settings_novel: "Classic-Euterpe", streaming_novel: false, + nai_preamble: default_preamble, }; const nai_tiers = { @@ -76,6 +79,7 @@ function loadNovelSettings(settings) { $(`#model_novel_select option[value=${nai_settings.model_novel}]`).attr("selected", true); $('#model_novel_select').val(nai_settings.model_novel); + if (settings.nai_preamble !== undefined) nai_settings.nai_preamble = settings.nai_preamble; nai_settings.preset_settings_novel = settings.preset_settings_novel; nai_settings.temperature = settings.temperature; nai_settings.repetition_penalty = settings.repetition_penalty; @@ -157,6 +161,7 @@ function loadNovelSettingsUi(ui_settings) { $("#phrase_rep_pen_counter_novel").text(getPhraseRepPenCounter(ui_settings.phrase_rep_pen)); $("#min_length_novel").val(ui_settings.min_length); $("#min_length_counter_novel").text(Number(ui_settings.min_length).toFixed(0)); + $('#nai_preamble_textarea').val(ui_settings.nai_preamble); $("#streaming_novel").prop('checked', ui_settings.streaming_novel); } @@ -334,6 +339,17 @@ export async function generateNovelWithStreaming(generate_data, signal) { } } +$("#nai_preamble_textarea").on('input', function () { + nai_settings.nai_preamble = $('#nai_preamble_textarea').val(); + saveSettingsDebounced(); +}); + +$("#nai_preamble_restore").on('click', function () { + nai_settings.nai_preamble = default_preamble; + $('#nai_preamble_textarea').val(nai_settings.nai_preamble); + saveSettingsDebounced(); +}); + $(document).ready(function () { sliders.forEach(slider => { $(document).on("input", slider.sliderId, function () { From c8b5b7da220b76193cec8677415a7c34579962fb Mon Sep 17 00:00:00 2001 From: Mike Weldon Date: Wed, 2 Aug 2023 23:07:17 -0700 Subject: [PATCH 3/3] Use prose augmenter by default for Kayra --- public/scripts/nai-settings.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/scripts/nai-settings.js b/public/scripts/nai-settings.js index bd49687c0..79331219f 100644 --- a/public/scripts/nai-settings.js +++ b/public/scripts/nai-settings.js @@ -264,6 +264,13 @@ export function getNovelGenerationData(finalPromt, this_settings, this_amount_ge .map(t => getTextTokens(tokenizerType, t)) : undefined; + let useInstruct = false; + if (isNewModel) { + // NovelAI claims they scan backwards 1000 characters (not tokens!) to look for instruct brackets. That's really short. + const tail = finalPromt.slice(-1500); + useInstruct = tail.includes("}"); + } + return { "input": finalPromt, "model": nai_settings.model_novel, @@ -291,7 +298,7 @@ export function getNovelGenerationData(finalPromt, this_settings, this_amount_ge "use_cache": false, "use_string": true, "return_full_text": false, - "prefix": isNewModel ? "special_instruct" : "vanilla", + "prefix": useInstruct ? "special_instruct" : (isNewModel ? "special_proseaugmenter" : "vanilla"), "order": this_settings.order, "streaming": nai_settings.streaming_novel, };