Title: DoReMi: Optimizing Data Mixtures Speeds Up Language Model Pretraining
Venue: NeurIPS 2023
Accepted: yes
Keywords: language models

pretraining

domain reweighting

data curation
Abstract: The mixture proportions of pretraining data domains (e.g., Wikipedia, books, web text) greatly affect language model (LM) performance. In this paper, we propose Domain Reweighting with Minimax Optimization (DoReMi), which first trains a small proxy model using group distributionally robust optimization (Group DRO) over domains to produce domain weights (mixture proportions) without knowledge of downstream tasks. We then resample a dataset with these domain weights and train a larger, full-sized model. In our experiments, we use DoReMi on a 280M-parameter proxy model to set the domain weights for training an 8B-parameter model (30x larger) more efficiently. On The Pile, DoReMi improves perplexity across all domains, even when it downweights a domain. DoReMi improves average few-shot downstream accuracy by 6.5% points over a baseline model trained using The Pile's default domain weights and reaches the baseline accuracy with 2.6x fewer training steps. On the GLaM dataset, DoReMi, which has no knowledge of downstream tasks, even matches the performance of using domain weights tuned on downstream tasks.

DoReMi: Optimizing Data Mixtures Speeds Up Language Model Pretraining

Abstract

The mixture proportions of pretraining data domains (e.g., Wikipedia, books, web text) greatly affect language model (LM) performance. In this paper, we propose Domain Reweighting with Minimax Optimization (DoReMi), which first trains a small proxy model using group distributionally robust optimization (Group DRO) over domains to produce domain weights (mixture proportions) without knowledge of downstream tasks. We then resample a dataset with these domain weights and train a larger, full-sized model. In our experiments, we use DoReMi on a 280Mparameter proxy model to set the domain weights for training an 8B-parameter model (30x larger) more efficiently. On The Pile, DoReMi improves perplexity across all domains, even when it downweights a domain. DoReMi improves average few-shot downstream accuracy by 6.5% points over a baseline model trained using The Pile's default domain weights and reaches the baseline accuracy with 2.6x fewer training steps. On the GLaM dataset, DoReMi, which has no knowledge of downstream tasks, even matches the performance of using domain weights tuned on downstream tasks.

1 Introduction

Datasets for training language models (LMs) are typically sampled from a mixture of many domains [17; 13; 10; 9]. For example, The Pile [17], a large publicly available dataset, is composed of 24% web data, 9% Wikipedia, 4% GitHub, etc. 1 The composition of the pretraining data greatly affects the effectiveness of an LM [13; 20; 55]. However, it is unclear how much of each domain to include to produce a model that performs well for a wide variety of downstream tasks.

Existing works determine domain weights (the sampling probabilities for each domain) by using intuition or a set of downstream tasks. For example, The Pile uses heuristically-chosen domain weights, which could be suboptimal. On the other hand, existing LMs such as PaLM [10] and GLaM [13] tune the domain weights based on a set of downstream tasks, but requires training potentially thousands of LMs on different domain weights and risks overfitting to the particular set of downstream tasks.

Instead of optimizing domain weights based on a set of downstream tasks, our approach aims to find domain weights which lead to models that perform well on all domains by minimizing the worst-case excess loss over domains, following Oren et al. [35]; Mindermann et al. [30]. The excess loss is the loss gap between the model being evaluated and a pretrained reference model.

This motivates our algorithm, Do main Re weighting with Mi nimax Optimization (DoReMi), which leverages distributionally robust optimization (DRO) to tune the domain weights without knowledge of downstream tasks (Figure 1). First, DoReMi trains a small reference model (e.g., 280M parameters)

Wiki

Step1

Wiki

Step3

Books

Books

Trainlarge

News

Train small

Train small proxy

News

language

Web

reference

model with DRO

Web

modelwith

Code

model

togetdomain

weights

Code

reweighted

Law

Law

dataset

Med

Med

Referencedomain

Smallreference

Optimizeddomainweights

Largelanguage

weights

model

definereweighteddataset

model

Smallproxymodel

25

6.5%better

(%)

2.6x faster

match

20-

Exact

15

Tune domain weights

with30xsmallermodel

10

Baseline (8B)

DoReMi(280M->8B)

50000

100000

150000

200000

Steps

in a standard way. Second, DoReMi trains a small distributionally robust language model (DRO-LM) [35], which minimizes the worst-case excess loss (relative to the reference's model's loss) across all domains. Notably, rather than using the robust LM , we take the domain weights produced by DRO training. Finally, we train a large (8B) LM on a new dataset defined by these domain weights.

Our approach adapts the DRO-LM framework [35] to optimize domain weights instead of producing a robust model. To do this, DoReMi uses the online learning-based optimizer from Group DRO [43; 34], which dynamically updates domain weights according to the loss on each domain for rescaling the training objective, instead of sub-selecting examples from a minibatch as in Oren et al. [35]; Mindermann et al. [30]. Finally, DoReMi takes the averaged domain weights over DRO training steps.

In Section 3, we run DoReMi on 280M proxy and reference models to optimize domain weights on The Pile [17] and the GLaM dataset [13] (used in PaLM [10]). The DoReMi domain weights are used to train an 8B parameter LM (over 30x larger). On The Pile, DoReMi reduces perplexity on all domains over baseline domain weights, even when it downweights a domain. DoReMi improves average downstream accuracy over a baseline model trained on The Pile's default domain weights by 6.5% points on generative few-shot tasks and achieves the baseline downstream accuracy 2.6x faster (Figure 2). In Section 4, we find that DoReMi consistently improves LM training when varying the sizes of the proxy model and the main model trained with optimized domain weights. On the

GLaMdataset where domain weights tuned on downstream tasks are available, DoReMi even performs comparably to tuning domain weights on downstream task performance. 2

2 Domain Reweighting with Minimax Optimization (DoReMi)

In this section we define DoReMi, an algorithm for using a small proxy model to optimize the domain weights of a language modeling dataset, which then improves the training of a large model.

Setup. Suppose that we have k domains (e.g., Wikipedia, GitHub), where for each domain i , we have a set of examples D i . Domain weights α ∈ ∆ k specify a probability distribution over the k domains, and consequently a distribution over the training data: P α = ∑ k i =1 α i · unif ( D i ) where unif ( D ) = 1 | D | ∑ x ∈ D δ x is the uniform distribution over the examples in D and δ x ( x ′ ) is 1 if x ′ = x and 0 otherwise.

DoReMi. The inputs of DoReMi are the data D 1 , ... , D k , reference domain weights α ref (e.g., uniform or based on raw token count of each domain), and training hyperparameters for the large, full-size model (number of training steps T and batch size b ). DoReMi returns optimized domain weights ¯ α and ultimately, a large model trained on P ¯ α .

Step 1: Obtain a small reference model. We first train a model p ref on some reference domain weights α ref (e.g., based on raw token count as a default) for T steps, batch size b . This model serves as the reference model for step 2 and captures a baseline level of difficulty of each example/domain. The reference model can be a relatively small model (280M parameters in our experiments).

Step 2: Train proxy model with Group DRO to obtain domain weights. To obtain domain weights, we train a small proxy model p θ in the distributionally robust language modeling (DROLM) [35] framework with the Group DRO optimizer [43], where θ are the weights of the proxy model. This framework trains a robust model by optimizing the worst-case loss over domains, which is equivalent to the following minimax objective:

where the losses glyph[lscript] θ ( x ) = -log p θ ( x ) and glyph[lscript] ref ( x ) = -log p ref ( x ) are the negative log-likelihoods of the proxy and reference models respectively in this paper, and | x | is the number of tokens in an example x . The objective aims to minimize the worst-case excess loss across domains because the inner maximization over α puts all the weight on the domain with the highest excess loss.

Intuitively, the excess loss ( glyph[lscript] θ ( x ) -glyph[lscript] ref ( x ) ) measures the headroom for the proxy model to improve, with respect to the reference model, on example x . Examples with higher excess loss are those where the reference model achieves low loss (such that the example is 'learnable') but the proxy model still has high loss. Examples with low excess loss may be very high entropy (i.e. optimal loss is high, and thus the reference loss is high) or very low entropy (i.e., easy to learn, and thus the proxy loss is low). The Group DRO optimizer works by interleaving exponentiated gradient ascent updates on domain weights α t with gradient updates on the proxy model weights θ t over training steps t . The optimizer updates α t to upweight domains with high excess loss, which scales up the proxy model's gradient update on examples from these domains. Following Nemirovski et al. [34], we return the average weights over the training trajectory ¯ α = 1 T ∑ T i =1 α t as the optimized domain weights to use in step 3.

Step 3: Train large model with new domain weights. The tuned domain weights ¯ α define a new training distribution P ¯ α . Weresample the data from this new distribution to train a main model (larger than the reference/proxy models), using a standard training procedure.

