MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / _call

Method _call

bmtools/models/opt_model.py:23–43  ·  view source on GitHub ↗
(self, prompt: str, stop: Optional[List[str]] = None)

Source from the content-addressed store, hash-verified

21 return self.model_name
22
23 def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
24
25 inputs = self.tokenizer(
26 prompt,
27 padding=True,
28 max_length=512, # 512 by default,tokenizer.model_max_length=1000000000000000019884624838656
29 truncation=True,
30 return_tensors="pt"
31 )
32
33 inputs_len = inputs["input_ids"].shape[1]
34
35 generated_outputs = self.model.generate(
36 inputs['input_ids'],
37 max_new_tokens=512,
38 )
39 decoded_output = self.tokenizer.batch_decode(
40 generated_outputs[..., inputs_len:], skip_special_tokens=True, clean_up_tokenization_spaces=False)
41
42 output = decoded_output[0]
43 return output
44
45 @property
46 def _identifying_params(self) -> Mapping[str, Any]:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected