more prompt format fixes

This commit is contained in:
Yazan Agha-Schrader 2024-05-29 13:19:22 +02:00
parent ca565f4ed6
commit 80b6143f78
2 changed files with 29 additions and 20 deletions

View file

@ -257,9 +257,10 @@
console.log('already running...'); console.log('already running...');
return; return;
} }
// just in case
const suffix = session.value.userMsgSuffix || ""; const suffix = session.value.userMsgSuffix || "";
const userMsg = msg + suffix; const prefix = session.value.userMsgPrefix || "";
const userMsg = prefix + msg + suffix;
transcriptUpdate([...session.value.transcript, ["{{user}}", userMsg]]) transcriptUpdate([...session.value.transcript, ["{{user}}", userMsg]])
@ -276,7 +277,7 @@
data, data,
} }
) )
).join("\n"), )
}); });
if (selected_image) { if (selected_image) {
prompt = `A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\nUSER:[img-10]${msg}\nASSISTANT:`; prompt = `A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\nUSER:[img-10]${msg}\nASSISTANT:`;
@ -284,7 +285,7 @@
await runLlama(prompt, { await runLlama(prompt, {
...params.value, ...params.value,
slot_id: slot_id, slot_id: slot_id,
stop: ["</s>", template("{{char}}"), template("{{user}}")], stop: ["</s>", template("{{stops}}"), template("{{char}}"), template("{{user}}")],
}, "{{char}}"); }, "{{char}}");
} }

View file

@ -40,31 +40,39 @@ user: "user",
userMsgSuffix: "" userMsgSuffix: ""
}, },
// ----------------------------
"llama3": { "llama3": {
template: `<|begin_of_text|><|start_header_id|>system<|end_header_id|> template: `<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n{{prompt}}{{history}}`,
historyTemplate: `<|start_header_id|>{{name}}<|end_header_id|>\n\n{{message}}<|eot_id|>`,
{{prompt}}<|eot_id|>{{history}}`,
historyTemplate: `<|start_header_id|>{{name}}<|end_header_id|>
{{message}}`,
char: "assistant", char: "assistant",
charMsgPrefix: "",
charMsgSuffix: "",
user: "user", user: "user",
userMsgSuffix: "<|eot_id|>" userMsgPrefix: "",
userMsgSuffix: "",
stops: "<|eot_id|>"
}, },
// ----------------------------
"phi3": { "phi3": {
template: `{{history}} template: `{{history}}{{char}}`,
{{char}}
`, historyTemplate: `<|{{name}}|>\n{{message}}<|end|>\n`,
historyTemplate: `{{name}}
{{message}}`, char: "assistant",
char: "<|assistant|>", charMsgPrefix: "",
user: "<|user|>", charMsgSuffix: "",
userMsgSuffix: "<|end|>"
user: "user",
userMsgPrefix: "",
userMsgSuffix: "",
stops: "<|end|>"
}, },