MCPcopy Create free account
hub / github.com/codefuse-ai/codefuse-devops-eval / load_model

Method load_model

src/models/baichuan_model.py:82–91  ·  view source on GitHub ↗

加载模型

(self, model_path, peft_path=None, trust_remote_code=True, tensor_parallel_size=1, gpu_memory_utilization=0.25)

Source from the content-addressed store, hash-verified

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

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected