Add separator sequence for instruct mode

This commit is contained in:
SillyLossy
2023-05-18 15:28:31 +03:00
parent d3c5eed4c1
commit 80dd3af587
10 changed files with 32 additions and 9 deletions

View File

@ -1289,7 +1289,7 @@
<div class="flex-container">
<div class="flex1">
<label for="instruct_system_sequence">
System Sequence
<small>System Sequence</small>
</label>
<div>
<input id="instruct_system_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="100" />
@ -1297,12 +1297,20 @@
</div>
<div class="flex1">
<label for="instruct_stop_sequence">
Stop Sequence
<small>Stop Sequence</small>
</label>
<div>
<input id="instruct_stop_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="100" />
</div>
</div>
<div class="flex1">
<label for="instruct_separator_sequence">
<small>Separator</small>
</label>
<div>
<input id="instruct_separator_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="100" />
</div>
</div>
</div>
</div>
</div>

View File

@ -5,5 +5,6 @@
"stop_sequence": "",
"input_sequence": "### Instruction:",
"output_sequence": "### Response:",
"separator_sequence": "",
"wrap": true
}

View File

@ -1,9 +1,10 @@
{
"name": "Koala",
"system_prompt": "Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n",
"system_sequence": "BEGINNING OF CONVERSATION:",
"system_sequence": "BEGINNING OF CONVERSATION: ",
"stop_sequence": "",
"input_sequence": "USER: ",
"output_sequence": "GPT: ",
"separator_sequence": "</s>",
"wrap": false
}

View File

@ -5,5 +5,6 @@
"stop_sequence": "</s>",
"input_sequence": "<|user|>",
"output_sequence": "<|model|>",
"separator_sequence": "",
"wrap": false
}

View File

@ -5,5 +5,6 @@
"stop_sequence": "",
"input_sequence": "### Human:",
"output_sequence": "### Assistant:",
"separator_sequence": "",
"wrap": true
}

View File

@ -5,5 +5,6 @@
"stop_sequence": "",
"input_sequence": "USER: ",
"output_sequence": "ASSISTANT: ",
"wrap": true
"separator_sequence": "</s>",
"wrap": false
}

View File

@ -3,7 +3,8 @@
"system_prompt": "Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n",
"system_sequence": "",
"stop_sequence": "",
"input_sequence": "### Instruction:",
"input_sequence": "",
"output_sequence": "### Response:",
"separator_sequence": "</s>",
"wrap": true
}

View File

@ -435,6 +435,10 @@ Text added before the character's reply.
Text added before the system prompt.
#### Separator Sequence
Text added after the character reply to separate the chat history logs.
#### Stop Sequence
Text that denotes the end of the reply. Will be trimmed from the output text.

View File

@ -2014,7 +2014,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
if (!mesSendString.endsWith('\n')) {
mesSendString += '\n';
}
mesSendString += name2 + ':' + promptBias;
mesSendString += (`${name2}:${promptBias || ''}`);
}
return mesSendString;

View File

@ -134,6 +134,7 @@ let power_user = {
input_sequence: '### Instruction:',
output_sequence: '### Response:',
preset: 'Alpaca',
separator_sequence: '',
}
};
@ -584,6 +585,7 @@ function loadInstructMode() {
{ id: "instruct_wrap", property: "wrap", isCheckbox: true },
{ id: "instruct_system_prompt", property: "system_prompt", isCheckbox: false },
{ id: "instruct_system_sequence", property: "system_sequence", isCheckbox: false },
{ id: "instruct_separator_sequence", property: "separator_sequence", isCheckbox: false },
{ id: "instruct_input_sequence", property: "input_sequence", isCheckbox: false },
{ id: "instruct_output_sequence", property: "output_sequence", isCheckbox: false },
{ id: "instruct_stop_sequence", property: "stop_sequence", isCheckbox: false },
@ -642,7 +644,10 @@ export function formatInstructModeChat(name, mes, isUser, isNarrator) {
const includeNames = isNarrator ? false : power_user.instruct.names || !!selected_group;
const sequence = (isUser || isNarrator) ? power_user.instruct.input_sequence : power_user.instruct.output_sequence;
const separator = power_user.instruct.wrap ? '\n' : '';
const textArray = includeNames ? [sequence, `${name}: ${mes}`, separator] : [sequence, mes, separator];
const separatorSequence = power_user.instruct.separator_sequence && !isUser
? power_user.instruct.separator_sequence
: (power_user.instruct.wrap ? '\n' : '');
const textArray = includeNames ? [sequence, `${name}: ${mes}`, separatorSequence] : [sequence, mes, separatorSequence];
const text = textArray.filter(x => x).join(separator);
return text;
}
@ -661,7 +666,7 @@ export function formatInstructModePrompt(name, isImpersonate) {
const sequence = isImpersonate ? power_user.instruct.input_sequence : power_user.instruct.output_sequence;
const separator = power_user.instruct.wrap ? '\n' : '';
const text = includeNames ? (separator + sequence + separator + `${name}:`) : (separator + sequence);
return text;
return text.trimEnd();
}
const sortFunc = (a, b) => power_user.sort_order == 'asc' ? compareFunc(a, b) : compareFunc(b, a);