Elamur Research

AD-NLP: A Benchmark for Anomaly Detection in Natural Language Processing

Paper · 2023 · Matei Bejan, Andrei Manolache and Marius Popescu

Summary

What makes a passage unusual depends on what it is being compared with. A sentence can depart from ordinary grammar while discussing a familiar subject. A grammatical sentence can be unusual because it contains a metaphor. A passage can fit the topic of a collection and still sound as though someone else wrote it. AD-NLP is a benchmark for testing whether text anomaly detectors can handle these different cases. Its starting point is that the familiar examples can be easier to define than the unfamiliar ones. It is straightforward to collect writing by a particular author, for instance, while deciding what should represent all other writing is a much less settled problem.

The benchmark brings together existing collections of news, acceptability judgments, and metaphor annotations, and adds Song Genres, Gutenberg Categories, and Gutenberg Authors. Each evaluation defines a class of familiar texts, called inliers, and trains a detector on examples from that class. The detector then scores held-out examples from the familiar class alongside examples designated as anomalies. For the collections with several topics, authors, or genres, the benchmark changes which class counts as familiar and runs the evaluation again. This makes it possible to see both how a method fares across a collection and how much its performance depends on the particular class it learns.

The authors compare two classical detectors, a one-class support vector machine and Isolation Forest, with two neural approaches, CVDD and DATE. They report that DATE leads on six of the seven datasets by AUROC, a measure of how well a score separates familiar and unfamiliar examples across thresholds. Its reported overall average is 71.11%. CVDD leads on the VUA metaphor task by that measure, and the classical methods also outperform DATE there on the precision–recall measure focused on anomalies. Song Genres is difficult even for the strongest method on average. Its labels refer to musical genres, but the detector receives lyrics, with information such as melody and rhythm left out.

The breakdown by class is especially revealing for authorship. DATE can separate some Gutenberg author classes with very high scores and rank other classes poorly. Examples of its word-level scores show that the detector sometimes responds to topical vocabulary, punctuation, and word choice. CVDD’s analysis of hip-hop lyrics likewise shows that its learned contexts can collect distinctive word forms. These examples give plausible accounts of particular decisions, while the scores across classes show how much remains to be explained. The authors release evaluation, download, and preprocessing code for the benchmark.

Deep dive: AD-NLP: A Benchmark for Anomaly Detection in Natural Language Processing

AD-NLP benchmarks how well text anomaly detectors recognize unusual topics, grammar, metaphors, and writing styles when trained on familiar examples. · about 32 minutes to read

The problem and its context

An anomaly needs a reference set

An unusual document is unusual in some respect. A computer-related article fits comfortably in a collection devoted to computing and might stand out in one devoted to recreation. A change of subject can make the distinction easy to see, but subject is only one property of writing. Text reflects the writer’s vocabulary and habits, the conventions of the period, the purpose of the document, and the kind of audience it addresses. A method can be sensitive to any of these properties when it scores a sample. The benchmark is concerned with making the intended distinction explicit enough to evaluate in natural language processing.

The authors describe an anomaly, or outlier, as an observation that diverges enough from a reference population to attract suspicion. The reference population gives the term its meaning. In AD-NLP, that population is represented by examples from a designated class. An inlier belongs to that class. An outlier belongs to the comparison group specified for the evaluation. These terms tell us how the sample is treated in the experiment. An outlying article can be well written, and a passage outside a particular author’s class can still resemble the author’s work in many respects.

This setup is useful when the positive description of a familiar class comes easily and its complement has no obvious representative form. The paper uses writing by Shakespeare to make the point. Texts by Shakespeare are a collection one can define, whereas the remaining space of texts spans many subjects, writers, and periods. Similarly, a collection of scientific writing can be assembled without settling what a typical example of nonscientific writing ought to look like. The authors’ protocol takes the familiar class as the basis for training and defines a specific comparison group for evaluation. The resulting experiment can tell us whether the familiar examples provide enough evidence to separate that group.

The distinction matters when adapting an ordinary classification corpus. In text classification, labels commonly name categories that the system is expected to distinguish, such as subjects of news articles. An anomaly evaluation can start with the same labels and ask a different question. It can withhold the other subjects from training, ask a detector to learn the designated subject from its own examples, and see how the detector ranks all the examples at test time. The detector thus has a narrower description of its training population and a broader range of material confronting it during evaluation. The source labels make the experiment measurable even though training draws on only the familiar class.

Why a common benchmark mattered

The paper places text anomaly detection within a longer history of work on unusual observations. It describes research on general-purpose detectors and methods built for particular domains, including time series, computer vision, and network monitoring. Among the established benchmarks it discusses are datasets constructed for network intrusion detection and datasets for finding unusual events in video. It also describes several strands of detector development, including generative approaches, methods that create training signals from the data itself, and methods that learn a description of a single class. This range of techniques and applications forms the backdrop for its discussion of evaluation and benchmarks.

Earlier text studies often started with a labeled corpus and downsampled selected classes so that they became unusual in the resulting data. The authors’ concern is that choices about which labels to use and how to build the comparison can become specific to an individual study. Even where the source corpus is familiar, two experiments can give a detector rather different tasks. A method that separates one set of topics may receive a strong result under one choice of outliers. A second experiment, built around different topics or around a linguistic property such as metaphor, may demand different evidence. With different constructions, it is harder to tell how much of a result carries across evaluations.

The authors also discuss TAP-DLND 2.0, a newswire benchmark for document novelty. In their description, that task asks how novel a text is with respect to particular reference texts, including situations involving paraphrase or plagiarism. AD-NLP takes the reference to be a population represented by a class of examples. A detector sees a passage against what it has learned from that population. The related-work discussion also notes that researchers can deliberately create distribution shifts in validation or test data. That line of work gives another way to set up unfamiliar text, as in Types of Out-of-Distribution Texts and How to Detect Them.

A different precedent comes from general language benchmarks. The paper points to decaNLP, which organizes diverse tasks as question answering, and to GLUE and its successor SuperGLUE, which assemble several language-understanding tasks. AD-NLP shares the goal of bringing different evaluations together under an organizing principle. Here the common operation is to score familiarity after training on a designated class. The individual tasks retain their own sources of evidence, much as they retain their own labels and input units. The earlier multitask examples are the Natural Language Decathlon, GLUE, and SuperGLUE.

What can make a text unusual?

AD-NLP groups its tasks by the property intended to distinguish anomalous samples. The syntactic task concerns how words are arranged and combines familiar acceptable sentences with unacceptable ones. The semantic tasks concern subject or content, as when a news article belongs to a different topic from the training class. The pragmatic task uses the presence of metaphor. The stylistic tasks use author or song genre labels to define groups that may differ in how they use words, recurring forms, or punctuation. These categories give readers a way to connect each evaluation to the corresponding questions about syntax and grammar and semantics.

The grouping describes the intended anomaly and leaves room for the same passage to differ along several dimensions. A document from a different author may also be about a different subject. A Gutenberg bookshelf can contain writing by many authors, and its organization can reflect subject, intended audience, or genre. The labels let the benchmark specify which distinction is being scored. They also give the reader a reason to ask which differences a successful detector could have used.

The paper seeks variety inside these broad categories as well. A topic distinction between sports and other news is one sort of semantic test. Separating a Gutenberg category from other shelves puts the same broad kind of anomaly into a different collection, where books can cover overlapping subjects and the differences between categories may be uneven. The authors also vary the amounts of training and test material across datasets and allow the size of the familiar class to depend on which label is selected. These choices make AD-NLP a collection of related experiments with a common protocol, each with its own reference population and comparison.

The method, step by step

From corpus labels to a familiarity score

The experiment begins with a collection whose labels already have a meaning. In a news corpus, a label might identify the subject. In the authorship corpus, it identifies the writer or the organization treated as the source. The authors designate a label as familiar and use the training examples with that label to fit a detector. At test time, the detector sees fresh examples from the selected class together with examples from the other classes. It assigns scores to the texts. The evaluation then checks how well those scores separate examples with the familiar label from the rest.

A different choice of familiar class creates a different run of the experiment. For instance, a detector trained with sports as the familiar class sees sports examples in its training data. A detector trained with business as the familiar class learns from business examples. The test texts from any given category can play different roles across runs. This is the reason the paper reports results with names such as sports and business under an inlier heading. Each name specifies the class used to learn familiarity, with the remaining classes forming the comparison group.

The acceptable-sentence task and the metaphor task use fixed directions in the reported experiments. CoLA takes acceptable sentences as familiar and evaluates the detection of unacceptable ones. VUA treats sentences without an annotated metaphor as familiar and tests whether metaphor-bearing sentences can be detected. A change like training on metaphor-bearing sentences would pose a different learning problem. The reported VUA result concerns learning a description of the non-metaphorical class.

How AD-NLP evaluates a detector

The steps in order.

How AD-NLP evaluates a detectorStep 1: Prepare the corpus and its class labels1. Prepare the corpus and its class labelsStep 2: Select the class that defines familiar text2. Select the class that defines familiar textStep 3: Train using examples from that class3. Train using examples from that classStep 4: Score held-out texts from familiar and other classes4. Score held-out texts from familiar and other classesStep 5: Evaluate the score rankings against the labels5. Evaluate the score rankings against the labelsStep 6: Repeat for the other designated inlier classes6. Repeat for the other designated inlier classesStep 7: Summarize results across the runs7. Summarize results across the runs

The word split has a specific meaning in the results. A corpus has a division between training and evaluation data. The paper also calls each choice of inlier class a split. Thus, the average across splits in a multiclass corpus summarizes several experiments with different labels defining familiarity. It complements the scores for the individual choices. In CoLA and VUA, the authors report the results of the fixed choice, so there is no corresponding spread across choices of inlier class.

How the existing datasets are adapted