Details for Step 2. Algorithm 1 provides the pseudocode for Step 2. The main structure of Algorithm 1 is a training loop which updates the proxy model over T steps. At each step, we follow Sagawa et al. [43] and sample a minibatch with uniform domain weights (regardless of the reference domain

Algorithm 1 DoReMi domain reweighting (Step 2)

Require:

weights α ref, which only affects the reference model). We then compute the per-domain excess losses, normalized by the total number of tokens in each domain, and use them to update the domain weights α t at each step. We first compute the per-domain excess loss at a per-token level and then aggregate, where the token-level losses at index j are glyph[lscript] θ t -1 ,j ( x ) = -log p θ t -1 ( x j | x 1 ,...,x j -1 ) and glyph[lscript] ref ,j ( x ) = -log p ref ( x j | x 1 ,...,x j -1 ) . Since the Group DRO optimizer [43] requires a non-negative loss, we clip the per-token excess loss at 0. Finally, we update the proxy model for the objective L ( θ t -1 ,α t ) using a standard optimizer such as Adam [26] or Adafactor [46]. All experiments in this paper use Adafactor. We set the domain weight update step size to η =1 and the smoothing parameter to c = 1e-3 in all our experiments and did not extensively tune these hyperparameters.

Iterated DoReMi. We extend DoReMi by running it for multiple rounds, setting the reference domain weights α ref for the next round to be ¯ α from the previous round. We call this iterated DoReMi . The entire iterated process still only uses small models for tuning domain weights. We stop iterating when the domain weights converge, which we define as when maximum change in any domain weight ‖ ¯ α -α ref ‖ ∞ is less than 1e-3. Empirically, this takes only 3 rounds on the GLaM dataset (Section 3.2).

3 DoReMi Improves LM Training Efficiency and Performance

In this section, we use DoReMi domain weights optimized with a 280M-parameter proxy model to train a 8B-parameter main model (30x larger). We consider two datasets, The Pile [17] and the GLaM dataset [13]. On The Pile, DoReMi reduces perplexity significantly on every domain, improves average downstream accuracy on generative one-shot tasks by 6.5%, and achieves the baseline accuracy 2.6x faster. On the GLaM dataset where domain weights tuned on downstream datasets are available, DoReMi finds domain weights with comparable performance to downstream-tuned domain weights.

3.1 Experimental setup

The Pile dataset. The Pile [17] is a 800GB text dataset with 22 domains (Table 1). The default domain weights were determined heuristically. We use the default domain weights from The Pile dataset to train the baseline and as the reference domain weights α ref in DoReMi (see Appendix C).

GLaM dataset. The GLaM dataset [13] (also used in training PaLM [10]) includes text from 8 domains (Table 2). For comparison, the GLaM domain weights (downstream-tuned) were tuned according to the downstream performance of models trained on each domain and the size of each domain [13]. We consider this an oracle comparison, since these domain weights are tuned on downstream tasks that are in our evaluation set. We use uniform domain weights both for training the baseline and the reference domain weights α ref for DoReMi.

Training setup. Wetrain Transformer [51] decoder-only LMs with the standard next-token language modeling loss. We conduct a controlled comparison by equalizing the amount of compute, measured by the number of tokens processed during training. For The Pile, we train each model for 200k steps; for the GLaM dataset, we train each model for 300k steps. All models use a batch size of 512 and maximum token length of 1024. The proxy and reference models have 280M parameters. All models are trained from scratch (other hyperparameters are in Appendix C).

Evaluation. We use held-out validation data to measure the perplexity on each domain. For downstream evaluation, we use the generative one-shot tasks from the GPT-3 paper [9]: TriviaQA [21], NaturalQuestions [27], WebQuestions [5], SQuADv2 [41], and LAMBADA [36]. We use the standard exact-match accuracy metric for the these datasets. The performance on these datasets (particularly TriviaQA) has been shown to correlate well with model scale even at the 100M-1B range [9].

Compute used for optimizing domain weights. We train two 280M models (the reference and proxy models) to optimize the domain weights. This is 8% of the FLOPs required to train the main 8B model. All FLOPs come from standard forward and backward passes.

Notation for model sizes in DoReMi. We denote the size of the reference/proxy models (which are always the same size in our experiments) and the size of the main model trained with DoReMi domain weights as 'DoReMi (size of reference/proxy → size of main model)': for example, DoReMi (280M → 8B). When we are discussing the optimized domain weights independently of the main model, we only include one number (e.g., DoReMi (280M)) which refers to the reference/proxy model size.

(a) The Pile

(b) GLaM dataset

25

30

(%)

Exact match

20

Exact Match

25

20

15

15

Baseline (8B)

Baseline (8B)

DoReMi(280M->8B)round 1

10

10

DoReMi(280M->8B)round2

DoReMi (280M->8B)

Downstream-tuned(8B)

50000

100000

150000

200000

0

100000

200000

300000

Steps

Steps

1.5

Baseline (8B)

DoReMi(280M->8B)

Idd

1.0

60l

0.5

0.0

Pile-CC

PubMed Central

Books3

OpenWebText2-

ArXiv

Github

FreeLaw

StackExchange

USPTO Backgrounds-

PubMed Abstracts

OpenSubtitles

Wikipedia (en)

DM Mathematics

Ubuntu IRC

BookCorpus2

EuroParl

HackerNews

YoutubeSubtitles-

PhilPapers

NIH ExPorter-

Enron Emails

Source

3.2 DoReMi improves perplexity and downstream accuracy

We show that DoReMi significantly improves both the perplexity and downstream accuracy of 8B models trained on The Pile and the GLaM dataset over their respective baseline domain weights.

Downstream accuracy improves on The Pile. Figure 3 (left) shows the average downstream performance for baseline and DoReMi (280M → 8B) models on The Pile. DoReMi improves the downstream accuracy by 6.5% points and achieves the baseline accuracy within 75k steps - 2.6x faster than the baseline (200k steps). Thus, DoReMi can dramatically speed up training and improve downstream performance.

DoReMi can reduce perplexity across all domains without a tradeoff. Figure 4 shows the per-domain log-perplexity of the 8B models on The Pile. DoReMi significantly reduces the perplexity over the baseline across all domains, despite allocating lower weight to some domains. How can this occur? One hypothesis is that the domains with the lowest and highest entropy can be downweighted without impacting the perplexity much. The lowest entropy domains statistically require few samples to learn. The highest entropy domains have token distributions that are close to common uniform priors -for example, models at random initialization tend to output a uniform next token distribution. Thus, we need less samples to fit these domains. Positive transfer from allocating more samples to medium entropy domains can then improve perplexity on all domains. In Appendix D, we provide a simple example where reweighting domains can improve perplexity on all domains and DoReMi finds such domain weights in simulations.

Iterated DoReMi achieves performance of downstream-tuned weights on the GLaM dataset. Weemploy iterated DoReMi on the GLaM dataset over 3 rounds. We find that the second and third round domain weights are almost identical (Table 2). Figure 3 (right) shows one-shot results for the first two rounds of iterated DoReMi. After the first round, the DoReMi main model has comparable downstream accuracy to the baseline (uniform domain weights). After the second round, the DoReMi main model achieves comparable downstream accuracy to oracle domain weights tuned on downstream tasks in our evaluation set. Overall, domain reweighting has a smaller effect on GLaM, possibly because there are only 8 domains compared to 22 in The Pile.

Inspecting the DoReMi domain weights. Tables 1 and 2 present the DoReMi domain weights for The Pile and the GLaM dataset. When running DoReMi on a 280M proxy model (DoReMi (280M)), most weight is put on the diverse Pile-CC web text domain. Note that Wikipedia is downweighted in comparison to the baseline, but DoReMi still improves the downstream accuracy on tasks derived from Wikipedia (e.g., TriviaQA, Appendix Table 5). Domain weights for a 1B proxy model (Appendix 8)

9

(%)

8

Exact match

6

Baseline (280M)

5

DoReMi (280M->280M)

50000

100000

150000

200000

Steps

12

(%)

10

Exact match

8

6

Baseline (760M)

DoReMi(760M->760M)

50000

100000

150000

200000

Steps

9

Exact match

8

7

Baseline (510M)

6

DoReMi (510M->510M)

50000

100000

150000

200000

Steps

14

12

match

10

Exact i

8

Baseline (lB)

DoReMi(1B->1B)

6

50000

100000

150000

200000

Steps

shows a different trend, where OpenWebText is the mostly upweighted instead of Pile-CC. This suggests that there may be multiple possible local minima in the domain weight space. On the GLaM dataset, the DoReMi weights have the same general pattern as the downstream-tuned domain weights. DoReMi is able to recover a similar set of domain weights by starting from uniform initial reference domain weights, without any use of downstream data.

4 Ablations and Analysis Across Scales

