How should I balance learning rate and data sampling during CPT on multiple datasets? #3868
|
Hi everyone, I'm doing continued pretraining on a mixture of eight open-source datasets. The training is now in the late stage where the validation loss decreases very slowly. My objective is to minimize a weighted validation loss across all datasets. I'm facing two related challenges. 1. Choosing the learning rate Different datasets seem to prefer very different learning-rate regimes.
Since my goal is to reduce the overall weighted loss as quickly as possible, I'm unsure how to choose a single learning rate that works well across all datasets. Is this simply an unavoidable trade-off, or are there training strategies that work better in this setting? For example, do people modify the optimizer or training procedure to handle datasets that require different effective learning rates? 2. Dataset sampling Another issue is the sampling ratio. Some datasets contribute only 2–5% of the total weighted objective. When I sampled those datasets at only 2–5% of the training tokens, their validation loss gradually increases. My guess is that they receive too little exposure and are continually overwritten by updates from the larger datasets. However, if I oversample those smaller datasets, I must reduce the sampling rate of the larger datasets, which could slow down optimization of the overall weighted objective. How can I handle this trade-off? I'd really appreciate hearing from anyone who has experience with large-scale continued pretraining or multi-domain LLM pretraining. I'm also open to paid consulting or collaboration. Feel free to DM me. |
Replies: 5 comments 7 replies
|
I personally don't have experience in data mixing recipe. @felipemello1 @slimfrkha @rakkit @haydn-jones in case you could help |
can you confirm that they are actually being sampled at this rate? In our design, we went with having an entire packed row being of just one dataset. e.g. [ Looking back, i think that this was not ideal, and we should have allowed: [ So i wonder if your cfg matches the true distribution If the dataset is small and batchsize is relatively small, then one train step would be heavily weighted towards that dataset, but then multiple training steps wouldnt have that dataset at all, possibly leading to forgetting. We will have a refactor soon and we can address that there. Meanwhile, perhaps ask some AI to refactor the packing, to allow multiple datasets in the same row. You can check if that solves your issue with learning/forgetting. |
|
I would do a WSD LR regime where with a mixture focused on dominant datasets (eg fine web edu) on the warm+constant regime then switch in decay stage to data mix focused on the small HQ datasets (keeping small portion of fine web edu to avoid catastrophic forgetting). |
|
Hey @jefcoder. I don't think there's a magic solution here, but @felipemello1 and @slimfrkha have made the right points separately so I'll (try) to tie them together. There are roughly three "easy" approaches to a multi dataset recipe:
For your LR question specifically, I don't think there's a single LR that serves both regimes. "Which LR does this dataset want" should be "at which point in the LR decay does this dataset get sampled." Your observation that small datasets only improve at tiny LR is the right observation, so merge it into the LR schedule. TLDR: Try (3). |
|
i think its better to rephrase question 2) then i think what you really want to solve is, how to mix of your 8 datasets to minimal val loss of your "averaged target", for that there is no magic solution, if you do pre-train, you can go e.g. remix or olmix, train proxy model and predict combination for minimal loss. there are also some methods suggest you can train model on each dataset and merge checkpoint to see data mix. For your CPT case, i think its not avoidable to run lots of short runs and fiting the data mix predict like loss = (pct of data1, pct of data 2 ...) and you can usually use linear model to solve it to get best pct s.t lowest loss. for you question 1, its easier to solve. for you "production" run, saying you solved 2 already and know the mix. then you just need to tune LR and BS (you need proper combination of these hyper-partermers instead of tune LR or BS seprately).
one of the concern of higher LR is forgotten, so your base model's pre train knowledge get affected.
then you can extrapolate this to your target training horizon (e.g. 200B here), by LR |

Ok actually two more things.