The news portion of the benchmark starts with 20Newsgroups and AG News. The original 20Newsgroups corpus has almost 20,000 documents. For its benchmark, the paper follows earlier work in using the broad groups computer, recreation, science, miscellaneous, politics, and religion. The source corpus contains both closely related groups, such as discussions of hardware for different kinds of personal computer, and groups with distinct subjects. Using the broader groups makes it possible to treat a field such as computing as the reference population and bring a mixture of other subjects into the test comparison. The paper lists 10.996 training samples and 8.819 test samples for its 20Newsgroups setup.

AG News brings a larger news collection into the same protocol. The paper describes a source corpus of 496.835 categorized articles from over 2.000 news sources and uses business, science, sports, and world news. It retains the title and description, so the detector learns from those fields. The benchmark uses 30.000 training samples per class in the corpus, and the paper lists 120.000 training samples and 7.600 test samples for the dataset as a whole. In any individual anomaly experiment, the class selection determines which training examples are eligible. The news corpus is credited to the work on character-level convolutional networks for text classification.

CoLA supplies sentence-level judgments of grammatical acceptability. The authors describe the original corpus as 10.657 sentences drawn from 23 linguistics publications and use the public training and development partitions. In AD-NLP, the 8.551 sentences in the public training partition supply the pool from which acceptable training examples are drawn. The 1.043 sentences in the development partition serve as the evaluation set because the original test set is unavailable to the authors. The labels make it possible to check whether a score derived from familiar sentences responds to a grammatical departure. The distinction used for scoring comes from the corpus’s linguistic annotation.

The VUA corpus gives the authors a different annotation problem to solve. It is drawn from 117 fragments spanning academic writing, news, conversation, and fiction in the British National Corpus. In the original task, the annotation identifies metaphorically used content words. AD-NLP changes the object of the prediction from the word to the sentence. It removes the visible word-level markers and uses their presence in the original annotation to determine whether the sentence belongs to the metaphor-bearing class. A detector sees the text of the sentence and receives credit according to its sentence score. Locating the particular word is outside that evaluation.

The publicly accessible VUA material used by the authors contains 12.122 lines or sentences. The benchmark reports 8.485 training samples and 3.637 test samples from that material. The resulting task asks the detector to find unfamiliar sentences according to a label that can turn on a local choice of words. A metaphor-bearing sentence can share its topic, genre, and most of its wording with sentences that are literal throughout. Removing the original annotation markers is essential to making those textual distinctions, and the context around them, the evidence for the score.

How the new datasets are built

Song Genres starts from a wider multilingual lyrics collection assembled from four sources. The paper describes a collection of over 290.000 lyrics, beginning with material from the 2018 Textract Hackathon and adding material from other lyrics datasets. Where the authors applied their genre-labeling procedure, they queried Spotify for an artist’s genres using Spotipy. They used the mode of the returned genres as the dominant genre assigned to the artist’s lyrics. They also used langdetect to assign a language label automatically. The paper reports 34 languages for the wider lyrics collection. The hackathon data were excepted from the described labeling procedure.

The inputs for anomaly detection are the lyrics themselves. Artist, title, and year are left out of the input, although artist information helps produce genre labels during collection. The benchmark dataset has 15.120 training samples and 3.780 test samples as reported in the data statistics. Its description names genres such as pop, hip-hop, country, and jazz. The genre labels create the divisions needed for evaluation, while the text of a song supplies only part of the material normally associated with that label. The paper calls out melody and rhythm as examples of missing information.

The two Gutenberg datasets begin from a common collection. The authors gathered texts and bookshelf information from Project Gutenberg, associating texts with details such as titles, authors, and the categories assigned by the site. They describe a source collection of over 15.000 literary texts. They then selected different groupings for the benchmark. A Gutenberg Categories label is a bookshelf category. A Gutenberg Authors label identifies the source of the writing. In each case the detector scores pieces of text, with the label providing the connection between a piece and the group it belongs to.

For Gutenberg Categories, the authors choose 10 categories and use 500 training samples and 100 test samples per class. The dataset has 5.000 training samples and 1.000 test samples in the paper’s data statistics. The categories include Biology, Botany, Detective, and Children’s writing. The authors deliberately include a CIA category that they expect to stand apart, as well as categories they expect to overlap. Biology and Botany are an example of the latter. They sample from multiple authors within a category to expose the detector to varied writing under the same shelf label.

Gutenberg Authors comprises 10 source classes, including Arthur Conan Doyle, Agatha Christie, Charles Darwin, and the CIA. The benchmark reports 4.765 training samples and 1.000 test samples. For a class, the authors describe drawing between 400 and 500 training chunks and 100 test samples. They choose writers who can have features in common, including Doyle and Christie, whose fiction can belong to the same genre. They also include classes such as Darwin and the CIA to give the collection more distinctive sources.

Using several books per author is part of the construction. If the text for an author came from a narrow selection of works, a recurrent character or place could dominate that class. The authors mention names associated with individual books as examples of cues they wanted to dilute. Drawing from multiple works gives the class opportunities to exhibit recurring features across subjects and books. It also makes author attribution a less direct proxy for identifying a single story or setting. The paper makes evaluation, download, and preprocessing code available for the resulting benchmark.

