The contrastors library provides different entry points for training text models using train.py.
Masked Language Modeling (MLM) Pretraining
To train a model (like BERT) from scratch:
cd src/contrastors
deepspeed --num_gpus=8 train.py --config=configs/train/mlm.yaml --deepspeed_config=configs/deepspeed/ds_config.json --dtype=bf16
Contrastive Pretraining
To launch contrastive pretraining (e.g., on ~200M examples):
cd src/contrastors
torchrun --nproc-per-node=8 train.py --config=configs/train/contrastive_pretrain.yaml --dtype=bf16
Note: Modify data_args.input_shards in the config to change the dataset.
Contrastive Finetuning
To finetune nomic-bert-embed-v1-unsupervised:
# Use the finetune config instead of pretrain
torchrun --nproc-per-node=8 train.py --config=configs/train/contrastive_finetune.yaml --dtype=bf16
# MLM Pretraining
cd src/contrastors
deepspeed --num_gpus=8 train.py --config=configs/train/mlm.yaml --deepspeed_config=configs/deepspeed/ds_config.json --dtype=bf16
# Contrastive Pretraining
torchrun --nproc-per-node=8 train.py --config=configs/train/contrastive_pretrain.yaml --dtype=bf16