Previously in Section 3, we showed that DoReMi finds domain weights using 280M models that can improve training of 8B models. In this section, we conduct an analysis of DoReMi where we vary the scale of the proxy model in relation to the main model and ablate the components of the excess loss objective.

DoReMi improves LMs consistently across scales. We consider using proxy and main models of the same size to analyze DoReMi's behavior in a simple setting, without the need for the domain weights to generalize across scales. Note that this is just for scientific purposes since this does not save compute in practice. In particular, we run DoReMi (X → X) where X is 280M, 510M, 760M, or 1B on The Pile. Figure 5 shows that DoReMi consistently improves downstream accuracy over the baseline by 2% and achieves the baseline accuracy 4x faster on average across scales, and this improvement does not shrink with larger model size. DoReMi improves the worst-case perplexity on all scales and improves 18 of 22 individual domain perplexities on average across scales (Appendix Table 6). These experiments give a rough picture of how much is lost when using a smaller proxy model; our DoReMi (280M → 8B) model achieves the baseline accuracy 2.6x faster, while matching the proxy and main model sizes results in a 4x average speedup.

Proxy model underperforms main model, especially at larger sizes. Recall that DoReMi uses Group DRO to train a proxy model, which reweights the objective with the domain weights. In contrast, the main model is trained by resampling on the domain weights from DoReMi. When the proxy model and the main model are the same size, which one is the better model? Table 3b shows that the proxy

25

8

(%)

match

20-

Exact match

6

15

4

Baseline(280M)

Exact

Baseline (8B)

DoReMi(280M->280M)

Hardest(280M->280M)

10-

DoReMi(280M->8B)

2

Easiest(280M->280M)

E

DoReMi(150M->8B)

DoReMi(70M->8B)

0

50000

100000

150000

200000

50000

100000

150000

200000

Steps

Steps

(a) Varying the size of the proxy/reference model and training at 8B.

(b) Perplexity of the DoReMi main model and proxy model of the same size. Although the 1B proxy model is relatively poor quality, the resulting domain weights still improve the main model.

model typically underperforms the main model in this case. The gap between the proxy and main model increases with scale, as the 1B proxy model not only underperforms the 1B main model but also the 1B baseline model, while the 280M proxy model achieves better perplexity than the 280M baseline model on 19/22 domains. Despite the relatively poor quality of the 1B proxy model, the domain weights still allow the 1B main model to achieve the baseline performance over 2x faster. This suggests that DoReMi can succeed even if the proxy model is not trained well. However, we hypothesize that the mismatch between the proxy and main model training (loss reweighting vs. resampling) explains their performance difference and therefore a resampling-based Group DRO optimizer may improve DoReMi for larger proxy models.

Effect of proxy model scale on larger main model's performance. We consider 70M, 150M, 280M, and 1B scales for the DoReMi proxy model while fixing the main model size at 8B (DoReMi (X → 8B)). From 70M to 280M, increasing the proxy model size improves downstream accuracy at 8B (Figure 6 left). We hypothesize that this trend does not continue for the 1B proxy model because the Group DRO optimizer is worse at larger scales (Table 3b). While DoReMi (280M → 8B) results in the most improvement at 8B, DoReMi (150M → 8B) and DoReMi (1B → 8B) still achieve the baseline accuracy almost 2x faster. This suggests that DoReMi is robust to the proxy model scale. In practice, we suggest choosing a relatively small proxy model size (280M) to save compute.

Choosing the easiest or hardest domains do not suffice. Weablate the components of the excess loss metric glyph[lscript] θ ( x ) -glyph[lscript] ref ( x ) by running DoReMi using only the loss of the proxy model p θ on example x , i.e. glyph[lscript] θ ( x ) (prefer hardest domains for the proxy model) or only the negative loss of the reference -glyph[lscript] ref ( x ) (prefer easiest domains for the reference model). Figure 6 (right) shows that neither of the components of the excess loss alone are sufficient to achieve the gains of DoReMi.

5 Related Work

Curating pretraining data for LMs. Most closely related is the GLaM dataset [13] (also used for training PaLM [10]), which has domain weights that are tuned using downstream data. Optimizing domain weights for downstream tasks can be expensive and could require search/zero-order optimization [48], RL [56], or heuristic assumptions on how positive/negative transfer between domains work. Example-level filtering also brings benefits for LM training. The C4 dataset [39] shows gains over CommonCrawl via heuristic data cleaning methods. Du et al. [13]; Xie et al. [55] show that filtering the data at an example level for high-quality text that look like Wikipedia and books can significantly improve downstream performance for LMs. In contrast to these works, DoReMi sets domain weights automatically with only two small LM training runs and does not make assumptions about the type of data to prefer (Wikipedia-like, etc.).

General data selection methods. Moore-Lewis selection [32; 3; 15] selects examples with high cross-entropy difference (similar to excess log-perplexity) between language models trained on target and raw data. In contrast, DoReMi reweights the data without a target distribution. Coleman et al. [11] select examples based on the uncertainty of a small proxy model for active learning, while DoReMi uses DRO on the excess loss with respect to a reference model, and focuses on data mixture reweighting. Mindermann et al. [30] select examples in an online fashion by taking the top k examples in a minibatch according to excess loss. DoReMi optimizes the data mixture before training, allowing the larger main model to train in a standard way. Many other works on data selection are in vision [49; 22; 24; 23; 25; 53; 54; 38; 31; 45] and mainly focus on example-level subset selection with metrics such as gradient matching. Overall, these methods do not address data selection for pretraining, where the downstream data distribution may be very different from the pretraining distribution. DoReMi aims to address the pretraining/downstream distribution shift with a robust optimization approach. To the best of our knowledge, we are the first to show that reweighting the data according to losses of a small proxy LM can improve the training efficiency of much larger LM.

Distributionally robust optimization. Within DRO methods for deep learning [4; 47; 35; 43], we target a restricted form of shift called group shifts [14; 35; 43], where the test distribution can be an unknown mixture of groups (domains). We follow DRO-LM [35], which employs DRO for LMs in the group shift setting. DRO-LM also uses a baselined loss, but with a simple bigram reference model. DoReMi uses a reference model of the same size and architecture as the proxy model to ensure that the losses are on a similar scale. During optimization, DRO-LM takes a worst-case subset of each minibatch to update the model on, while we use the Group DRO optimizer [43] which doesn't require online subselection. If we equalize the number of examples in each minibatch used for gradient updates, online subselelction is more expensive than Group DRO since it requires running forward passes on a larger minibatch (e.g., double the minibatch size) before selecting a subset to update the model with. In comparison, the Group DRO optimizer updates the model on all examples in a weighted fashion. Overall, in contrast to these DRO methods which aim to produce robust models , we use DRO to optimize the data for training larger models more efficiently.

Data-centric AI. Large-scale datasets and benchmarks have driven much of the recent progress in AI, including vision, NLP, and multimodal models [12; 42; 52; 40; 39; 17; 44; 16]. However, most datasets are still painstakingly created with human-generated data, manual work, and heuristics [12; 39; 17; 44; 16]. DoReMi is a principled data-centric method that aims to improve language model training efficiency. We hope that DoReMi can provide a starting point for a general data-centric framework for language modeling via robust optimization.

6 Discussion and Limitations

Saving compute in DoReMi with extrapolation. In Section 2, we run DoReMi for the number of training steps that will be used to train the final model, which could be unnecessarily expensive. A future direction for saving compute would be to stop running DoReMi at an early step and extrapolate the domain weights for the desired number of steps, since we found that most of the variation in the domain weights during a DoReMi run seems to occur in the beginning of training (Appendix Figure 8).

Choice of reference model. The choice of reference model can affect the domain weights found by DoReMi. For example, iterated DoReMi (Section 3) improves performance by using a reference model trained on the tuned domain weights from a previous round of DoReMi. Further directions include varying the reference model size and using specialized reference models to optimize domain weights for a specific application area.

Whatis a domain? Wedefine a domain by data provenance in our experiments, but this only enables coarse-grained control. Using fine-grained domains could improve the gains from DoReMi. For example, DoReMi is more effective on The Pile (22 domains) than the GLaM dataset (8 domains). Open directions include automatically finding fine-grained domains (e.g., via clustering as in DRO-LM [35]) andreweighting the data at an example level. When domains are very fine-grained, it will be important to control the pessimism of DRO (e.g., DRO can put all the weight on a small set of worst-case examples).

Transferability of domain weights across scales. Weoptimized the domain weights with a small proxy model (280M) and directly used these domain weights to improve training at a larger scale (8B). Understanding why the domain weights can be transferred across scales and the limits of how far these domain weights transfer are important questions to answer in future work.

Broader impacts. Large language models are We hope to improve training efficiency and reduce the environmental impact of training large LMs [50; 28; 37; 29]. In particular, by reducing the training time by 2x, we can halve the cost and energy consumption of training large language models. Since such efficiency improvements may be used to develop even larger models, there may be no absolute improvement in energy consumption. Ultimately, we hope to improve the training efficiency and cost of developing future language models relative to existing methods.

