Cross Entropy Data Selection for Domain Adaptation

207 concepts154 papers2 proposals

In machine learning, we often operate under the assumption that more data is always better. However, when training a model for a highly specialized target domain—such as medical text, legal documents, or informal customer chat—flooding the training pipeline with massive, general-purpose web crawls can backfire. The unique vocabulary, stylistic nuances, and semantic patterns of the target domain get diluted by billions of tokens of generic text.

Conversely, training exclusively on a small, manually curated in-domain dataset frequently leads to overfitting and poor generalization. To bridge this gap, researchers look to extract "pseudo-in-domain" data: highly relevant subsets hidden within massive, heterogeneous corpora. The challenge lies in how to precisely score and filter these millions of sentences.

Why Naive Filtering Fails

A natural first instinct might be to train a small language model on your target domain and use it to score sentences from a large general corpus. You could compute the cross-entropy (or perplexity) of each candidate sentence and keep only those with the lowest scores.

However, this naive approach suffers from a fundamental flaw: it prioritizes ubiquity over specificity. A sentence like "Thank you very much" or "This is a good idea" will have low cross-entropy under almost any language model because those phrases are incredibly common across all English text. If you filter data based solely on in-domain cross-entropy, your selected corpus will be dominated by short, generic sentences rather than text that captures the actual technical vocabulary or stylistic markers of your target domain.

The Core Mechanism: Cross-Entropy Difference

To isolate truly domain-specific data, we need a contrastive approach. As shown by Robert C. Moore et al. in Intelligent Selection of Language Model Training Data, the key insight is to evaluate a sentence using two language models simultaneously: an in-domain model ($I$) trained on a small target sample, and a general background model ($G$) trained on a representative sample of the large corpus.

For a given sentence $s$, we compute the cross-entropy difference:

$$\Delta H(s) = H_I(s) - H_G(s)$$

Where $H_I(s)$ is the cross-entropy of the sentence according to the in-domain model, and $H_G(s)$ is its cross-entropy according to the background model.

Consider the intuition behind this subtraction:

  • Generic Sentences: If a sentence is common across all text ("Thank you very much"), both $H_I(s)$ and $H_G(s)$ will be low. Subtracting them cancels out, resulting in a score near zero.
  • Irrelevant Noise: If a sentence is completely garbled or irrelevant, both models will find it confusing, so both scores will be high, again canceling out.
  • Domain-Specific Sentences: If a sentence contains rich, domain-specific terminology ("The patient presented with acute myocardial infarction"), the in-domain model will find it highly predictable (low $H_I(s)$), while the general background model will find it surprising (high $H_G(s)$). This yields a highly negative $\Delta H(s)$.

By sorting sentences in ascending order of their cross-entropy difference, the authors demonstrated that a massive dataset can be pruned down to less than 7% of its original size while actually improving downstream language model performance.

Extending to Bilingual and Specialized Tasks

The elegance of cross-entropy difference selection allowed it to quickly expand beyond monolingual language modeling. In statistical machine translation, Amittai Axelrod et al. extended this formulation to bilingual parallel corpora in Domain Adaptation via Pseudo In-Domain Data Selection. They calculated the cross-entropy difference for both the source and target sides of a sentence pair, summing them to select highly relevant bitext. This allowed translation engines to achieve superior translation quality using a tiny fraction of the original data volume.

Similarly, Xiaodong He et al. applied cross-entropy difference filtering in Robust Speech Translation by Domain Adaptation to adapt general text translation engines to speech translation tasks, demonstrating how contrastive scoring isolates the unique structural and lexical properties of spoken language. Holger Schwenk et al. integrated these metrics into large-scale translation pipelines in LIUM's SMT Machine Translation Systems for WMT 2012, proving that data quality and domain alignment consistently outperform raw data volume.

Modern Evolution: Token-Level and Embedding Selection

While early work focused on filtering entire sentences or documents for statistical models, the underlying intuition remains highly relevant in the era of deep learning and Large Language Models (LLMs).

Instead of filtering at the sentence level, recent advancements apply contrastive scoring at the token level. For instance, the Selective Language Modeling objective introduced by Weizhu Chen et al. in Not All Tokens Are What You Need for Pretraining uses a reference model trained on high-quality data to evaluate the utility of individual tokens within a larger, noisier corpus. By computing a localized loss ratio, the training loop dynamically focuses compute on high-signal tokens while ignoring background noise, drastically improving pre-training efficiency.

Other modern variations substitute or augment language models with neural classifiers and embedding spaces. Zuchao Li et al. utilized contrastive learning in MiSS@WMT21: Contrastive Learning-reinforced Domain Adaptation in Neural Machine Translation to train sentence encoders that map domain-relevant and irrelevant text into a shared vector space, providing a geometric alternative to probabilistic cross-entropy. Similarly, Daimeng Wei et al. in HW-TSC's Participation in the WMT 2020 News Translation Shared Task and Zhengzhe Yu et al. in HW-TSC's Participation in the WAT 2020 Indic Languages Multilingual Task deployed classifier-based scoring pipelines to filter massive web-crawled datasets, ensuring that synthetic or crawled data closely mirrors the target distribution.

Applications Across the Training Pipeline

Cross-entropy and contrastive data selection act as a versatile bridge across various stages of model training:

History & citationVersion 2 · 2026-10-04

Current · Permanent link

  1. Version 2 (latest) · 2026-10-04 · 156 papers
  2. Version 1 · 2026-10-04 · 87 papers
Cite this direction

Latest version (a living page):

@misc{lacuna_cross_entropy_data_selection_71c6faab,
  title = {cross-entropy data selection},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/cross-entropy-data-selection/rdr_71c6faabcf7f47baafb717e7298e4d6b},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-25},
}

This exact version (version 2, frozen text):

@misc{lacuna_cross_entropy_data_selection_71c6faab_v2,
  title = {cross-entropy data selection},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/cross-entropy-data-selection/rdr_71c6faabcf7f47baafb717e7298e4d6b/v/2},
  note = {Version 2, frozen 2026-10-04. Accessed 2026-11-25},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake