加载模型
(self, model_path, peft_path=None, trust_remote_code=True, tensor_parallel_size=1, gpu_memory_utilization=0.25)
| 78 | return params |
| 79 | |
| 80 | def load_model(self, model_path, peft_path=None, trust_remote_code=True, tensor_parallel_size=1, gpu_memory_utilization=0.25): |
| 81 | '''加载模型''' |
| 82 | print(model_path, peft_path, trust_remote_code) |
| 83 | self.tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=trust_remote_code) |
| 84 | self.model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto", trust_remote_code=trust_remote_code).eval() |
| 85 | if peft_path: |
| 86 | self.model = PeftModel.from_pretrained(self.model, peft_path) |
| 87 | |
| 88 | # self.model = LLM(model=model_path, trust_remote_code=trust_remote_code, tensor_parallel_size=tensor_parallel_size, gpu_memory_utilization=gpu_memory_utilization) |