Large LMs have also been well-documented to have risks and biases [1; 33; 7; 6; 18]. For example, GPT-3 tends to have an anti-Muslim bias, where Muslims are frequently related to violence or terrorism in analogy and completion tasks [1]. As large language models are increasingly relied upon in applications, the magnitude of the risks increases [8]. Distributionally robust optimization (DRO), which is used in DoReMi to optimize the data mixture, can have a favorable impact on fairness [19]. While the standard approach of minimizing the average loss can lead to disparate performance on minority subgroups that do not contribute heavily to the loss [2], DRO promotes good performance on all groups via a worst-case loss. In this way, DRO-style data-centric methods such as DoReMi can improve the representation disparity between majority and minority subgroups in a dataset.

7 Conclusion

We introduced DoReMi, an algorithm reweighting data domains for training language models. DoReMiis able to run on small models and transfer the benefits to 30x larger models, resulting in a 2.6x speedup in training on the Pile just by changing the sampling probabilities on domains. We hope to instigate more research on data-centric approaches for improving language model training efficiency.

Acknowledgments

Wethank Xiangning Chen, Andrew Dai, Zoubin Ghahramani, Balaji Lakshminarayanan, Paul Michel, Yonghui Wu, Steven Zheng, Chen Zhu, anonymous reviewers, and the broader Google Bard team members for insightful discussions and pointers.

References

Abubakar Abid, Maheen Farooqi, and James Zou. Persistent anti-muslim bias in large language models. arXiv preprint arXiv:2101.05783 , 2021.

Dario Amodei et al. Deep speech 2 end to end speech recognition in English and mandarin. In International Conference on Machine Learning (ICML) , pages 173-182, 2016.

Amittai Axelrod. Cynical selection of language model training data. CoRR , abs/1709.02279, 2017. URL http://arxiv.org/abs/1709.02279 .

Aharon Ben-Tal, Dick den Hertog, Anja De Waegenaere, Bertrand Melenberg, and Gijs Rennen. Robust solutions of optimization problems affected by uncertain probabilities. Management Science , 59:341-357, 2013.

Jonathan Berant, Andrew Chou, Roy Frostig, and Percy Liang. Semantic parsing on Freebase from question-answer pairs. In Empirical Methods in Natural Language Processing (EMNLP) , 2013.

Su Lin Blodgett and Brendan OConnor. Racial disparity in natural language processing: A case study of social media African-American English. arXiv preprint arXiv:1707.00061 , 2017.

Rishi Bommasani, Drew A. Hudson, Ehsan Adeli, Russ Altman, Simran Arora, Sydney von Arx, Michael S. Bernstein, Jeannette Bohg, Antoine Bosselut, Emma Brunskill, Erik Brynjolfsson, Shyamal Buch, Dallas Card, Rodrigo Castellon, Niladri Chatterji, Annie Chen, Kathleen Creel, Jared Quincy Davis, Dorottya Demszky, Chris Donahue, Moussa Doumbouya, Esin Durmus, Stefano Ermon, John Etchemendy, Kawin Ethayarajh, Li Fei-Fei, Chelsea Finn, Trevor Gale, Lauren Gillespie, Karan Goel, Noah Goodman, Shelby Grossman, Neel Guha, Tatsunori Hashimoto, Peter Henderson, John Hewitt, Daniel E. Ho, Jenny Hong, Kyle Hsu, Jing Huang, Thomas Icard, Saahil Jain, Dan Jurafsky, Pratyusha Kalluri, Siddharth Karamcheti, Geoff Keeling, Fereshte Khani, Omar Khattab, Pang Wei Koh, Mark Krass, Ranjay Krishna, Rohith Kuditipudi, Ananya Kumar, Faisal Ladhak, Mina Lee, Tony Lee, Jure Leskovec, Isabelle Levent, Xiang Lisa Li, Xuechen Li, Tengyu Ma, Ali Malik, Christopher D. Manning, Suvir Mirchandani, Eric Mitchell, Zanele Munyikwa, Suraj Nair, Avanika Narayan, Deepak Narayanan, Ben Newman, Allen Nie, Juan Carlos Niebles, Hamed Nilforoshan, Julian Nyarko, Giray Ogut, Laurel Orr, Isabel Papadimitriou, Joon Sung Park, Chris Piech, Eva Portelance, Christopher Potts, Aditi Raghunathan, Rob Reich, Hongyu Ren, Frieda Rong, Yusuf Roohani, Camilo Ruiz, Jack Ryan, Christopher Ré, Dorsa Sadigh, Shiori Sagawa, Keshav Santhanam, Andy Shih, Krishnan Srinivasan, Alex Tamkin, RohanTaori, Armin W. Thomas, Florian Tramèr, Rose E. Wang, William Wang, Bohan Wu, Jiajun Wu, Yuhuai Wu, Sang Michael Xie, Michihiro Yasunaga, Jiaxuan You, Matei Zaharia, Michael Zhang, Tianyi Zhang, Xikun Zhang, Yuhui Zhang, Lucia Zheng, Kaitlyn Zhou, and Percy Liang. Onthe opportunities and risks of foundation models. arXiv preprint arXiv:2108.07258 , 2021.

Rishi Bommasani, Kathleen A. Creel, Ananya Kumar, Dan Jurafsky, and Percy Liang. Picking on the same person: Does algorithmic monoculture lead to outcome homogenization? In Advances in Neural Information Processing Systems (NeurIPS) , 2022.

Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. arXiv preprint arXiv:2005.14165 , 2020.

Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, A. Rao, Parker Barnes, Yi Tay, NoamM.Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, B. Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, M. Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, S. Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier García, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, D. Luan, Hyeontaek Lim, Barret Zoph, A. Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, T. S. Pillai, Marie Pellat, Aitor Lewkowycz, E. Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, K. Meier-Hellstern, D. Eck, J. Dean, Slav Petrov, and Noah Fiedel. PaLM: Scaling language modeling with pathways. arXiv , 2022.

Cody Coleman, Christopher Yeh, Stephen Mussmann, Baharan Mirzasoleiman, Peter Bailis, Percy Liang, Jure Leskovec, and Matei Zaharia. Selection via proxy: Efficient data selection for deep learning. In International Conference on Learning Representations (ICLR) , 2020.

Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. ImageNet: A large-scale hierarchical image database. In Computer Vision and Pattern Recognition (CVPR) , pages 248-255, 2009.

Nan Du, Yanping Huang, Andrew M. Dai, Simon Tong, Dmitry Lepikhin, Yuanzhong Xu, M. Krikun, Yanqi Zhou, Adams Wei Yu, Orhan Firat, Barret Zoph, Liam Fedus, Maarten Bosma, Zongwei Zhou, Tao Wang, Yu Emma Wang, Kellie Webster, Marie Pellat, Kevin Robinson, K.Meier-Hellstern, Toju Duke, Lucas Dixon, Kun Zhang, Quoc V. Le, Yonghui Wu, Zhifeng Chen, and Claire Cui. GLaM: Efficient scaling of language models with mixture-of-experts. arXiv , 2021.

John Duchi, Tatsunori Hashimoto, and Hongseok Namkoong. Distributionally robust losses against mixture covariate shifts. https://cs.stanford.edu/~thashim/assets/ publications/condrisk.pdf , 2019.

Yukun Feng, Patrick Xia, Benjamin Van Durme, and João Sedoc. Automatic document selection for efficient encoder pretraining, 2022. URL https://arxiv.org/abs/2210.10951 .

Samir Yitzhak Gadre, Gabriel Ilharco, Alex Fang, Jonathan Hayase, Georgios Smyrnis, Thao Nguyen, Ryan Marten, Mitchell Wortsman, Dhruba Ghosh, Jieyu Zhang, Eyal Orgad, Rahim Entezari, Giannis Daras, Sarah Pratt, Vivek Ramanujan, Yonatan Bitton, Kalyani Marathe, Stephen Mussmann, Richard Vencu, Mehdi Cherti, Ranjay Krishna, Pang Wei Koh, Olga Saukh, Alexander Ratner, Shuran Song, Hannaneh Hajishirzi, Ali Farhadi, Romain Beaumont, Sewoong Oh, Alex Dimakis, Jenia Jitsev, Yair Carmon, Vaishaal Shankar, and Ludwig Schmidt. Datacomp: In search of the next generation of multimodal datasets. arXiv preprint arXiv:2304.14108 , 2023.

Leo Gao, Stella Biderman, Sid Black, Laurence Golding, Travis Hoppe, Charles Foster, Jason Phang, Horace He, Anish Thite, Noa Nabeshima, Shawn Presser, and Connor Leahy. The pile: An800gb dataset of diverse text for language modeling. arXiv , 2020.

