mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-09 12:18:12 +00:00
llms: add cpu support
This commit is contained in:
parent
f52c7523b5
commit
89970bd71c
@ -9,6 +9,8 @@ from transformers import (
|
|||||||
AutoModel
|
AutoModel
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from pilot.configs.model_config import DEVICE
|
||||||
|
|
||||||
class BaseLLMAdaper:
|
class BaseLLMAdaper:
|
||||||
"""The Base class for multi model, in our project.
|
"""The Base class for multi model, in our project.
|
||||||
We will support those model, which performance resemble ChatGPT """
|
We will support those model, which performance resemble ChatGPT """
|
||||||
@ -64,10 +66,17 @@ class ChatGLMAdapater(BaseLLMAdaper):
|
|||||||
|
|
||||||
def loader(self, model_path: str, from_pretrained_kwargs: dict):
|
def loader(self, model_path: str, from_pretrained_kwargs: dict):
|
||||||
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
||||||
model = AutoModel.from_pretrained(
|
|
||||||
model_path, trust_remote_code=True, **from_pretrained_kwargs
|
if DEVICE != "cuda":
|
||||||
).half().cuda()
|
model = AutoModel.from_pretrained(
|
||||||
return model, tokenizer
|
model_path, trust_remote_code=True, **from_pretrained_kwargs
|
||||||
|
).float()
|
||||||
|
return model, tokenizer
|
||||||
|
else:
|
||||||
|
model = AutoModel.from_pretrained(
|
||||||
|
model_path, trust_remote_code=True, **from_pretrained_kwargs
|
||||||
|
).half().cuda()
|
||||||
|
return model, tokenizer
|
||||||
|
|
||||||
class CodeGenAdapter(BaseLLMAdaper):
|
class CodeGenAdapter(BaseLLMAdaper):
|
||||||
pass
|
pass
|
||||||
|
@ -155,6 +155,7 @@ if __name__ == "__main__":
|
|||||||
model_path = LLM_MODEL_CONFIG[CFG.LLM_MODEL]
|
model_path = LLM_MODEL_CONFIG[CFG.LLM_MODEL]
|
||||||
print(model_path, DEVICE)
|
print(model_path, DEVICE)
|
||||||
|
|
||||||
|
|
||||||
worker = ModelWorker(
|
worker = ModelWorker(
|
||||||
model_path=model_path,
|
model_path=model_path,
|
||||||
model_name=CFG.LLM_MODEL,
|
model_name=CFG.LLM_MODEL,
|
||||||
|
@ -42,6 +42,7 @@ tenacity==8.2.2
|
|||||||
peft
|
peft
|
||||||
pycocoevalcap
|
pycocoevalcap
|
||||||
sentence-transformers
|
sentence-transformers
|
||||||
|
cpm_kernels
|
||||||
umap-learn
|
umap-learn
|
||||||
notebook
|
notebook
|
||||||
gradio==3.23
|
gradio==3.23
|
||||||
|
Loading…
Reference in New Issue
Block a user