| 286 | random.shuffle(self.data) |
| 287 | |
| 288 | def sample( |
| 289 | self, |
| 290 | num_requests: int, |
| 291 | lora_path: Optional[str] = None, |
| 292 | max_loras: Optional[int] = None, |
| 293 | output_len: Optional[int] = None, |
| 294 | enable_multimodal_chat: bool = False, |
| 295 | **kwargs, |
| 296 | ) -> list: |
| 297 | samples: list = [] |
| 298 | cnt = 1 |
| 299 | for entry in self.data: |
| 300 | if len(samples) >= num_requests: |
| 301 | break |
| 302 | json_data = entry |
| 303 | prompt = entry["messages"][-1].get("content", "") |
| 304 | history_QA = entry.get("messages", []) |
| 305 | response_format = entry.get("response_format") |
| 306 | new_output_len = int(entry.get("max_tokens", output_len if output_len else 12288)) |
| 307 | |
| 308 | if enable_multimodal_chat: |
| 309 | prompt = self.apply_multimodal_chat_transformation(prompt, None) |
| 310 | samples.append( |
| 311 | SampleRequest( |
| 312 | no=cnt, |
| 313 | json_data=json_data, |
| 314 | prompt=prompt, |
| 315 | prompt_len=0, |
| 316 | history_QA=history_QA, |
| 317 | expected_output_len=new_output_len, |
| 318 | response_format=response_format, |
| 319 | ) |
| 320 | ) |
| 321 | cnt += 1 |
| 322 | |
| 323 | self.maybe_oversample_requests(samples, num_requests) |
| 324 | return samples |
| 325 | |
| 326 | |
| 327 | class RandomTextDataset(BenchmarkDataset): |