Samuel Gehman, Suchin Gururangan, Maarten Sap, Yejin Choi, and Noah A Smith. Realtoxicityprompts: Evaluating neural toxic degeneration in language models. arXiv preprint arXiv:2009.11462 , 2020.

Tatsunori B. Hashimoto, Megha Srivastava, Hongseok Namkoong, and Percy Liang. Fairness without demographics in repeated loss minimization. In International Conference on Machine Learning (ICML) , 2018.

Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, Tom Hennigan, Eric Noland, Katie Millican, George van den Driessche, Bogdan Damoc, Aurelia Guy, Simon Osindero, Karen Simonyan, Erich Elsen, Jack W. Rae, Oriol Vinyals, and Laurent Sifre. An empirical analysis of compute-optimal large language model training. In Advances in Neural Information Processing Systems (NeurIPS) , 2022.

MandarJoshi, Eunsol Choi, Daniel Weld, and Luke Zettlemoyer. TriviaQA: A large scale distantly supervised challenge dataset for reading comprehension. In Association for Computational Linguistics (ACL) , 2017.

Vishal Kaushal, Rishabh Iyer, Suraj Kothawade, Rohan Mahadev, Khoshrav Doctor, and Ganesh Ramakrishnan. Learning from less data: A unified data subset selection and active learning framework for computer vision. IEEE/CVF Winter Conference on Applicatios of Computer Vision (WACV) , 2019.

Krishnateja Killamsetty, Durga S, Ganesh Ramakrishnan, Abir De, and Rishabh Iyer. GRADMATCH: Gradient matching based data subset selection for efficient deep model training. In International Conference on Machine Learning (ICML) , 2021.

Krishnateja Killamsetty, Durga Sivasubramanian, Ganesh Ramakrishnan, and Rishabh Iyer. Glister: Generalization based data subset selection for efficient and robust learning. In Association for the Advancement of Artificial Intelligence (AAAI) , 2021.

Krishnateja Killamsetty, Xujiang Zhao, Feng Chen, and Rishabh Iyer. Retrieve: Coreset selection for efficient and robust semi-supervised learning. In Advances in Neural Information Processing Systems (NeurIPS) , 2021.

Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR) , 2015.

Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Matthew Kelcey, Jacob Devlin, Kenton Lee, Kristina N. Toutanova, Llion Jones, Ming-Wei Chang, Andrew Dai, Jakob Uszkoreit, Quoc Le, and Slav Petrov. Natural questions: A benchmark for question answering research. In Association for Computational Linguistics (ACL) , 2019.

Alexandre Lacoste, Alexandra Luccioni, Victor Schmidt, and Thomas Dandres. Quantifying the carbon emissions of machine learning. arXiv preprint arXiv:1910.09700 , 2019.

Anne-Laure Ligozat, Julien Lefèvre, Aurélie Bugeau, and Jacques Combaz. Unraveling the hidden environmental impacts of AI solutions for environment. CoRR , abs/2110.11822, 2021. URL https://arxiv.org/abs/2110.11822 .

Sören Mindermann, Jan Brauner, Muhammed Razzak, Mrinank Sharma, Andreas Kirsch, Winnie Xu, Benedikt Höltgen, Aidan N. Gomez, Adrien Morisot, Sebastian Farquhar, and Yarin Gal. Prioritized training on points that are learnable, worth learning, and not yet learnt. In International Conference on Machine Learning (ICML) , 2022.

Baharan Mirzasoleiman, Jeff Bilmes, and Jure Leskovec. Coresets for data-efficient training of machine learning models. In International Conference on Machine Learning (ICML) , 2020.

Robert C. Moore and William Lewis. Intelligent selection of language model training data. In Proceedings of the ACL 2010 Conference Short Papers , pages 220-224, Uppsala, Sweden, July 2010. Association for Computational Linguistics. URL https://aclanthology.org/P10-2041 .

Moin Nadeem, Anna Bethke, and Siva Reddy. Stereoset: Measuring stereotypical bias in pretrained language models. arXiv preprint arXiv:2004.09456 , 2020.

Arkadi Nemirovski, Anatoli Juditsky, Guanghui Lan, and Alexander Shapiro. Robust stochastic approximation approach to stochastic programming. SIAM Journal on optimization , 19(4): 1574-1609, 2009.

Yonatan Oren, Shiori Sagawa, Tatsunori Hashimoto, and Percy Liang. Distributionally robust language modeling. In Empirical Methods in Natural Language Processing (EMNLP) , 2019.

Denis Paperno, German Kruszewski, Angeliki Lazaridou, Quan Ngoc Pham, Raffaella Bernardi, Sandro Pezzelle, Marco Baroni, Gemma Boleda, and Raquel Fernandez. The LAMBADA dataset: Word prediction requiring a broad discourse context. In Association for Computational Linguistics (ACL) , 2016.

David A. Patterson, Joseph Gonzalez, Quoc V. Le, Chen Liang, Lluis-Miquel Munguia, Daniel Rothchild, David R. So, Maud Texier, and Jeff Dean. Carbon emissions and large neural network training. CoRR , abs/2104.10350, 2021. URL https://arxiv.org/abs/2104.10350 .

Mansheej Paul, Surya Ganguli, and Gintare Karolina Dziugaite. Deep learning on a data diet: Finding important examples early in training. In Association for the Advancement of Artificial Intelligence (AAAI) , 2021.

Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683 , 2019.

Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: 100,000+ questions for machine comprehension of text. In Empirical Methods in Natural Language Processing (EMNLP) , 2016.

Pranav Rajpurkar, Robin Jia, and Percy Liang. Know what you don't know: Unanswerable questions for SQuAD. In Association for Computational Linguistics (ACL) , 2018.

Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al. ImageNet large scale visual recognition challenge. International Journal of Computer Vision , 115(3):211-252, 2015.

Shiori Sagawa, Pang Wei Koh, Tatsunori B. Hashimoto, and Percy Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. In International Conference on Learning Representations (ICLR) , 2020.

Christoph Schuhmann, Romain Beaumont, Richard Vencu, Cade Gordon, Ross Wightman, Mehdi Cherti, Theo Coombes, Aarush Katta, Clayton Mullis, Mitchell Wortsman, Patrick Schramowski, Srivatsa Kundurthy, Katherine Crowson, Ludwig Schmidt, Robert Kaczmarczyk, and Jenia Jitsev. Laion-5b: An open large-scale dataset for training next generation image-text models. In Advances in Neural Information Processing Systems (NeurIPS) , 2022.

Ozan Sener and Silvio Savarese. Active learning for convolutional neural networks: A core-set approach. In International Conference on Learning Representations (ICLR) , 2018.

NoamShazeer and Mitchell Stern. 2018.

AmanSinha, Hongseok Namkoong, and John Duchi. Certifiable distributional robustness with principled adversarial training. In International Conference on Learning Representations (ICLR) , 2018.

Jasper Snoek, Hugo Larochelle, and Ryan P. Adams. Practical Bayesian optimization of machine learning algorithms. In Advances in Neural Information Processing Systems (NeurIPS) , 2012.

Ben Sorscher, Robert Geirhos, Shashank Shekhar, Surya Ganguli, and Ari S. Morcos. Beyond neural scaling laws: beating power law scaling via data pruning. arXiv , 2022.

EmmaStrubell, Ananya Ganesh, and Andrew McCallum. Energy and policy considerations for deep learning in NLP. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics , pages 3645-3650, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1355. URL https://aclanthology.org/P19-1355 .

Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. arXiv preprint arXiv:1706.03762 , 2017.

Alex Wang, Amapreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In International Conference on Learning Representations (ICLR) , 2019.

Xinyi Wang, Hieu Pham, Paul Michel, Antonios Anastasopoulos, Jaime Carbonell, and Graham Neubig. Optimizing data usage via differentiable rewards. In International Conference on Machine Learning (ICML) , 2020.

Kai Wei, Rishabh Iyer, and Jeff Bilmes. Submodularity in data subset selection and active learning. In International Conference on Machine Learning (ICML) , 2015.

Sang Michael Xie, Shibani Santurkar, Tengyu Ma, and Percy Liang. Data selection for language models via importance resampling. arXiv preprint arXiv:2302.03169 , 2023.

Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. arXiv preprint arXiv:1611.01578 , 2016.

(a) 280M

(b) 510M

(c) 760M

(d) 1B

8

12

(%) L

Exact Match (%)

Exact Match

6

10

8

4

Baseline(280M)

Baseline (510M)

DoReMi(280M->280M)round 1

DoReMi (510M->510M)

DoReMi(280M->280M)round 2

6

Downstream-tuned (510M)

Downstream-tuned(280M)

0

100000

200000

300000

0

100000

200000

300000

Steps

Steps

14

17.5

(%)

(%)

12

15.0

Exact Match

Match

10

12.5

Exact

8

Baseline (760M)

10.0

Baseline (1B)

DoReMi (760M->760M)

DoReMi (1B->1B)

6

