Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Example for training ColBERT using Pylate in terms of contrastive way #164

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Use bf16
Antoine Chaffin committed Jan 2, 2025
commit ea42756cee893299c9d61b2822e3a2e422d3463b
7 changes: 4 additions & 3 deletions examples/train_pylate_contrastive.py
Original file line number Diff line number Diff line change
@@ -9,10 +9,10 @@


def main():
# Define model parameters for contrastive training
model_name = "answerdotai/ModernBERT-base" # Choose the pre-trained model you want to use as base
model_shortname = model_name.split("/")[-1]

# Define model parameters for contrastive training
batch_size = 64 # Larger batch size often improves results, but requires more memory
lr = 3e-6
num_train_epochs = 5 # Adjust based on your requirements
@@ -49,10 +49,11 @@ def main():
num_train_epochs=num_train_epochs,
per_device_train_batch_size=batch_size,
per_device_eval_batch_size=batch_size,
fp16=True, # Set to False if you get an error that your GPU can't run on FP16
bf16=False, # Set to True if you have a GPU that supports BF16
fp16=False, # Set to False if you get an error that your GPU can't run on FP16
bf16=True, # Set to True if you have a GPU that supports BF16
run_name=run_name, # Will be used in W&B if `wandb` is installed
learning_rate=lr,
logging_steps=100,
)

# Initialize the trainer for the contrastive training