half measure for mistral spaced formats

This commit is contained in:
Concedo 2025-08-04 23:48:11 +08:00
parent 8bd0a560f0
commit 9fbbd9e127
6 changed files with 17 additions and 26 deletions

View file

@ -91,9 +91,9 @@
"search": ["[/INST]", "[SYSTEM_PROMPT]"], "search": ["[/INST]", "[SYSTEM_PROMPT]"],
"name": "Mistral V7 (with system prompt)", "name": "Mistral V7 (with system prompt)",
"adapter": { "adapter": {
"system_start": "[SYSTEM_PROMPT]", "system_start": "[SYSTEM_PROMPT] ",
"system_end": "[/SYSTEM_PROMPT]", "system_end": "[/SYSTEM_PROMPT]",
"user_start": "[INST]", "user_start": "[INST] ",
"user_end": "", "user_end": "",
"assistant_start": "[/INST]", "assistant_start": "[/INST]",
"assistant_end": "</s>" "assistant_end": "</s>"
@ -201,9 +201,9 @@
"search": ["[/INST]"], "search": ["[/INST]"],
"name": "Mistral (Generic)", "name": "Mistral (Generic)",
"adapter": { "adapter": {
"system_start": "[INST]", "system_start": "[INST] ",
"system_end": "[/INST]\n", "system_end": "[/INST]\n",
"user_start": "[INST]", "user_start": "[INST] ",
"user_end": "", "user_end": "",
"assistant_start": "[/INST]\n", "assistant_start": "[/INST]\n",
"assistant_end": "</s>" "assistant_end": "</s>"

View file

@ -1,7 +1,7 @@
{ {
"system_start": "", "system_start": "",
"system_end": "", "system_end": "",
"user_start": " [INST] ", "user_start": " [INST]",
"user_end": "", "user_end": "",
"assistant_start": " [/INST]", "assistant_start": " [/INST]",
"assistant_end": "</s>" "assistant_end": "</s>"

View file

@ -1,7 +1,7 @@
{ {
"system_start": "", "system_start": "",
"system_end": "", "system_end": "",
"user_start": "[INST] ", "user_start": "[INST]",
"user_end": "", "user_end": "",
"assistant_start": "[/INST]", "assistant_start": "[/INST]",
"assistant_end": "</s>" "assistant_end": "</s>"

View file

@ -1,7 +1,7 @@
{ {
"system_start": "[SYSTEM_PROMPT]", "system_start": "[SYSTEM_PROMPT] ",
"system_end": "[/SYSTEM_PROMPT]", "system_end": "[/SYSTEM_PROMPT]",
"user_start": "[INST]", "user_start": "[INST] ",
"user_end": "", "user_end": "",
"assistant_start": "[/INST]", "assistant_start": "[/INST]",
"assistant_end": "</s>" "assistant_end": "</s>"

View file

@ -12,7 +12,7 @@ Current version indicated by LITEVER below.
--> -->
<script id="init-config"> <script id="init-config">
const LITEVER = 266; const LITEVER = 267;
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
var localflag = urlParams.get('local'); //this will be replaced automatically in embedded kcpp var localflag = urlParams.get('local'); //this will be replaced automatically in embedded kcpp
const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_"; const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_";
@ -3595,7 +3595,7 @@ Current version indicated by LITEVER below.
"system_end":"", "system_end":"",
}, },
{ {
"name":"Mistral V1", "name":"Mistral Legacy",
"user":" [INST] ", "user":" [INST] ",
"user_end":"", "user_end":"",
"assistant":" [/INST]", "assistant":" [/INST]",
@ -3604,20 +3604,11 @@ Current version indicated by LITEVER below.
"system_end":"", "system_end":"",
}, },
{ {
"name":"Mistral V2 & V3", "name":"Mistral Modern",
"user":"[INST] ", "user":"[INST] ",
"user_end":"", "user_end":"",
"assistant":"[/INST]", "assistant":"[/INST]",
"assistant_end":"</s>", "assistant_end":"</s>",
"system":"",
"system_end":"",
},
{
"name":"Mistral V7 & V3-Tekken",
"user":"[INST]",
"user_end":"",
"assistant":"[/INST]",
"assistant_end":"</s>",
"system":"[SYSTEM_PROMPT]", //if no sysprompt provided, treat as V3 tekken "system":"[SYSTEM_PROMPT]", //if no sysprompt provided, treat as V3 tekken
"system_end":"[/SYSTEM_PROMPT]", "system_end":"[/SYSTEM_PROMPT]",
}, },

View file

@ -2610,8 +2610,8 @@ ws ::= | " " | "\n" [ \t]{0,20}
prompt = prompt.replace("{{[INPUT_END]}}", user_message_end) prompt = prompt.replace("{{[INPUT_END]}}", user_message_end)
prompt = prompt.replace("{{[OUTPUT_END]}}", assistant_message_end) prompt = prompt.replace("{{[OUTPUT_END]}}", assistant_message_end)
prompt = prompt.replace("{{[SYSTEM_END]}}", system_message_end) prompt = prompt.replace("{{[SYSTEM_END]}}", system_message_end)
memory = memory.replace("{{[INPUT]}}", assistant_message_end + user_message_start) memory = memory.replace("{{[INPUT]}}", user_message_start)
memory = memory.replace("{{[OUTPUT]}}", user_message_end + assistant_message_start) memory = memory.replace("{{[OUTPUT]}}", assistant_message_start)
memory = memory.replace("{{[SYSTEM]}}", system_message_start) memory = memory.replace("{{[SYSTEM]}}", system_message_start)
memory = memory.replace("{{[INPUT_END]}}", user_message_end) memory = memory.replace("{{[INPUT_END]}}", user_message_end)
memory = memory.replace("{{[OUTPUT_END]}}", assistant_message_end) memory = memory.replace("{{[OUTPUT_END]}}", assistant_message_end)
@ -2631,13 +2631,13 @@ ws ::= | " " | "\n" [ \t]{0,20}
memory = memory.replace("{{[SYSTEM_END]}}", "") memory = memory.replace("{{[SYSTEM_END]}}", "")
for i in range(len(stop_sequence)): for i in range(len(stop_sequence)):
if stop_sequence[i] == "{{[INPUT]}}": if stop_sequence[i] == "{{[INPUT]}}":
stop_sequence[i] = user_message_start stop_sequence[i] = user_message_start.strip()
elif stop_sequence[i] == "{{[OUTPUT]}}": elif stop_sequence[i] == "{{[OUTPUT]}}":
stop_sequence[i] = assistant_message_start stop_sequence[i] = assistant_message_start.strip()
elif stop_sequence[i] == "{{[INPUT_END]}}": elif stop_sequence[i] == "{{[INPUT_END]}}":
stop_sequence[i] = (user_message_end if user_message_end.strip()!="" else "") stop_sequence[i] = (user_message_end.strip() if user_message_end.strip()!="" else "")
elif stop_sequence[i] == "{{[OUTPUT_END]}}": elif stop_sequence[i] == "{{[OUTPUT_END]}}":
stop_sequence[i] = (assistant_message_end if assistant_message_end.strip()!="" else "") stop_sequence[i] = (assistant_message_end.strip() if assistant_message_end.strip()!="" else "")
stop_sequence = list(filter(None, stop_sequence)) stop_sequence = list(filter(None, stop_sequence))
genparams["prompt"] = prompt genparams["prompt"] = prompt
genparams["memory"] = memory genparams["memory"] = memory