feat(model): Support DeepSeek v2 lite model (#1537)

This commit is contained in:
Fangyin Cheng
2024-05-20 10:46:38 +08:00
committed by GitHub
parent 8d8411fcd3
commit d81bbec4e9
3 changed files with 29 additions and 1 deletions

View File

@@ -184,6 +184,7 @@ LLM_MODEL_CONFIG = {
# 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"),
"deepseek-v2-lite-chat": os.path.join(MODEL_PATH, "DeepSeek-V2-Lite-Chat"),
}
EMBEDDING_MODEL_CONFIG = {

View File

@@ -370,6 +370,32 @@ class Llama3Adapter(NewHFChatModelAdapter):
return str_prompt
class DeepseekV2Adapter(NewHFChatModelAdapter):
support_4bit: bool = False
support_8bit: bool = False
def do_match(self, lower_model_name_or_path: Optional[str] = None):
return (
lower_model_name_or_path
and "deepseek" in lower_model_name_or_path
and "v2" in lower_model_name_or_path
and "chat" in lower_model_name_or_path
)
def load(self, model_path: str, from_pretrained_kwargs: dict):
if not from_pretrained_kwargs:
from_pretrained_kwargs = {}
if "trust_remote_code" not in from_pretrained_kwargs:
from_pretrained_kwargs["trust_remote_code"] = True
model, tokenizer = super().load(model_path, from_pretrained_kwargs)
from transformers import GenerationConfig
model.generation_config = GenerationConfig.from_pretrained(model_path)
model.generation_config.pad_token_id = model.generation_config.eos_token_id
return model, tokenizer
# The following code is used to register the model adapter
# The last registered model adapter is matched first
register_model_adapter(YiAdapter)
@@ -381,3 +407,4 @@ register_model_adapter(StarlingLMAdapter)
register_model_adapter(QwenAdapter)
register_model_adapter(QwenMoeAdapter)
register_model_adapter(Llama3Adapter)
register_model_adapter(DeepseekV2Adapter)

View File

@@ -41,7 +41,7 @@ clone_repositories() {
}
install_dbgpt_packages() {
conda activate dbgpt && cd /root/DB-GPT && pip install -e ".[default]"
conda activate dbgpt && cd /root/DB-GPT && pip install -e ".[default]" && pip install transformers_stream_generator einops
cp .env.template .env && sed -i 's/LLM_MODEL=vicuna-13b-v1.5/LLM_MODEL=qwen-1.8b-chat/' .env
}