Fixing Mistral Templates (#2883) * Update Mistral.json * Rename Mistral.json to Mistral V1.json * Create Mistral V2 & V3.json * Create Mistral V3-Tekken.json * Update and rename Mistral.json to Mistral V1.json * Update Mistral V1.json * Update Mistral V2 & V3.json * Update Mistral V2 & V3.json * Update Mistral V3-Tekken.json * Update Mistral V1.json * Create Mistral V2 & V3.json * Create Mistral V3-Tekken.json * Update Mistral V1.json * Update Mistral V2 & V3.json * Update Mistral V3-Tekken.json * Update Mistral V1.json * Update Mistral V2 & V3.json * Update Mistral V3-Tekken.json * Update Mistral V1.json * Update Mistral V2 & V3.json * Update Mistral V1.json * Update Mistral V3-Tekken.json * Update Mistral V1.json * Update Mistral V2 & V3.json * Update Mistral V3-Tekken.json * Add to content index * Remove example separators * Simplify context fillers * Add a hack for proper V1 format with names * Readability --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>

125498cfd5d779173932854fbad41d50e4f27fed

pandora <128635000+pandora-s-git@users.noreply.github.com>

Signed
8 files changed, +116 -17Ignore whitespace
default/content/index.json+24 -8
@@ -512,10 +512,6 @@
512512 "type": "context"
513513 },
514514 {
515- "filename": "presets/context/Mistral.json",
516- "type": "context"
517- },
518- {
519515 "filename": "presets/context/NovelAI.json",
520516 "type": "context"
521517 },
@@ -600,10 +596,6 @@
600596 "type": "instruct"
601597 },
602598 {
603- "filename": "presets/instruct/Mistral.json",
604- "type": "instruct"
605- },
606- {
607599 "filename": "presets/instruct/OpenOrca-OpenChat.json",
608600 "type": "instruct"
609601 },
@@ -686,5 +678,29 @@
686678 {
687679 "filename": "presets/instruct/Gemma 2.json",
688680 "type": "instruct"
681+ },
682+ {
683+ "filename": "presets/instruct/Mistral V1.json",
684+ "type": "instruct"
685+ },
686+ {
687+ "filename": "presets/context/Mistral V1.json",
688+ "type": "context"
689+ },
690+ {
691+ "filename": "presets/instruct/Mistral V2 & V3.json",
692+ "type": "instruct"
693+ },
694+ {
695+ "filename": "presets/context/Mistral V2 & V3.json",
696+ "type": "context"
697+ },
698+ {
699+ "filename": "presets/instruct/Mistral V3-Tekken.json",
700+ "type": "instruct"
701+ },
702+ {
703+ "filename": "presets/context/Mistral V3-Tekken.json",
704+ "type": "context"
689705 }
690706]
default/content/presets/context/Mistral V1.json+12 -0
@@ -0,0 +1,12 @@
1+{
2+ "story_string": " [INST] {{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{personality}}\n{{/if}}{{#if scenario}}{{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}} [/INST] Understood.</s>",
3+ "example_separator": "",
4+ "chat_start": "",
5+ "use_stop_strings": false,
6+ "allow_jailbreak": false,
7+ "always_force_name2": true,
8+ "trim_sentences": false,
9+ "include_newline": false,
10+ "single_line": false,
11+ "name": "Mistral V1"
12+}
default/content/presets/context/Mistral.json → default/content/presets/context/Mistral V2 & V3.json+3 -3
@@ -1,6 +1,6 @@
11{
22 "story_string": "[INST] {{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}} [/INST] Understood.</s>",
33 "example_separator": "Examples:",
44 "chat_start": "",
55 "use_stop_strings": false,
66 "allow_jailbreak": false,
@@ -8,5 +8,5 @@
88 "trim_sentences": false,
99 "include_newline": false,
1010 "single_line": false,
1111 "name": "Mistral V2 & V3"
1212}
default/content/presets/context/Mistral V3-Tekken.json+12 -0
@@ -0,0 +1,12 @@
1+{
2+ "story_string": "[INST]{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{personality}}\n{{/if}}{{#if scenario}}{{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}}[/INST]Understood.</s>",
3+ "example_separator": "",
4+ "chat_start": "",
5+ "use_stop_strings": false,
6+ "allow_jailbreak": false,
7+ "always_force_name2": true,
8+ "trim_sentences": false,
9+ "include_newline": false,
10+ "single_line": false,
11+ "name": "Mistral V3-Tekken"
12+}
default/content/presets/instruct/Mistral V1.json+23 -0
@@ -0,0 +1,23 @@
1+{
2+ "system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.",
3+ "input_sequence": " [INST] ",
4+ "output_sequence": " [/INST] ",
5+ "last_output_sequence": " [/INST]",
6+ "system_sequence": "",
7+ "stop_sequence": "",
8+ "wrap": false,
9+ "macro": true,
10+ "names_behavior": "always",
11+ "activation_regex": "",
12+ "system_sequence_prefix": "",
13+ "system_sequence_suffix": "",
14+ "first_output_sequence": "",
15+ "skip_examples": false,
16+ "output_suffix": "</s>",
17+ "input_suffix": "",
18+ "system_suffix": "",
19+ "user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.",
20+ "system_same_as_user": true,
21+ "last_system_sequence": "",
22+ "name": "Mistral V1"
23+}
default/content/presets/instruct/Mistral.json → default/content/presets/instruct/Mistral V2 & V3.json+5 -5
@@ -1,8 +1,8 @@
11{
22 "system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.",
33 "input_sequence": "[INST] ",
44 "output_sequence": "[/INST] ",
55 "last_output_sequence": "[/INST]",
66 "system_sequence": "",
77 "stop_sequence": "",
88 "wrap": false,
@@ -13,11 +13,11 @@
1313 "system_sequence_suffix": "",
1414 "first_output_sequence": "",
1515 "skip_examples": false,
1616 "output_suffix": "\n</s>",
1717 "input_suffix": " [/INST]\n",
1818 "system_suffix": "",
1919 "user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.",
2020 "system_same_as_user": true,
2121 "last_system_sequence": "",
2222 "name": "Mistral V2 & V3"
2323}
default/content/presets/instruct/Mistral V3-Tekken.json+23 -0
@@ -0,0 +1,23 @@
1+{
2+ "system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.",
3+ "input_sequence": "[INST]",
4+ "output_sequence": "[/INST]",
5+ "last_output_sequence": "",
6+ "system_sequence": "",
7+ "stop_sequence": "",
8+ "wrap": false,
9+ "macro": true,
10+ "names_behavior": "always",
11+ "activation_regex": "",
12+ "system_sequence_prefix": "",
13+ "system_sequence_suffix": "",
14+ "first_output_sequence": "",
15+ "skip_examples": false,
16+ "output_suffix": "</s>",
17+ "input_suffix": "",
18+ "system_suffix": "",
19+ "user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.",
20+ "system_same_as_user": true,
21+ "last_system_sequence": "",
22+ "name": "Mistral V3-Tekken"
23+}
public/scripts/instruct-mode.js+14 -1
@@ -532,6 +532,19 @@ export function formatInstructModePrompt(name, isImpersonate, promptBias, name1,
532532 }
533533
534534 let sequence = getSequence() || '';
535+ let nameFiller = '';
536+
537+ // A hack for Mistral's formatting that has a normal output sequence ending with a space
538+ if (
539+ includeNames &&
540+ power_user.instruct.last_output_sequence &&
541+ power_user.instruct.output_sequence &&
542+ sequence === power_user.instruct.last_output_sequence &&
543+ /\s$/.test(power_user.instruct.output_sequence) &&
544+ !/\s$/.test(power_user.instruct.last_output_sequence)
545+ ) {
546+ nameFiller = power_user.instruct.output_sequence.slice(-1);
547+ }
535548
536549 if (power_user.instruct.macro) {
537550 sequence = substituteParams(sequence, name1, name2);
@@ -539,7 +552,7 @@ export function formatInstructModePrompt(name, isImpersonate, promptBias, name1,
539552 }
540553
541554 const separator = power_user.instruct.wrap ? '\n' : '';
542555 let text = includeNames ? (separator + sequence + separator + nameFiller + `${name}:`) : (separator + sequence);
543556
544557 // Quiet prompt already has a newline at the end
545558 if (isQuiet && separator) {