BERT pretraining requires a sharded data format managed by a streaming dataloader.
Directory Structure:
Data/
├── json/
│ ├── train.json
│ └── valid.json
├── shard/
│ ├── train/
│ │ ├── 00000.txt
│ │ └── ...
│ └── valid/
│ ├── 00000.txt
│ └── ...
├── dict.txt
└── sentencepiece.bpe.model
Shard File Format:
Each shard should contain no more than 10K lines. One sentence per line, with an empty line separating documents.
JSON Metadata Format:
[
{
"source": [
"shard/train/00000.txt",
"shard/train/00001.txt"
],
"source_lang": "en",
"weight": 1.0
}
]
Extracting dict.txt from a SentencePiece model:
spm_export_vocab --model=sentencepiece.bpe.model | sed 's/\t/ /g' | tail -n +4 > dict.txt