From 8efe0b6437a47e75b423030b8ec854e2f3121984 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 20 Sep 2024 22:42:56 +0300 Subject: [PATCH] Add Min P for Novel --- default/content/presets/novel/Asper-Kayra.json | 3 ++- .../content/presets/novel/Blended-Coffee-Kayra.json | 3 ++- default/content/presets/novel/Blook-Kayra.json | 3 ++- default/content/presets/novel/Carefree-Kayra.json | 3 ++- default/content/presets/novel/CosmicCube-Kayra.json | 3 ++- default/content/presets/novel/Edgewise-Clio.json | 3 ++- .../content/presets/novel/Fresh-Coffee-Clio.json | 3 ++- .../content/presets/novel/Fresh-Coffee-Kayra.json | 3 ++- .../presets/novel/Green-Active-Writer-Kayra.json | 3 ++- default/content/presets/novel/Keelback-Clio.json | 3 ++- default/content/presets/novel/Long-Press-Clio.json | 3 ++- default/content/presets/novel/Pilotfish-Kayra.json | 3 ++- default/content/presets/novel/Pro_Writer-Kayra.json | 3 ++- default/content/presets/novel/Stelenes-Kayra.json | 3 ++- default/content/presets/novel/Talker-Chat-Clio.json | 3 ++- default/content/presets/novel/Tea_Time-Kayra.json | 3 ++- default/content/presets/novel/Tesseract-Kayra.json | 3 ++- default/content/presets/novel/Vingt-Un-Clio.json | 3 ++- .../content/presets/novel/Writers-Daemon-Kayra.json | 3 ++- public/index.html | 13 +++++++++++++ public/scripts/nai-settings.js | 12 ++++++++++++ src/endpoints/novelai.js | 1 + 22 files changed, 64 insertions(+), 19 deletions(-) diff --git a/default/content/presets/novel/Asper-Kayra.json b/default/content/presets/novel/Asper-Kayra.json index c611949cc..8c0817c81 100644 --- a/default/content/presets/novel/Asper-Kayra.json +++ b/default/content/presets/novel/Asper-Kayra.json @@ -16,5 +16,6 @@ "prefix": "vanilla", "cfg_scale": 1, "phrase_rep_pen": "medium", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Blended-Coffee-Kayra.json b/default/content/presets/novel/Blended-Coffee-Kayra.json index 62dad3a4d..1b0b0e144 100644 --- a/default/content/presets/novel/Blended-Coffee-Kayra.json +++ b/default/content/presets/novel/Blended-Coffee-Kayra.json @@ -15,5 +15,6 @@ "prefix": "vanilla", "phrase_rep_pen": "medium", "cfg_scale": 1.55, - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Blook-Kayra.json b/default/content/presets/novel/Blook-Kayra.json index 87d845a1a..9710d5544 100644 --- a/default/content/presets/novel/Blook-Kayra.json +++ b/default/content/presets/novel/Blook-Kayra.json @@ -16,5 +16,6 @@ "prefix": "vanilla", "phrase_rep_pen": "very_aggressive", "cfg_scale": 1.3, - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Carefree-Kayra.json b/default/content/presets/novel/Carefree-Kayra.json index 28e75a371..b8626d72d 100644 --- a/default/content/presets/novel/Carefree-Kayra.json +++ b/default/content/presets/novel/Carefree-Kayra.json @@ -17,5 +17,6 @@ "prefix": "vanilla", "cfg_scale": 1, "phrase_rep_pen": "aggressive", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/CosmicCube-Kayra.json b/default/content/presets/novel/CosmicCube-Kayra.json index ae95c4f97..48fbf3dc6 100644 --- a/default/content/presets/novel/CosmicCube-Kayra.json +++ b/default/content/presets/novel/CosmicCube-Kayra.json @@ -16,5 +16,6 @@ "prefix": "vanilla", "phrase_rep_pen": "off", "cfg_scale": 1.48, - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Edgewise-Clio.json b/default/content/presets/novel/Edgewise-Clio.json index 77ecaef71..f5961bf64 100644 --- a/default/content/presets/novel/Edgewise-Clio.json +++ b/default/content/presets/novel/Edgewise-Clio.json @@ -17,5 +17,6 @@ "prefix": "vanilla", "cfg_scale": 1, "phrase_rep_pen": "very_light", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Fresh-Coffee-Clio.json b/default/content/presets/novel/Fresh-Coffee-Clio.json index ad520adfb..3517b7010 100644 --- a/default/content/presets/novel/Fresh-Coffee-Clio.json +++ b/default/content/presets/novel/Fresh-Coffee-Clio.json @@ -18,5 +18,6 @@ "prefix": "vanilla", "cfg_scale": 1, "phrase_rep_pen": "very_light", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Fresh-Coffee-Kayra.json b/default/content/presets/novel/Fresh-Coffee-Kayra.json index 383fcba1c..a7583f5bc 100644 --- a/default/content/presets/novel/Fresh-Coffee-Kayra.json +++ b/default/content/presets/novel/Fresh-Coffee-Kayra.json @@ -16,5 +16,6 @@ "prefix": "vanilla", "cfg_scale": 1, "phrase_rep_pen": "off", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Green-Active-Writer-Kayra.json b/default/content/presets/novel/Green-Active-Writer-Kayra.json index 73b18a087..d096c1845 100644 --- a/default/content/presets/novel/Green-Active-Writer-Kayra.json +++ b/default/content/presets/novel/Green-Active-Writer-Kayra.json @@ -16,5 +16,6 @@ "prefix": "vanilla", "phrase_rep_pen": "very_aggressive", "cfg_scale": 1.4, - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Keelback-Clio.json b/default/content/presets/novel/Keelback-Clio.json index 9412a116b..bd14f3b4d 100644 --- a/default/content/presets/novel/Keelback-Clio.json +++ b/default/content/presets/novel/Keelback-Clio.json @@ -18,5 +18,6 @@ "prefix": "vanilla", "cfg_scale": 1, "phrase_rep_pen": "very_light", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Long-Press-Clio.json b/default/content/presets/novel/Long-Press-Clio.json index c978924b3..a14fe81b1 100644 --- a/default/content/presets/novel/Long-Press-Clio.json +++ b/default/content/presets/novel/Long-Press-Clio.json @@ -18,5 +18,6 @@ "prefix": "vanilla", "cfg_scale": 1, "phrase_rep_pen": "very_light", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Pilotfish-Kayra.json b/default/content/presets/novel/Pilotfish-Kayra.json index 4a8d06ac2..9e8029d86 100644 --- a/default/content/presets/novel/Pilotfish-Kayra.json +++ b/default/content/presets/novel/Pilotfish-Kayra.json @@ -18,5 +18,6 @@ "prefix": "vanilla", "phrase_rep_pen": "medium", "cfg_scale": 1.35, - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Pro_Writer-Kayra.json b/default/content/presets/novel/Pro_Writer-Kayra.json index a020d462b..eba7bab73 100644 --- a/default/content/presets/novel/Pro_Writer-Kayra.json +++ b/default/content/presets/novel/Pro_Writer-Kayra.json @@ -16,5 +16,6 @@ "prefix": "vanilla", "phrase_rep_pen": "medium", "cfg_scale": 1.0, - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Stelenes-Kayra.json b/default/content/presets/novel/Stelenes-Kayra.json index dae13cecd..ae67941cf 100644 --- a/default/content/presets/novel/Stelenes-Kayra.json +++ b/default/content/presets/novel/Stelenes-Kayra.json @@ -13,5 +13,6 @@ "return_full_text": false, "prefix": "vanilla", "phrase_rep_pen": "medium", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Talker-Chat-Clio.json b/default/content/presets/novel/Talker-Chat-Clio.json index 136845554..677a2b838 100644 --- a/default/content/presets/novel/Talker-Chat-Clio.json +++ b/default/content/presets/novel/Talker-Chat-Clio.json @@ -18,5 +18,6 @@ "prefix": "vanilla", "cfg_scale": 1, "phrase_rep_pen": "very_light", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Tea_Time-Kayra.json b/default/content/presets/novel/Tea_Time-Kayra.json index af57676ce..abd1d63ba 100644 --- a/default/content/presets/novel/Tea_Time-Kayra.json +++ b/default/content/presets/novel/Tea_Time-Kayra.json @@ -15,5 +15,6 @@ "prefix": "vanilla", "phrase_rep_pen": "aggressive", "cfg_scale": 1.0, - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Tesseract-Kayra.json b/default/content/presets/novel/Tesseract-Kayra.json index 919461937..808e4eaf0 100644 --- a/default/content/presets/novel/Tesseract-Kayra.json +++ b/default/content/presets/novel/Tesseract-Kayra.json @@ -14,5 +14,6 @@ "prefix": "vanilla", "phrase_rep_pen": "aggressive", "cfg_scale": 1.3, - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Vingt-Un-Clio.json b/default/content/presets/novel/Vingt-Un-Clio.json index 296b8c564..6251c8aa3 100644 --- a/default/content/presets/novel/Vingt-Un-Clio.json +++ b/default/content/presets/novel/Vingt-Un-Clio.json @@ -18,5 +18,6 @@ "prefix": "vanilla", "cfg_scale": 1, "phrase_rep_pen": "very_light", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/default/content/presets/novel/Writers-Daemon-Kayra.json b/default/content/presets/novel/Writers-Daemon-Kayra.json index 8ae98884c..ca1402fcc 100644 --- a/default/content/presets/novel/Writers-Daemon-Kayra.json +++ b/default/content/presets/novel/Writers-Daemon-Kayra.json @@ -17,5 +17,6 @@ "return_full_text": false, "prefix": "vanilla", "phrase_rep_pen": "very_aggressive", - "max_context": 7800 + "max_context": 7800, + "min_p": 0 } diff --git a/public/index.html b/public/index.html index 64659cc82..3f10e64f5 100644 --- a/public/index.html +++ b/public/index.html @@ -323,6 +323,19 @@ +
+
+ Min P +
+
+
+ +
+
+ +
+
+
TFS diff --git a/public/scripts/nai-settings.js b/public/scripts/nai-settings.js index 6b59033a8..6ac80c2dd 100644 --- a/public/scripts/nai-settings.js +++ b/public/scripts/nai-settings.js @@ -38,6 +38,7 @@ export const nai_settings = { top_p: 0.75, top_a: 0.08, typical_p: 0.975, + min_p: 0, min_length: 1, model_novel: 'clio-v1', preset_settings_novel: 'Talker-Chat-Clio', @@ -151,6 +152,7 @@ export function loadNovelPreset(preset) { nai_settings.order = preset.order || default_order; nai_settings.logit_bias = preset.logit_bias || []; nai_settings.preamble = preset.preamble || default_preamble; + nai_settings.min_p = preset.min_p || 0; loadNovelSettingsUi(nai_settings); } @@ -188,6 +190,7 @@ export function loadNovelSettings(settings) { nai_settings.banned_tokens = settings.banned_tokens || ''; nai_settings.order = settings.order || default_order; nai_settings.logit_bias = settings.logit_bias || []; + nai_settings.min_p = settings.min_p || 0; loadNovelSettingsUi(nai_settings); } @@ -227,6 +230,8 @@ function loadNovelSettingsUi(ui_settings) { $('#nai_prefix').val(ui_settings.prefix || 'vanilla'); $('#nai_cfg_uc').val(ui_settings.cfg_uc || ''); $('#nai_banned_tokens').val(ui_settings.banned_tokens || ''); + $('#min_p_novel').val(ui_settings.min_p); + $('#min_p_counter_novel').val(Number(ui_settings.min_p).toFixed(3)); $('#streaming_novel').prop('checked', ui_settings.streaming_novel); sortItemsByOrder(ui_settings.order); @@ -336,6 +341,12 @@ const sliders = [ format: (val) => val, setValue: (val) => { nai_settings.banned_tokens = val; }, }, + { + sliderId: '#min_p_novel', + counterId: '#min_p_counter_novel', + format: (val) => Number(val).toFixed(3), + setValue: (val) => { nai_settings.min_p = Number(val); }, + }, ]; function getBadWordIds(banned_tokens, tokenizerType) { @@ -469,6 +480,7 @@ export function getNovelGenerationData(finalPrompt, settings, maxLength, isImper 'top_a': Number(nai_settings.top_a), 'top_p': Number(nai_settings.top_p), 'top_k': Number(nai_settings.top_k), + 'min_p': Number(nai_settings.min_p), 'typical_p': Number(nai_settings.typical_p), 'mirostat_lr': Number(nai_settings.mirostat_lr), 'mirostat_tau': Number(nai_settings.mirostat_tau), diff --git a/src/endpoints/novelai.js b/src/endpoints/novelai.js index d21602cc2..14aba9b84 100644 --- a/src/endpoints/novelai.js +++ b/src/endpoints/novelai.js @@ -175,6 +175,7 @@ router.post('/generate', jsonParser, async function (req, res) { 'prefix': req.body.prefix, 'order': req.body.order, 'num_logprobs': req.body.num_logprobs, + 'min_p': req.body.min_p, }, };