From e2f88e6243c08c63e051ae4e2127ac9de1648bda Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 21 Sep 2024 00:24:52 +0300 Subject: [PATCH] Add Unified sampling for Novel --- .../content/presets/novel/Asper-Kayra.json | 5 +- .../presets/novel/Blended-Coffee-Kayra.json | 5 +- .../content/presets/novel/Blook-Kayra.json | 5 +- .../content/presets/novel/Carefree-Kayra.json | 5 +- .../presets/novel/CosmicCube-Kayra.json | 5 +- .../content/presets/novel/Edgewise-Clio.json | 5 +- .../presets/novel/Fresh-Coffee-Clio.json | 5 +- .../presets/novel/Fresh-Coffee-Kayra.json | 5 +- .../novel/Green-Active-Writer-Kayra.json | 5 +- .../content/presets/novel/Keelback-Clio.json | 5 +- .../presets/novel/Long-Press-Clio.json | 5 +- .../presets/novel/Pilotfish-Kayra.json | 5 +- .../presets/novel/Pro_Writer-Kayra.json | 5 +- .../content/presets/novel/Stelenes-Kayra.json | 5 +- .../presets/novel/Talker-Chat-Clio.json | 5 +- .../content/presets/novel/Tea_Time-Kayra.json | 5 +- .../presets/novel/Tesseract-Kayra.json | 5 +- .../content/presets/novel/Vingt-Un-Clio.json | 5 +- .../presets/novel/Writers-Daemon-Kayra.json | 5 +- public/index.html | 363 ++++++++++-------- public/scripts/nai-settings.js | 36 ++ src/endpoints/novelai.js | 3 + 22 files changed, 321 insertions(+), 176 deletions(-) diff --git a/default/content/presets/novel/Asper-Kayra.json b/default/content/presets/novel/Asper-Kayra.json index 8c0817c81..0fa8f9979 100644 --- a/default/content/presets/novel/Asper-Kayra.json +++ b/default/content/presets/novel/Asper-Kayra.json @@ -17,5 +17,8 @@ "cfg_scale": 1, "phrase_rep_pen": "medium", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Blended-Coffee-Kayra.json b/default/content/presets/novel/Blended-Coffee-Kayra.json index 1b0b0e144..de830aee7 100644 --- a/default/content/presets/novel/Blended-Coffee-Kayra.json +++ b/default/content/presets/novel/Blended-Coffee-Kayra.json @@ -16,5 +16,8 @@ "phrase_rep_pen": "medium", "cfg_scale": 1.55, "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Blook-Kayra.json b/default/content/presets/novel/Blook-Kayra.json index 9710d5544..fd35d9920 100644 --- a/default/content/presets/novel/Blook-Kayra.json +++ b/default/content/presets/novel/Blook-Kayra.json @@ -17,5 +17,8 @@ "phrase_rep_pen": "very_aggressive", "cfg_scale": 1.3, "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Carefree-Kayra.json b/default/content/presets/novel/Carefree-Kayra.json index b8626d72d..bba4378fc 100644 --- a/default/content/presets/novel/Carefree-Kayra.json +++ b/default/content/presets/novel/Carefree-Kayra.json @@ -18,5 +18,8 @@ "cfg_scale": 1, "phrase_rep_pen": "aggressive", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/CosmicCube-Kayra.json b/default/content/presets/novel/CosmicCube-Kayra.json index 48fbf3dc6..ed9318449 100644 --- a/default/content/presets/novel/CosmicCube-Kayra.json +++ b/default/content/presets/novel/CosmicCube-Kayra.json @@ -17,5 +17,8 @@ "phrase_rep_pen": "off", "cfg_scale": 1.48, "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Edgewise-Clio.json b/default/content/presets/novel/Edgewise-Clio.json index f5961bf64..ff5f517f5 100644 --- a/default/content/presets/novel/Edgewise-Clio.json +++ b/default/content/presets/novel/Edgewise-Clio.json @@ -18,5 +18,8 @@ "cfg_scale": 1, "phrase_rep_pen": "very_light", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Fresh-Coffee-Clio.json b/default/content/presets/novel/Fresh-Coffee-Clio.json index 3517b7010..15df88905 100644 --- a/default/content/presets/novel/Fresh-Coffee-Clio.json +++ b/default/content/presets/novel/Fresh-Coffee-Clio.json @@ -19,5 +19,8 @@ "cfg_scale": 1, "phrase_rep_pen": "very_light", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Fresh-Coffee-Kayra.json b/default/content/presets/novel/Fresh-Coffee-Kayra.json index a7583f5bc..4abbc5bec 100644 --- a/default/content/presets/novel/Fresh-Coffee-Kayra.json +++ b/default/content/presets/novel/Fresh-Coffee-Kayra.json @@ -17,5 +17,8 @@ "cfg_scale": 1, "phrase_rep_pen": "off", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Green-Active-Writer-Kayra.json b/default/content/presets/novel/Green-Active-Writer-Kayra.json index d096c1845..7fe1e6eb1 100644 --- a/default/content/presets/novel/Green-Active-Writer-Kayra.json +++ b/default/content/presets/novel/Green-Active-Writer-Kayra.json @@ -17,5 +17,8 @@ "phrase_rep_pen": "very_aggressive", "cfg_scale": 1.4, "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Keelback-Clio.json b/default/content/presets/novel/Keelback-Clio.json index bd14f3b4d..821bbdd42 100644 --- a/default/content/presets/novel/Keelback-Clio.json +++ b/default/content/presets/novel/Keelback-Clio.json @@ -19,5 +19,8 @@ "cfg_scale": 1, "phrase_rep_pen": "very_light", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Long-Press-Clio.json b/default/content/presets/novel/Long-Press-Clio.json index a14fe81b1..3bd67c84a 100644 --- a/default/content/presets/novel/Long-Press-Clio.json +++ b/default/content/presets/novel/Long-Press-Clio.json @@ -19,5 +19,8 @@ "cfg_scale": 1, "phrase_rep_pen": "very_light", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Pilotfish-Kayra.json b/default/content/presets/novel/Pilotfish-Kayra.json index 9e8029d86..87cd24ba4 100644 --- a/default/content/presets/novel/Pilotfish-Kayra.json +++ b/default/content/presets/novel/Pilotfish-Kayra.json @@ -19,5 +19,8 @@ "phrase_rep_pen": "medium", "cfg_scale": 1.35, "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Pro_Writer-Kayra.json b/default/content/presets/novel/Pro_Writer-Kayra.json index eba7bab73..11a18f031 100644 --- a/default/content/presets/novel/Pro_Writer-Kayra.json +++ b/default/content/presets/novel/Pro_Writer-Kayra.json @@ -17,5 +17,8 @@ "phrase_rep_pen": "medium", "cfg_scale": 1.0, "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Stelenes-Kayra.json b/default/content/presets/novel/Stelenes-Kayra.json index ae67941cf..68cb0b8de 100644 --- a/default/content/presets/novel/Stelenes-Kayra.json +++ b/default/content/presets/novel/Stelenes-Kayra.json @@ -14,5 +14,8 @@ "prefix": "vanilla", "phrase_rep_pen": "medium", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Talker-Chat-Clio.json b/default/content/presets/novel/Talker-Chat-Clio.json index 677a2b838..390cbf178 100644 --- a/default/content/presets/novel/Talker-Chat-Clio.json +++ b/default/content/presets/novel/Talker-Chat-Clio.json @@ -19,5 +19,8 @@ "cfg_scale": 1, "phrase_rep_pen": "very_light", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Tea_Time-Kayra.json b/default/content/presets/novel/Tea_Time-Kayra.json index abd1d63ba..2142a0c2b 100644 --- a/default/content/presets/novel/Tea_Time-Kayra.json +++ b/default/content/presets/novel/Tea_Time-Kayra.json @@ -16,5 +16,8 @@ "phrase_rep_pen": "aggressive", "cfg_scale": 1.0, "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Tesseract-Kayra.json b/default/content/presets/novel/Tesseract-Kayra.json index 808e4eaf0..0948dbe60 100644 --- a/default/content/presets/novel/Tesseract-Kayra.json +++ b/default/content/presets/novel/Tesseract-Kayra.json @@ -15,5 +15,8 @@ "phrase_rep_pen": "aggressive", "cfg_scale": 1.3, "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Vingt-Un-Clio.json b/default/content/presets/novel/Vingt-Un-Clio.json index 6251c8aa3..bf0eb8f23 100644 --- a/default/content/presets/novel/Vingt-Un-Clio.json +++ b/default/content/presets/novel/Vingt-Un-Clio.json @@ -19,5 +19,8 @@ "cfg_scale": 1, "phrase_rep_pen": "very_light", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/default/content/presets/novel/Writers-Daemon-Kayra.json b/default/content/presets/novel/Writers-Daemon-Kayra.json index ca1402fcc..70561d483 100644 --- a/default/content/presets/novel/Writers-Daemon-Kayra.json +++ b/default/content/presets/novel/Writers-Daemon-Kayra.json @@ -18,5 +18,8 @@ "prefix": "vanilla", "phrase_rep_pen": "very_aggressive", "max_context": 7800, - "min_p": 0 + "min_p": 0, + "math1_temp": 1, + "math1_quad": 0, + "math1_quad_entropy_scale": 0 } diff --git a/public/index.html b/public/index.html index 3f10e64f5..26de88a79 100644 --- a/public/index.html +++ b/public/index.html @@ -349,6 +349,136 @@ +
+
+ Top P +
+
+
+ +
+
+ +
+
+
+
+
+ Top A +
+
+
+ +
+
+ +
+
+
+
+
+ Top K +
+
+
+ +
+
+ +
+
+
+
+
+ Mirostat Tau +
+
+
+ +
+
+ +
+
+
+
+
+ Mirostat LR +
+
+
+ +
+
+ +
+
+
+
+
+ Typical P +
+
+
+ +
+
+ +
+
+
+
+
+ Linear +
+
+
+ +
+
+ +
+
+
+
+
+ Quad +
+
+
+ +
+
+ +
+
+
+
+
+ Conf +
+
+
+ +
+
+ +
+
+
+
+
+ Min Length +
+
+
+ +
+
+ +
+
+
Phrase Repetition Penalty @@ -362,6 +492,72 @@
+
+
+ Preamble +
+
+
+
+
+ Use style tags to modify the writing style of the output. +
+
+ +
+
+
+
+ Banned Tokens +
+
+ Sequences you don't want to appear in the output. One per line. Text or [token ids]. +
+
+ +
+
+
+
+ Logit Bias +
+ + Add +
+
+
+ Helps to ban or reinforce the usage of certain tokens. +
+
+
+
+
+
+
+
+ CFG Scale +
+
+
+ +
+
+ +
+
+
+
+
+ Negative Prompt +
+
+ +
+ + Used if CFG Scale is unset globally, per chat or character + +
+
@@ -920,163 +1116,6 @@
-
-
- Preamble -
-
-
-
-
- Use style tags to modify the writing style of the output. -
-
- -
-
-
-
- Banned Tokens -
-
- Sequences you don't want to appear in the output. One per line. Text or [token ids]. -
-
- -
-
-
-
- Logit Bias -
- - Add -
-
-
- Helps to ban or reinforce the usage of certain tokens. -
-
-
-
-
-
-
-
- CFG Scale -
-
-
- -
-
- -
-
-
-
-
- Negative Prompt -
-
- -
- - Used if CFG Scale is unset globally, per chat or character - -
-
-
-
- Top P -
-
-
- -
-
- -
-
-
-
-
- Top A -
-
-
- -
-
- -
-
-
-
-
- Top K -
-
-
- -
-
- -
-
-
-
-
- Mirostat Tau -
-
-
- -
-
- -
-
-
-
-
- Mirostat LR -
-
-
- -
-
- -
-
-
-
-
- Typical P -
-
-
- -
-
- -
-
-
-
-
- Min Length -
-
-
- -
-
- -
-
-
Samplers Order @@ -1126,6 +1165,16 @@ 8
+
+ Unified Sampling + 9 +
+
+
+ Min P + 10 +
+
diff --git a/public/scripts/nai-settings.js b/public/scripts/nai-settings.js index 6ac80c2dd..2aee79537 100644 --- a/public/scripts/nai-settings.js +++ b/public/scripts/nai-settings.js @@ -39,6 +39,9 @@ export const nai_settings = { top_a: 0.08, typical_p: 0.975, min_p: 0, + math1_temp: 1, + math1_quad: 0, + math1_quad_entropy_scale: 0, min_length: 1, model_novel: 'clio-v1', preset_settings_novel: 'Talker-Chat-Clio', @@ -153,6 +156,9 @@ export function loadNovelPreset(preset) { nai_settings.logit_bias = preset.logit_bias || []; nai_settings.preamble = preset.preamble || default_preamble; nai_settings.min_p = preset.min_p || 0; + nai_settings.math1_temp = preset.math1_temp || 1; + nai_settings.math1_quad = preset.math1_quad || 0; + nai_settings.math1_quad_entropy_scale = preset.math1_quad_entropy_scale || 0; loadNovelSettingsUi(nai_settings); } @@ -191,6 +197,9 @@ export function loadNovelSettings(settings) { nai_settings.order = settings.order || default_order; nai_settings.logit_bias = settings.logit_bias || []; nai_settings.min_p = settings.min_p || 0; + nai_settings.math1_temp = settings.math1_temp || 1; + nai_settings.math1_quad = settings.math1_quad || 0; + nai_settings.math1_quad_entropy_scale = settings.math1_quad_entropy_scale || 0; loadNovelSettingsUi(nai_settings); } @@ -232,6 +241,12 @@ function loadNovelSettingsUi(ui_settings) { $('#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)); + $('#math1_temp_novel').val(ui_settings.math1_temp); + $('#math1_temp_counter_novel').val(Number(ui_settings.math1_temp).toFixed(2)); + $('#math1_quad_novel').val(ui_settings.math1_quad); + $('#math1_quad_counter_novel').val(Number(ui_settings.math1_quad).toFixed(2)); + $('#math1_quad_entropy_scale_novel').val(ui_settings.math1_quad_entropy_scale); + $('#math1_quad_entropy_scale_counter_novel').val(Number(ui_settings.math1_quad_entropy_scale).toFixed(2)); $('#streaming_novel').prop('checked', ui_settings.streaming_novel); sortItemsByOrder(ui_settings.order); @@ -347,6 +362,24 @@ const sliders = [ format: (val) => Number(val).toFixed(3), setValue: (val) => { nai_settings.min_p = Number(val); }, }, + { + sliderId: '#math1_temp_novel', + counterId: '#math1_temp_counter_novel', + format: (val) => Number(val).toFixed(2), + setValue: (val) => { nai_settings.math1_temp = Number(val); }, + }, + { + sliderId: '#math1_quad_novel', + counterId: '#math1_quad_counter_novel', + format: (val) => Number(val).toFixed(2), + setValue: (val) => { nai_settings.math1_quad = Number(val); }, + }, + { + sliderId: '#math1_quad_entropy_scale_novel', + counterId: '#math1_quad_entropy_scale_counter_novel', + format: (val) => Number(val).toFixed(2), + setValue: (val) => { nai_settings.math1_quad_entropy_scale = Number(val); }, + }, ]; function getBadWordIds(banned_tokens, tokenizerType) { @@ -481,6 +514,9 @@ export function getNovelGenerationData(finalPrompt, settings, maxLength, isImper 'top_p': Number(nai_settings.top_p), 'top_k': Number(nai_settings.top_k), 'min_p': Number(nai_settings.min_p), + 'math1_temp': Number(nai_settings.math1_temp), + 'math1_quad': Number(nai_settings.math1_quad), + 'math1_quad_entropy_scale': Number(nai_settings.math1_quad_entropy_scale), '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 14aba9b84..9cdbdf8cf 100644 --- a/src/endpoints/novelai.js +++ b/src/endpoints/novelai.js @@ -176,6 +176,9 @@ router.post('/generate', jsonParser, async function (req, res) { 'order': req.body.order, 'num_logprobs': req.body.num_logprobs, 'min_p': req.body.min_p, + 'math1_temp': req.body.math1_temp, + 'math1_quad': req.body.math1_quad, + 'math1_quad_entropy_scale': req.body.math1_quad_entropy_scale, }, };