Skip to content

Commit

Permalink
ChatML prompt template (#1882)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysjprojects authored Dec 23, 2024
1 parent 1811ecc commit 5670d46
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions litgpt/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,31 +290,32 @@ def apply(self, prompt: str, **kwargs: str) -> str:
return f"<|endoftext|><|user|>\n{prompt}\n<|assistant|>\n"


class Qwen2_5(PromptStyle):
def apply(self, prompt: str, **kwargs: str) -> str:
system_message = "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."
return f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
class ChatML(PromptStyle):
def __init__(self, system_message: str):
self.system_message = system_message

class Qwen2_5_Math(PromptStyle):
def apply(self, prompt: str, **kwargs: str) -> str:
system_message = "Please reason step by step, and put your final answer within \\boxed{}."
return f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
return f"<|im_start|>system\n{self.system_message}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"

class QwQ(PromptStyle):
def apply(self, prompt: str, **kwargs: str) -> str:
system_message = "You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step."
return f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
class Qwen2_5(ChatML):
def __init__(self):
super().__init__("You are Qwen, created by Alibaba Cloud. You are a helpful assistant.")

class Salamandra(PromptStyle):
def apply(self, prompt: str, **kwargs: str) -> str:
system_message = "I am Salamandra, an AI language model developed at the Barcelona Supercomputing Centre (BSC) by the Language Technologies Unit. My knowledge base was last updated on August 2023. Today Date: 2024-09-30\nSoy Salamandra, un modelo lingüístico de IA desarrollado en el Barcelona Supercomputing Centre (BSC) por la Language Technologies Unit. Mi base de conocimientos se actualizó por última vez en agosto de 2023.\nSoc Salamandra, un model de llenguatge d'IA desenvolupat al Barcelona Supercomputing Centre (BSC) per la Language Technologies Unit. La meva base de coneixement es va actualitzar per última vegada l'agost de 2023."
return f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
class Qwen2_5_Math(ChatML):
def __init__(self):
super().__init__("Please reason step by step, and put your final answer within \\boxed{}.")

class QwQ(ChatML):
def __init__(self):
super().__init__("You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step.")

class SmolLM2(PromptStyle):
def apply(self, prompt: str, **kwargs: str) -> str:
system_message = "You are a helpful AI assistant named SmolLM, trained by Hugging Face"
return f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
class SmolLM2(ChatML):
def __init__(self):
super().__init__("You are a helpful AI assistant named SmolLM, trained by Hugging Face")

class Salamandra(ChatML):
def __init__(self):
super().__init__("I am Salamandra, an AI language model developed at the Barcelona Supercomputing Centre (BSC) by the Language Technologies Unit. My knowledge base was last updated on August 2023. Today Date: 2024-09-30\nSoy Salamandra, un modelo lingüístico de IA desarrollado en el Barcelona Supercomputing Centre (BSC) por la Language Technologies Unit. Mi base de conocimientos se actualizó por última vez en agosto de 2023.\nSoc Salamandra, un model de llenguatge d'IA desenvolupat al Barcelona Supercomputing Centre (BSC) per la Language Technologies Unit.")


# Maps prompt style names to PromptStyle classes
Expand Down

0 comments on commit 5670d46

Please sign in to comment.