Skip to content

Commit

Permalink
feat(model): Support Starling-LM-7B-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyinc committed Mar 29, 2024
1 parent e0ab852 commit 943951e
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ At present, we have introduced several key features to showcase our current capa
We offer extensive model support, including dozens of large language models (LLMs) from both open-source and API agents, such as LLaMA/LLaMA2, Baichuan, ChatGLM, Wenxin, Tongyi, Zhipu, and many more.

- News
- 🔥🔥🔥 [Starling-LM-7B-beta](https://huggingface.co/Nexusflow/Starling-LM-7B-beta)
- 🔥🔥🔥 [gemma-7b-it](https://huggingface.co/google/gemma-7b-it)
- 🔥🔥🔥 [gemma-2b-it](https://huggingface.co/google/gemma-2b-it)
- 🔥🔥🔥 [SOLAR-10.7B](https://huggingface.co/upstage/SOLAR-10.7B-Instruct-v1.0)
Expand Down
2 changes: 2 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
海量模型支持,包括开源、API代理等几十种大语言模型。如LLaMA/LLaMA2、Baichuan、ChatGLM、文心、通义、智谱等。当前已支持如下模型:

- 新增支持模型
- 🔥🔥🔥 [Starling-LM-7B-beta](https://huggingface.co/Nexusflow/Starling-LM-7B-beta)
- 🔥🔥🔥 [gemma-7b-it](https://huggingface.co/google/gemma-7b-it)
- 🔥🔥🔥 [gemma-2b-it](https://huggingface.co/google/gemma-2b-it)
- 🔥🔥🔥 [SOLAR-10.7B](https://huggingface.co/upstage/SOLAR-10.7B-Instruct-v1.0)
Expand All @@ -161,6 +162,7 @@
- [更多开源模型](https://www.yuque.com/eosphoros/dbgpt-docs/iqaaqwriwhp6zslc#qQktR)

- 支持在线代理模型
- [x] [零一万物.Yi](https://platform.lingyiwanwu.com/docs)
- [x] [OpenAI·ChatGPT](https://api.openai.com/)
- [x] [百川·Baichuan](https://platform.baichuan-ai.com/)
- [x] [阿里·通义](https://www.aliyun.com/product/dashscope)
Expand Down
1 change: 1 addition & 0 deletions dbgpt/configs/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def get_device() -> str:
"gemma-7b-it": os.path.join(MODEL_PATH, "gemma-7b-it"),
# https://huggingface.co/google/gemma-2b-it
"gemma-2b-it": os.path.join(MODEL_PATH, "gemma-2b-it"),
"starling-lm-7b-beta": os.path.join(MODEL_PATH, "Starling-LM-7B-beta"),
}

EMBEDDING_MODEL_CONFIG = {
Expand Down
54 changes: 54 additions & 0 deletions dbgpt/model/adapter/hf_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,61 @@ def do_match(self, lower_model_name_or_path: Optional[str] = None):
)


class StarlingLMAdapter(NewHFChatModelAdapter):
"""
https://huggingface.co/Nexusflow/Starling-LM-7B-beta
"""

support_4bit: bool = True
support_8bit: bool = True
support_system_message: bool = False

def do_match(self, lower_model_name_or_path: Optional[str] = None):
return (
lower_model_name_or_path
and "starling-" in lower_model_name_or_path
and "lm" in lower_model_name_or_path
)

def get_str_prompt(
self,
params: Dict,
messages: List[ModelMessage],
tokenizer: Any,
prompt_template: str = None,
convert_to_compatible_format: bool = False,
) -> Optional[str]:
str_prompt = super().get_str_prompt(
params,
messages,
tokenizer,
prompt_template,
convert_to_compatible_format,
)
chat_mode = None
if params and "context" in params and "chat_mode" in params["context"]:
chat_mode = params["context"].get("chat_mode")
if chat_mode in [
"chat_dashboard",
"chat_with_db_execute",
"excel_learning",
"chat_excel",
]:
# Coding conversation, use code prompt
# This is a temporary solution, we should use a better way to distinguish the conversation type
# https://huggingface.co/Nexusflow/Starling-LM-7B-beta#code-examples
str_prompt = str_prompt.replace("GPT4 Correct User:", "Code User:").replace(
"GPT4 Correct Assistant:", "Code Assistant:"
)
logger.info(
f"Use code prompt for chat_mode: {chat_mode}, transform 'GPT4 Correct User:' to 'Code User:' "
"and 'GPT4 Correct Assistant:' to 'Code Assistant:'"
)
return str_prompt


register_model_adapter(YiAdapter)
register_model_adapter(Mixtral8x7BAdapter)
register_model_adapter(SOLARAdapter)
register_model_adapter(GemmaAdapter)
register_model_adapter(StarlingLMAdapter)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ def default_requires():
"zhipuai",
"dashscope",
"chardet",
"sentencepiece",
]
setup_spec.extras["default"] += setup_spec.extras["framework"]
setup_spec.extras["default"] += setup_spec.extras["rag"]
Expand Down

0 comments on commit 943951e

Please sign in to comment.