Downstream-tuned (760M)

7.5

Downstream-tuned (1B)

0

100000

200000

300000

0

100000

200000

300000

Steps

Steps

A Results Across Scales on the GLaM dataset

Figure 7 presents results across different scales (280M, 510M, 760M, 1B) on the GLaM dataset, where the proxy/reference models are the same size as the main model trained with DoReMi domain weights. Across all scales, DoReMi is comparable or better than both the baseline (uniform) domain weights and downstream-tuned domain weights. Interestingly, for iterated DoReMi at the 280M scale, the second round weights achieve slightly worse downstream accuracy than the round 1 weights when used to train 280M models, but transfer better to training 8B models.

B Detailed Results for The Pile

Per-domain perplexities for 8B models. Table 4 shows per-domain perplexities for 8B models trained on the Pile. The reference/proxy models in this case are 70M, 150M, 280M, and 1B. DoReMi improves the perplexity on each domain compared to the baseline domain weights.

Per-task accuracies for 8B models. Table 5 shows the accuracies on one-shot generative tasks for various reference/proxy model sizes from 70M to 1B. All DoReMi models improve downstream performance significantly over the baseline.

Summaryofperplexity results across scales. Table 6 shows a summary of per-domain perplexities for DoReMi across 4 scales (280M, 510M, 760M, 1B). Here, the reference/proxy models are the same size as the main model trained with DoReMi domain weights. On average, DoReMi improves perplexity on 18.25 out of 22 domains from The Pile. The worst-case perplexity is always reduced (or comparable in the 510M case) with respect to the baseline domain weights.

0

50000

100000

150000

200000

Steps

0.0

0.2

0.4

0.6

Weight

Pile-CC

PubMed Central

Books3

OpenWebText2

ArXiv

Github

FreeLaw

StackExchange

USPTO Backgrounds

PubMed Abstracts

OpenSubtitles

Wikipedia (en)

DM Mathematics

Ubuntu IRC

BookCorpus2

EuroParl

HackerNews

YoutubeSubtitles

PhilPapers

NIH ExPorter

Enron Emails

(a) 280M

0

50000

100000

150000

200000

Steps

0.0

0.2

0.4

0.6

Weight

Pile-CC

PubMed Central

Books3

OpenWebText2

ArXiv

Github

FreeLaw

StackExchange

USPTO Backgrounds

PubMed Abstracts

OpenSubtitles

Wikipedia (en)

DM Mathematics

Ubuntu IRC

BookCorpus2

EuroParl

HackerNews

YoutubeSubtitles

PhilPapers

NIH ExPorter

Enron Emails

(b) 1B

Perplexity results for ablations. Table 7 shows the perplexities for ablations on the DRO objective. Wechange the DRO objective and use these to tune domain weights on 280M reference/proxy models. These tuned domain weights are then used to train a main 280M model. Hardest refers to optimizing the domain-level log-perplexity without baselining with a reference model. Easiest refers to optimizing for the domains with lowest log-perplexity under the reference model. Both ablations do not improve perplexity on any domain over the baseline. Optimizing for the 'hardest' domain does not actually result in improving worst-case perplexity, supporting the results of Oren et al. [35], which also employs DROfor language modeling with a baselined loss.

Trajectory of domain weights. Figure 8 shows the exponential moving average (smoothing parameter 0.99) of domain weights during a run of DoReMi. In both cases, there are domains with very high weight initially and decrease in weight very quickly (within 50k steps). Since we compute the final domain weights by integrating these curves over steps and normalizing, this suggests that if we have a smaller compute budget, these domains could become more important - this highlights the dependence of the mixture weights on the compute budget. At the same time, the domain weights tend to quickly stabilize after 50k steps, suggesting that the optimal domain weights should be similar for larger compute budgets. We may also be able to take advantage of this stability after 50k steps to run DoReMi for a smaller number of steps and extrapolate the domain weights to save compute.

Comparison of domain weights for 280M and 1B. Table 8 presents the DoReMi domain weights for The Pile at 280M and 1B proxy models. Different proxy model sizes can result in different domain weights, which suggests that there may be multiple local minima in domain weight space. With a 280M proxy model, most of the weight is put on the Pile-CC web text domain, while DoReMi with a

1B proxy model puts most of the weight on OpenWebText2. The overall pattern of the domain weights for the rest of the domains are similar.

C Training Details

Data preprocessing. For all datasets, we preprocessed the data by chunking into length 1024 examples with respect to a SentencePiece tokenizer with 256k vocabulary size. The examples are separated by domain to facilitate hierarchical sampling (first sample a domain according to some domain weights, then sample an example from that domain at random). To reduce the amount of padding tokens, we made an effort to pack examples (possibly from different domains) together into the same sequence. When doing such a packing, we compute the domain perplexities on a per-token level in DoReMi.

Baseline domain weights for The Pile. The baseline domain weights for The Pile were computed from The Pile dataset and the number of epochs for each domain given in Gao et al. [17]. After chunking into length 1024 examples, we counted the number of examples in each domain and multiplied by the number of epochs that domain specified in Gao et al. [17]. We then normalized these counts to obtain the baseline domain weights.

Training setup. For all training runs (including DRO runs), we train with a batch size of 512, initial learning rate of 1e-3, weight decay of 1e-2, and gradient clipping to norm 1. We decay the learning rate exponentially until it reaches a minimum of 1e-4 at the end of training, with a linear warmup of 6%of the total training steps. We train for 200k steps on The Pile and 300k steps on the GLaM dataset. Models under 1B parameters were trained with TPUv3 accelerators, while 1B and 8B models were trained with TPUv4.

Model architectures. Table 9 shows the architecture hyperparameters for the model sizes used in the paper. All the models we use are vanilla Transformer decoder-only models with a 256k vocab size.

D Simple Example Where Data Reweighting Has No Tradeoff

Motivated by the findings in Section 3.2, we present a simple language modeling example where reweighting the training data from different domains improves perplexity on all domains. The example shows that DoReMi downweights domains that are extremely high or low entropy.

Setup. Suppose the ground-truth distribution of text p ∗ is a mixture over k domains, where each domain z ∈{ 1 ,...,k } is defined by a different unigram distribution p ∗ ( x | z ) over m tokens. Given a

budget of n training samples, the goal is choose domain weights p ( z ) ( k scalars that add to 1) to sample training data with such that we learn the parameters of the unigram distributions p ∗ ( · | z ) well for all z from 1 to k . Notably, we do not aim to estimate the ground truth mixture proportions across domains.

Data. Given some domain weights p ( z ) , we sample training data hierarchically: first we determine the number of samples n z per domain z by drawing from a multinomial distribution over k possibilities with probabilities defined by p ( z ) and n total trials. Then, for each domain z , we sample n z tokens from p ∗ ( · | z ) , forming a vector of tokens X z with length n z .

Model. For each domain z , we consider a Bayesian model of the unigram distribution p ( x | z ; θ ) with a Dirichlet prior p ( θ | z ; β ) over the unigram distribution parameters θ ∈ ∆ m . The Dirichlet prior has hyperparameters β ∈ R m , which can be viewed as a 'pseudo-count' for each token. For each domain z , we estimate the parameters ˆ θ z by computing the mean of the posterior distribution conditioned on the data:

where s z = ∑ x λ z ( x ) is the sum of pseudocounts.

For a domain z , we can write the parameter error of this estimator as a function of the 'difficulty' H z of predicting the next token and the 'quality' of the prior ∆ z , defined below.

LemmaD.1. For domain index z with n z samples, the parameter error is

where

Proof. The parameter error is

Evaluating the terms separately,

Putting it all together, the parameter error can be written as

No-tradeoff example. Suppose there are 3 domains z ∈ { 1 , 2 , 3 } and m = 3 vocabulary tokens x ∈ { 1 , 2 , 3 } . We use a symmetric Dirichlet prior (preferring a uniform token distribution) where λ z ( x ) = 1 / 3 for all tokens x and domains z . Here, s z = ∑ x λ z ( x ) = 1 . In this setting, we show that there is a set of domain weights that has strictly lower parameter error than the baseline where we sample the same number of tokens from each domain: n z are equal for all domains z .

Suppose the ground truth paramaters for the unigram distributions are

where row z contains the parameters for domain z . For example, token 1 has probability 1 under domain 1's unigram distribution.

For domain z = 1 (non-noisy domain), we have H 1 = 0 so the parameter error (according to LemmaD.1) is

which is strictly decreasing in the number of samples n 1 .

For domain z =3 (noisy domain), we have ∆ 3 =0 so the parameter error is

by Lemma D.1. This error is minimized to zero at n 3 =0 (no samples). This means that we can allocate samples elsewhere while still reducing error.

For z =2 (intermediate entropy domain), we have ∆ 2 =0 . 207 and H 2 =0 . 46 . The derivative of the parameter error with respect to the number of samples n 2 is

