(index, name)
| 398 | print_split_stats('test', 2) |
| 399 | |
| 400 | def build_dataset(index, name): |
| 401 | from megatron.data.bert_dataset import BertDataset |
| 402 | from megatron.data.ict_dataset import ICTDataset |
| 403 | dataset = None |
| 404 | if splits[index + 1] > splits[index]: |
| 405 | # Get the pointer to the original doc-idx so we can set it later. |
| 406 | doc_idx_ptr = indexed_dataset.get_doc_idx() |
| 407 | # Slice the doc-idx |
| 408 | start_index = splits[index] |
| 409 | # Add +1 so we can index into the dataset to get the upper bound. |
| 410 | end_index = splits[index + 1] + 1 |
| 411 | # New doc_idx view. |
| 412 | indexed_dataset.set_doc_idx(doc_idx_ptr[start_index:end_index]) |
| 413 | # Build the dataset accordingly. |
| 414 | kwargs = dict( |
| 415 | name=name, |
| 416 | data_prefix=data_prefix, |
| 417 | num_epochs=None, |
| 418 | max_num_samples=train_valid_test_num_samples[index], |
| 419 | max_seq_length=max_seq_length, |
| 420 | seed=seed |
| 421 | ) |
| 422 | |
| 423 | if dataset_type == DSET_TYPE_ICT: |
| 424 | args = get_args() |
| 425 | dataset = ICTDataset( |
| 426 | block_dataset=indexed_dataset, |
| 427 | title_dataset=title_dataset, |
| 428 | query_in_block_prob=args.query_in_block_prob, |
| 429 | use_one_sent_docs=args.use_one_sent_docs, |
| 430 | **kwargs |
| 431 | ) |
| 432 | else: |
| 433 | dataset = BertDataset( |
| 434 | indexed_dataset=indexed_dataset, |
| 435 | masked_lm_prob=masked_lm_prob, |
| 436 | short_seq_prob=short_seq_prob, |
| 437 | **kwargs |
| 438 | ) |
| 439 | |
| 440 | # Set the original pointer so dataset remains the main dataset. |
| 441 | indexed_dataset.set_doc_idx(doc_idx_ptr) |
| 442 | # Checks. |
| 443 | assert indexed_dataset.doc_idx[0] == 0 |
| 444 | assert indexed_dataset.doc_idx.shape[0] == \ |
| 445 | (total_num_of_documents + 1) |
| 446 | return dataset |
| 447 | |
| 448 | train_dataset = build_dataset(0, 'train') |
| 449 | valid_dataset = build_dataset(1, 'valid') |
no test coverage detected