From f50bd5c5ba62d36056e38d072675fbbd9e42a738 Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Thu, 27 Jun 2024 22:57:08 +0200 Subject: [PATCH 1/3] server : fix templates for llama2, llama3 and zephyr --- examples/server/public/prompt-formats.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/server/public/prompt-formats.js b/examples/server/public/prompt-formats.js index 73ddb7187eb7a..bdb23e654ccbc 100644 --- a/examples/server/public/prompt-formats.js +++ b/examples/server/public/prompt-formats.js @@ -56,9 +56,9 @@ export const promptFormats = { // ---------------------------- "llama2": { - template: `[INST] <>\n{{prompt}}\n<>\n\nTest Message [/INST] Test Successfull {{history}}{{char}}`, + template: `[INST] <>\n{{prompt}}\n<>\n\nTest Message [/INST] Test Successful {{history}}`, - historyTemplate: `{{name}}: {{message}}`, + historyTemplate: `{{message}}`, char: "Assistant", charMsgPrefix: "", @@ -75,9 +75,9 @@ export const promptFormats = { // ---------------------------- "llama3": { - template: `<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n{{prompt}}{{history}}{{char}}`, + template: `<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n{{prompt}}<|eot_id|>\n{{history}}<|start_header_id|>{{char}}<|end_header_id|>\n\n`, - historyTemplate: `<|start_header_id|>{{name}}<|end_header_id|>\n\n{{message}}<|eot_id|>`, + historyTemplate: `<|start_header_id|>{{name}}<|end_header_id|>\n\n{{message}}<|eot_id|>\n`, char: "assistant", charMsgPrefix: "", @@ -314,7 +314,7 @@ export const promptFormats = { // ---------------------------- "zephyr": { - template: `<|system|>\n{{prompt}}\n{{history}}{{char}}`, + template: `<|system|>\n{{prompt}}\n{{history}}<|{{char}}|>\n`, historyTemplate: `<|{{name}}|>\n{{message}}\n`, @@ -328,4 +328,6 @@ export const promptFormats = { stops: "" } + // ref: https://huggingface.co/HuggingFaceH4/zephyr-7b-alpha + }; From 4be8de1604c8485a8570c36d823e20c6e70cf3e3 Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Fri, 28 Jun 2024 20:27:53 +0200 Subject: [PATCH 2/3] server : remove initial start-of-text tokens from llama2, llama3 templates --- examples/server/public/prompt-formats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/server/public/prompt-formats.js b/examples/server/public/prompt-formats.js index bdb23e654ccbc..8f9c6db41efb6 100644 --- a/examples/server/public/prompt-formats.js +++ b/examples/server/public/prompt-formats.js @@ -56,7 +56,7 @@ export const promptFormats = { // ---------------------------- "llama2": { - template: `[INST] <>\n{{prompt}}\n<>\n\nTest Message [/INST] Test Successful {{history}}`, + template: `[INST] <>\n{{prompt}}\n<>\n\nTest Message [/INST] Test Successful {{history}}`, historyTemplate: `{{message}}`, @@ -75,7 +75,7 @@ export const promptFormats = { // ---------------------------- "llama3": { - template: `<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n{{prompt}}<|eot_id|>\n{{history}}<|start_header_id|>{{char}}<|end_header_id|>\n\n`, + template: `<|start_header_id|>system<|end_header_id|>\n\n{{prompt}}<|eot_id|>\n{{history}}<|start_header_id|>{{char}}<|end_header_id|>\n\n`, historyTemplate: `<|start_header_id|>{{name}}<|end_header_id|>\n\n{{message}}<|eot_id|>\n`, From 2727b02b4d043bef9ca5269da266b69d21b32ce1 Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Wed, 3 Jul 2024 22:33:33 +0200 Subject: [PATCH 3/3] server : remove extra \n after <|eot_id|> in llama3 template --- examples/server/public/prompt-formats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/server/public/prompt-formats.js b/examples/server/public/prompt-formats.js index 8f9c6db41efb6..721ebbb98f48b 100644 --- a/examples/server/public/prompt-formats.js +++ b/examples/server/public/prompt-formats.js @@ -75,9 +75,9 @@ export const promptFormats = { // ---------------------------- "llama3": { - template: `<|start_header_id|>system<|end_header_id|>\n\n{{prompt}}<|eot_id|>\n{{history}}<|start_header_id|>{{char}}<|end_header_id|>\n\n`, + template: `<|start_header_id|>system<|end_header_id|>\n\n{{prompt}}<|eot_id|>{{history}}<|start_header_id|>{{char}}<|end_header_id|>\n\n`, - historyTemplate: `<|start_header_id|>{{name}}<|end_header_id|>\n\n{{message}}<|eot_id|>\n`, + historyTemplate: `<|start_header_id|>{{name}}<|end_header_id|>\n\n{{message}}<|eot_id|>`, char: "assistant", charMsgPrefix: "",