How the classical detectors score a sample

The classical comparisons use the one-class support vector machine, abbreviated OC-SVM, and Isolation Forest. Both receive numerical representations based on word embeddings. A word embedding represents a word with a vector, so the method can work with numerical features derived from lexical information. The paper compares FastText with GloVe and gives the embedding size as 300 for both. The choice of representation belongs to the search for a suitable classical baseline. The feature families are word embeddings, including GloVe.

OC-SVM estimates a region occupied by familiar examples. When a test point departs from the fitted description, the method can give it a score associated with an anomaly. A kernel controls how the method represents similarities when learning that region. The authors try a radial basis function kernel, a polynomial kernel, and a linear kernel. They also search the following values of its parameter ν.

ν ∈ {0.05, 0.1, 0.2, 0.5}

Here ν is a parameter of OC-SVM that governs how strictly the description fits the familiar training examples. The symbol ∈ means that the search chooses a value from the set listed in braces. The four entries are the candidate values the authors compare. The search is conducted for each class choice in the benchmark.

Isolation Forest approaches the same task through the ease of separating points in the input space. A forest contains multiple estimators that partition the space. A point lying apart from concentrations of familiar examples can be isolated more readily, giving the method a basis for treating it as unusual. The paper relates this to the expectation that inliers occupy denser parts of a feature space and that outliers are more dispersed. For each split, the authors try forests with 64, 100, 128, or 256 estimators, alongside the choice of embedding.

The contrast between the classical methods is useful even with the same embeddings. OC-SVM relies on how a point relates to a fitted description of the familiar region. Isolation Forest uses the behavior of a point under successive divisions of the space. Each can be sensitive to the way the familiar texts occupy the chosen representation, and the searches let the authors show both methods in settings selected for the particular split. The two scores therefore give separate classical reference points for comparing CVDD and DATE.

How CVDD learns several familiar contexts

Context Vector Data Description, or CVDD, learns several ways to summarize a familiar text. It starts with pretrained word embeddings and learns an attention mechanism whose heads can give weight to different words. For each learned context, the mechanism forms a representation of the sequence. The training objective brings those representations close to corresponding learned context vectors in cosine distance. Cosine distance concerns the directions of vectors, so the objective encourages the projected sequence and its context to point in similar directions.

A context vector serves as a center for a particular kind of familiar pattern. With several such vectors, different projections of a passage can emphasize different features. The objective can penalize context vectors that are not orthogonal, encouraging the learned contexts to separate in direction. This supports an interpretation of the method as learning several centers together with the mechanism that assigns weight to words around them. The paper investigates their interpretability by inspecting words associated with contexts learned from song lyrics.

At evaluation time the paper describes CVDD’s anomaly score as a mean distance between the sequence projections and their corresponding contexts. The scoring rule can be written directly from that description.

s = (Σᵢ dᵢ) / c

Here s is the sample’s anomaly score. The index i identifies a learned context and its associated sequence projection. The quantity dᵢ is the cosine distance for that pair. The symbol Σᵢ indicates addition across the contexts, c is their total number, and the division produces the mean. A larger distance means that the text fits the corresponding familiar context less closely.

The reported CVDD search varies the number of context vectors.

c ∈ {3, 5, 10}

Here c again counts the context vectors. The symbol ∈ indicates that c is chosen from the candidate counts in braces. The paper reports CVDD’s best-performing settings from that search. The context count is the part of the configuration varied in the benchmark’s description of this method.

How DATE learns from edited training text

DATE trains a discriminator to detect changes that have been made to familiar texts. This is self-supervision in the sense that the edits provide training targets. The system masks tokens at selected positions, and a generator supplies replacements. A distribution over the vocabulary describes the generator. The discriminator is a BERT architecture trained from scratch for the procedure. It learns to inspect tokens in their surroundings using a Transformer and attention architecture, with the discriminator based on BERT.

The detector has two pretext tasks, meaning tasks used to create the learning signal for the eventual anomaly evaluation. Replaced Token Detection provides a target at each token position. It trains the discriminator to recognize when a token has been replaced. Replaced Mask Detection gives the discriminator a task concerning the pattern of masked positions. Both tasks are derived from operations on the training texts. The subsequent benchmark labels still refer to the original source classes, such as author or subject. Those labels define familiar training data and determine which test texts count as outliers.

For a test sequence, the paper describes obtaining the document score by averaging the token-level score from Replaced Token Detection. In the notation below, q represents the token score described as part of the PL RTD scoring procedure.

s = (Σᵢ qᵢ) / L

Here s is the score for the sequence, i identifies a token position, and qᵢ is the Replaced Token Detection score at that position. The sum Σᵢ ranges over the sequence, and L is the number of token positions included in the average. The individual terms can also be inspected. The paper’s word highlights illustrate where DATE assigns a stronger local anomaly score.

The authors use previously specified DATE setups for 20Newsgroups and AG News. For the other datasets, they use the AG News setup. This gives the tests outside news a common starting configuration. It also means the depth of the search differs across the methods in the benchmark. The classical methods get a search over several configuration choices on each split, CVDD varies its number of contexts, and DATE carries over established settings.

Experiments and results

Three ways to read a score ranking

The main measure is AUROC, the area under the receiver operating characteristic curve. The curve traces how the true positive rate moves against the false positive rate as the threshold on a detector’s score changes. A threshold governs which samples are flagged. The true positive rate measures how many examples of the designated positive class are caught, and the false positive rate measures how frequently examples outside that class are flagged. The area summarizes separation over the range of thresholds. It is a ranking measure instead of the performance of a single operating point.

The paper also reports areas under precision–recall curves. Precision concerns the share of flagged examples that belong to the target class. Recall concerns the share of all examples in that class that are flagged. AUPR-In takes the familiar texts as the class of interest. AUPR-Out takes anomalous texts as the class of interest. These measures are useful because the same collection can be viewed from the perspective of recovering familiar texts or from the perspective of recovering anomalous ones. The relative numbers of familiar and unfamiliar examples also affect how to read precision.

The main comparisons use the authors’ class-by-class searches and configurations. Where several choices of inlier class are tested, the paper reports the mean and standard deviation across those choices. The spread describes variation across different reference classes. For instance, a sports split and a business split use different training populations. The spread therefore provides information about how much the definition of familiarity matters within a dataset. The paper’s dataset-level scores for CoLA and VUA each come from a single inlier choice.

The overall result and the news datasets

The authors report an overall average AUROC of 71.11% for DATE, which leads their comparison on six of the seven datasets. The reported averages for the other methods are 64.9% for OC-SVM, 64.3% for CVDD, and 63.2% for Isolation Forest. These are the paper’s overall figures. They summarize results from a benchmark whose tasks differ in both the source of the labels and the unit of text.

Overall average AUROC across the AD-NLP benchmark

DATE leads the benchmark average, while the other detectors have similar reported averages.

Overall average AUROC across the AD-NLP benchmarkIsolation Forest: 63.2Isolation Forest63.2CVDD: 64.3CVDD64.3OC-SVM: 64.9OC-SVM64.9DATE (this paper): 71.11DATE (this paper)71.11
The numbers
System or settingAUROC %
Isolation Forest63.2
CVDD64.3
OC-SVM64.9
DATE (this paper)71.11

The news datasets show particularly strong results for DATE. On 20Newsgroups, its mean AUROC across inlier choices is 83.2 ± 6.8. OC-SVM scores 71.3 ± 6.6, Isolation Forest scores 66.5 ± 7.8, and CVDD scores 55.6 ± 4.7. DATE reaches 92.1 AUROC with the computer group as the inlier class. With science as the inlier, its AUROC is 69.7, and OC-SVM reaches 73.5 on that same split. So the overall ordering on 20Newsgroups has an exception when the familiar population changes.

On AG News, the mean AUROC across inlier choices is 90.0 ± 4.2 for DATE and 84.9 ± 3.1 for OC-SVM. Isolation Forest records 77.6 ± 4.0, and CVDD records 69.9 ± 5.9. DATE has 95.9 AUROC with sports as familiar, compared with 89.1 for OC-SVM on that split. With science as familiar, DATE has 84.0 while OC-SVM has 80.6. DATE leads on the reported AG News splits, and the numbers show that the strength of the separation still depends on what the detector has been trained to recognize.

The authors view the news results as broadly similar across the inlier choices. The splits support that reading at the level of the task: the procedure can separate several different news categories from their respective comparison groups. The individual scores qualify the claim. A detector can place one topic much more reliably than another, and the science result on 20Newsgroups illustrates why the benchmark retains the split-level figures. The practical question for a reader is which familiar population the reported score describes.

The summary precision–recall results add a different view. For AG News, the paper reports mean AUPR-Out of 95.9 ± 1.7 for DATE and 70.4 ± 6.7 for OC-SVM. For AUPR-In, the corresponding reported means are 76.9 ± 9.7 and 93.1 ± 1.0. Those columns should be read with attention to their labeled target and the score convention, which becomes important when interpreting the paper’s precision–recall results across datasets.

The gap between genre labels and lyrics

Song Genres produces much lower average AUROC for all four methods than the news datasets do. DATE’s mean across the reported splits is 58.0 ± 7.2. Isolation Forest records 52.3 ± 7.8, OC-SVM 51.1 ± 7.4, and CVDD 50.1 ± 6.7. The authors connect this difficulty to the information available to the detector. Genre can be expressed through music as well as words, and AD-NLP supplies only the lyrical text for this task.

Mean AUROC across Song Genres inlier splits

DATE has the highest mean AUROC on the lyrics, and several genre splits are difficult for all the detectors.

Mean AUROC across Song Genres inlier splitsCVDD: 50.1CVDD50.1OC-SVM: 51.1OC-SVM51.1Isolation Forest: 52.3Isolation Forest52.3DATE (this paper): 58.0DATE (this paper)58.0
The numbers
System or settingAUROC
CVDD50.1
OC-SVM51.1
Isolation Forest52.3
DATE (this paper)58.0

Different genres also produce different rankings of the methods. With hip-hop designated as familiar, OC-SVM reaches 68.0 AUROC, CVDD 66.8, Isolation Forest 63.3, and DATE 54.0. With jazz as familiar, DATE reaches 70.2 AUROC. Isolation Forest has 53.3 on that split, and OC-SVM has 53.0. The higher mean for DATE therefore coexists with examples in which another method learns a better description of a particular genre from lyrics.

The paper’s data description and result labels differ in one detail that matters when counting the genre comparisons. The collection description names nine genres, while the results also report an R&B inlier split. On that reported split, DATE reaches 70.1 AUROC. This figure belongs to the R&B row of the results. The discrepancy leaves the exact correspondence between the described genre list and the evaluated splits unclear.

A further point is visible in the genre precision–recall summary. The reported means for DATE are 12.8 ± 3.6 for AUPR-In and 92.3 ± 1.9 for AUPR-Out. Isolation Forest has 90.7 ± 1.9 and 11.7 ± 4.0 in the respective columns. The metric columns assign strikingly different advantages depending on which class is treated as the target. Their relation to the more modest AUROC results is one reason to distinguish the literal values in the paper from conclusions about how these methods would behave at a chosen threshold.

What changes across the Gutenberg collections

For Gutenberg Categories, DATE records mean AUROC of 77.4 ± 12.0 across the inlier choices. Isolation Forest reaches 68.2 ± 13.8, OC-SVM 68.0 ± 16.2, and CVDD 64.6 ± 12.3. Each reported spread is larger than the corresponding spread on AG News. The choice of bookshelf creates substantially different comparisons, even though the same approach is used to define familiar examples.

The CIA bookshelf is a case where the class is easy to separate in the reported experiment. DATE reaches 99.9 AUROC, OC-SVM 94.8, Isolation Forest 88.1, and CVDD 85.6 when CIA text is the inlier. The authors had included the category because they expected it to be distinct. By comparison, with Canada as the inlier, DATE reaches 53.3 AUROC, and the other reported scores are 49.0 for CVDD, 45.5 for Isolation Forest, and 39.7 for OC-SVM. A benchmark built around one of these shelves alone would give a very different impression of the same methods.

Other bookshelf comparisons sharpen that point. DATE reaches 74.2 AUROC with Botany as the familiar class and 81.9 with Biology as familiar. On Biology, Isolation Forest reaches 83.5 and OC-SVM reaches 82.3. For Historical writing, Isolation Forest reaches 77.3 AUROC, whereas DATE reaches 66.7. DATE’s aggregate lead thus captures its performance across a range of bookshelf definitions. The other methods can be preferable for individual categories in the published comparisons.

Gutenberg Authors produces some of the sharpest reversals. DATE scores 100 AUROC on the CIA inlier split and 99.8 on the Charles Darwin split. With Walter Scott as the inlier, CVDD reports 91.0, Isolation Forest 87.1, and OC-SVM 82.1, while DATE reports 11.0. With H. G. Wells as the inlier, DATE reports 11.8 and OC-SVM reaches 59.8. These low DATE scores indicate that the ranking is badly oriented for the labeled distinction under the reported evaluation. They tell the reader much more about the risk of relying on the overall average than a single high-scoring author can.

The Edgar Allan Poe split offers another concrete comparison. Its AUROC is 48.7 for DATE, 78.6 for CVDD, 72.7 for OC-SVM, and 71.9 for Isolation Forest. The authors single out Poe as a case where a more detailed linguistic investigation could help explain the result. The scores show a difference in performance on the same author split. Identifying the relevant habits of writing, and establishing which habits affected each detector, would require additional analysis.

The sentence tasks

On CoLA, the authors describe DATE as the strongest of the compared approaches by AUROC and say the remaining detectors are close to 50% AUROC. The fixed CoLA experiment takes acceptable sentences as the inlier class and evaluates on the public development partition. For precision–recall on that partition, DATE has 36.4 AUPR-In and 73.5 AUPR-Out. CVDD scores 34.2 AUPR-In and 69.9 AUPR-Out. OC-SVM reports 31.8 and 68.0, respectively, while Isolation Forest reports 31.6 and 66.9. The advantage for DATE is visible on both reported target classes in this setup.

VUA is the exception to DATE’s dataset-level lead by AUROC. The authors report that CVDD leads there. The paper’s precision–recall scores show a further distinction. With anomalous, metaphor-bearing sentences as the target, CVDD scores 75.0 AUPR-Out, Isolation Forest 74.8, and OC-SVM 73.3. DATE reaches 48.4. With the non-metaphorical inliers as the target, Isolation Forest reaches 78.1 AUPR-In, OC-SVM 77.2, CVDD 76.1, and DATE 55.7. Here the AUROC winner also leads the ranking focused on outliers, and a classical method leads the ranking focused on inliers.

AUPR-Out for metaphor-bearing sentences on the VUA test split

CVDD and both classical detectors score higher than DATE when metaphor-bearing sentences are the target.

