Skip to content

Commit

Permalink
fix for system prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
winglian committed Aug 16, 2023
1 parent 0650a0f commit 9cd1ec7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/axolotl/prompt_strategies/alpaca_w_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class SystemDataPrompter(AlpacaPrompter):
Alpaca Style Prompter that uses system prompts from the dataset
"""

system_format: str = "### System:\n{system}\n\n"

def build_prompt_w_system(
self,
system: str,
Expand Down
2 changes: 1 addition & 1 deletion src/axolotl/prompt_strategies/user_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def load(tokenizer, cfg, ds_cfg: Optional[UserDefinedDatasetConfig] = None):
raise ValueError("Missing dataset prompt configuration")

system_prompt = ""
if ds_cfg.system_prompt and not ds_cfg.field_system:
if ds_cfg.system_prompt:
system_prompt = ds_cfg.system_prompt

def parse_instruction_fields(
Expand Down
14 changes: 7 additions & 7 deletions src/axolotl/prompters.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AlpacaPrompter:

system_prompt = "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n"
system_no_input_prompt = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n"
system_format: str
system_format: str = "{system}"
turn_format: str
turn_no_input_format: str
prompt_style: Optional[PromptStyle] = None
Expand Down Expand Up @@ -63,13 +63,13 @@ def build_prompt(
# returns the full prompt from instruction and optional input
# if a label (=response, =output) is provided, it's also appended.
if input:
res = self.system_prompt + self.turn_format.format(
instruction=instruction, input=input
)
res = self.system_format.format(
system=self.system_prompt
) + self.turn_format.format(instruction=instruction, input=input)
else:
res = self.system_no_input_prompt + self.turn_no_input_format.format(
instruction=instruction
)
res = self.system_format.format(
system=self.system_no_input_prompt
) + self.turn_no_input_format.format(instruction=instruction)
if output:
res = f"{res}{output}"
yield res
Expand Down

0 comments on commit 9cd1ec7

Please sign in to comment.