Skip to content

Commit

Permalink
add prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
awaelchli committed Apr 19, 2024
1 parent 67d0d12 commit 76137da
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions litgpt/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,23 @@ def apply(self, prompt: str, **kwargs: str) -> str:
)


class Llama3(PromptStyle):
def apply(self, prompt: str, **kwargs: str) -> str:
return (
"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n"
"You are a helpful assistant.<|eot_id|>\n"
"<|start_header_id|>user<|end_header_id|>\n\n"
f"{prompt}<|eot_id|>\n"
"<|start_header_id|>assistant<|end_header_id|>\n\n"
)

def stop_tokens(self, tokenizer: "Tokenizer") -> Tuple[List[int], ...]:
return (
[tokenizer.eos_id],
[tokenizer.token_to_id("<|eot_id|>")],
)


class FreeWilly2(PromptStyle):
def apply(self, prompt: str, **kwargs: str) -> str:
return (
Expand Down Expand Up @@ -316,6 +333,8 @@ def model_name_to_prompt_style(model_name: str) -> PromptStyle:
return Llama2FunctionCalling()
if re.search("Llama-2.*-chat", model_name):
return Llama2()
if re.search("Llama-3.*-Instruct", model_name):
return Llama3()
if re.search("FreeWilly2", model_name):
return FreeWilly2()
if re.search("Platypus", model_name):
Expand Down

0 comments on commit 76137da

Please sign in to comment.