-
-
Notifications
You must be signed in to change notification settings - Fork 877
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from OpenAccess-AI-Collective/prompter-fixes
fix camel ai, add guanaco/oasst mapping for sharegpt
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |