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

Method __init__

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

Source from the content-addressed store, hash-verified

9class PULSEEvaluator(Evaluator):
10
11 def __init__(self, pretrained_model_name_or_path, cache_dir=None, do_sample=False, max_length=4096):
12 super(PULSEEvaluator, 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 = AutoModelForCausalLM.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 self.max_length = max_length
30 print(f'Memory footprint: {self.model.get_memory_footprint() / 1e6:.2f} MB')
31
32 def format_prompt(self, prompt):
33 return f'Instructions: You are Helper, a large language model full of intelligence. Respond conversationally.</s>User: {prompt}</s> Helper: '

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected