Skip to content

Commit

Permalink
support stable-vicuna model (lm-sys#2696)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-jin authored and zhanghao.smooth committed Jan 26, 2024
1 parent 2c11c16 commit b207d02
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
14 changes: 14 additions & 0 deletions fastchat/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,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 @@ -1829,6 +1829,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 @@ -1913,6 +1929,7 @@ def get_default_conv_template(self, model_path: str) -> Conversation:
# The one registered earlier has a higher matching priority.
register_model_adapter(RerankAdapter)
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

0 comments on commit b207d02

Please sign in to comment.