From 995557bdf3c6c8b3e839b224ef9513fc2b097f30 Mon Sep 17 00:00:00 2001 From: kingbri Date: Fri, 1 Sep 2023 13:48:33 -0400 Subject: [PATCH] Prompters: ShareGPT: Allow for custom system prompts If a system prompt is present in a conversation, add it instead of using the default. Signed-off-by: kingbri --- src/axolotl/prompters.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/axolotl/prompters.py b/src/axolotl/prompters.py index f1fe7d456..5322a1018 100644 --- a/src/axolotl/prompters.py +++ b/src/axolotl/prompters.py @@ -309,10 +309,6 @@ class ShareGPTPrompter: # pylint: disable=too-few-public-methods ) def build_prompt(self, source) -> Generator[str, None, None]: - # ignore the system prompt if provided - if source[0]["from"] == "system": - source.pop(0) - if len(source) < 2: # If there isn't a back and forth conversation, ignore it # also happens on the data splitting leaving empty conversations @@ -321,6 +317,12 @@ class ShareGPTPrompter: # pylint: disable=too-few-public-methods ) conv = self._conversation.copy() + + # Add the conversation system prompt if provided, otherwise use the default one + if source[0]["from"] == "system": + conv.system = source[0]["value"] + source.pop(0) + roles = {"human": conv.roles[0], "gpt": conv.roles[1]} try: