Standardizing Outliers: Cheap Counterfactual Negatives for Open-Set Arabic Dialect Identification

Systems that guess which regional dialect a sentence is written in tend to be confidently wrong in two common situations. The first is a sentence that carries no regional signal at all, such as Modern Standard Arabic (the formal written standard), a religious quotation, spam, or text in another language that uses the same script. The second is a sentence from a dialect the system never saw in training. The usual fix in other areas of machine learning is to train with synthetic "outliers," artificial examples the model is taught to reject. The standard recipe blends examples from two different classes and calls the blend an outlier. For dialects that recipe is backwards, because the space between two neighboring dialects is full of real speech. We propose making outliers along a different axis. We take real in-domain sentences and replace their dialect-marking words with standard-language equivalents, using a lexicon mined from a parallel corpus. The result keeps the topic, register, and noise of a tweet but loses its regional evidence. The classifier is trained so that its confidence in a dialect falls in proportion to how many markers were removed.

This addresses three problems with one cheap mechanism. It gives text dialect identifiers a way to reject inputs, which they currently lack. It targets the topical shortcut that makes dialect models fail when moving from travel or news text to social media, since the counterfactual changes only the dialect evidence and holds the topic fixed. And it costs a lexicon lookup per sentence: no large language model, no filtering teacher, and no continued pre-training over ten million tweets.

Core Claim

For fine-grained dialect identification, the region a classifier must learn to reject lies toward the shared standard language and toward non-dialect noise. It does not lie between neighboring dialects. Synthetic negatives built by standardizing real target-domain text will tighten open-set behavior and improve cross-domain accuracy more than three alternatives: between-class interpolation, real external outlier pools, or post-hoc confidence scores. They should do this at negligible generation cost.

Where This Sits

Synthetic outlier work supplies the general principle and the main design we argue against. Networks trained with cross-entropy assign high confidence to inputs far from any training data (Deep neural networks are easily fooled). In text, the closest method is A Closer Look at Few-Shot Out-of-Distribution Intent Detection. It mixes BERT representations of different intents and assigns the mixtures to an extra (K+1)-th rejection class. HGOE and Full-Spectrum OOD Detection use similar interpolation or negative augmentation.

These methods constrain our design. Interpolation is sensible when the gap between "book flight" and "check balance" is semantically empty. Dialects are different. NADI 2024 reports that about 70% of dialectal tweets are valid in two or more regional dialects. Interpolated "outliers" there would penalize real transitional speech.

Non-parametric Outlier Synthesis samples candidates around low-density boundary points in an embedding space and keeps only those outside the data. It operates in dense semantic embeddings. Dialect work consistently finds that surface character and word features beat such embeddings, so we instead build outliers in the surface text itself.

Two speech papers are the only prior work on open-set dialect identification, and both motivate our setup. Exploring Energy-Based Models for OOD Detection in Dialect Identification trains with a margin loss on a real external pool (Common Voice) and adds expensive, unstable Langevin sampling. Unsupervised OOD Dialect Detection with Mahalanobis Distance fits a Gaussian to each class at every wav2vec 2.0 layer and needs no outliers. Neither handles text. Neither faces a shared written standard that masks regional signal; NADI 2020 reports that about half of dialect tweets show dominant Modern Standard Arabic patterns.

Domain-mismatch work on dialects relies on passive exposure to target-domain text. Arabic Dialect Identification Using BERT-Based Domain Adaptation continued masked-language-model pre-training of AraBERT on 10 million tweets. Dialect Identification under Domain Shift self-trained an n-gram SVM from news to Twitter for about a 2-point gain. Neither produces targeted examples that separate dialect evidence from topic.

From the generation-overhead literature, we take the lesson of DISCO: a small set of well-targeted counterfactuals beats a large uncurated set. We reject its cost structure, which requires a GPT-3 generator plus a DeBERTa filter. No reliable filter exists for city-level Arabic, so in our design the label must be correct by construction.

Research Program

Building the lexicon. The MADAR travel corpus (The MADAR Shared Task) is parallel across 25 cities and Modern Standard Arabic. We align each dialect sentence to its standard counterpart at the word level and extract a substitution lexicon from dialect forms to standard forms. Each entry is scored by how much it shifts the log-odds between the dialect and the standard language. Standard word-alignment tools are enough here; no neural generator is involved. MADAR is travel-domain, so tweet coverage will be incomplete. We therefore add a second marker source: n-grams with high dialect-versus-standard log-odds in labeled NADI training tweets, which can be deleted or masked when no substitution exists.

Generating outliers. For each labeled target-domain training tweet $x$ with dialect label $y$, we detect its markers and neutralize a random fraction $\rho \in \{0.25, 0.5, 0.75, 1\}$ of them, producing $\tilde{x}_\rho$. The classifier has $K$ dialect classes plus one "no regional evidence" class $s$. It is trained on $\tilde{x}_\rho$ toward a graded target

$$\hat{p}(\tilde{x}_\rho) = (1-\rho)\, e_y + \rho\, e_s ,$$

where $e_y$ and $e_s$ are one-hot vectors for the original dialect and the no-evidence class. Fully standardized copies act as hard outliers. Partial copies teach the model that confidence should decline smoothly as evidence is removed, which echoes the continuous dialectness scale introduced in NADI 2024. Generation runs on a CPU at the speed of a dictionary lookup. We will report wall-clock time and acceptance rate, which is 100% because nothing is filtered.

