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

Method complete

bmtools/tools/database/utils/llm.py:103–117  ·  view source on GitHub ↗

Generates text from the model and returns the log prob data.

(self, prompt, n)

Source from the content-addressed store, hash-verified

101 return text
102
103 def complete(self, prompt, n):
104 """Generates text from the model and returns the log prob data."""
105 if not isinstance(prompt, list):
106 prompt = [prompt]
107 batch_size = self.config['batch_size']
108 prompt_batches = [prompt[i:i + batch_size]
109 for i in range(0, len(prompt), batch_size)]
110 if not self.disable_tqdm:
111 print(
112 f"[{self.config['name']}] Generating {len(prompt) * n} completions, "
113 f"split into {len(prompt_batches)} batches of size {batch_size * n}")
114 res = []
115 for prompt_batch in tqdm(prompt_batches, disable=self.disable_tqdm):
116 res += self.__complete(prompt_batch, n)
117 return res
118
119 def log_probs(self, text, log_prob_range=None):
120 """Returns the log probs of the text."""

Callers

nothing calls this directly

Calls 1

__completeMethod · 0.95

Tested by

no test coverage detected