AUPR-Out for metaphor-bearing sentences on the VUA test splitDATE: 48.4DATE48.4OC-SVM: 73.3OC-SVM73.3Isolation Forest: 74.8Isolation Forest74.8CVDD (this paper): 75.0CVDD (this paper)75.0
The numbers
System or settingAUPR-Out
DATE48.4
OC-SVM73.3
Isolation Forest74.8
CVDD (this paper)75.0

The sentence tasks illustrate why the benchmark benefits from separating types of anomaly. CoLA asks about acceptability, so the sentence’s grammatical properties matter to the label. VUA starts from a local annotation and asks whether a whole sentence contains a metaphor. A detector can excel at spotting some ways that a sequence departs from its training examples and still fail to rank these metaphor-bearing sentences reliably. The evaluation establishes that the tasks behave differently for the tested detectors. It leaves open how much of the difference comes from the properties being measured, the construction of the datasets, or the particular training configurations.

What the ablations show

The paper reports no component-removal ablation, and its analyses instead compare inlier choices, inspect DATE’s local scores, and examine the contexts CVDD learns.

Changing the familiar class

Rotating the inlier class is the closest the benchmark comes to a systematic comparison of what drives performance. The experimental procedure stays recognizable across runs, while the familiar population and the composition of the other group change together. This is sufficient to show which definitions of familiarity are easier for a given detector on that corpus. It does not isolate the effect of the training class from the effect of the comparison classes, since both are determined by the same choice.

The news experiments provide examples where several choices yield good separation for DATE. Gutenberg Authors provides examples where the ranking changes sharply depending on who counts as familiar. Song Genres adds a case where DATE has the higher mean but the classical methods or CVDD can be stronger for a specific class. Together these comparisons show why the unit of analysis matters. A corpus-level mean answers how a method fares across the tested definitions of familiarity. A split-level figure answers how it fares when trained to recognize a particular class against the pooled comparison.

The reported searches also help establish the scope of the comparisons. The classical results are selected after varying parameters and embeddings, and CVDD is evaluated over a set of context counts. The published scores do not trace the effect of changing each individual parameter. They therefore support comparisons among the resulting detector configurations. They provide much less evidence about whether a particular embedding, kernel, forest size, or number of contexts explains a winning result.

Reading DATE’s local scores

For Gutenberg Categories, the paper shows examples from the Botany split and uses the intensity of a highlight to indicate the local anomaly score. A passage whose content concerns botany receives little strong highlighting. In the contrasting outlier example, the detector assigns higher scores to words referring to vehicles, such as ships and cars. These items give a concrete example of lexical evidence that can distinguish the outlier from the familiar subject. The same display also shows the relationship between the token task and the sequence score: individual positions contribute evidence that the method later combines.

The supplementary examples turn to Biology and to text from Agatha Christie and the CIA. They show the kinds of positions DATE can flag within examples whose overall classifications differ. The authors remark on punctuation, individual vocabulary choices, and function words. They suggest that unexpected function-word use in familiar material could reflect a change in the register used by an author. This remains a proposed interpretation. The visualizations identify where the detector responded, while explaining that response would require separating possible causes such as subject, phrasing, and register.

A local score is particularly helpful for seeing that the document is not handled as an indivisible item. The method can mark words inside a generally familiar passage, and it can leave much of an outlying passage with weaker highlights. Since the sequence score averages evidence across positions, a visible highlight and a final classification answer different questions. The examples reveal a response to specific material. The ranking results show how the aggregated evidence behaves over the test set.

Reading CVDD’s learned contexts

The authors look at CVDD’s contexts after training it with hip-hop as the familiar class. One context groups colloquial verb spellings with the same ending, including forms such as “livin” and “turnin”. Other contexts give prominence to pronouns, function words, or words from languages other than English. The paper also notes that some contexts associate certain words with obscene expressions. The authors single out the colloquial verb context as the most meaningful one for anomaly detection in this example.

That analysis gives substance to the idea that a context vector can represent a recognizable pattern. Recurrent forms are visible in the displayed groups, and some of the patterns have a plausible connection to the wording in lyrics. The contexts also differ in what they collect. A grouping defined by verb spelling and a grouping that emphasizes pronouns are broad patterns of different kinds. This is consistent with CVDD’s use of several projections and several centers for familiar text.

The quantitative result helps set the scope of that interpretation. The hip-hop split is one where CVDD obtains 66.8 AUROC, with OC-SVM slightly ahead at 68.0 and DATE at 54.0. The word groupings illustrate what CVDD can learn in that setting. The paper gives no controlled comparison in which a context is removed and the score is measured again. The importance attributed to the displayed verb forms thus comes from inspecting the learned contexts, while the AUROC quantifies the behavior of the method as a whole.

Limitations

Limits identified by the authors

The authors emphasize that the neural approaches can perform poorly on particular tasks and that classical baselines can outperform them. They call attention to the VUA metaphor comparison, where both classical methods exceed DATE on the reported precision–recall measures. They also discuss cases across the benchmark where the stronger method depends on the definition of the familiar class. Their conclusion is about the value of testing a wide range of scenarios, since a method’s assumptions can help in one setting and fit another setting poorly.