Classifiers. We apply the procedure to two learners. The first is a character and word n-gram linear model, the style that won MADAR. Here the synthetic examples simply join the training matrix. The second is AraBERT fine-tuned with the same loss. Running both tests whether the benefit depends on architecture, which matters because shallow models usually win this task.

Analysis. We measure what each model attends to. We check whether predictions on held-out tweets change when topic words are swapped while markers are kept, and when markers are swapped while topic is kept. The method claims to shift reliance from the first kind of word to the second.

Baselines

The naive reference is a closed-set classifier trained with plain cross-entropy that rejects inputs by thresholding maximum softmax probability. It is run on identical splits.

The strongest closed-set competitor is the n-gram ensemble from ArbDialectID at MADAR. It combines linear SVC with multinomial and Bernoulli Naive Bayes over word 1–5-grams, character 2–5-grams, and skip-grams, and it reports 67.32% macro F1 on 26-way MADAR city classification. We reimplement it, then train it on the same data with and without our synthetic examples, using an identical hyperparameter search.

On Twitter, the strongest neural competitor is domain-adapted AraBERT from Arabic Dialect Identification Using BERT-Based Domain Adaptation. It reports 23.09% test macro F1 on NADI 2020 country-level identification, against a best shared-task score of 26.78% in NADI 2020. We run it with the published 10M-tweet adaptation and log its GPU-hours, since the file has no reported compute figure for it. Our method's AraBERT variant gets the same fine-tuning budget but no continued pre-training. A combined variant then tests whether the two are additive.

For open-set rejection, the strongest existing methods come from speech, and we port both to text embeddings. One is layer-wise Mahalanobis scoring from Unsupervised OOD Dialect Detection. The other is energy scoring with a margin loss on a real auxiliary pool, following MEJEM, where the pool is real Modern Standard Arabic news, Quranic text, and other-language tweets. We drop the Langevin sampling and say so explicitly. No reported result exists for any of these methods on text dialect identification; the only open-set dialect numbers in the file are speech results, such as MEJEM's 0.987 AUROC on UK/Ireland English as unknown.

We also run between-dialect Mixup assigned to a (K+1) class, as in the few-shot intent work, and the embedding-space boundary sampling of NPOS, each with matched numbers of synthetic examples.

Three ablations isolate the key ingredient. The first replaces the same number of randomly chosen tokens instead of markers, which tests whether targeting matters. The second uses binary rather than graded targets. The third substitutes with random standard-language words rather than aligned equivalents, which separates "evidence removal" from "adding standard-language vocabulary."

Beating the baselines means two things. Rejection must improve, measured by AUROC and false-positive rate at 95% true-positive rate on held-out countries and on natural non-dialect noise. Closed-set macro F1 must not drop by more than about one point compared with the best baseline on the same split.

Why not just…?

Why not just use real standard-language text as the outlier class? This is the most serious threat. MADAR already contains a Modern Standard Arabic class, and news text is plentiful. Our concern is that real standard text differs from dialect tweets in register and topic as well as dialect evidence. A model trained on it can learn "formal register means not a dialect" and still be fooled by informal tweets with no regional markers. The real-pool energy baseline tests this directly. If it matches our synthetic negatives on the noise and held-out-country tests, the synthesis adds nothing and we will report that.

Why not just use a character n-gram SVM with a confidence threshold? It is the reigning closed-set method, and the MADAR results show it is hard to beat. However, it has no rejection mechanism, and its thresholded confidence has never been evaluated against unseen dialects in text. Because we apply our examples to this same model, the experiment distinguishes "a better model" from "better negatives."

Why not just continue pre-training on 10M tweets? That baseline gains about 4.5 points on NADI, but it gives no negative supervision. It also absorbs exactly the noise we want rejected, such as Quranic verses and spam. The compute comparison and the additive variant settle whether it substitutes for our method or complements it.

Why not just have a large language model translate tweets into the standard language? That would produce better-quality standardization. It reintroduces the API and filtering cost that DISCO-style pipelines incur, and there is no dialect teacher to verify the output. We will run it on a 5k-tweet subset as a quality ceiling, with cost per example reported. If lexicon substitution reaches most of the ceiling's gain, the cheap route is justified.

Proposed Experiments

Cross-domain open-set. We train on MADAR Corpus-26 (travel) and test on the MADAR Twitter Corpus-21 and NADI 2020 at country level, mapping cities to countries. Following the proposal's protocol, five countries are withheld from training as unknowns. A small human-verified set of non-dialect tweets drawn from the NADI unlabeled corpus (standard-language news, religious quotations, Farsi) serves as natural noise.

In-domain open-set. We train on NADI 2020 country-level data with the same held-out countries. Closed-set macro F1 is reported against the 23.09% and 26.78% reference points.

Calibration to the dialect continuum. On NADI 2024, we test whether the model's probability mass outside the no-evidence class predicts the continuous dialectness score. We compare against the subtask's winning RMSE of 0.1403, without claiming parity, and also report multi-label macro F1 against the winning 50.57.

Decisive checks. Three outcomes would refute the claim. If random-token replacement matches marker substitution, targeting is not the cause. If Mixup between dialects lowers F1 on adjacent city pairs, such as Jerusalem and Amman, while our method does not, that confirms the geometric argument; the reverse would refute it. If the real standard-language pool equals synthetic negatives on informal noise, the counterfactual construction is unnecessary.

As a negative control, we will try the method on Romanian versus Moldavian (MOROCO news to Twitter). There, one variety is itself the standard and no parallel lexicon exists, so we expect little gain. That result would mark the method's scope honestly.