---
title: "Types of Out-of-Distribution Texts and How to Detect Them (2021)"
description: "This paper compares ways to detect unfamiliar text and shows how their performance depends on whether the topic, style, or evidence for a…"
canonical: "https://research.elamur.ai/free/en/papers/arora-2021-types-out-distribution-texts-how/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/arora-2021-types-out-distribution-texts-how/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2021](https://md.research.elamur.ai/free/en/papers/2021/) / Types of Out-of-Distribution Texts and How to Detect Them

# Types of Out-of-Distribution Texts and How to Detect Them

Paper · 2021 · Udit Arora, William Huang and He He

**Authors:** Udit Arora, [William Huang](https://md.research.elamur.ai/free/en/authors/william-huang/) and [He He](https://md.research.elamur.ai/free/en/authors/he-he/) · **Year:** 2021 · **Venue:** Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing · **Licence:** [CC BY 4.0 (ACL Anthology)](https://creativecommons.org/licenses/by/4.0/)

[**52** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W3211439810|W6947917200) · [Cited by **51** papers in our library of more than 163,000 papers whose bibliographies we read](https://md.research.elamur.ai/free/en/papers/arora-2021-types-out-distribution-texts-how/cited-by/) · [Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing](https://aclanthology.org/volumes/2021.emnlp-main/) · [licence](https://creativecommons.org/licenses/by/4.0/)

- [Publisher's page](https://aclanthology.org/2021.emnlp-main.835/)
- [PDF](https://aclanthology.org/2021.emnlp-main.835.pdf)
- [DOI 10.18653/v1/2021.emnlp-main.835](https://doi.org/10.18653/v1/2021.emnlp-main.835)
- [OpenAlex](https://openalex.org/W3211439810)

Citations: OpenAlex, 2026-10-14.

## Summary

A sentiment classifier trained on movie reviews may remain confident when it reads a restaurant review. The setting has changed, but the words that express approval or disappointment can still support a familiar prediction. A news classifier faces a different situation when it receives an article from a category it has never been trained to recognize. Both inputs can be out of distribution, or OOD, relative to the training data. The question is what changed, and whether the detector has any reason to notice it.

The authors distinguish background shift, where properties such as domain or style change, from semantic shift, where the evidence that matters for predicting the task label changes. They compare a confidence score from a classifier with a score from a [language model](https://md.research.elamur.ai/free/en/concepts/language-model/) trained to predict the text itself. The classifier can flag an input when none of its familiar labels seems convincing. The language model can flag text whose words or patterns are surprising even when the classifier has ample evidence for a label. Both scores use the in-distribution training data, with no examples of the target shift during training.

The comparison covers 14 pairs of English [natural language understanding](https://md.research.elamur.ai/free/en/concepts/natural-language-understanding/) datasets and 8 additional pairs involving challenge data. In the News Category comparison between familiar and held-out classes, classifier confidence reaches an AUROC of 78.9, compared with 60.2 for the language-model score. AUROC measures how well a score separates unfamiliar from familiar inputs across decision thresholds. On the domain comparisons, the pattern usually reverses. With SST-2 as the familiar source and IMDB as the unfamiliar one, the language-model score reaches 97.9 AUROC and classifier confidence reaches 66.2. A simulation and controlled changes to real text help explain why these different rankings arise.

Challenge data exposes weaknesses in both approaches. A classifier can remain confident when an input contains a cue that worked during training and fails on the challenge. A language model can favor unusually repetitive text because much of it is easy to predict. Human-edited counterfactual reviews are also difficult to separate from ordinary reviews. The paper’s main contribution is to make the intended shift part of the evaluation. A detector’s score makes more sense once it is clear what changed in the input, how that change relates to the task, and what evidence the detector uses.

## Deep dive: Types of Out-of-Distribution Texts and How to Detect Them

This paper compares ways to detect unfamiliar text and shows how their performance depends on whether the topic, style, or evidence for a label changes. · about 34 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### What changes when a system leaves its benchmark

A system trained and evaluated on splits of the same benchmark sees training and test examples drawn from a common source. Once deployed, it can receive text from different sources, requests outside the categories it knows, or examples that make familiar cues unreliable. These situations pose different problems for the system, yet all can be described as distribution shift. The paper asks what assumptions are needed to make the narrower problem of detecting such inputs tractable.

Detection concerns the input the system has just received. Flagging it makes several responses possible, including abstaining, requesting information, or handing the case to a person. The primary task still has its own prediction and its own standard of correctness. In sentiment classification, the task asks whether the text expresses a positive or negative opinion. The detector asks whether the text resembles the kind of input on which that classifier was trained. The system can answer the sentiment question correctly and still have good grounds for flagging the input as unfamiliar. The authors connect the option to abstain or seek help to earlier work on [AI safety](https://md.research.elamur.ai/free/en/papers/amodei-2016-concrete-problems-ai-safety/).

That distinction matters for [evaluation and benchmarks](https://md.research.elamur.ai/free/en/topics/evaluation-benchmarks/). A classifier may make a confident error on a review that looks ordinary, while correctly interpreting a review from a new domain. The events of interest are therefore different. Some evaluations ask whether a score separates material from different sources. Others ask whether a score spots inputs on which a system’s behavior is unreliable. A benchmark built around the first question can include many examples the classifier handles well, even though the examples satisfy the benchmark’s definition of OOD.

The authors also distinguish a change within the intended task from a change of task. Earlier detection studies frequently paired datasets that differ substantially, including pairs in which one dataset contains sentiment examples and the other contains inference examples. Such a comparison can establish that a score separates the chosen datasets. It leaves open whether the same score can handle a new kind of review or an unfamiliar category of request. The authors focus on inputs that could plausibly arrive through the original task interface. Their reason for excluding task swaps is that users generally know what task they are asking the system to perform.

#### Earlier ways to pose the detection problem

The paper describes several lines of earlier work. Some studies addressed a particular application, such as recognizing requests outside the supported intents of a task-oriented dialogue system. That setting gives the distinction a practical meaning. A flight-booking system can receive an intelligible request concerning an airline service even when the request falls outside its supported actions. The input is close enough to the application to be plausible, while the task’s known label set has no suitable category for it.

Other work treated the classifier’s confidence as a signal. If a system tends to be less accurate away from its training distribution, a lower probability for its preferred label can help identify unfamiliar inputs. The paper describes prior comparisons in which pretrained [transformers](https://md.research.elamur.ai/free/en/concepts/transformer/) improved confidence-based detection. It uses the strongest probability among the familiar labels as a simple instance of that approach. The earlier findings establish a reason to take this baseline seriously, and motivate asking which changes can leave the confidence score intact. [Pretrained Transformers Improve Out-of-Distribution Robustness](https://md.research.elamur.ai/free/en/papers/hendrycks-2020-pretrained-transformers-improve-out-distribution/)

A different line of work estimated how likely an input was under a description of the training data. The authors describe density estimation as widely studied for images and less extensively evaluated for OOD detection in text. The text counterpart estimates a sequence’s probability using the probabilities of its successive tokens. This approach can respond to familiar or unfamiliar properties anywhere in the input. The classifier has a different objective, since it needs primarily to encode information that helps select a task label.

The authors also describe work on a broader range of naturally occurring distribution changes. Those benchmarks make the choice of evaluation pairs especially consequential. A method tuned to distinguish one pair may have little reason to separate another pair whose distinguishing feature differs. The organizing question becomes whether the differences that define the evaluation are visible to the method being tested. The paper situates that question alongside benchmarks such as [WILDS](https://md.research.elamur.ai/free/en/papers/koh-2020-wilds-benchmark-wild-distribution-shifts/).

#### What counts as background depends on the task

Domain changes give an intuitive example. A review of a film and a review of a book can use similar expressions of approval. The words that identify what is being reviewed can change much more. If the label is sentiment, terms identifying the medium may mainly describe the background. If the task were to identify the medium, the same terms would be evidence for the answer. The paper’s use of *semantic* refers to the relationship between a feature and the task label. It is more specific than the ordinary sense in which practically every meaningful word contributes to what a text says.

The authors relate this distinction to earlier work on separating content and style. A style change can reorganize many properties of the text while leaving the task-relevant content recognizable. A new label poses a different problem. In [question answering](https://md.research.elamur.ai/free/en/topics/question-answering/), a system accustomed to questions with answers in a passage can be asked a question the passage leaves unresolved. The change affects what qualifies as a valid output. Open-set classification likewise allows test inputs whose correct category was absent during training. These settings motivate the authors’ semantic-shift category. [Style Transfer in Text](https://md.research.elamur.ai/free/en/papers/fu-2017-style-transfer-text-exploration-evaluation/) · [Unanswerable Questions for SQuAD](https://md.research.elamur.ai/free/en/papers/rajpurkar-2018-know-what-you-don-t/)

In practice, changes in genre, vocabularies, and label evidence can coincide. The paper organizes such comparisons by whichever change is most prominent. That choice lets the authors build an experiment around a reason for calling the text unfamiliar. It also means that describing a pair as background shift is a statement about the dominant difference under a task definition. The designation leaves room for changes in task-relevant evidence as well.

### The method, step by step

#### Define the familiar data and the expected shift

The starting point is a labeled training collection for [text classification](https://md.research.elamur.ai/free/en/concepts/text-classification/). Text and labels jointly define the reference population. At test time the detector sees a text and assigns it a score, using no true task label for the incoming example. In the actual comparisons, the benchmark supplies the source of each test item so that the authors can evaluate those scores. The detector itself works from the input.

The collection used for supervised training is denoted Dₜᵣₐᵢₙ. Its examples consist of x, the input in the space X of possible inputs, and y, a label in the set Y of task labels. The paper uses p(x, y) for the joint training distribution. With only the input available for the detection decision, the measurable question concerns its relationship to the input distribution induced by that joint distribution. This is why a change that leaves the inputs indistinguishable can be especially difficult to detect. The benchmark can know which pool supplied an input even when the text offers limited evidence about that origin.

The research procedure includes a judgment about the kind of change present in each comparison. That judgment belongs to the benchmark design. The detector runs on the text as it ordinarily would, and the shift category helps the researchers interpret the resulting performance.

How the paper compares detectors under distribution shift The steps in order.

#### Describe the two kinds of features

The authors give their intuition a mathematical form by supposing that every input has a representation with separate semantic and background components.

```
φ(x) = [φₛ(x) ; φᵦ(x)]
```

Here x is the input and φ is a function that represents it as a vector of features. The subscript s identifies the semantic features in φₛ(x), and b identifies the background features in φᵦ(x). The square brackets and separator indicate that the vectors are joined. The semantic vector has n real-valued components and the background vector has m. The letters n and m are dimensions of the representation.

The idealized representation treats the two sets of features as independent. The paper expresses the input density using the corresponding factors.

```
p(x) = p(φₛ(x)) p(φᵦ(x))
```

The symbol p denotes the underlying distribution. On the left it is evaluated at input x. On the right it gives the marginal density of the semantic vector φₛ(x) and of the background vector φᵦ(x), respectively. Juxtaposition means multiplication. In the paper’s decomposition, the product expresses the assumption that seeing one part of the representation gives no extra information about how probable the other part is.

The semantic and background components also differ in their relationship to the class label.

```
p(φᵦ(x) | y) = p(φᵦ(x))
```

The vertical bar means conditioning. The left side measures the distribution of the background features within the class identified by y. The right side measures it in the population as a whole. The equality is assumed for each label y in Y. An example is a property of how reviews are written that occurs in similar ways across both sentiment labels.

```
p(φₛ(x) | y) ≠ p(φₛ(x))
```

The inequality expresses the opposite dependency for semantic features. The distribution of φₛ(x) conditional on y differs from its marginal distribution. The symbol p still refers to the underlying distributions. Language expressing approval, for instance, has a different distribution within the positive class than across all reviews. An unfamiliar topic category can likewise change the mix of evidence on which a topic classifier relies.

Under this definition, a background shift changes the distribution of φᵦ(x) between training and evaluation. A semantic shift changes the distribution of φₛ(x). The real-text experiments assign these categories using how the datasets were obtained or altered. They do not require a human annotation of every feature in every text.

#### Score the classifier’s certainty

The general detection rule assumes a score whose higher values indicate a better fit to the training distribution.

```
s(x) < γ
```

The function s assigns a real-valued score to input x, and γ is a decision threshold. The inequality gives the condition for flagging an input as OOD. Depending on the threshold, the same ranked inputs can produce a stricter or more permissive detector. The evaluation examines the consequences of varying that threshold.

The confidence method uses the classifier’s largest label probability, called maximum softmax probability, or MSP.

```
sᴹˢᴾ(x) = maxₖ∈Y pₘₒ𝒹ₑₗ(y = k | x)
```

The notation sᴹˢᴾ(x) is the confidence score for input x. The function pₘₒ𝒹ₑₗ is the classifier’s estimated conditional distribution. The label variable is y, k is a candidate label in Y, and max selects the largest estimated probability over those candidates. The expression inside the maximum is the probability the classifier assigns to class k given x.

A well-calibrated classifier’s confidence tracks its empirical chance of being right. The authors use MSP directly as a representative of confidence-based detection, without adding a separate calibration procedure to the score. Calibration concerns the relationship between confidence and correctness. OOD detection uses the same confidence for a further purpose. It treats a lack of confidence in the available labels as evidence that the input comes from a different population. The inference depends on the new population producing lower confidence frequently enough to separate the two groups.

The reason this procedure emphasizes semantic evidence comes from the class posterior. The paper first writes Bayes’ rule up to a factor shared by candidate labels.

```
p(y | x) ∝ p(x | y) p(y)
```

Here p(y | x) is the underlying probability of label y after observing input x. The symbol ∝ means proportional to. On the right, p(x | y) is the likelihood of x within the class y, and p(y) is the class prior. For fixed x, the normalizing factor would be the same for all values of y. It therefore drops out of the proportional comparison.

With the assumed feature separation, the expression on the right can be written in terms of the feature vectors.

```
p(x | y) p(y) = p(φᵦ(x) | y) p(φₛ(x) | y) p(y)
```

The right side multiplies the class-conditional probabilities or densities for the background vector φᵦ(x) and the semantic vector φₛ(x), then weights by the prior p(y). The likelihood p(x | y) on the left describes the full input in class y. This factorization is the idealized step that allows the effect of the two feature sets to be compared.

The independence of the background features from the class then gives the paper’s final proportionality.

```
p(y | x) ∝ p(φₛ(x) | y) p(y)
```

The symbols have the same meanings as above. The background factor p(φᵦ(x) | y) has the same value across candidate labels for this input, so it cancels when the label probabilities are normalized. In the ideal setting, a change that affects only the background leaves the class posterior intact. A classifier trained on finite data can still learn background cues. The derivation gives the reason for expecting confidence to follow label evidence when the assumptions hold.

#### Score how predictable the text is

The density method sees the whole input as a sequence. It uses a language model to estimate the probability of each successive token given the preceding tokens. That gives it a route to noticing patterns, including vocabulary and constructions, that have little bearing on which task label the classifier will prefer.

The paper evaluates token-level perplexity as a length-normalized score. Its displayed expression corresponds to the geometric mean of the token probabilities, which gives the higher-is-more-familiar direction used in the threshold rule.

```
sᴾᴾᴸ(x) = exp((1/T) ∑ₜ₌₁ᵀ log pᴸᴹ(xₜ | x₁:ₜ₋₁))
```

Here sᴾᴾᴸ(x) is the density-based score, and x is the input sequence. T is the number of tokens. The index t runs from 1 through T, xₜ is the token at position t, and x₁:ₜ₋₁ denotes the preceding tokens. The function pᴸᴹ is the estimated next-token distribution. The vertical bar indicates conditioning on the preceding text. The sum ∑ adds the logarithms of the assigned probabilities, 1/T turns that sum into an average, and exp exponentiates it. The usual orientation of perplexity uses the reciprocal of this geometric mean, so a larger perplexity corresponds to a smaller score in the displayed orientation.

The paper also writes the unnormalized log probability of a sequence as the sum of its token log probabilities.

```
log p(x) = ∑ᵢ₌₁ᵀ log p(xᵢ | x₍₍ᵢ)
```

Here x remains the input, T is its length, and i is the index of the token xᵢ. In this expression, x₍₍ᵢ denotes the prefix at positions before i, written in the paper as x with a subscript less than i. The function p gives the sequence probability on the left and the next-token conditional probability on the right. The sum runs across token positions. Each additional token contributes another log probability, so sequence length can strongly affect the total even for text composed of familiar words and phrases.

Averaging addresses that accumulation. An input can still score poorly because its individual tokens are consistently hard to predict. It can also score highly when it contains a pattern that becomes easy to continue. The score expresses average predictability under the fitted language model. Its utility as a detector depends on whether the unfamiliarity defined by the benchmark actually reduces that predictability.

#### Fit the scores to the same source

For the text experiments, the authors use [fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/) to adapt pretrained systems to the in-distribution training split. On the confidence side they fine-tune [RoBERTa](https://md.research.elamur.ai/free/en/papers/liu-2019-roberta-robustly-optimized-bert-pretraining/) with the task labels. They use 3 epochs, a learning rate of 1e-5, and batches of 16. An epoch is a pass through the training data. The learning rate controls the size of the parameter updates, and the batch size gives the number of examples grouped for an update.

On the density side they fine-tune GPT-2 to predict the text in the same training split. This step runs for a single epoch with batches of 8 and a 5e-5 learning rate. The training objectives thus differ in the evidence they ask the systems to remember. RoBERTa is trained to assign the task labels, whereas GPT-2 is trained to assign probabilities to the words or token pieces in context.

The main comparison pairs RoBERTa Base, with 110M parameters, with GPT-2 Small, with 117M. The authors also test RoBERTa Large and GPT-2 Medium, which have 355M and 345M parameters, respectively. The sizes make the systems comparable in parameter count within each comparison. The paper identifies its official implementation as `ood-text-emnlp`.

#### Build an experiment with known probabilities

The simulated task removes the need to estimate either a classifier or an input density from text. The authors generate points from a Gaussian mixture with a component for each class. The class is drawn with equal probability.

```
y = 0 with probability 0.5, and 1 otherwise
```

Here y is the generated class. The values 0 and 1 are the class identifiers, and 0.5 is the probability of selecting class 0. The remaining probability belongs to class 1. Given the class, the simulation draws a point from the corresponding Gaussian distribution.

```
x | y = i ∼ N(μᵢ, Σ)
```

The symbol ∼ means that x is sampled from the stated distribution, conditional on y having the value i. The letter i indexes the class, N denotes a multivariate Gaussian, μᵢ is its mean vector, and Σ is the covariance matrix describing variation around that mean. The same covariance matrix is used for both classes.

```
μ₁ = [μₛ ; μᵦ],  μ₀ = [−μₛ ; μᵦ]
```

Here μ₁ and μ₀ are the class means. The first part, μₛ, is the semantic mean vector, and μᵦ is the background mean vector. The minus sign reverses the semantic vector for class 0. The unchanged background vector gives both classes the same background center. The semicolon inside the brackets separates the vector components being joined.

With the identity matrix as Σ, linear discriminant analysis gives the optimal classifier for the simulated familiar data. The paper writes its weight vector as follows.

```
w = [2μₛ ; 0ᵦ]
```

Here w is the vector of classifier weights, 2 multiplies the semantic mean vector μₛ, and 0ᵦ is the vector of zeros in the m background dimensions. A background coordinate therefore contributes nothing to the classifier’s decision. It still affects the probability under the full Gaussian mixture. This is the simulation’s direct counterpart to the distinction between the class posterior and input density.

For semantic shift, the authors vary the features shared by familiar and unfamiliar points.

```
r = |μₛ ∩ μₛˢʰⁱᶠᵗ| / |μₛ|
```

Here r is the overlap rate, μₛ represents the original semantic features, and μₛˢʰⁱᶠᵗ represents their counterpart after the shift. The intersection sign ∩ selects the shared features. The vertical bars around a set count its elements, and the slash divides the shared count by the original count. The formula makes larger r greater overlap. The accompanying description reverses that direction in one sentence. The simulation results describe no overlap as the large-shift case and complete overlap as the no-shift case.

The semantic experiment uses a total of 200 dimensions, split into 40 semantic and 160 background dimensions. The overlap changes in increments of 10%. For each overlap setting the authors resample the features, average over 20 trials, and plot 95% confidence bands. The resampling lets the comparison reflect variation across arrangements of the feature sets.

For background shift, the authors translate both class centers by the same vector.

```
μᵢˢʰⁱᶠᵗ = μᵢ + z
```

The symbol μᵢˢʰⁱᶠᵗ is the moved mean of class i, μᵢ is its original mean, and z is the displacement. The addition moves each coordinate by its corresponding entry in z. The displacement is confined to the background coordinates.

```
z = α[0ₛ ; 1ᵦ]
```

Here α sets the amount of displacement along each background coordinate, 0ₛ is the vector of zeros in the n semantic coordinates, and 1ᵦ is the vector of ones in the m background coordinates. The bracketed expression joins these two vectors. The simulation keeps the total dimension at 200 while changing the partition between semantic and background dimensions in increments of 20. Moving the means this way creates points that still have the same semantic evidence about the class, while placing them somewhere different under the whole-input distribution.

### Experiments and results

#### What the measurements answer

The main results compare the scores from familiar and shifted evaluation sets. The area under the receiver operating characteristic curve, or AUROC, reflects the ability to rank the two groups as the detection threshold changes. A score with strong separation gives the detector more room to catch shifted inputs without flagging large numbers of familiar ones. The paper gives 50 as the chance reference on its AUROC scale.

The second metric, FAR95, fixes an operating point. It asks what fraction of familiar inputs would be flagged when the detector is set to catch 95% of the OOD inputs. Lower FAR95 is better because it means fewer false alarms at the specified recall. The two metrics answer related questions. AUROC summarizes ranking across operating points. FAR95 emphasizes the threshold range relevant when the goal is to catch nearly all of the shifted inputs.

The authors also train an oracle detector for comparison. It uses logistic regression with bag-of-words features, which represent a text by its words while discarding their order. This detector gets examples of both evaluation populations, training on 80% of the test data and being evaluated on the remaining 20%. The oracle asks how much separation can be learned with direct examples of the shift. Its results provide an empirical reference for a different information setting. They can be especially revealing when ordinary detectors struggle on a pair that is readily separable through supervised training.

The domain results also report task accuracy. This measures how often the classifier chooses the correct sentiment or inference label, whereas the detection scores measure separation of the evaluation sources. Reading the two quantities together shows whether a shift the detector can see also coincides with declining task performance.

#### Held-out news and encyclopedia categories

The real semantic-shift comparisons hold out whole classes from training. The first uses the News Category dataset of HuffPost material. News Top-5 contains the five most frequent classes, and News Rest contains the remaining 36. The design preserves the news source while changing which kinds of articles count as familiar to the classifier. At detection time the classifier still assigns probabilities over its trained categories.

The second comparison uses the DBPedia Ontology Classification dataset, built from Wikipedia material representing 14 disjoint DBPedia 2014 classes. DBPedia Top-4 uses the first four classes by class number, and DBPedia Rest uses the remaining ones. The holdout again changes label coverage inside a common source. [DBpedia](https://md.research.elamur.ai/free/en/papers/lehmann-2015-dbpedia-large-scale-multilingual-knowledge/) · [Character-level Convolutional Networks for Text Classification](https://md.research.elamur.ai/free/en/papers/zhang-2015-character-level-convolutional-networks-text/)

Detector AUROC for News Top-5 versus News Rest Classifier confidence gives the strongest separation of familiar and held-out news categories in this comparison.

**The numbers**

| System or setting | AUROC |
| --- | --- |
| GPT-2 token perplexity | 60.2 |
| Bag-of-words oracle | 72.0 |
| RoBERTa maximum softmax probability (this paper) | 78.9 |

The news comparison is a case where the confidence score even exceeds the particular oracle the authors fit. The oracle’s privileged access to examples helps define its purpose, but its bag-of-words representation and logistic regression still constrain what it can learn. The result shows why the authors’ oracle is best read as a supervised reference. Its score does not set a mathematical ceiling on what the other methods can achieve.

With DBPedia Top-4 as familiar and DBPedia Rest as OOD, MSP reaches 88.8 AUROC and PPL reaches 75.4. The bag-of-words oracle reaches 99.6. The two ordinary methods have the same ordering as in the news experiment, even though the oracle’s relative position changes. A classifier restricted to the familiar categories provides a stronger overall ranking signal than the text-prediction score in both held-out-category comparisons.

FAR95 exposes an exception within that result. On News Top-5 versus News Rest, MSP has a false-alarm rate of 75.7 at the stated recall, compared with 88.5 for PPL. On DBPedia Top-4 versus DBPedia Rest, PPL records 78.3 and MSP records 86.3 at that operating point. Thus DBPedia favors MSP when ranking performance is summarized across thresholds and favors PPL when evaluated at 95% OOD recall. Even the favorable FAR95 result for each pair involves many familiar inputs being flagged at the required recall. The AUROC ranking gives only part of the operational picture.

#### A new source for the same prediction task

The background comparisons use transfers among binary [sentiment](https://md.research.elamur.ai/free/en/topics/sentiment-emotion/) datasets, then among natural language inference datasets. In sentiment, the authors rotate SST-2, IMDB, and Yelp Polarity through the in-distribution and OOD roles. SST-2 and IMDB both concern movie reviews, with differences in how long the examples tend to be. Yelp Polarity covers reviews of businesses, changing what is being evaluated while retaining positive and negative labels. The paper evaluates SST-2 on its validation split and uses the test splits for IMDB and Yelp Polarity. [Sentiment Treebank](https://md.research.elamur.ai/free/en/papers/socher-2013-recursive-deep-models-semantic-compositionality/) · [IMDB sentiment data](https://md.research.elamur.ai/free/en/papers/maas-2011-learning-word-vectors-sentiment-analysis/)

Detector AUROC with SST-2 as familiar and IMDB as OOD Token perplexity separates the review sources more clearly than classifier confidence.

**The numbers**

| System or setting | AUROC |
| --- | --- |
| RoBERTa maximum softmax probability | 66.2 |
| GPT-2 token perplexity (this paper) | 97.9 |
| Bag-of-words oracle | 100.0 |

The SST-2-trained classifier obtains 93.8 task accuracy on the familiar SST-2 evaluation data. Its task accuracy on IMDB is 92.0, and on Yelp it reaches 94.4. These results make the distinction between detection and classification concrete. Input density separates the review sources strongly, while the labels remain usable across those sources. For SST-2 versus Yelp, PPL scores 98.7 AUROC and MSP scores 57.5. The confidence score has relatively little separation to work with when unfamiliar reviews still contain clear sentiment evidence.

The direction of transfer also matters. Fine-tuning on Yelp and treating SST-2 as OOD gives 98.9 AUROC for PPL and 85.9 for MSP. Fine-tuning on IMDB and treating Yelp as OOD gives 77.9 for PPL and 67.1 for MSP. In the latter comparison, task accuracy reaches 95.5 on the familiar IMDB test data and 95.4 on Yelp. Here the detection ranking has a smaller separation between the methods, and the classification results again give little reason to treat every shifted input as a likely error.

For natural language inference, the input contains a premise and a hypothesis. The classifier uses the relationship between them to choose a label, such as entailment, contradiction, or neutrality. The authors rotate SNLI, MNLI, and RTE through the familiar and unfamiliar roles, using validation data in the evaluation. SNLI and MNLI draw on different genres, and RTE brings another domain as well as a change in how the task labels are grouped. When evaluating transfers with RTE, the paper treats both neutral and contradictory cases as non-entailment. The authors categorize the comparisons as predominantly background shift because the evidence needed to judge the relation remains broadly similar. [MNLI](https://md.research.elamur.ai/free/en/papers/williams-2018-broad-coverage-challenge-corpus-sentence/) · [GLUE](https://md.research.elamur.ai/free/en/papers/wang-2018-glue-multi-task-benchmark-analysis/)

With SNLI as familiar and MNLI as OOD, PPL achieves 96.7 AUROC and MSP achieves 75.6. The classifier’s task accuracy on the familiar SNLI data is 90.1, and its accuracy on MNLI is 77.9. Background-dominated shift can therefore coincide with a sizable loss in task accuracy, even though other pairs in the same category generalize well. The shift category is a description of the data. The task accuracy records what happened to this classifier on that data.

The exception to the general AUROC pattern among the domain pairs is MNLI as familiar and RTE as OOD. MSP scores 76.5, ahead of PPL at 68.0. FAR95 favors MSP there as well, with 69.8 against PPL’s 93.2. The paper’s account of these sources includes both a domain difference and a difference in label structure. That combination illustrates the need to keep the specific pair visible when reporting a general trend.

An additional comparison separates genres within MNLI. The genres examined are Fiction, Government, Slate, Telephone, and Travel. Each takes a turn as the familiar source, and the authors use validation splits to test the transfers. For Fiction as familiar and Telephone as OOD, PPL attains 92.3 AUROC and MSP attains 51.0. The classifier’s inference accuracy is 86.1 on familiar Fiction and 84.0 on Telephone. With Travel as familiar and Telephone as OOD, PPL records 92.7 AUROC and MSP records 56.0. The within-benchmark design shows that changing the genre can alter input predictability substantially even while the task interface and label scheme stay stable.

#### Human edits and rule-based challenges

Challenge datasets are intended to expose unreliable inference behavior or gaps in a system’s abilities. The paper’s human-edited comparison takes ordinary IMDB as familiar and counterfactually edited IMDB, called c-IMDB, as OOD. Annotators edit reviews so that the sentiment label changes with a minimal intervention. For evaluation, the experiment combines all three c-IMDB splits: training, validation, and test. The authors classify this as semantic shift because the edit changes evidence relevant to the sentiment decision, frequently within otherwise similar text.

For IMDB versus c-IMDB, PPL reaches 53.5 AUROC and MSP reaches 63.7. The bag-of-words oracle reaches 77.5. The false-alarm rates at 95% OOD recall are 93.1 for PPL and 82.8 for MSP. These scores show the difficulty of distinguishing a source created through human revision. A review can remain plausible as ordinary review prose while containing a carefully altered reason for its label. The ordinary task label alone gives little information about whether the review was edited.

The rule-based comparisons treat MNLI as the familiar reference. HANS uses templates to probe reliance on syntactic heuristics. The authors emphasize cases in which the premise and hypothesis share substantial wording even though entailment does not follow. They classify HANS primarily as a background shift because of the distinctive templates and syntax. The paper uses the HANS and MNLI validation splits for evaluation.

The [Stress Test for Natural Language Inference](https://md.research.elamur.ai/free/en/papers/naik-2018-stress-test-evaluation-natural-language/) creates other challenges through targeted changes. In the paper, the background shift category includes the matched cases for Length Mismatch, Word Overlap, Spelling Errors, and Negation. These constructions introduce changes such as short added phrases or spelling alterations whose role is mostly independent of the entailment conditions. Antonym and Numerical Reasoning are grouped under semantic shift because they concentrate the examples on particular kinds of evidence that matter to the inference label.

Detector AUROC with MNLI as familiar and HANS as OOD Token perplexity detects the templated challenge inputs much more successfully than classifier confidence.

**The numbers**

| System or setting | AUROC |
| --- | --- |
| RoBERTa maximum softmax probability | 55.0 |
| GPT-2 token perplexity (this paper) | 98.3 |
| Bag-of-words oracle | 100.0 |

The HANS outcome is unusual among the challenge results. On Negation, the corresponding AUROCs are 44.5 for PPL and 60.5 for MSP. For Word Overlap they are 42.4 for PPL and 61.7 for MSP. The classifier-confidence score offers some separation on these pairs, yet the density score falls below the chance reference in the paper’s direction of scoring.

Other challenges illustrate a more pronounced reversal. On Length Mismatch, PPL has an AUROC of 19.6 while MSP has 51.6. On Antonym, PPL falls to 4.5 and MSP reaches 55.3. On Numerical Reasoning, PPL obtains 27.5 while MSP obtains 75.8. Under the usual score direction, these very low PPL results indicate that shifted inputs often look more predictable than familiar ones. The difference between Numerical Reasoning and Antonym also shows variation within the paper’s semantic-shift category. Changing label-relevant evidence gives the confidence score something it might detect. Its success still depends on what happens to confidence on the resulting examples.

### What the ablations show

#### Changing the shift while keeping the task fixed

The Gaussian experiment is the cleanest test of the mechanism. The authors know the class posterior and the input density by construction, so errors in learning either quantity cannot account for their behavior. During a background translation, the coordinates used by the classifier retain their distribution, while the translated samples move away from the familiar clusters in the remaining coordinates. The confidence detector therefore does not improve as the background shift grows. The density detector can respond to the movement, and its advantage becomes clear for larger background shifts.

The semantic manipulation changes how much label evidence overlaps between the reference and shifted distributions. Calibration generally outperforms density estimation in this experiment. When there is little or no overlap, the shifted points give weaker evidence for either of the familiar classes under the original classifier. Both detectors approach very strong separation under the largest semantic shifts described by the paper. At complete overlap they approach chance. The pattern matters because it shows where the comparison is informative. When the populations become extremely easy to separate or essentially coincide, a difference in what the scores emphasize has less opportunity to change the result.

The authors then make related changes to real text. For the background experiment, they start from SST-2 and append unrelated text from Wikitext to create the familiar condition and from Civil Comments to create the shifted condition. The appended passages have lengths of 25, 50, 100, 150, or 200 words. Changing how much material is attached increases the amount of source-specific text while leaving the original review fragment available. This gives the density method additional text on which the sources can differ. [Wikitext](https://md.research.elamur.ai/free/en/papers/merity-2016-pointer-sentinel-mixture-models/) · [Civil Comments](https://md.research.elamur.ai/free/en/papers/borkan-2019-nuanced-metrics-measuring-unintended-bias/)

The language-model score is more responsive as the appended passages grow. The classifier has less incentive to respond with a corresponding change in confidence because it can continue to use the sentiment evidence in the review fragment. This manipulation gives a more direct test than swapping whole review datasets. A whole-source comparison changes many properties at once. The appended-text experiment changes how much text carries the unfamiliar background while preserving the original evidence the classifier can use.

In the controlled news experiment, the authors start from the top 40 classes by frequency and move classes to the OOD group in increments of 10. This reduces the class coverage of the familiar pool. Confidence is more sensitive than perplexity to the changes in which classes the training set covers. The result complements the SST-2 manipulation. The news experiment changes familiarity with the categories represented by the articles, while the review experiment changes the amount of accompanying material from another source.

#### Changing system size

The size experiment revisits one domain pair and one held-out-label pair. For IMDB as familiar and Yelp as OOD, base-size MSP scores 67.1 AUROC, and the larger classifier scores 74.5. The density score is 77.9 in the base-size comparison and 75.5 with the larger language model. A larger RoBERTa therefore narrows the performance gap on this pair. The authors suggest that a larger classifier may retain more information about the background in its representation. That explanation is a hypothesis about the representation, inferred from the behavior of the scores.

For News Top-5 as familiar and News Rest as OOD, the corresponding size change produces little movement. MSP goes from 78.9 to 79.1 AUROC, and PPL goes from 60.2 to 61.7. The ordering persists. The contrast between the two pairs gives the size comparison a narrower interpretation. Increasing size can affect sensitivity to some background changes, while the distinction between the two training objectives still matters on these held-out news categories.

#### Changing how likelihood is normalized

The appendix compares normalized token predictability with the log probability of the entire sequence. With IMDB as familiar and SST-2 as OOD, the unnormalized score yields near 0 AUROC. It also gives a FAR95 close to 100. These are results for detecting the validation examples of SST-2 against the IMDB test examples in the direction used by the paper. The authors attribute the reversal to length. The IMDB inputs are typically paragraph-length, while the SST-2 inputs in this comparison are one or two sentences.

Each new token contributes another log probability to the total. Long familiar texts can therefore receive much smaller whole-sequence probabilities than shorter shifted texts even if their average token probabilities indicate a better fit. The nearly reversed ranking is evidence that length alone can dominate the intended detection signal in this comparison. Averaging reduces that particular dependence. It leaves intact the possibility that a repeated or very predictable pattern can push average predictability in the wrong direction for OOD detection.

#### Why challenge examples behave differently

The first failure mechanism concerns cues whose relationship with the label changes. High premise–hypothesis overlap can be useful in an ordinary inference training set. Challenge examples can deliberately preserve that overlap while changing whether the premise supports the hypothesis. The trained classifier can then remain confident because the familiar cue is present. HANS gives a case where the density score has another route to success. Its templates change the text distribution in a way that the language model can recognize, even when the classifier’s preferred cue remains strong. The study connects this motivation to behavioral tests that probe specific failures hidden by aggregate accuracy. [CheckList](https://md.research.elamur.ai/free/en/papers/ribeiro-2020-beyond-accuracy-behavioral-testing-nlp/)

The second mechanism concerns small changes. A short phrase added to a hypothesis may alter the structure of the challenge dataset while leaving most tokens close to the familiar population. The Negation and Word Overlap results show weak density-based separation under these short interventions. The simulation likewise shows that overlapping populations are difficult to distinguish. These observations connect the theoretical picture to a practical property of a test. The amount of changed material matters, in addition to whether the authors would classify it as semantic or background.

The third mechanism is repetition. Length Mismatch repeats a phrase in the premise. Antonym and Numerical Reasoning often retain substantial overlap between the two parts of the input. Repetition can make later tokens easier to predict from earlier context. A detector that equates easy prediction with familiarity then gives some challenge examples unusually favorable scores. The paper relates this behavior to prior findings about repetitive sequences in [text generation](https://md.research.elamur.ai/free/en/topics/text-generation/). [The Curious Case of Neural Text Degeneration](https://md.research.elamur.ai/free/en/papers/holtzman-2019-curious-case-neural-text-degeneration/)

These mechanisms help explain why the oracle comparisons matter. For the Length Mismatch pair, the bag-of-words oracle achieves 100.0 AUROC, even though the ordinary density detector performs far below chance. A source-specific pattern can be highly informative after direct supervision and still be assigned the wrong meaning by a score trained only on familiar text. The counterfactual IMDB comparison is different. Its lower oracle score indicates that even the supervised bag-of-words comparison has a harder job finding a reliable distinction between human-edited and ordinary reviews.

### Limitations

#### Limits the authors identify

The authors explicitly simplify the representation by treating semantic and background features as independent and disjoint. In natural text, what someone discusses, how they express it, and what the expression implies about a task label can be connected. The paper allows both types of shift to occur at once and assigns the experimental label according to the dominant change. That is a way to organize meaningful comparisons under a simplifying assumption. It gives no general procedure for proving that a dataset pair differs exclusively along one axis.

The scope also excludes task shift, such as feeding inference examples to a sentiment classifier. The authors argue that users typically have enough knowledge of a system’s purpose to provide inputs for the intended task. Their experiments consequently address changes within plausible task use. They leave the behavior of these methods on task changes outside the reported comparison.

Challenge data qualifies the more regular pattern seen in the main pairs. The authors identify weak density separation when populations overlap heavily and misleadingly high likelihood when patterns repeat. They also identify persistent confidence when the classifier relies on a cue undermined by the challenge. These observations motivate the paper’s call for more explicit OOD definitions. Its suggested directions include hybrid systems that use both kinds of evidence, and training or augmentation aimed at a specified shift. Those directions are proposals. The reported comparisons establish the behavior of the approaches evaluated separately.

The paper also distinguishes domain adaptation from detection and abstention. For changes that preserve useful label evidence, improving transfer across domains can be a reasonable objective. In settings where an erroneous prediction carries a greater cost, a detector may help decide what to send for review. The experiments measure the detectors and, on several comparisons, the underlying classifier’s accuracy. The authors discuss these different response policies as applications of the results. [Domain adaptation](https://md.research.elamur.ai/free/en/papers/iii-2007-frustratingly-easy-domain-adaptation/) · [Selective Question Answering under Domain Shift](https://md.research.elamur.ai/free/en/papers/kamath-2020-selective-question-answering-under-domain/)

#### Limits of what the experiments establish

The main evidence comes from English classification and inference datasets with known source boundaries. The researchers choose the test pairs, specify which source is familiar, and identify the prevailing shift. A deployed system could receive a mixture whose sources are unknown. The method comparison helps explain what its scores might respond to under such conditions. Discovering the prevailing shift from an unlabeled stream would require evidence beyond these tests.

The terms *background* and *semantic* also describe an interpretation of the dataset constructions. Holding out classes can change word choice or style as well as label evidence. Moving from one inference benchmark to another can change genres, conventions, and label definitions. The controlled experiments improve the case for the proposed distinction because they manipulate a more specific part of the setup. Their changes remain constructed examples of a shift. The strength of the explanation comes from the agreement between those experiments and much of the natural-text evidence, with exceptions that make the conditions of the explanation visible.

There is also a limit on how broadly the system comparison can be generalized. The principal confidence estimator is MSP from fine-tuned RoBERTa. The principal density estimator is token perplexity from fine-tuned GPT-2. These systems have approximately matched parameter counts in the size comparisons, but they differ in architecture and training objective. The paper’s analysis provides a reason for similar tendencies in other systems that use confidence or density. The measured rankings apply directly to the implementations and datasets evaluated here.

The oracle has its own scope. It sees examples of the target data and learns using bag-of-words features. High oracle scores establish that supervised source discrimination can work for particular pairs under that representation. The performance of the News Category oracle shows that an empirical reference of this kind can also be weaker than an ordinary detector. A stronger or differently informed oracle could change the reference values, and the reported ordering should be read in terms of the particular comparison the authors ran.

A further distinction concerns what happens after a flag. The paper reports ranking performance and the false-alarm rate at a chosen level of recall. It does not estimate the costs of acting on individual flags or measure outcomes from handing unfamiliar cases to a person. The high task accuracies on some domain transfers make that distinction consequential. Automatically discarding every flagged review could reduce coverage while withholding many correct classifications. The benchmark supports statements about sorting examples by source and about classifier performance on the named splits. A policy for using those scores also needs the costs of mistakes and abstentions in its intended setting.

The ethical discussion raises a related concern about decisions involving demographic groups. The authors note that awareness of a domain shift could help a system change its handling of cases where errors are concentrated, and that the ability to identify a group could also support discriminatory behavior. Their own experiments do not measure the fairness effects of such interventions. The discussion illustrates the importance of the decision attached to a detector output, especially when a predictable difference in text is associated with who wrote it or whom it mentions.

### What came after

#### Detection and reliability in language generation

[Out-of-Distribution Detection and Selective Generation for Conditional Language Models](https://md.research.elamur.ai/free/en/papers/ren-2022-out-distribution-detection-selective-generation/) (2022) brings the detection question into conditional generation. The title identifies selective generation as the action associated with detection. In the earlier classification setup, the system can withhold a label when the input appears unfamiliar. In a generation setting, the corresponding question is whether to produce a response from the conditioning input. This is the closest continuation among the citing works named here. Its stated subject joins OOD detection to a decision about when to generate. The title alone leaves its choice of detection score and treatment of the two shift types open.

[Prompting GPT-3 To Be Reliable](https://md.research.elamur.ai/free/en/papers/si-2022-prompting-gpt-3-reliable/) (2022) places reliability in the design of the prompt. That is a different point of intervention from setting a detector threshold after scoring a text. The connection is the broader question of how input conditions affect the reliability of a language system. Its title establishes that prompting is the intervention under study. It leaves open whether the paper tests background and semantic shift separately or uses either of the detectors compared here.

#### Trustworthiness as an evaluation problem

[DecodingTrust](https://md.research.elamur.ai/free/en/papers/wang-2023-decodingtrust-comprehensive-assessment-trustworthiness-gpt/) (2023) addresses trustworthiness through a comprehensive assessment of GPT systems. The connection is one of evaluation scope. The OOD study isolates properties of inputs that affect whether a score detects a shift. DecodingTrust’s stated scope brings such concerns into a wider question about how to assess trustworthiness. Its title does not establish which dataset pairs, scores, or distinctions it takes from the earlier study.

[A Survey of Safety and Trustworthiness](https://md.research.elamur.ai/free/en/papers/huang-2023-survey-safety-trustworthiness-large-language/) (2023) approaches safety and trustworthiness through verification and validation. Its role among these citing works is to situate reliability questions in a survey. The connection to the OOD paper is particularly clear at the level of validation. An evaluation result describes performance under specified conditions, and the OOD experiments demonstrate why the conditions governing unfamiliar inputs can change the judgment. The survey’s title gives its organizing perspective, with no detail about a direct reproduction of these experiments.

#### Prompt changes and in-context examples

[LLMLingua](https://md.research.elamur.ai/free/en/papers/jiang-2023-llmlingua-compressing-prompts-accelerated-inference/) (2023) studies prompt compression for faster inference. It addresses what happens when the text supplied to a system is deliberately changed for efficiency. That connects thematically to the distinction between changes in input form and changes in task-relevant evidence. The OOD paper studies how detectors react to those kinds of change. LLMLingua’s title identifies compression and inference speed as its own objective. The citation and title do not establish a transfer of the earlier detector or its experimental taxonomy.

[From Fake to Real](https://md.research.elamur.ai/free/en/papers/song-2026-fake-real-mitigating-out-distribution/) (2026) explicitly studies OOD bias in in-context learning and names feedback supervision as its means of addressing it. This places the distribution question in a setting where examples supplied in context are part of how the system performs the task. The earlier study asks which unfamiliar inputs can be recognized by a score. The later title identifies mitigation of bias under unfamiliar conditions as the objective. It leaves the cause of that bias and the precise form of the feedback unspecified. Across these citing works, the clearest continuities are the move from detecting distribution shift to deciding when to generate, and the move from describing a shift to trying to mitigate its effects.

## Cite

Cite as Udit Arora, William Huang and He He. 2021. Types of Out-of-Distribution Texts and How to Detect Them. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.18653/v1/2021.emnlp-main.835](https://doi.org/10.18653/v1/2021.emnlp-main.835)

```bibtex
@inproceedings{arora2021types,
  title = {{Types of Out-of-Distribution Texts and How to Detect Them}},
  author = {Udit Arora, William Huang and He He},
  booktitle = {Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.emnlp-main.835},
  url = {https://doi.org/10.18653/v1/2021.emnlp-main.835}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