The paper also identifies an information limit in Song Genres. The target is a musical genre, while the input consists of lyrics. The authors designed the task to make the detector work with subtle differences in the text when cues such as melody and rhythm are unavailable. The relatively low AUROC scores show the difficulty of the resulting task for the tested methods. The design does not quantify the contribution that each missing cue would have made, because the experiments do not compare the lyrics against another version of the task with musical information.

The authors call for finer linguistic analysis of difficult cases. They give Poe as an example where one could investigate whether distinctive linguistic properties help explain DATE’s weaker authorship result. Their visualizations offer starting points for such questions. The paper leaves that analysis open. It also proposes expanding the collection with new datasets and improving access to the benchmark and its code.

Limits visible in the design and reporting

The benchmark’s outliers are the alternatives available in the selected corpus. A 20Newsgroups score describes separation from the other selected groups. A Gutenberg Authors score describes separation from the other selected sources. These are concrete, repeatable comparisons, and the results belong to those populations. Open-ended use can present samples whose authors, writing styles, topics, and mixes of features fall outside all the comparison classes used in an experiment. The reported measurements give no direct estimate for that population.

The rotation of the familiar class varies more than the label alone. A new inlier choice can change the amount of training material, the variety inside the familiar population, and the composition of the anomalies at test time. For instance, the 20Newsgroups category counts range from 577-2.856 training examples and 382-1.909 validation examples in the corpus description. When performance differs between two such classes, several explanations remain available. One class can have more consistent vocabulary, more examples, or a set of comparison groups that is easier to distinguish. The design measures the combined effect of those changes.

The intended anomaly types can also share observable cues. The authors sample several books per writer in an effort to reduce reliance on recurring characters, places, and similar particulars. The experiment still gives no direct measurement of how much a detector uses authorship style versus the subjects, names, or conventions associated with an author’s books. A source such as the CIA can differ from fiction writers in its subject matter as well as in expression. Likewise, the multiple authors in a bookshelf category give some variety in expression, while topic and style can both correlate with the shelf. Reading the labels as experimental definitions of the task keeps the interpretation close to what was measured.

The sentence-level conversion in VUA introduces another limit. A sentence is positive if it contains an annotated metaphor. The benchmark thereby gives every such sentence the same target label regardless of where in the sentence the cue occurs or how much context is needed to recognize it. A whole-sequence score may respond weakly when the evidence is localized, and some metaphor-bearing sentences may resemble the literal training material in most other ways. This gives a plausible explanation of why the task can be hard. The paper does not compare sentence averaging with a scoring rule designed to concentrate on a local expression.

Some details of the reporting warrant caution. The VUA description gives 80-20 as the split procedure and separately lists the resulting training and test counts. Those figures leave the exact division procedure unclear. The Song Genres description and result rows differ over the inclusion of R&B. The data-sample caption also describes pooling non-outlier classes as inliers, while the experimental procedure and result headings say that one class is used as the inlier and the other classes are scored as outliers. The reported class-by-class comparisons are described using the experimental procedure.

Precision–recall comparisons deserve particular care. The paper defines AUPR-In and AUPR-Out by their target labels, yet some results show large reversals between DATE and the other methods. The appendix also repeats DATE’s 20Newsgroups AUROC sequence in both sets of split-level precision–recall entries. These details prevent a confident explanation of the reversals from the tabulated values alone. The AUROC comparisons and the more consistent results such as the VUA rankings can be described as reported, while the most striking precision–recall contrasts remain difficult to interpret without a fuller account of the scoring convention or tables.

Finally, the searches differ in scope across detectors. The experiment shows the performance of the selected configurations under the authors’ procedure. It gives limited evidence for claims about a detector family’s best attainable performance under equal tuning, or about an individual design feature’s contribution. The spread across splits is also a description of different class choices. It supplies no estimate of how much a particular run would vary if repeated under the same conditions.

What came after

There are no documented follow-on studies to describe here. The paper itself sets out two directions for further work. One is to widen the benchmark with additional datasets, both to add variety within the existing anomaly types and to cover more kinds of departure. The other is to study difficult splits at the level of particular linguistic features. The Poe result gives that second direction a concrete question: which properties of the writing are available to the detector, and which of them explain its ranking of familiar and unfamiliar passages? The paper leaves the answer open.

Cite

Cite as Matei Bejan, Andrei Manolache and Marius Popescu. 2023. AD-NLP: A Benchmark for Anomaly Detection in Natural Language Processing. Proceedings of the 2023 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/2023.emnlp-main.664

@inproceedings{bejan2023ad,
  title = {{AD-NLP: A Benchmark for Anomaly Detection in Natural Language Processing}},
  author = {Matei Bejan, Andrei Manolache and Marius Popescu},
  booktitle = {Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.664},
  url = {https://doi.org/10.18653/v1/2023.emnlp-main.664}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/bejan-2023-ad-nlp-benchmark-anomaly-detection/