File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,4 +99,34 @@ python3 train.py \
9999 --config_file=configs/experiments/wiki_tfds_pretrain.yaml \
100100 --tpu=${TPU_NAME} \
101101 --params_override=$PARAMS
102- ```
102+ ```
103+
104+ ## Pre-train ELECTRA from scratch
105+
106+ The ` electra/pretraining ` experiment uses the same BERT-style TFRecord input
107+ format as the BERT pretraining experiment. First prepare the input files with
108+ the ` create_pretraining_data.py ` command above, then update
109+ ` configs/experiments/wiki_books_pretrain.yaml ` with the training and validation
110+ input paths. The default ELECTRA configuration uses a 12-layer, 768-hidden
111+ discriminator and generator; override the model fields when a different model
112+ size is required.
113+
114+ Start a training and evaluation job with:
115+
116+ ``` shell
117+ export OUTPUT_DIR=gs://some_bucket/my_electra_output_dir
118+ export PARAMS=runtime.distribution_strategy=tpu
119+
120+ python3 train.py \
121+ --experiment=electra/pretraining \
122+ --mode=train_and_eval \
123+ --model_dir=$OUTPUT_DIR \
124+ --config_file=configs/experiments/wiki_books_pretrain.yaml \
125+ --tpu=${TPU_NAME} \
126+ --params_override=$PARAMS
127+ ```
128+
129+ The experiment trains both the generator's masked-language-model objective and
130+ the discriminator's replaced-token-detection objective. For GPU or CPU runs,
131+ omit ` --tpu ` and set ` runtime.distribution_strategy ` to the strategy supported
132+ by the target environment.
You can’t perform that action at this time.
0 commit comments