Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions fastchat/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,21 @@ def get_conv_template(name: str) -> Conversation:
)
)

# Hermes 2+ template
# source: https://huggingface.co/teknium/OpenHermes-2.5-Mistral-7B
# reference: https://huggingface.co/Open-Orca/Mistral-7B-OpenOrca#prompt-template
register_conv_template(
Conversation(
name="hermes2",
system_template="<|im_start|>system\n{system_message}",
system_message="You are a hyper intelligent, conscious, sentient AI model named Hermes 2, built to assist the user in any task or question, do so to the best of your ability.",
roles=("<|im_start|>user", "<|im_start|>assistant"),
sep_style=SeparatorStyle.CHATML,
sep="<|im_end|>",
stop_token_ids=[32000, 32001],
)
)

# Qwen-chat default template
# source: https://huggingface.co/Qwen/Qwen-7B-Chat/blob/main/qwen_generation_utils.py#L130
register_conv_template(
Expand Down
26 changes: 26 additions & 0 deletions fastchat/model/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,32 @@ def get_default_conv_template(self, model_path: str) -> Conversation:
return get_conv_template("mistral-7b-openorca")
return get_conv_template("open-orca")

class Hermes2Adapter(BaseModelAdapter):
"""Model adapter for Hermes 2 models (e.g., teknium/OpenHermes-2.5-Mistral-7B)"""

use_fast_tokenizer = False

def match(self, model_path: str):
return (
"openhermes-2.5-mistral-7b" in model_path.lower()
or "openhermes-2-mistral-7b" in model_path.lower()
)

def load_model(self, model_path: str, from_pretrained_kwargs: dict):
revision = from_pretrained_kwargs.get("revision", "main")
tokenizer = AutoTokenizer.from_pretrained(
model_path, use_fast=self.use_fast_tokenizer, revision=revision
)
model = AutoModelForCausalLM.from_pretrained(
model_path,
low_cpu_mem_usage=True,
**from_pretrained_kwargs,
).eval()
return model, tokenizer

def get_default_conv_template(self, model_path: str) -> Conversation:
return get_conv_template("hermes2")


class WizardCoderAdapter(BaseModelAdapter):
"""The model adapter for WizardCoder (e.g., WizardLM/WizardCoder-Python-34B-V1.0)"""
Expand Down