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

Method __init__

code/inference/evaluators/yichat.py:11–30  ·  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 YiChatEvaluator(Evaluator):
10
11 def __init__(self, pretrained_model_name_or_path, cache_dir=None, do_sample=False):
12 super(YiChatEvaluator, 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 use_fast=False,
18 trust_remote_code=True
19 )
20 self.model = AutoModelForCausalLM.from_pretrained(
21 pretrained_model_name_or_path=pretrained_model_name_or_path,
22 cache_dir=cache_dir,
23 device_map='auto',
24 low_cpu_mem_usage=True,
25 torch_dtype=torch.float16,
26 trust_remote_code=True
27 )
28 self.model = self.model.eval()
29 self.do_sample = do_sample
30 print(f'Memory footprint: {self.model.get_memory_footprint() / 1e6:.2f} MB')
31
32 def format_prompt(self, prompt):
33 return [

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected