Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support stable-vicuna model #2696

Merged
merged 3 commits into from
Nov 23, 2023
Merged
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
14 changes: 14 additions & 0 deletions fastchat/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,20 @@ def get_conv_template(name: str) -> Conversation:
)
)

# Stable Vicuna default template
# source: https://huggingface.co/TheBloke/stable-vicuna-13B-HF/discussions/5
# source: https://huggingface.co/spaces/CarperAI/StableVicuna/blob/main/app.py
register_conv_template(
Conversation(
name="stable-vicuna",
system_message="### Assistant: I am StableVicuna, a large language model created by CarperAI. I am here to chat!\n",
roles=("### Human", "### Assistant"),
sep_style=SeparatorStyle.ADD_COLON_TWO,
sep="\n",
sep2="\n\n",
)
)

register_conv_template(
Conversation(
name="vigogne_chat_v3",
Expand Down
17 changes: 17 additions & 0 deletions fastchat/model/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,22 @@ def get_default_conv_template(self, model_path: str) -> Conversation:
return get_conv_template("llama-2")


class StableVicunaAdapter(BaseModelAdapter):
"""The model adapter for StableVicuna"""

def match(self, model_path: str):
return "stable-vicuna" in model_path.lower()

def load_model(self, model_path: str, from_pretrained_kwargs: dict):
model, tokenizer = super().load_model(model_path, from_pretrained_kwargs)
model.config.eos_token_id = tokenizer.eos_token_id
model.config.pad_token_id = tokenizer.pad_token_id
return model, tokenizer

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


class PhindCodeLlamaAdapter(CodeLlamaAdapter):
"""The model adapter for Phind-CodeLlama (e.g., Phind/Phind-CodeLlama-34B-v2)"""

Expand Down Expand Up @@ -1867,6 +1883,7 @@ def get_default_conv_template(self, model_path: str) -> Conversation:
# Note: the registration order matters.
# The one registered earlier has a higher matching priority.
register_model_adapter(PeftModelAdapter)
register_model_adapter(StableVicunaAdapter)
register_model_adapter(VicunaAdapter)
register_model_adapter(AiroborosAdapter)
register_model_adapter(LongChatAdapter)
Expand Down
6 changes: 6 additions & 0 deletions fastchat/model/model_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ def get_model_info(name: str) -> ModelInfo:
"https://huggingface.co/bofenghuang/vigogne-2-7b-chat",
"Vigogne-Chat is a French large language model (LLM) optimized for instruction-following and multi-turn dialogues, developed by Bofeng Huang",
)
register_model_info(
["stable-vicuna-13B-HF"],
"stable-vicuna",
"https://huggingface.co/TheBloke/stable-vicuna-13B-HF",
"StableVicuna is a Vicuna model fine-tuned using RLHF via PPO on various conversational and instructional datasets.",
)
register_model_info(
["deluxe-chat-v1", "deluxe-chat-v1.1"],
"DeluxeChat",
Expand Down