From ac7ec7ed1030468bcf16d2999c3304fc330c5df7 Mon Sep 17 00:00:00 2001 From: hiyouga Date: Fri, 19 Apr 2024 15:46:51 +0800 Subject: [PATCH] fix llama3 template Former-commit-id: 14a605a2da16367ff64219b9f301c352b4812c4c --- src/llmtuner/data/template.py | 20 ++++++++++---------- src/llmtuner/extras/constants.py | 4 ++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/llmtuner/data/template.py b/src/llmtuner/data/template.py index 00bdbf10..67b447f0 100644 --- a/src/llmtuner/data/template.py +++ b/src/llmtuner/data/template.py @@ -649,6 +649,14 @@ _register_template( ) +_register_template( + name="llama2_zh", + format_user=StringFormatter(slots=[{"bos_token"}, "[INST] {{content}} [/INST]"]), + format_system=StringFormatter(slots=["<>\n{{content}}\n<>\n\n"]), + default_system="You are a helpful assistant. 你是一个乐于助人的助手。", +) + + _register_template( name="llama3", format_user=StringFormatter( @@ -657,20 +665,12 @@ _register_template( ] ), format_system=StringFormatter(slots=[{"bos_token"}, "{{content}}"]), - format_separator=EmptyFormatter(slots=["<|eot_id|>"]), - efficient_eos=True, + stop_words=["<|eot_id|>"], + replace_eos=True, force_system=True, ) -_register_template( - name="llama2_zh", - format_user=StringFormatter(slots=[{"bos_token"}, "[INST] {{content}} [/INST]"]), - format_system=StringFormatter(slots=["<>\n{{content}}\n<>\n\n"]), - default_system="You are a helpful assistant. 你是一个乐于助人的助手。", -) - - _register_template( name="mistral", format_user=StringFormatter(slots=[" [INST] {{content}} [/INST]"]), diff --git a/src/llmtuner/extras/constants.py b/src/llmtuner/extras/constants.py index 07ccbc0d..78352a01 100644 --- a/src/llmtuner/extras/constants.py +++ b/src/llmtuner/extras/constants.py @@ -517,15 +517,19 @@ register_model_group( models={ "LLaMA3-8B": { DownloadSource.DEFAULT: "meta-llama/Meta-Llama-3-8B", + DownloadSource.MODELSCOPE: "LLM-Research/Meta-Llama-3-8B", }, "LLaMA3-70B": { DownloadSource.DEFAULT: "meta-llama/Meta-Llama-3-70B", + DownloadSource.MODELSCOPE: "LLM-Research/Meta-Llama-3-70B", }, "LLaMA3-8B-Chat": { DownloadSource.DEFAULT: "meta-llama/Meta-Llama-3-8B-Instruct", + DownloadSource.MODELSCOPE: "LLM-Research/Meta-Llama-3-8B-Instruct", }, "LLaMA3-70B-Chat": { DownloadSource.DEFAULT: "meta-llama/Meta-Llama-3-70B-Instruct", + DownloadSource.MODELSCOPE: "LLM-Research/Meta-Llama-3-70B-Instruct", }, }, template="llama3",