add hacky llama2 prompt solution, reduce redundancy in promptFormats.js

This commit is contained in:
Yazan Agha-Schrader 2024-05-29 20:03:20 +02:00
parent 1c24ab6e20
commit c2badb4697
2 changed files with 140 additions and 133 deletions

View file

@ -257,7 +257,7 @@
console.log('already running...');
return;
}
// just in case
// just in case (e.g. llama2)
const suffix = session.value.userMsgSuffix || "";
const prefix = session.value.userMsgPrefix || "";
const userMsg = prefix + msg + suffix;
@ -285,7 +285,7 @@
await runLlama(prompt, {
...params.value,
slot_id: slot_id,
stop: ["</s>", "<|end|>", "<|eot_id|>", "<|end_of_text|>", "<|im_end|>", "<|EOT|>", "<|END_OF_TURN_TOKEN|>", "<|endoftext|>", template("{{char}}"), template("{{user}}")],
stop: ["</s>", "<|end|>", "<|eot_id|>", "<|end_of_text|>", "<|im_end|>", "<|EOT|>", "<|END_OF_TURN_TOKEN|>", "<|end_of_turn|>", "<|endoftext|>", template("{{char}}"), template("{{user}}")],
}, "{{char}}");
}
@ -642,6 +642,7 @@ const BoolField = ({ label, title, name, value }) => {
id="prompt"
class="persistent-input"
name="prompt"
placeholder="The following models do not support System Prompt by design: OpenChat, Orion, Phi-3, Starling"
value="${session.value.prompt}"
oninput=${updateSession}
></textarea>
@ -663,16 +664,17 @@ const BoolField = ({ label, title, name, value }) => {
<option value="llama2">Llama 2</option>
<option value="llama3">Llama 3</option>
<option value="phi3">Phi-3</option>
<option value="openchat">OpenChat/Starling</option>
<option value="vicuna">Vicuna</option>
<option value=""></option>
</optgroup>
<optgroup label="More Prompt-Styles">
<option value="airoboros180">Airoboros L2</option>
<option value="bakllava">BakLLaVA-1</option>
<option value="vicuna">Airoboros L2</option>
<option value="vicuna">BakLLaVA-1</option>
<option value="codeCherryPop">Code Cherry Pop</option>
<option value="deepseekCoder">Deepseek Coder</option>
<option value="dolphinMistral">Dolphin Mistral</option>
<option value="evolvedSeeker">evolvedSeeker 1.3B</option>
<option value="chatml">Dolphin Mistral</option>
<option value="chatml">evolvedSeeker 1.3B</option>
<option value="goliath120b">Goliath 120B</option>
<option value="jordan">Jordan</option>
<option value="llava">LLaVA</option>
@ -687,15 +689,15 @@ const BoolField = ({ label, title, name, value }) => {
<option value="neuralchat">Neural Chat</option>
<option value="nousCapybara">Nous Capybara</option>
<option value="nousHermes">Nous Hermes</option>
<option value="openChat">OpenChat</option>
<option value="openchatMath">OpenChat Math</option>
<option value="openhermes2Mistral">OpenHermes 2.5-Mistral</option>
<option value="orcamini">Orca Mini v3</option>
<option value="orion">Orion</option>
<option value="sauerkrautLM">SauerkrautLM</option>
<option value="samantha">Samantha</option>
<option value="samanthaMistral">Samantha Mistral</option>
<option value="scarlett">Scarlett</option>
<option value="starlingLM">Starling-7B</option>
<option value="starlingLM">Starling-7B Coding</option>
<option value="starlingCode">Starling Coding</option>
<option value="sydney">Sydney</option>
<option value="synthia">Synthia</option>
<option value="tess">Tess</option>

View file

@ -1,44 +1,56 @@
// extended list
export const promptFormats = {
"alpaca": {
template: `{{prompt}}
template: `{{prompt}}\n\n{{history}}\n\n{{char}}:`,
{{history}}
historyTemplate: `### {{name}}:\n{{message}}`,
### {{char}}:`,
historyTemplate: `### {{name}}:
{{message}}`,
char: "Response",
user: "Instruction"
charMsgPrefix: "",
charMsgSuffix: "",
user: "Instruction",
userMsgPrefix: "",
userMsgSuffix: "",
stops: ""
},
// ----------------------------
"chatml": {
template: `<|im_start|>system
{{prompt}}<|im_end|>
{{history}}
{{char}}`,
historyTemplate: `{{name}}
{{message}}`,
char: "<|im_start|>assistant",
user: "<|im_start|>user",
userMsgSuffix: "<|im_end|>"
template: `<|im_start|>system\n{{prompt}}<|im_end|>{{history}}{{char}}`,
historyTemplate: `\n<|im_start|>{{name}}\n{{message}}<|im_end|>`,
char: "assistant",
charMsgPrefix: "",
charMsgSuffix: "",
user: "user",
userMsgPrefix: "",
userMsgSuffix: "",
stops: ""
},
// ----------------------------
"llama2": {
template: `<s>[INST] <<SYS>>
{{prompt}}
<</SYS>>
template: `<s>[INST] <<SYS>>\n{{prompt}}\n<</SYS>>\n\nTest Message [/INST] Test Successfull </s>{{history}}{{char}}`,
historyTemplate: `{{name}}: {{message}}`,
{{history}} [/INST] {{char}} </s><s>[INST] `,
historyTemplate: `{{name}}: {{message}} [/INST]`,
char: "llama",
user: "user",
userMsgSuffix: ""
char: "Assistant",
charMsgPrefix: "",
charMsgSuffix: "</s>",
user: "User",
userMsgPrefix: "<s>[INST] ",
userMsgSuffix: " [/INST]",
stops: ""
},
// ref: https://huggingface.co/blog/llama2#how-to-prompt-llama-2
// ----------------------------
@ -59,6 +71,23 @@ stops: "<|eot_id|>"
// ----------------------------
"openchat": {
template: `{{history}}{{char}}`,
historyTemplate: `GPT4 Correct {{name}}: {{message}}<|end_of_turn|>`,
char: "Assistant",
charMsgPrefix: "",
charMsgSuffix: "",
user: "User",
userMsgPrefix: "",
userMsgSuffix: "",
stops: ""
},
// ----------------------------
"phi3": {
template: `{{history}}{{char}}`,
@ -75,26 +104,26 @@ userMsgSuffix: "",
stops: "<|end|>"
},
// ----------------------------
"vicuna": {
template: `SYSTEM: {{prompt}}\n{{history}}{{char}}`,
historyTemplate: `
{{name}}: {{message}}\n`,
"airoborosl2": {
template: `{{prompt}} {{history}} {{char}}`,
historyTemplate: `{{name}}: {{message}}`,
char: "ASSISTANT",
user: "USER"
charMsgPrefix: "",
charMsgSuffix: "",
user: "USER",
userMsgPrefix: "",
userMsgSuffix: "",
stops: ""
},
"bakllava": {
template: `{{history}}{{char}}:`,
historyTemplate: `{{name}}: {{message}}
`,
char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"codeCherryPop": {
template: `{{prompt}}
@ -108,45 +137,25 @@ char: "Response",
user: "Instruction"
},
// ----------------------------
"deepseekCoder": {
template: `{{prompt}}
{{history}}
### {{char}}:`,
historyTemplate: `### {{name}}:
{{message}}`,
template: `{{prompt}}{{history}}{{char}}:`,
historyTemplate: `### {{name}}:\n{{message}}`,
char: "Response",
user: "Instruction"
charMsgPrefix: "",
charMsgSuffix: "",
user: "Instruction",
userMsgPrefix: "",
userMsgSuffix: "",
stops: "<|EOT|>"
},
"dolphinMistral": {
template: `<|im_start|>system
{{prompt}}<|im_end|>
{{history}}
<|im_start|>{{char}}`,
historyTemplate: `<|im_start|>{{user}}
{{message}}<|im_end|>`,
char: "assistant",
user: "user"
},
"evolvedSeeker": {
template: `<|im_start|>system
{{prompt}}<|im_end|>
{{history}}
<|im_start|>{{char}}`,
historyTemplate: `<|im_start|>{{user}}
{{message}}<|im_end|>`,
char: "assistant",
user: "user"
},
// ----------------------------
"goliath120b": {
template: `{{prompt}}
@ -158,7 +167,7 @@ char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"jordan": {
template: `{{prompt}}
@ -170,7 +179,7 @@ char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"llava": {
template: `{{history}}{{char}}:`,
@ -180,7 +189,7 @@ char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"leoHessianai": {
template: `<|im_start|>system
@ -193,7 +202,7 @@ char: "assistant",
user: "user"
},
// ----------------------------
"leoMistral": {
template: `{{prompt}} {{history}} {{char}}`,
@ -202,7 +211,7 @@ char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"marx": {
template: `{{history}}
@ -212,7 +221,7 @@ char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"med42": {
template: `<|system|>: {{prompt}}
@ -223,7 +232,7 @@ char: "assistant",
user: "prompter"
},
// ----------------------------
"metaMath": {
template: `{{prompt}}
@ -237,7 +246,7 @@ char: "Response",
user: "Instruction"
},
// ----------------------------
"mistralInstruct": {
template: `<s>[INST] ({{prompt}}) {{history}} {{char}}</s>`,
@ -246,7 +255,7 @@ char: "[/INST] Assistant:",
user: "[INST] User:"
},
// ----------------------------
"mistralOpenOrca": {
template: `<|im_start|>system
@ -259,7 +268,7 @@ char: "assistant",
user: "user"
},
// ----------------------------
"mythomax": {
template: `{{prompt}}
@ -273,7 +282,7 @@ char: "Response",
user: "Instruction"
},
// ----------------------------
"neuralchat": {
template: `### System:
@ -286,7 +295,7 @@ char: "Assistant",
user: "User"
},
// ----------------------------
"nousCapybara": {
template: `{{history}}
@ -297,7 +306,7 @@ char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"nousHermes": {
template: `### Instruction: {{prompt}}
@ -309,16 +318,16 @@ char: "Response",
user: "Input"
},
// ----------------------------
"openChat": {
"openchatMath": {
template: `{{history}}{{char}}`,
historyTemplate: `GPT4 {{user}}: {{message}}<|end_of_turn|>`,
historyTemplate: `Math Correct {{name}}: {{message}}<|end_of_turn|>`,
char: "Assistant",
user: "User"
},
// ----------------------------
"openhermes2Mistral": {
template: `<|im_start|>system
@ -331,7 +340,7 @@ char: "assistant",
user: "user"
},
// ----------------------------
"orcamini": {
template: `{{prompt}}
@ -345,7 +354,24 @@ char: "Response",
user: "Instruction"
},
// ----------------------------
"orion": {
template: `<s>Human: Test Message\n\nAssistant: </s>Test Successful</s>{{history}}{{char}}:`,
historyTemplate: `{{name}}: {{message}}`,
char: "Assistant </s>",
charMsgPrefix: "",
charMsgSuffix: "",
user: "Human",
userMsgPrefix: "",
userMsgSuffix: "\n\n",
stops: ""
},
// ----------------------------
"sauerkraut": {
template: `{{prompt}}
@ -356,7 +382,7 @@ char: "Assistant",
user: "User"
},
// ----------------------------
"samantha": {
template: `{{prompt}}
@ -368,7 +394,7 @@ char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"samanthaMistral": {
template: `<|im_start|>system
@ -381,7 +407,7 @@ char: "assistant",
user: "user"
},
// ----------------------------
"scarlett": {
template: `{{prompt}}
@ -393,25 +419,16 @@ char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"starlingLM": {
"starlingCode": {
template: `{{history}}{{char}}`,
historyTemplate: `GPT4 Correct {{user}}: {{message}}<|end_of_turn|>`,
historyTemplate: `Code {{name}}: {{message}}<|end_of_turn|>`,
char: "Assistant",
user: "User"
},
"starlingLMCode": {
template: `{{history}}{{char}}`,
historyTemplate: `Code {{user}}: {{message}}<|end_of_turn|>`,
char: "Assistant",
user: "User"
},
// ----------------------------
"sydney": {
template: `{{prompt}}
@ -425,7 +442,7 @@ char: "Response",
user: "Instruction"
},
// ----------------------------
"synthia": {
template: `SYSTEM: {{prompt}}
@ -436,7 +453,7 @@ char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"tess": {
template: `SYSTEM: {{prompt}}
@ -447,19 +464,7 @@ char: "ASSISTANT",
user: "USER"
},
"vicuna": {
template: `{{prompt}}
{{history}}
{{char}}:`,
historyTemplate: `
{{name}}: {{message}}`,
char: "ASSISTANT",
user: "USER"
},
// ----------------------------
"yi34b": {
template: `{{history}} {{char}}`,
@ -468,7 +473,7 @@ char: "Assistant",
user: "Human"
},
// ----------------------------
"zephyr": {
template: `<|system|>