MCPcopy Create free account
hub / github.com/WeixiangYAN/ClinicalLab / __init__

Method __init__

code/inference/evaluators/bianque2.py:11–29  ·  view source on GitHub ↗
(self, pretrained_model_name_or_path, cache_dir=None, do_sample=False)

Source from the content-addressed store, hash-verified

9class BianQue2Evaluator(Evaluator):
10
11 def __init__(self, pretrained_model_name_or_path, cache_dir=None, do_sample=False):
12 super(BianQue2Evaluator, self).__init__()
13
14 self.tokenizer = AutoTokenizer.from_pretrained(
15 pretrained_model_name_or_path=pretrained_model_name_or_path,
16 cache_dir=cache_dir,
17 trust_remote_code=True
18 )
19 self.model = AutoModel.from_pretrained(
20 pretrained_model_name_or_path=pretrained_model_name_or_path,
21 cache_dir=cache_dir,
22 device_map='auto',
23 low_cpu_mem_usage=True,
24 torch_dtype=torch.float16,
25 trust_remote_code=True
26 )
27 self.model = self.model.eval()
28 self.do_sample = do_sample
29 print(f'Memory footprint: {self.model.get_memory_footprint() / 1e6:.2f} MB')
30
31 def format_prompt(self, prompt):
32 return f'病人:{prompt}\n医生:'

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected