Sampling and Loss Weights in Multi-Domain Training

Mahdi Salmani, Pratik Worah, Meisam Razaviyayn, Vahab MirrokniarXiv 2025 · DOI

Abstract

In multi-domain training, researchers typically assign a single scalar weight to each data source. This paper demonstrates that this approach conflates two distinct goals: generalization and optimization. By decomposing domain weighting into loss weights (to handle data reliability) and sampling weights (to manage optimization efficiency), we can achieve superior model performance and training stability. We introduce ERMA for loss weighting and VA sampling for variance reduction, validating these methods across synthetic and real-world datasets.

1. Introduction

Modern machine learning models are increasingly trained on diverse datasets aggregated from various sources, such as Wikipedia, GitHub, and web crawls. These domains vary significantly in quality, reliability, and information density. The conventional method for managing this diversity is to assign a single "importance weight" to each domain, which dictates both its contribution to the loss function and its frequency in the training batches.

This paper argues that this one-dimensional approach is fundamentally flawed. A single weight cannot simultaneously optimize for the "what" (the target objective) and the "how" (the optimization path). We propose a two-dimensional weighting framework that separates loss weights from sampling weights.

2. The Two Dimensions of Weighting

The authors identify two primary roles for domain weights:

2.1 Generalization via Loss Weights

Loss weights determine how much a specific domain should influence the final model parameters. This is primarily a question of reliability. If a domain is "noisy" (e.g., contains mislabeled data or low-quality content), it should have a lower loss weight to prevent the model from overfitting to errors. The goal here is to improve the model's ability to generalize to unseen, clean data.

2.2 Optimization via Sampling Weights

Sampling weights determine how frequently the optimizer looks at a domain during training. This is a question of efficiency and variance reduction. If a domain is highly redundant, we may want to sample it less frequently to save computation, even if it is highly reliable. Conversely, domains with high gradient variance—where the model is still learning significant information—require more frequent sampling to stabilize the training process.

3. Proposed Methodology

The paper introduces two distinct algorithms to manage these weights:

3.1 ERM Aware Weighting (ERMA)

For loss weighting, the authors propose ERMA. In linear settings, this simplifies to a "One-shot FGLS" (Feasible Generalized Least Squares) approach that estimates noise variance dynamically. For non-linear models like neural networks, ERMA uses a mirror descent update rule. It adjusts weights based on the mean and variance of losses observed in each domain, effectively downweighting domains that exhibit high noise and low reliability.

3.2 Variance Aware (VA) Sampling

For sampling weights, the authors introduce VA sampling. This method focuses on variance reduction within Stochastic Gradient Descent (SGD). By calculating the variance of gradients for each domain, VA sampling allocates more samples to domains with "jumpy" or unpredictable gradients. This leads to a smoother optimization landscape and faster convergence.

4. Experimental Evaluation

The proposed framework was tested across three distinct environments:

  1. Synthetic Linear Regression: Establishing theoretical performance against classical statistical baselines like the Aitken estimator.
  2. Logistic Regression: Measuring the cosine distance to ground-truth parameters in non-linear classification.
  3. Modified MNIST: A controlled experiment where the MNIST dataset was split into groups, with one group intentionally corrupted by 20% label noise.

In the Modified MNIST task, ERMA successfully identified the noisy domain and reduced its influence, leading to significantly higher classification accuracy compared to uniform weighting. In regression tasks, the combination of VA sampling and ERMA reached lower error rates faster than standard SGD.

5. Key Insights

A critical finding of the research is the failure of the "Single Weight Proxy." When the authors attempted to merge the two weights into a single sampling weight (by multiplying them), the performance was inferior to the two-dimensional approach. This confirms that loss and sampling weights are complementary rather than redundant; loss weights act on the objective function, while sampling weights act on the stochastic noise of the solver.

6. Conclusion and Future Work

Separating loss and sampling weights provides a principled foundation for multi-domain training. While the current implementation introduces some computational overhead for gradient variance calculation and requires tuning of new hyperparameters, the benefits in stability and accuracy are substantial.

Future research will focus on extending these methods to autoregressive language models (LLMs), where data points are not independent, and exploring ways to automate hyperparameter selection to make these techniques more accessible for massive-scale training runs.

Summary updated

Abstract

In the training of large deep neural networks, there is a need for vast amounts of training data. To meet this need, data is collected from multiple domains, such as Wikipedia and GitHub. These domains are heterogeneous in both data quality and the diversity of information they provide. This raises the question of how much we should rely on each domain. Several methods have attempted to address this issue by assigning sampling weights to each data domain using heuristics or approximations. As a first step toward a deeper understanding of the role of data mixing, this work revisits the problem by studying two kinds of weights: sampling weights, which control how much each domain contributes in a batch, and loss weights, which scale the loss from each domain during training. Through a rigorous study of linear regression, we show that these two weights play complementary roles. First, they can reduce the variance of gradient estimates in iterative methods such as stochastic gradient descent (SGD). Second, they can improve generalization performance by reducing the generalization gap. We provide both theoretical and empirical support for these claims. We further study the joint dynamics of sampling weights and loss weights, examining how they can be combined to capture both contributions.
BibTeX
@misc{salmani2025sampling,
  author = {Mahdi Salmani and Pratik Worah and Meisam Razaviyayn and Vahab Mirrokni},
  title = {{Sampling and Loss Weights in Multi-Domain Training}},
  year = {2025},
  eprint = {2511.06913},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.06913},
}
Figure