Source Prompt: Coordinated Pre-training of Language Models on Diverse Corpora from Multiple Sources

Yipei Xu, Dakuan Lu, Jiaqing Liang, Xintao Wang, Yipeng Geng, Yingsi Xin, Hengkui Wu, Ken Chen, ruiji zhang, Yanghua Xiao

TL;DR

Combining diverse text sources to scale up language model pre-training often introduces conflicting data distributions that can actually degrade model performance. This paper introduces Source Prompts (SP)—simple metadata tags indicating data origin—allowing models to gracefully navigate heterogeneous corpora and achieve significant downstream performance boosts without the need for complex data resampling.

What Problem Does This Paper Address?

In the quest to build more powerful Pre-trained Language Models (PLMs), the standard recipe has been simple: use a bigger model and feed it more data. To build these massive datasets, researchers typically aggregate text from multiple distinct sources (e.g., Wikipedia, academic papers, web scrapes, and forums).

However, more data isn't always better. This paper highlights a hidden downside: heterogeneous corpora can suffer from distribution conflicts. For instance, the authors point out that a T5 model pre-trained on the massive 745 GB C4 corpus actually scores lower on the SuperGLUE benchmark than the same model trained on a much smaller, cleaner 20 GB mix of Wikipedia and BooksCorpus.

Standard fixes like data resampling (filtering or re-weighting data for specific downstream tasks) are impractical because they waste valuable data and ruin the model's generality. The authors set out to find a way to let models ingest diverse data streams without getting confused by conflicting linguistic styles.

Methods

The authors propose a remarkably simple and lightweight solution called Source Prompt (SP). Instead of altering the data distribution, they explicitly tell the model where each piece of text came from.

  1. Pre-training with SP: During pre-training, a source tag (like [WIKI] or [BOOK]) is prepended to the input text.
  2. Masked Source Prediction (MSP): For encoder-only (BERT) and encoder-decoder (T5) models, the authors introduce a novel objective. They randomly mask the source prompt token itself, forcing the model to predict the data source based on the context. For decoder-only models (like LLMs), they use standard Next Token Prediction, placing the SP either at the beginning or the end of the text.
  3. Fine-tuning and Inference: When adapting the model to a downstream task, they experiment with three strategies:
  4. Manual SP: Manually assigning a matching pre-training source tag if the downstream dataset's domain is known (e.g., using [WIKI] for a Wikipedia-derived dataset).
  5. Auto SP: Letting the pre-trained model use its MSP capability to automatically predict and append the closest matching source tag for each individual sample.
  6. No SP: Fine-tuning conventionally without any tags.
Figure 1: For encoder-only or encoder-decoder models, we employ Masked Source Prediction task, training it with Masked Language Modeling. For decoder-only models, we utilize Next Token Prediction in pre-training. During fine-tuning and in- ference, SP can be manually added for data from known sources (manual SP), or automatically appended MSP’s or NTP’s prediction of the closest source (auto SP) for data from unknown sources. we can also fine-tune and inference without any SP.

Datasets

The authors validated their approach across both domain-specific (financial) and general Chinese language domains using the following datasets:

  • Pre-training Corpora:
  • BBT-FinCorpus: A ~200GB Chinese financial dataset spanning corporate announcements, research reports, financial news, and stock forum discussions.
  • CLUECorpusSmall: A ~14GB general Chinese corpus containing comments, news, web text, and Wikipedia.
  • WudaoCorpora: A ~220GB massive general Chinese corpus covering 25 distinct data types.
  • Evaluation Benchmarks:
  • BBT-FinCUGE: A financial evaluation benchmark consisting of five understanding tasks and three generation tasks.
  • CLUE: A general Chinese NLP benchmark consisting of nine comprehension tasks.

Key Insights and Ideas

  • It’s about clustering, not semantics: In a fascinating ablation study, the authors replaced meaningful source names (like [WIKI]) with completely meaningless letters ([A], [B], [C]) or even intentionally mismatched names. Surprisingly, the model's performance barely dropped. This proves that the power of Source Prompts doesn't come from the semantic meaning of the prompt text, but rather because it acts as a structural anchor that helps the model internally cluster and separate different data distributions.
  • Auto SP wins at the sample level: Automatically letting the model predict the source tag (Auto SP) frequently outperformed manually assigning a dataset-wide tag. This is because downstream datasets are rarely completely pure; Auto SP allows for sample-by-sample adaptation based on the specific style of the text.
  • Zero-cost generalizability: Even if you choose not to use any prompts during downstream fine-tuning (No SP), models pre-trained with SP still outperform standard baselines. The structured pre-training phase fundamentally improves how the model represents language.

Key Results

The inclusion of Source Prompts yielded consistent, significant improvements across multiple architectures:

  • T5 (Financial Domain): On the BBT-FinCUGE benchmark, the baseline T5 model achieved an average score of 71.76. Introducing SP during pre-training and using Auto SP during fine-tuning boosted the average score to 75.99.
  • BERT (Financial Domain): The baseline BERT model averaged 62.42. Adding abbreviation-based source prompts pushed this up to 67.36.
  • OpenLLaMA-3b (Decoder-Only LLM): SP improved average performance across both financial benchmarks (from 75.8 to 76.6) and general benchmarks (from 68.57 to 70.5), with placing the prompt at the end of the text ("Post SP") yielding the best results for causal language models.

Limitations and Future Work

The primary limitation of this method is that it relies on knowing the macro-level "source" of the data. For massive, unstructured web scrapes like the C4 corpus—which crawls millions of independent web pages simultaneously—clean source metadata is virtually non-existent. Currently, this method is restricted to scenarios where a handful of distinct, well-defined sub-corpora are being merged.

Additionally, due to compute constraints, the authors only scaled their experiments up to a 3-billion parameter model (OpenLLaMA-3b). Verifying whether this approach holds up or becomes even more vital for 70B+ parameter models remains an open question for future research.

Summary updated

Abstract

Pre-trained language models (PLMs) have established the new paradigm in the field of NLP. For more powerful PLMs, one of the most popular and successful way is to continuously scale up sizes of the models and the pre-training corpora. These large corpora are generally obtained by converging smaller ones from multiple sources, they are thus growing increasingly diverse. However, the side-effects of these colossal converged corpora remain understudied. In this paper, we identify the disadvantage of heterogeneous corpora from multiple sources for pre-training PLMs. Towards coordinated pre-training on diverse corpora, we further propose source prompts (SP), which explicitly prompt the model of the data source at the pre-training and fine-tuning stages. Results of extensive experiments demonstrate that PLMs pre-trained with SP on diverse corpora gain significant improvement in various downstream tasks.
BibTeX
@inproceedings{xu2024source,
  author = {Yipei Xu and Dakuan Lu and Jiaqing Liang and Xintao Wang and Yipeng Geng and Yingsi Xin and Hengkui Wu and Ken Chen and ruiji zhang and Yanghua Xiao},
  title = {{Source Prompt: Coordinated Pre-training of Language Models on Diverse Corpora from Multiple Sources}},
  booktitle = {ACM International Conference on Information and Knowledge Management},
  year = {2024},
  doi = {10.1145/3627673.3679835},
}
Figure