Aligning Instruction Tuning with Pre-training

Yiming Liang, Tianyu Zheng, Xinrun Du, Ge Zhang, Jiaheng Liu, Xingwei Qu, Wenqiang Zu, Xingrun Xing, Chujie Zheng, Lei Ma, Guoyin Wang, Zhaoxiang Zhang, Wenhao Huang, Xiang Yue, Jiajun Zhang

TL;DR

Standard instruction tuning often forces large language models (LLMs) into narrow data distributions, causing them to lose touch with the broad knowledge they acquired during pre-training. To bridge this gap, the authors introduce AITP (Aligning Instruction Tuning with Pre-training), a method that uses density estimation to identify underrepresented topics in instruction datasets and fills these gaps by rewriting raw pre-training text into high-quality instruction-response pairs. Adding less than 10% of this targeted synthetic data yields consistent performance boosts across multiple open-source LLMs and benchmarks.

What Problem Does This Paper Address?

During pre-training, LLMs ingest massive, diverse corpora to build a broad understanding of language, code, science, and world knowledge. However, when we transition to Supervised Fine-Tuning (SFT) to make them follow human instructions, we typically rely on narrow, curated datasets.

This creates a severe distributional mismatch. Standard SFT datasets often over-represent general chat or basic NLP tasks while neglecting massive swathes of the pre-training distribution (like advanced code or specialized scientific literature). This bottleneck restricts the model's ability to generalize and prevents it from fully leveraging its internal pre-trained knowledge.

Methods

The authors propose a three-stage pipeline called AITP to systematically align instruction tuning with the pre-training data distribution:

  1. Difference Set Generation: To find what's missing, the authors embed documents from both the pre-training corpus and the SFT dataset using a text encoder (e.g., BAAI/bge-m3). They project these high-dimensional embeddings into 2D space using Principal Component Analysis (PCA) and apply Kernel Density Estimation (KDE). By comparing the two distributions, they isolate a "difference set"—regions of the pre-training corpus that are heavily underrepresented or entirely absent in the SFT dataset.
  2. Data Transformation: Raw text from this difference set is converted into instruction-following data using a three-step LLM pipeline (powered by Qwen2.5-72B-Instruct):
  3. Query Generation: Creating relevant questions from the raw text.
  4. Query Scoring: Evaluating and filtering out low-quality or ambiguous questions.
  5. Answer Generation: Producing detailed, accurate responses based on the original text context.
  6. Training: The newly synthesized instruction-response pairs are blended back into the original SFT dataset. The base model then undergoes full-parameter fine-tuning on this combined set.
Figure 2: The pipeline of AITP. AITP first generates a difference set, then rewrites the raw text into instruction-response pairs to form a rewritten set, and finally combines the rewritten set with the original SFT dataset for model training.

Datasets

The authors validated their approach using fully transparent open-source models, matching them with their exact pre-training and SFT data:

  • Pre-training Corpora: Dolma (for OLMo), Matrix (for MAP-Neo), and Pile (for Pythia).
  • SFT Datasets: TuluV2 and Neo-SFT.
  • Evaluation Benchmarks: Models were evaluated across 8 standard benchmarks: IFEval (instruction following), MMLU (multitask knowledge), ARC-c and GPQA-diamond (scientific reasoning), HumanEval and MBPP (coding), HellaSwag (commonsense), and GSM8K (mathematics).

Key Insights and Ideas

  • SFT Datasets Have Massive Blind Spots: Density visualization reveals that popular SFT datasets like TuluV2 almost completely miss dense clusters corresponding to code and scientific literature that are highly prevalent in pre-training corpora like Dolma.
  • Less is More: Surprisingly, flooding the training set with too much rewritten data degrades performance. The optimal ratio is adding a small sliver of data—less than 10% of the original SFT dataset size. Targeted gap-filling is highly effective, but too much synthetic data introduces quality degradation.
  • It’s Distribution, Not Just Distillation: Ablation studies proved that the performance boost isn't merely a byproduct of increasing the dataset size or distilling knowledge from a stronger teacher model. Replacing the SFT data entirely with rewritten data performed poorly, proving that preserving the high-quality original SFT data while expanding its coverage to match pre-training density is the secret sauce.

Key Results

Applying AITP yielded consistent, across-the-board performance improvements over standard SFT baselines:

  • OLMo-7B: Achieved a +3.8 average score improvement across all benchmarks, highlighted by a massive +12.9 jump on ARC-c and +7.1 on GPQA.
  • MAP-Neo-7B: Saw a +1.1 average score improvement.
  • Pythia-12B: Gained a +0.9 average score improvement.

The method also proved robust to implementation choices, showing similar gains regardless of whether bge-m3 or MiniLM was used for text embeddings.

Limitations and Future Work

  • Computational Overhead: Generating embeddings, performing dimensionality reduction, and running density estimation over massive pre-training corpora is computationally expensive. The authors report that data transformation alone required approximately 640 GPU hours.
  • Synthetic Data Quality: The performance drop observed when adding higher ratios of rewritten data indicates that synthetic generation pipelines still introduce noise or lack the pristine quality of human-curated SFT data.

Future work will likely focus on optimizing the computational efficiency of the density estimation step and refining the instruction-rewriting pipeline to produce higher-quality, more complex instruction pairs.

Summary updated

BibTeX
@misc{liang2025aligning,
  author = {Yiming Liang and Tianyu Zheng and Xinrun Du and Ge Zhang and Jiaheng Liu and Xingwei Qu and Wenqiang Zu and Xingrun Xing and Chujie Zheng and Lei Ma and Guoyin Wang and Zhaoxiang Zhang and Wenhao Huang and Xiang Yue and Jiajun Zhang},
  title = {{Aligning Instruction Tuning with Pre-training}},
  year = {2025},
  eprint = {2501.09368},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.09368},
}
Figure