which is negative when

This inequality holds in this case since 2∆ 2 H 2 < 1 and s 2 =1 . Therefore the parameter error is decreasing in the number of samples n 2 .

Thus, any domain weights that reallocate the examples from domain 3 to domains 1 and 2 reduces the parameter error for all domains.

What kind of domains are downweighted? Intuitively, we can downweight the very noisy (high entropy/difficulty) domain 3 because the initialization perfectly matches the ground truth. This allows us to reallocate samples to the other domains 1 and 2. Between these, domain 1 requires less additional samples since the parameter error decreases very quickly with the number of samples n 1 (the difficulty H 1 is zero). Thus, the easiest domains should also receive relatively less weight. In practice, positive transfer between domains (which is not captured here) can also contribute to scenarios where reweighting results in no tradeoff across domains.

Simulation with DoReMi. Weconsider running DoReMi on the above no-tradeoff instance of the simple example with the ground truth unigram distributions in Equation 14. Note that DoReMi's domain reweighting step (Step 2, Algorithm 1) involves a loop over T iterative model updates, while the estimator from Equation 2 is computed in closed form. To adapt the estimator for DoReMi, we consider an iterative version where the average is computed in an online fashion. We run DoReMi for T =500 steps using minibatch size 1 over the n =500 training examples with domain weight update rate η =0 . 5 . For the model update at step t on an example x from domain z , we increase the pseudo-count ˆ θ z ( x ) by the current domain weight α t corresponding to domain z . Instead of using the examples in the minibatch (which is only size 1 and doesn't represent all domains), we compute the per-domain excess log-perplexities in Algorithm 1 using a fixed, independent evaluation set of 30 examples.

Wecompare DoReMi against a model trained with baseline domain weights, which are uniform over the 3 domains. All models are trained on n =500 training examples. We evaluate the log-perplexity of a model on each domain in closed form using the ground truth unigram distribution parameters.

Onthis simple example, DoReMi returns domain weights [0 . 39 , 0 . 61 , 0 . 0] after rounding to 2 decimal places. These weights correspond to our intuitions - the first domain (non-noisy) is increased by a small amount, the third domain (noisy) is decreased to 0 weight, and most of the weight is allocated to the second domain. We use these domain weights to generate a new dataset of 500 examples. The model trained with this new dataset improves over the baseline model in perplexity on all domains.

