GRAPE: Optimize Data Mixture for Group Robust Multi-target Adaptive Pretraining

Simin Fan, Maria Ios Glarou, Martin Jaggi

Abstract

Large Language Models (LLMs) are highly sensitive to the composition of their pretraining data. While existing methods often optimize for a single target task or a simple average, they frequently suffer from overfitting or performance degradation on diverse benchmarks. We present GRAPE (Group Robust Multi-target Adaptive PrEtraining), a framework that dynamically adjusts data mixtures using minimax optimization to ensure robust performance across multiple target tasks. By prioritizing tasks with the slowest rate of improvement, GRAPE achieves significant gains in reasoning and multilingual tasks while requiring up to 40% fewer training tokens.

Introduction

The "pretraining diet" of an LLM—the specific mixture of code, web crawls, and academic papers—is the primary determinant of its eventual capabilities. Traditionally, researchers have relied on fixed data recipes or targeted adaptation for single domains. However, real-world applications require models to be polymaths, excelling across a wide array of reasoning, linguistic, and factual tasks simultaneously.

The Multi-Target Optimization Challenge

Optimizing for multiple targets is difficult due to two primary phenomena:

  1. Single-Target Overfitting: Methods that optimize for a specific benchmark (e.g., mathematics) often see a sharp decline in performance on unrelated tasks.
  2. Suboptimal Averaging: Simple averaging fails when tasks exhibit "dominant gradients" (where high-loss tasks drown out others) or "conflicting gradients" (where improving one task actively harms another).

Methodology: Minimax Optimization with GRAPE

GRAPE addresses these challenges by formulating pretraining as a Group Distributed Robust Optimization (DRO) problem. The core principle is that tasks improving the slowest should receive the most attention.

Rate-of-Improvement (RoI)

Instead of raw loss, GRAPE uses Rate-of-Improvement (RoI) to identify struggling tasks. RoI measures the drop in task loss normalized by its current value. This normalization prevents "hard" tasks with naturally high losses from monopolizing training resources unless they are failing to learn.

Dynamic Domain Reweighting

The framework employs a two-step optimization loop:

  • Inner Maximization: Identify target tasks with the lowest RoI.
  • Outer Minimization: Adjust source domain sampling weights to favor those that align with the gradients of the identified lagging tasks.

To maintain computational efficiency, these updates occur periodically (e.g., every 100 steps), adding only ~15% overhead.

Experimental Results

The researchers evaluated GRAPE across diverse environments including ClimbLab, SlimPajama, and Wiki-40B.

Figure 1: Comparison of 5-shot accuracy on reasoning tasks for the 125M model scale. GRAPE consistently outperforms uniform and state-of-the-art baselines like DoGE.

As shown in the figure above, GRAPE achieves superior accuracy compared to uniform sampling and previous adaptive methods. Notably, on 0.7B parameter models, GRAPE reached the same average reasoning scores as a uniform mixture while using 40% fewer training tokens. In multilingual settings, learning for low-resource languages was accelerated by over 60%.

Emergent Skill-Wise Curriculum

A key finding is that GRAPE naturally discovers a logical learning order without manual intervention.

Figure 2: Evolution of task weights during optimization. The model initially prioritizes foundational tasks (ARC) before shifting focus to complex reasoning (PIQA, Hellaswag).

The weight dynamics illustrate an emergent curriculum: early training focuses on foundational reading comprehension (ARC-Easy), while later stages shift toward physical and commonsense reasoning (PIQA, HellaSwag). Similarly, in multilingual experiments, GRAPE "discovered" linguistic proximity, upweighting Russian data to improve Ukrainian performance.

Conclusion and Future Work

GRAPE provides a robust, automated way to balance the pretraining needs of multi-task LLMs. While highly effective, the method's sensitivity to hyperparameters and the assumption of strong convexity for theoretical convergence remain areas for future exploration. Moving from task-level to sample-level granularity represents a promising next step for even finer-grained model optimization.

Summary updated

BibTeX
@inproceedings{fan2025grape,
  author = {Simin Fan and Maria Ios Glarou and Martin Jaggi},
  title = {{GRAPE: Optimize Data Mixture for Group Robust Multi-target Adaptive Pretraining}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=JRmIvBcnWc},
}
Figure