Generate results given a list of inputs. Args: inputs (List[PromptType]): A list of strings or PromptDicts. The PromptDict should be organized in OpenCompass' API format. max_out_len (int): The maximum length of the output. Re
(
self,
inputs: List[PromptType],
max_out_len: int = 512,
)
| 231 | self.model = path |
| 232 | |
| 233 | def generate( |
| 234 | self, |
| 235 | inputs: List[PromptType], |
| 236 | max_out_len: int = 512, |
| 237 | ) -> List[str]: |
| 238 | """Generate results given a list of inputs. |
| 239 | |
| 240 | Args: |
| 241 | inputs (List[PromptType]): A list of strings or PromptDicts. |
| 242 | The PromptDict should be organized in OpenCompass' |
| 243 | API format. |
| 244 | max_out_len (int): The maximum length of the output. |
| 245 | |
| 246 | Returns: |
| 247 | List[str]: A list of generated strings. |
| 248 | """ |
| 249 | with ThreadPoolExecutor() as executor: |
| 250 | results = list( |
| 251 | executor.map(self._generate, inputs, |
| 252 | [max_out_len] * len(inputs))) |
| 253 | self.flush() |
| 254 | return results |
| 255 | |
| 256 | def _generate( |
| 257 | self, |