From b32c08f8cc1d21ef52eb80d424cb7f16e7e0f5b5 Mon Sep 17 00:00:00 2001 From: Antoni-Joan Solergibert <74564958+TJ-Solergibert@users.noreply.github.com> Date: Fri, 10 May 2024 16:40:05 +0200 Subject: [PATCH] adding llama3 fastchat conversation monkeypatch (#1539) * adding llama3 fastchat conversation monkeypatch * Updated conversation turns to work with PR3259 of FastChat * fixed bos token * bump fastchat version --------- Co-authored-by: Wing Lian --- requirements.txt | 2 +- .../monkeypatch/fastchat_conversation_turns.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 26525be15d..b15a28c901 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,7 +28,7 @@ scipy scikit-learn==1.2.2 pynvml art -fschat @ git+https://github.com/lm-sys/FastChat.git@5095615810cf613dba7f27dd155f571fcff976d8 +fschat @ git+https://github.com/lm-sys/FastChat.git@27a05b04a35510afb1d767ae7e5990cbd278f8fe gradio==3.50.2 tensorboard diff --git a/src/axolotl/monkeypatch/fastchat_conversation_turns.py b/src/axolotl/monkeypatch/fastchat_conversation_turns.py index 7ab07d4854..a09bfddb4b 100644 --- a/src/axolotl/monkeypatch/fastchat_conversation_turns.py +++ b/src/axolotl/monkeypatch/fastchat_conversation_turns.py @@ -123,6 +123,17 @@ def get_turns( # pylint: disable=too-many-return-statements else: yield role, "" return + if self.sep_style == SeparatorStyle.LLAMA3: + if self.system_message: + # For llama3, the system message is NOT incorporated into the first human instruction + # All messages follow <|start_header_id|>' + role + '<|end_header_id|>\n\n'+ message + '<|eot_id|> + yield "", system_prompt + for i, (role, message) in enumerate(self.messages): + if message: + yield f"<|start_header_id|>{role}<|end_header_id|>\n\n", f"{message.strip()}<|eot_id|>" + else: + yield f"<|start_header_id|>{role}<|end_header_id|>\n\n", "" + return if self.sep_style == SeparatorStyle.GEMMA: if self.system_message: raise ValueError("Gemma chat template does not support system messages")