mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-23 04:12:13 +00:00
feat(model): Support Yi-1.5 models (#1516)
This commit is contained in:
parent
c21cc8f583
commit
81fb56a67c
@ -158,6 +158,9 @@ 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
|
||||
- 🔥🔥🔥 [Yi-1.5-34B-Chat](https://huggingface.co/01-ai/Yi-1.5-34B-Chat)
|
||||
- 🔥🔥🔥 [Yi-1.5-9B-Chat](https://huggingface.co/01-ai/Yi-1.5-9B-Chat)
|
||||
- 🔥🔥🔥 [Yi-1.5-6B-Chat](https://huggingface.co/01-ai/Yi-1.5-6B-Chat)
|
||||
- 🔥🔥🔥 [Qwen1.5-110B-Chat](https://huggingface.co/Qwen/Qwen1.5-110B-Chat)
|
||||
- 🔥🔥🔥 [Qwen1.5-MoE-A2.7B-Chat](https://huggingface.co/Qwen/Qwen1.5-MoE-A2.7B-Chat)
|
||||
- 🔥🔥🔥 [Meta-Llama-3-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct)
|
||||
|
@ -152,6 +152,9 @@
|
||||
海量模型支持,包括开源、API代理等几十种大语言模型。如LLaMA/LLaMA2、Baichuan、ChatGLM、文心、通义、智谱等。当前已支持如下模型:
|
||||
|
||||
- 新增支持模型
|
||||
- 🔥🔥🔥 [Yi-1.5-34B-Chat](https://huggingface.co/01-ai/Yi-1.5-34B-Chat)
|
||||
- 🔥🔥🔥 [Yi-1.5-9B-Chat](https://huggingface.co/01-ai/Yi-1.5-9B-Chat)
|
||||
- 🔥🔥🔥 [Yi-1.5-6B-Chat](https://huggingface.co/01-ai/Yi-1.5-6B-Chat)
|
||||
- 🔥🔥🔥 [Qwen1.5-110B-Chat](https://huggingface.co/Qwen/Qwen1.5-110B-Chat)
|
||||
- 🔥🔥🔥 [Qwen1.5-MoE-A2.7B-Chat](https://huggingface.co/Qwen/Qwen1.5-MoE-A2.7B-Chat)
|
||||
- 🔥🔥🔥 [Meta-Llama-3-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct)
|
||||
|
@ -174,6 +174,10 @@ LLM_MODEL_CONFIG = {
|
||||
# https://huggingface.co/01-ai/Yi-34B-Chat-4bits
|
||||
"yi-34b-chat-4bits": os.path.join(MODEL_PATH, "Yi-34B-Chat-4bits"),
|
||||
"yi-6b-chat": os.path.join(MODEL_PATH, "Yi-6B-Chat"),
|
||||
# https://huggingface.co/01-ai/Yi-1.5-6B-Chat
|
||||
"yi-1.5-6b-chat": os.path.join(MODEL_PATH, "Yi-1.5-6B-Chat"),
|
||||
"yi-1.5-9b-chat": os.path.join(MODEL_PATH, "Yi-1.5-9B-Chat"),
|
||||
"yi-1.5-34b-chat": os.path.join(MODEL_PATH, "Yi-1.5-34B-Chat"),
|
||||
# https://huggingface.co/google/gemma-7b-it
|
||||
"gemma-7b-it": os.path.join(MODEL_PATH, "gemma-7b-it"),
|
||||
# https://huggingface.co/google/gemma-2b-it
|
||||
|
@ -524,11 +524,11 @@ def get_model_adapter(
|
||||
"""
|
||||
adapter = None
|
||||
# First find adapter by model_name
|
||||
for adapter_entry in model_adapters:
|
||||
for adapter_entry in model_adapters[::-1]:
|
||||
if adapter_entry.model_adapter.match(model_type, model_name, None):
|
||||
adapter = adapter_entry.model_adapter
|
||||
break
|
||||
for adapter_entry in model_adapters:
|
||||
for adapter_entry in model_adapters[::-1]:
|
||||
if adapter_entry.model_adapter.match(model_type, None, model_path):
|
||||
adapter = adapter_entry.model_adapter
|
||||
break
|
||||
|
@ -135,6 +135,41 @@ class YiAdapter(NewHFChatModelAdapter):
|
||||
)
|
||||
|
||||
|
||||
class Yi15Adapter(YiAdapter):
|
||||
"""Yi 1.5 model adapter."""
|
||||
|
||||
def do_match(self, lower_model_name_or_path: Optional[str] = None):
|
||||
return (
|
||||
lower_model_name_or_path
|
||||
and "yi-" in lower_model_name_or_path
|
||||
and "1.5" in lower_model_name_or_path
|
||||
and "chat" 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,
|
||||
)
|
||||
terminators = [
|
||||
tokenizer.eos_token_id,
|
||||
]
|
||||
exist_token_ids = params.get("stop_token_ids", [])
|
||||
terminators.extend(exist_token_ids)
|
||||
params["stop_token_ids"] = terminators
|
||||
return str_prompt
|
||||
|
||||
|
||||
class Mixtral8x7BAdapter(NewHFChatModelAdapter):
|
||||
"""
|
||||
https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1
|
||||
@ -335,7 +370,10 @@ class Llama3Adapter(NewHFChatModelAdapter):
|
||||
return str_prompt
|
||||
|
||||
|
||||
# The following code is used to register the model adapter
|
||||
# The last registered model adapter is matched first
|
||||
register_model_adapter(YiAdapter)
|
||||
register_model_adapter(Yi15Adapter)
|
||||
register_model_adapter(Mixtral8x7BAdapter)
|
||||
register_model_adapter(SOLARAdapter)
|
||||
register_model_adapter(GemmaAdapter)
|
||||
|
Loading…
Reference in New Issue
Block a user