Skip to content

Commit

Permalink
Merge pull request #158 from OpenAccess-AI-Collective/prompter-fixes
Browse files Browse the repository at this point in the history
fix camel ai, add guanaco/oasst mapping for sharegpt
  • Loading branch information
winglian authored Jun 7, 2023
2 parents 9a02e7e + 59bb219 commit 6abfd87
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/axolotl/prompt_strategies/alpaca_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def parse_instruction_fields(self, prompt) -> Tuple[str, str, str]:
return (
prompt["message_1"],
"",
prompt["message_1"],
prompt["message_2"],
)


Expand Down
46 changes: 46 additions & 0 deletions src/axolotl/prompt_strategies/sharegpt_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Module containing the SimpleShareGPTPromptTokenizingStrategy class"""

from axolotl.prompt_tokenizers import ShareGPTPromptTokenizingStrategy
from axolotl.prompters import PromptStyle, ShareGPTPrompter


def load(tokenizer, cfg):
return SimpleShareGPTPromptTokenizingStrategy(
ShareGPTPrompter(PromptStyle.CHAT.value),
tokenizer,
cfg.train_on_inputs,
cfg.sequence_len,
)


def load_guanaco(tokenizer, cfg):
return GuanacoShareGPTPromptTokenizingStrategy(
ShareGPTPrompter(PromptStyle.CHAT.value),
tokenizer,
cfg.train_on_inputs,
cfg.sequence_len,
)


class SimpleShareGPTPromptTokenizingStrategy(ShareGPTPromptTokenizingStrategy):
"""
basic sharegpt strategy to grab conversations from the sample row
"""

def get_conversation_thread(self, prompt):
return prompt["conversations"]


class GuanacoShareGPTPromptTokenizingStrategy(ShareGPTPromptTokenizingStrategy):
"""
sharegpt strategy that remaps oasst data to sharegpt format
"""

def get_conversation_thread(self, prompt):
conversations = prompt["conversations"]
# remap role: prompter/assistant, text: ... => from: human/gpt, value: ...
role_map = {"prompter": "human", "assistant": "gpt"}
turns = [
{"from": role_map[t["role"]], "value": t["text"]} for t in conversations
]
return turns

0 comments on commit 6abfd87

Please sign in to comment.