|
@@ -6,15 +6,15 @@ import torch
|
|
|
|
|
|
|
|
|
class ChatGLM_LLM(LLM):
|
|
|
- # 基于本地 InternLM 自定义 LLM 类
|
|
|
+ # 鍩轰簬鏈�湴 InternLM 鑷�畾涔� LLM 绫�
|
|
|
tokenizer: AutoTokenizer = None
|
|
|
model: AutoModelForCausalLM = None
|
|
|
|
|
|
def __init__(self, model_path: str):
|
|
|
- # model_path: InternLM 模型路径
|
|
|
- # 从本地初始化模型
|
|
|
+ # model_path: InternLM 妯″瀷璺�緞
|
|
|
+ # 浠庢湰鍦板垵濮嬪寲妯″瀷
|
|
|
super().__init__()
|
|
|
- print("正在从本地加载模型...")
|
|
|
+ print("姝e湪浠庢湰鍦板姞杞芥ā鍨�...")
|
|
|
self.tokenizer = AutoTokenizer.from_pretrained(
|
|
|
model_path, trust_remote_code=True
|
|
|
)
|
|
@@ -24,7 +24,7 @@ class ChatGLM_LLM(LLM):
|
|
|
.cuda(device=1)
|
|
|
)
|
|
|
self.model = self.model.eval()
|
|
|
- print("完成本地模型的加载")
|
|
|
+ print("瀹屾垚鏈�湴妯″瀷鐨勫姞杞�")
|
|
|
|
|
|
def _call(
|
|
|
self,
|
|
@@ -33,7 +33,7 @@ class ChatGLM_LLM(LLM):
|
|
|
run_manager: Optional[CallbackManagerForLLMRun] = None,
|
|
|
**kwargs: Any
|
|
|
):
|
|
|
- # 重写调用函数
|
|
|
+ # 閲嶅啓璋冪敤鍑芥暟
|
|
|
response, history = self.model.chat(
|
|
|
self.tokenizer, prompt, history=[], do_sample=False
|
|
|
)
|