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...');
return;
}
// just in case
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]])
@ -276,7 +277,7 @@
data,
}
)
).join("\n"),
)
});
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:`;
@ -284,7 +285,7 @@
await runLlama(prompt, {
...params.value,
slot_id: slot_id,
stop: ["</s>", template("{{char}}"), template("{{user}}")],
stop: ["</s>", template("{{stops}}"), template("{{char}}"), template("{{user}}")],
}, "{{char}}");
}

View file

@ -40,31 +40,39 @@ user: "user",
userMsgSuffix: ""
},
// ----------------------------
"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",
charMsgPrefix: "",
charMsgSuffix: "",
user: "user",
userMsgSuffix: "<|eot_id|>"
userMsgPrefix: "",
userMsgSuffix: "",
stops: "<|eot_id|>"
},
// ----------------------------
"phi3": {
template: `{{history}}
{{char}}
`,
historyTemplate: `{{name}}
{{message}}`,
char: "<|assistant|>",
user: "<|user|>",
userMsgSuffix: "<|end|>"
template: `{{history}}{{char}}`,
historyTemplate: `<|{{name}}|>\n{{message}}<|end|>\n`,
char: "assistant",
charMsgPrefix: "",
charMsgSuffix: "",
user: "user",
userMsgPrefix: "",
userMsgSuffix: "",
stops: "<|end|>"
},