Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nopperl authored and winglian committed Feb 26, 2024
1 parent a057076 commit 36397ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/axolotl/prompt_strategies/dpo/chatml.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def transform_fn(sample):
return transform_fn


def prompt_pairs(cfg, **kwargs): # pylint: disable=possibly-unused-variable,unused-argument
def prompt_pairs(
cfg, **kwargs
): # pylint: disable=possibly-unused-variable,unused-argument
def transform_fn(sample):
if "system" in sample and sample["system"]:
sample["prompt"] = (
Expand Down
16 changes: 12 additions & 4 deletions src/axolotl/prompt_strategies/dpo/user_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"""


def default(cfg, dataset_idx=0, **kwargs):
def default(cfg, dataset_idx=0, **kwargs): # pylint: disable=unused-argument
ds_cfg = cfg["datasets"][dataset_idx]["type"]
if not isinstance(ds_cfg, dict):
raise ValueError(f"User-defined dataset type must be a dictionary. Got: {ds_cfg}")
raise ValueError(
f"User-defined dataset type must be a dictionary. Got: {ds_cfg}"
)
field_prompt = ds_cfg.get("field_prompt", "prompt")
field_system = ds_cfg.get("field_system", "system")
field_chosen = ds_cfg.get("field_chosen", "chosen")
Expand All @@ -22,8 +24,14 @@ def default(cfg, dataset_idx=0, **kwargs):
rejected_format = "{" + field_rejected + "}"

def transform_fn(sample):
if "{" + field_system + "}" in prompt_format and field_system in sample and sample[field_system]:
sample["prompt"] = prompt_format.format(system=sample[field_system], prompt=sample[field_prompt])
if (
"{" + field_system + "}" in prompt_format
and field_system in sample
and sample[field_system]
):
sample["prompt"] = prompt_format.format(
system=sample[field_system], prompt=sample[field_prompt]
)
else:
sample["prompt"] = prompt_format.format(prompt=sample["prompt"])
sample["chosen"] = chosen_format.format(chosen=sample[field_chosen])
Expand Down

0 comments on commit 36397ab

Please sign in to comment.