Peer reviews:
{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper proposes to pretrain language models (LMs) by first automatically learning domain weights using a small proxy model and then pretraining a large model under the learned weights. The proposed method, Domain Reweighting with Minimax Optimization (DoReMi), improves pretraining perplexity across all domains and results in better downstream task accuracy with better efficiency.\n\nSTRENGTHS:\n* Originality: The paper studies an interesting direction in seeking the optimal pretraining data mixture/weighting. Both the angle and the proposed method are novel.\n* Quality: The method is generally well-designed to accomplish the goal discussed and there have been plenty of experiment results that analyze the effects of DoReMi, but I feel that the paper has not sufficiently motivated the necessity and benefits of learning domain weights (see weaknesses below).\n* Clarity: The paper is overall clear.\n* Significance: The problem tackled in this paper (i.e., automatic data selection/weighting in pretraining) is important, and the paper shows that the method can improve pretraining perplexity and certain downstream task performance, which can be considered moderately significant. However, there are concerns regarding whether the evaluations are comprehensive w.r.t. tasks and model scales (see weaknesses below).\n\nWEAKNESSES:\n* Insufficient motivation: While it's well acknowledged that the data quality is variable across different domains, it's unclear to me whether learning domain weights and using them to construct a \"better\" corpus is the appropriate way. First, domains are quite coarse partitions of the data, and I'm not very convinced that assigning a single scalar weight to each domain as a whole is an ideal setup. As the authors mentioned, some data might be noisy that should be down-weighted, but shouldn't this be done at an instance level? For example, some code snippets from Github might be erroneous but others are correct. If the entire Github domain is down-weighted, it doesn't really tell apart the clean vs. noisy data, but instead puts a lower priority on learning all code-related data. Second, the authors do not seem to mention or compare with a naive baseline that directly removes noisy domains from the pretraining corpus. For example, what if only high-quality data are used? Gunasekar et al. (I'm aware that this paper came out after the paper submission deadline, but it seems relevant) showed that textbook-quality data with only 6B tokens are sufficient to train good models. \n* Unclear generalization ability to large model scales: Although the authors conduct experiments across different model scales, the largest model size tested is 8B. I understand that it's very expensive to train even larger models, but for a paper studying pretraining, I'd expect to see results on larger scales (e.g., 65B), considering that the model performance has a strong correlation with model sizes. This concern appears imminent given that the proxy model does not seem to scale to larger models.\n* Choice of evaluation tasks: The paper mainly evaluates on pretraining perplexity and QA-related tasks. For a paper that aims at \"models that perform well on all domains\", I believe the evaluation should have a more comprehensive coverage of tasks, such as coding and reasoning, especially considering that these tasks are relevant to certain domains in the pretraining corpora (e.g., Github). I'd be curious to know if the performance on code completion will be still higher than the baseline if the Github domain is down-weighted.\n* (Minor) As I understand, the appendix should be submitted separately from the main paper.\n\nReference:\nGunasekar et al. “Textbooks Are All You Need.” 2023.\n\nQUESTIONS:\n* How to set the size of the proxy model given the main model size?\n* How do the learned domain weights by different sizes of proxy models look like?\n\nPlease also clarify any misunderstandings in my review.\n\nLIMITATIONS:\nPlease refer to the Weaknesses section.", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-01"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper introduces a significant advancement by exploring the topic of data mixture proportions during pre-training, which holds great importance. Determining how to sample pre-trained data from diverse sources to achieve balanced results is a fundamental question. Previous approaches have often relied on intuitive-based weights or extensive experimentation to select a setting. However, these approaches either require extensive computational resources or lack generalization across different settings. Therefore, finding the optimal mixture settings using a smaller model is an intriguing and crucial question.\n\nTo address this, the authors propose a group-DRO-based method for determining the weights. The weight is dynamically adjusted during the learning process, and the final weight is selected as the sampling weight. Additionally, the authors conducted extensive experiments, providing substantial evidence to support the effectiveness of the proposed approach.\n\nSTRENGTHS:\nThe direction is really important and the general framework is valuable that uses a small network to get the best practice and apply it on larger models. \n\n\nThe proposed method is clearly-written, and the improvements it offers have been convincingly substantiated through extensive experiments.\n\nThe general idea is also very elegant. If my understanding is correct, the method generally assigns larger weights to the data that can be learned in the future, and assigns smaller weights to those too easy or difficult data. The general idea is cool.\n\nWEAKNESSES:\nThe selected weights vary significantly across different models with varying scales.\n\nI still have some concerns about the final implementation. Following the optimization objectives, the authors use the learned weight as the re-sampling weight. It is a little bit strange.\n\nQUESTIONS:\nFor instance, the selection of the best weight differs among models with different scales. Does this imply the existence of multiple sub-optimal weight candidates? Moreover, I still do not comprehend why the authors do not apply the final model during the learning process but instead utilize the final weights for re-weighting purposes.\n\nLIMITATIONS:\nn/a", "TITLE": "Official Review", "RECOMMENDATION": 8, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThe authors proposed DoReMi for optimizing the mixture proportions of pretraining data domains when training language models (LMs). The authors demonstrate that DoReMi, which utilizes a small proxy model trained via group distributionally robust optimization (Group DRO), can be used to determine optimal domain weights without knowledge of downstream tasks. Subsequently, these weights are used to resample a dataset for training a larger model. Experimental results indicate significant improvements in LM performance using DoReMi, including a 6.5% increase in average few-shot downstream accuracy and achieving baseline accuracy with 2.6x fewer training steps.\n\nSTRENGTHS:\n- DoReMi offers a unique and efficient way to determine domain weights, speeding up LM training and improving accuracy. Moreover, the down-weighted domains are not getting a worse performance, which is surprising.\n- It also shows that the domain weights determined by DoReMi are transferable across a broad range of model scales, compute budgets, and other training hyperparameters, making it wide applicability.\n- Overall, the idea of DoReMi is simple, and the results can show its effectiveness.\n\nWEAKNESSES:\n- Lack of the baselines: In this paper, the baselines are the LMs trained on the original data distribution of Pile, but there should be some simple but stronger baselines as well, like calculating the lexical overlap within each domain and assigning weights to maximize the lexical diversity. Although this simple baseline sounds naive, we still need to justify that their improvement would not be as much as DoReMi.\n- DoReMi needs two or more proxy LM training processes in order to obtain the domain weights. However, the authors need to justify that there doesn't exist simpler but equally effective heuristics that only need one proxy LM training, such as the number of example forgetting times [1].\n- Based on Figure 6, it seems that the choice of proxy model size is very crucial. For 8B model, the 280M proxy is significantly better than other larger or smaller proxy models. It would be better if the author can provide explanation or principles to select the size of the proxy model, otherwise, people who want to use DoReMi actually need to empirically run different proxy models in order to get better performance.\n\n[1] An Empirical Study of Example Forgetting during Deep Neural Network Learning. Mariya Toneva, Alessandro Sordoni, Remi Tachet des Combes, Adam Trischler, Yoshua Bengio, Geoffrey J. Gordon. ICLR 2019\nhttps://arxiv.org/abs/1812.05159\n\nQUESTIONS:\n- For the domain weight $\\alpha$, I am wondering why we need gradient ascent to update it? Isn't it already optimal if we simply assign 1.0 for the domain with the highest excess loss and 0.0 for all the other domains? If the reason is that we need a single set of consistent domain weights till the end of the training, we could also collect the weights along the training process and average them at the end. Did you try this before?\n- I am curious whether there are simple heuristics that can achieve the same level of effects. For example, in [1], people found that the number of forgetting times of a training example is a good indicator of how important each training example is. We need this kind of baseline to prove that the 2 runs in DoReMi are necessary and its result is more effective than others.\n\n[1] An Empirical Study of Example Forgetting during Deep Neural Network Learning. Mariya Toneva, Alessandro Sordoni, Remi Tachet des Combes, Adam Trischler, Yoshua Bengio, Geoffrey J. Gordon. ICLR 2019\nhttps://arxiv.org/abs/1812.05159\n\nLIMITATIONS:\nYes.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 5, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper introduces DoReMi, a method for automatically deriving optimal/improved domain weights for aggregated pretraining datasets for LLMs. DoReMi works in three 3: (1) train a small reference model to use for the excess loss in DRO; (2) train a small proxy model with DRO to obtain optimised domain weights; (3) use the optimised weights with a larger model. The authors demonstrate their method leads to significant improvements on The Pile, and also matches manual tuning on GLaM. In ablations, the scaling behaviour is studied, showcasing that proxy model size improves downstream performance up to ~280M parameters, after which improvements degrade as the larger models are inadequately trained by DRO.\n\nSTRENGTHS:\n* **S1.** Automatic optimisation of domain weights for pretraining datasets is an incredibly valuable contribution for the LLM community. Standard procedures have been mostly based on expensive manual tuning, and have not necessarily been principled in their finding. \n\n* **S2.** The paper is well grounded in works around DRO, and adequately position itself -- diverging from existing methods when necessary. The authors also take care in pointing out current limitations of the DRO approach, and potential for future improvements. \n\n* **S3.** The results obtained on The Pile reproduce the observations recently made by the RedPjamas & RefinedWeb datasets: some components of The Pile should ideally be downsampled, and increased web data may be beneficial. The fact that DoReMi repeatedly reproduces results obtained from manual tuning is a good validation of the method. \n\n* **S4.** The paper is well-written and presented, and easy to follow.\n\nWEAKNESSES:\n* **W1. The evaluation setup could be broader.** The authors evaluate downstream performance: (1) in 1-shot; (2) in a generative/exact-match setting; (3) on 5 tasks. \n   * **W1.1.** The choice of a generative exact-match setting is strange for models in the ~100M-1B range, as they consistently struggle with exact match. Instead, for small models, leveraging logprob-based evaluation of multiple choices is more common, and can deliver stronger signal. \n   * **W1.2.** The choice of task is arbitrary. Rather than these 5 tasks, the authors could have evaluated on the full set of GPT-3 tasks, or on a popular benchmark such as HELM or BigBench (for the larger models).\n\n* **W2. The poor scaling behaviour of DoReMi past 280M parameters for the proxy model is a concern for robustness.** Notably, this might make it difficult for practitioners to apply DoReMi as a \"set it and forget it\" method. Some level of manual inspection & analysis is required, which holds back the method from fully delivering on its promise of completely automated domain weight optimization. However, I appreciate that the authors discuss this limitation openly and propose some potential ideas for further improvements in this direction.\n\n* **W3.** (smaller nits)\n    * **W3.1.** The authors showcase in Table 1 the baseline & DoReMi domain weights on The Pile; the presentation of the table could be improved, to better identify which domains are upsampled and which are downsampled -- this could be as simple as sorting the domains and explicitly providing the up/downsampling value in the table.\n\nQUESTIONS:\nThis is an excellent paper introducing a method which could see wide adoption in the community as a way to improve aggregated pretraining datasets. The paper is well-written, and opens the door to numerous exciting follow-up works. Accordingly, I would currently rate it as a **Strong Accept (8)**. Note that should my concerns about evaluation be addressed, I would be willing to further increase my score to a 9/10 -- this paper has significant potential for the community, and my only main concern currently is regarding the robustness of the selected evaluation setup. \n\n* **Q1.** (W1.1.) Could the authors better justify their choice of going with generative exact match for the evaluation?\n\n* **Q2.** (W1.2.) Could the authors provide scores (in 0-shot or 1-shot) using logprob-based multiple choices instead?\n\n* **Q3.** (W1.2.) Could the authors provide evaluation results on additional tasks, such as the full set of GPT-3 tasks, or scores on a popular benchmark such as HELM or BigBench? (this applies mostly to the headline 8B models).\n\nLIMITATIONS:\nThe authors extensively discuss limitations of their work in a dedicated section and provide interesting pointers for further research.", "TITLE": "Official Review", "RECOMMENDATION": 8, "REVIEWER_CONFIDENCE": 5, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-08"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis work buils upon prior studies’ empirical findings, emphasizing how the composition of pretraining data affects the performance of Language Models (LMs). To avoid reliance on heuristic or iterative performance measurements on downstream tasks, this work introduces a method that employs a trainable model, capable of assigning appropriate weights to each “domain” of pretrainng data.\n\nThe proposed approach leverages the concept of Distributionally Robust Optimization (DRO) to train a small proxy model that learns to assign weights to each domain, thereby minimizing the worst-case excess losses. Subsequently, a larger model is trained using pretraining data that has been adjusted by these optimized domain weights.\n\nThe authors demonstrate through experiments that their proposed method significantly accelerates the pretraining process by showing the few-shot accuracy on factual QA tasks. They show that the model trained with optimized pretraining data reaches the performance level of baseline models much faster.\n\nSTRENGTHS:\n- The idea to optimize the pre-training data sounds clever, particularly their use of a proxy model trained with DRO. This offers a novel approach to learning the optimal data distribution without the costly estimation of the large pre-trained model’s task performance under different pretraining data settings.\n- This work provides solid experimental evidence, exploring a variety of settings including various proxy and main model sizes, two widely-used pretraining datasets (GLaM dataset and The Pile), and different domain compositions. These experiments adequately address questions that arise during a review of the paper to some extent.\n- This research yields some interesting observations. According to Tables 1 and 2, the webpage domain carries the largest weights across both pretraining datasets. This suggests that optimizing the model with respect to the webpage domain could potentially reduce excess loss in other domains. Consequently, pretraining large models with an optimized dataset results in lower perplexities across all domains. Interestingly, despite a decrease in weight for Wikipedia, task performance on tasks derived from it (TriviaQa, NaturalQuestions) improves (Table 5 in Appendix).\nThese insights could prove beneficial for other researchers in the field.\n\nWEAKNESSES:\n- The diversity of downstream tasks examined is relatively narrow, given the paper’s claim. \nWhile the experiments in this paper present solid empirical evidence that the proposed method improves language model performance, the evidence primarily focuses on language modeling and factual question answering tasks in a general domain. As such, the claim that the proposed method “speeds up language model pretraining” might mislead readers, since the evaluation of pretraining should be more rigorous. For example, incorporating experimental results on MMLU [1] or commonsense reasoning (ARC[2], CSQA[3], etc) could increase the credibility of the claim that the pre-trained model with the proposed method generally outperforms previous approaches.\n\n[1] Measuring Massive Multitask Language Understanding\n\n[2] Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challenge\n\n[3] Complex Sequential Question Answering: Towards Learning to Converse Over Linked Question Answer Pairs with a Knowledge Graph\n\nQUESTIONS:\n1) Why did the authors only experiment with a 280M main model in Figure 6 (right)? I understand the potential cost issues, but I believe it’s essential to show that DoReMi outperforms the webpage-only setting, even with a larger model.\n\n2) Could you clarify how the main model employs domain weight in detail (Step 3 in Section 2)? I was unable to find detailed information on this in the paper. Does the model sample instances in the mini-batch according to the domain weight during pre-training?\n\nNote: The appendix should be submitted as the separated supplementary file.\n\nLIMITATIONS:\nThe authors discuss limitations in Section 6. However, the limitations regarding the evaluation methods for pretraining are not thoroughly addressed in the paper. Please refer to the “Weaknesses” section for more details on my perspective.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 2, "DATE": "2023-07-20"}