---
abstract: 'Contextualized embeddings use unsupervised language model pretraining to compute word representations depending on their context. This is intuitively useful for generalization, especially in Named-Entity Recognition where it is crucial to detect mentions never seen during training. However, standard English benchmarks overestimate the importance of lexical over contextual features because of an unrealistic lexical overlap between train and test mentions. In this paper, we perform an empirical analysis of the generalization capabilities of state-of-the-art contextualized embeddings by separating mentions by novelty and with out-of-domain evaluation. We show that they are particularly beneficial for unseen mentions detection, especially out-of-domain. For models trained on CoNLL03, language model contextualization leads to a +1.2% maximal relative micro-F1 score increase in-domain against +13% out-of-domain on the WNUT dataset.'
author:
- Bruno Taillé
- Vincent Guigue
- Patrick Gallinari
bibliography:
- 'mendeley.bib'
title: 'Contextualized Embeddings in Named-Entity Recognition: An Empirical Study on Generalization'
---

Introduction
============

Named-Entity Recognition (NER) consists in detecting textual mentions of entities and classifying them into predefined types. It is modeled as sequence labeling, the standard neural architecture of which is BiLSTM-CRF [@Huang2015BidirectionalTagging]. Recent improvements mainly stem from using new types of representations: learned character-level word embeddings [@Lample2016NeuralRecognition] and contextualized embeddings derived from a language model (LM) [@Peters2018DeepRepresentations; @Akbik2018ContextualLabeling; @Devlin2019BERT:Understanding].

LM pretraining enables to obtain contextual word representations and reduce the dependency of neural networks on hand-labeled data specific to tasks or domains [@Howard2018UniversalClassification; @Radford2018ImprovingPre-Training]. This contextualization ability can particularly benefit to NER domain adaptation which is often limited to training a network on source data and either feeding its predictions to a new classifier or finetuning it on target data [@Lee2018TransferNetworks; @Rodriguez2018TransferClasses]. All the more as classical NER models have been shown to poorly generalize to unseen mentions or domains [@Augenstein2017GeneralisationAnalysis].

In this paper, we quantify the impact of ELMo [@Peters2018DeepRepresentations], Flair [@Akbik2018ContextualLabeling] and BERT [@Devlin2019BERT:Understanding] representations on generalization to unseen mentions and new domains in NER. To better understand their effectiveness, we propose a set of experiments to distinguish the effect of unsupervised LM contextualization ($C_{LM}$) from task supervised contextualization ($C_{NER}$). We show that the former mainly benefits unseen mentions detection, all the more out-of-domain where it is even more beneficial than the latter.

Lexical Overlap
===============

Neural NER models mainly rely on lexical features in the form of word embeddings, either learned at the character-level or not. Yet, standard NER benchmarks present a large lexical overlap between mentions in the train set and dev / test sets which leads to a poor evaluation of generalization to unseen mentions as shown by Augenstein et al. [@Augenstein2017GeneralisationAnalysis]. They separate seen from unseen mentions and evaluate out-of-domain to focus on generalization but only study models designed before 2011 and no longer in use.

We propose to use a similar setting to analyze the impact of state-of-the-art LM pretraining methods on generalization in NER. We introduce a slightly more fine-grained novelty partition by separating unseen mentions in *partial match* and *new* categories. A mention is an *exact match* (EM) if it appears in the exact same case-sensitive form in the train set, tagged with the same type. It is a *partial match* (PM) if at least one of its non stop words appears in a mention of same type. Every other mentions are *new*. We study lexical overlap in CoNLL03 [@Sang2003IntroductionTask] and OntoNotes [@Weischedel2013OntoNotesLDC2013T19], the two main English NER datasets, as well as WNUT17 [@Derczynski2017ResultsRecognition] which is smaller, specific to user generated content (tweets, comments) and was designed without exact overlap. For out-of-domain evaluation, we train on CoNLL03 (news articles) and test on the larger and more diverse OntoNotes (see Table \[table:genres\] for genres) and the very specific WNUT. We remap OntoNotes and WNUT entity types to match CoNLL03’s and denote the obtained dataset with $^\ast$.

[@ll\*[5]{}[Y]{}rYr\*[5]{}[Y]{}rYr\*[4]{}[Y]{}@]{} & & & & ON & & & & WNUT & &\
& & LOC & MISC & ORG & PER & ALL & & ALL& & LOC & MISC & ORG & PER & ALL & & ALL & & LOC & ORG & PER & ALL\
& EM & 82% & 67% & 54% & 14% & 52% & & 67% &

& 87% & 93% & 54% & 49% & 69% & & - & & - & - &- &-\
& PM & 4% & 11% & 17% & 43% & 20% & & 24% &

& 6% & 2% & 32% & 36% & 20% & & 12% & & 11% & 5% & 13% & 12%\
& New & 14% & 22% & 29% & 43% & 28% & & 9% &

& 7% & 5% & 14% & 15% & 11% & & 88% & & 89% & 95% & 87% & 88%\
& EM &- & - & -& - &- & &- &

& 70% & 78% & 18% & 16% & 42% & & - & & 26% & 8% & 1% & 7%\
& PM &- & - &- & -& - & & - & & 7% & 10% & 45% & 46% & 28% & & - & & 9% & 15% & 16% & 14%\
& New & - & - & - & - & - & & - & & 23% & 12% & 38% & 38% & 30%& & - & & 65% & 77% & 83% & 78%\

\[table:overlap\]

As reported in Table \[table:overlap\], the two main benchmarks for English NER mainly evaluate performance on occurrences of mentions already seen during training, although they appear in different sentences. Such lexical overlap proportions are unrealistic in real-life where the model must process orders of magnitude more documents in the inference phase than it has been trained on, to amortize the annotation cost. On the contrary, WNUT proposes a particularly challenging low-resource setting with no exact overlap. Furthermore, the overlap depends on the entity types: Location and Miscellaneous are the most overlapping types, even out-of-domain, whereas Person and Organization present a more varied vocabulary, also more subject to evolve with time and domain.

Word Representations
====================

### Word embeddings

map each word to a single vector which results in a lexical representation. We take **GloVe 840B** embeddings [@Pennington2014GloVe:Representation] trained on Common Crawl as the pretrained word embeddings baseline and fine-tune them as done in related work.

### Character-level word embeddings

are learned by a word-level neural network from character embeddings to incorporate orthographic and morphological features. We reproduce the **Char-BiLSTM** from [@Lample2016NeuralRecognition]. It is trained jointly with the NER model and its outputs are concatenated to GloVe embeddings. We also experiment with the Char-CNN layer from ELMo to isolate the effect of LM contextualization and denote it **ELMo\[0\]**.

### Contextualized word embeddings

take into account the context of a word in its representation, contrary to previous representations. A LM is pretrained and used to predict the representation of a word given its context. **ELMo** [@Peters2018DeepRepresentations] uses a Char-CNN to obtain a context-independent word embedding and the concatenation of a forward and backward two-layer LSTM LM for contextualization. These representations are summed with weights learned for each task as the LM is frozen after pretraining. **BERT** [@Devlin2019BERT:Understanding] uses WordPiece subword embeddings [@Wu2016GooglesTranslation] and learns a representation modeling both left and right contexts by training a Transformer encoder [@Vaswani2017AttentionNeed] for Masked LM and next sentence prediction. For a fairer comparison, we use the BERT~LARGE~ feature-based approach where the LM is not fine-tuned and its last four hidden layers are concatenated. **Flair** [@Akbik2018ContextualLabeling] uses a character-level LM for contextualization. As in ELMo, they train two opposite LSTM LMs, freeze them and concatenate the predicted states of the first and last characters of each word. Flair and ELMo are pretrained on the 1 Billion Word Benchmark [@Chelba2013OneModeling] while BERT uses Book Corpus [@Zhu2015AligningBooks] and English Wikipedia.

Experiments
===========

In order to compare the different embeddings, we feed them as input to a classifier. We first use the state-of-the-art BiLSTM-CRF [@Huang2015BidirectionalTagging] with hidden size 100 in each direction and present in-domain results on all datasets in Table \[table:in-domain\].

We then report out-of-domain performance in Table \[table:results\]. To better capture the intrinsic effect of LM contextualization, we introduce the Map-CRF baseline from [@Akbik2018ContextualLabeling] where the BiLSTM is replaced by a simple linear projection of each word embedding. We only consider domain adaptation from CoNLL03 to OntoNotes$^\ast$ and WNUT$^\ast$ assuming that labeled data is scarcer, less varied and more generic than target data in real use cases.

We use the IOBES tagging scheme for NER and no preprocessing. We fix a batch size of 64, a learning rate of 0.001 and a 0.5 dropout rate at the embedding layer and after the BiLSTM or linear projection. The maximum number of epochs is set to 100 and we use early stopping with patience 5 on validation global micro-F1. For each configuration, we use the best performing optimization method between SGD and Adam with $\beta_1=0.9$ and $\beta_2=0.999$. We report the mean and standard deviation of five runs.

[@lr@\*[4]{}[Y]{}r\*[4]{}[Y]{}r\*[3]{}[Y]{}@]{}

& & & & & &\
Embedding & Dim & EM & PM & New & All & & EM & PM & New & All & & PM & New & All\

BERT & 4096 & 95.7$_{{\scalebox{\s}}{.1}}$ & 88.8$_{{\scalebox{\s}}{.3}}$ & 82.2$_{{\scalebox{\s}}{.3}}$ & 90.5$_{{\scalebox{\s}}{.1}}$ & & 96.9$_{{\scalebox{\s}}{.2}}$ & 88.6$_{{\scalebox{\s}}{.3}}$ & 81.1$_{{\scalebox{\s}}{.5}}$ & **93.5**$_{{\scalebox{\s}}{.2}}$ & & 77.0$_{{\scalebox{\s}}{4.6}}$ & 53.9$_{{\scalebox{\s}}{.9}}$ & **57.0**$_{{\scalebox{\s}}{1.0}}$\
ELMo & 1024 & 95.9$_{{\scalebox{\s}}{.1}}$ & 89.2$_{{\scalebox{\s}}{.5}}$ & 85.8$_{{\scalebox{\s}}{.7}}$ & **91.8**$_{{\scalebox{\s}}{.3  }}$ & & 97.1$_{{\scalebox{\s}}{.2}}$ & 88.0$_{{\scalebox{\s}}{.2}}$ & 79.9$_{{\scalebox{\s}}{.7}}$ & **93.4**$_{{\scalebox{\s}}{.2}}$ & & 67.7$_{{\scalebox{\s}}{3.2}}$ & 49.5$_{{\scalebox{\s}}{.9}}$ & 52.1$_{{\scalebox{\s}}{1.0}}$\
Flair & 4096 & 95.4$_{{\scalebox{\s}}{.1}}$ & 88.1$_{{\scalebox{\s}}{.6}}$ & 83.5$_{{\scalebox{\s}}{.5}}$ & 90.6$_{{\scalebox{\s}}{.2}}$ & & 96.7$_{{\scalebox{\s}}{.1}}$ & 85.8$_{{\scalebox{\s}}{.5}}$ & 75.0$_{{\scalebox{\s}}{.6}}$ & 92.1$_{{\scalebox{\s}}{.2}}$ & & 64.9$_{{\scalebox{\s}}{.7}}$ & 48.2$_{{\scalebox{\s}}{2.0}}$ & 50.4$_{{\scalebox{\s}}{1.8}}$\
ELMo\[0\] & 1024 & 95.8$_{{\scalebox{\s}}{.1}}$ & 87.2$_{{\scalebox{\s}}{.2}}$ & 83.5$_{{\scalebox{\s}}{.4}}$ & 90.7$_{{\scalebox{\s}}{.1}}$ & & 96.9$_{{\scalebox{\s}}{.1}}$ & 85.9$_{{\scalebox{\s}}{.3}}$ & 75.5$_{{\scalebox{\s}}{.6}}$ & 92.4$_{{\scalebox{\s}}{.1}}$ & & 72.8$_{{\scalebox{\s}}{1.3}}$ & 45.4$_{{\scalebox{\s}}{2.8}}$ & 49.1$_{{\scalebox{\s}}{2.3}}$\
GloVe + char & 350 & 95.3$_{{\scalebox{\s}}{.3}}$ & 85.5$_{{\scalebox{\s}}{.7}}$ & 83.1$_{{\scalebox{\s}}{.7}}$ & 89.9$_{{\scalebox{\s}}{.5}}$ & & 96.3$_{{\scalebox{\s}}{.1}}$ & 83.3$_{{\scalebox{\s}}{.2}}$ & 69.9$_{{\scalebox{\s}}{.6}}$ & 91.0$_{{\scalebox{\s}}{.1}}$ & & 63.2$_{{\scalebox{\s}}{4.6}}$ & 33.4$_{{\scalebox{\s}}{1.5}}$ & 38.0$_{{\scalebox{\s}}{1.7}}$\
GloVe & 300 & 95.1$_{{\scalebox{\s}}{.4}}$ & 85.3$_{{\scalebox{\s}}{.5}}$ & 81.1$_{{\scalebox{\s}}{.5}}$ & 89.3$_{{\scalebox{\s}}{.4}}$ & & 96.2$_{{\scalebox{\s}}{.2}}$ & 82.9$_{{\scalebox{\s}}{.2}}$ & 63.8$_{{\scalebox{\s}}{.5}}$ & 90.4$_{{\scalebox{\s}}{.2}}$ & & 59.1$_{{\scalebox{\s}}{2.9}}$ & 28.1$_{{\scalebox{\s}}{1.5}}$ & 32.9$_{{\scalebox{\s}}{1.2}}$\

\[table:in-domain\]

[@l@lr\*[4]{}[Y]{}r\*[4]{}[Y]{}r\*[4]{}[Y]{}@]{}

& & & & & & &\
& Emb & & EM & PM & New & All & & EM & PM & New & All & & EM & PM & New & All\
& BERT & & 95.7$_{{\scalebox{\s}}{.1}}$ & 88.8$_{{\scalebox{\s}}{.3}}$ & 82.2$_{{\scalebox{\s}}{.3}}$ & 90.5$_{{\scalebox{\s}}{.1}}$ & & 95.1$_{{\scalebox{\s}}{.1}}$ & 82.9$_{{\scalebox{\s}}{.5}}$ & 73.5$_{{\scalebox{\s}}{.4}}$ & **85.0**$_{{\scalebox{\s}}{.3}}$ & & 57.4$_{{\scalebox{\s}}{1.0}}$ & 56.3$_{{\scalebox{\s}}{1.2}}$ & 32.4$_{{\scalebox{\s}}{.8}}$ & 37.6$_{{\scalebox{\s}}{.8}}$\
& ELMo & & 95.9$_{{\scalebox{\s}}{.1}}$ & 89.2$_{{\scalebox{\s}}{.5}}$ & 85.8$_{{\scalebox{\s}}{.7}}$ & **91.8**$_{{\scalebox{\s}}{.3}}$ & & 94.3$_{{\scalebox{\s}}{.1}}$ & 79.2$_{{\scalebox{\s}}{.2}}$ & 72.4$_{{\scalebox{\s}}{.4}}$ & 83.4$_{{\scalebox{\s}}{.2}}$ & & 55.8$_{{\scalebox{\s}}{1.2}}$ & 52.7$_{{\scalebox{\s}}{1.1}}$ & 36.5$_{{\scalebox{\s}}{1.5}}$ & **41.0**$_{{\scalebox{\s}}{1.2}}$\
& Flair & & 95.4$_{{\scalebox{\s}}{.1}}$ & 88.1$_{{\scalebox{\s}}{.6}}$ & 83.5$_{{\scalebox{\s}}{.5}}$ & 90.6$_{{\scalebox{\s}}{.2}}$ & & 94.0$_{{\scalebox{\s}}{.3}}$ & 76.1$_{{\scalebox{\s}}{1.1}}$ & 62.1$_{{\scalebox{\s}}{.5}}$ & 79.0$_{{\scalebox{\s}}{.5}}$ & & 56.2$_{{\scalebox{\s}}{2.2}}$ & 49.4$_{{\scalebox{\s}}{3.4}}$ & 29.1$_{{\scalebox{\s}}{3.3}}$ & 34.9$_{{\scalebox{\s}}{2.9}}$\
& ELMo\[0\] & & 95.8$_{{\scalebox{\s}}{.1}}$ & 87.2$_{{\scalebox{\s}}{.2}}$ & 83.5$_{{\scalebox{\s}}{.4}}$ & 90.7$_{{\scalebox{\s}}{.1}}$ & & 93.6$_{{\scalebox{\s}}{.1}}$ & 76.8$_{{\scalebox{\s}}{.6}}$ & 66.1$_{{\scalebox{\s}}{.3}}$ & 80.5$_{{\scalebox{\s}}{.2}}$ & & 52.3$_{{\scalebox{\s}}{1.2}}$ & 50.8$_{{\scalebox{\s}}{1.5}}$ & 32.6$_{{\scalebox{\s}}{2.2}}$ & 37.6$_{{\scalebox{\s}}{1.8}}$\
& G + char & & 95.3$_{{\scalebox{\s}}{.3}}$ & 85.5$_{{\scalebox{\s}}{.7}}$ & 83.1$_{{\scalebox{\s}}{.7}}$ & 89.9$_{{\scalebox{\s}}{.5}}$ & & 93.9$_{{\scalebox{\s}}{.2}}$ & 73.9$_{{\scalebox{\s}}{1.1}}$ & 60.4$_{{\scalebox{\s}}{.7}}$ & 77.9$_{{\scalebox{\s}}{.5}}$ & & 55.9$_{{\scalebox{\s}}{.8}}$ & 46.8$_{{\scalebox{\s}}{1.8}}$ & 19.6$_{{\scalebox{\s}}{1.6}}$ & 27.2$_{{\scalebox{\s}}{1.3}}$\
& GloVe & & 95.1$_{{\scalebox{\s}}{.4}}$ & 85.3$_{{\scalebox{\s}}{.5}}$ & 81.1$_{{\scalebox{\s}}{.5}}$ & 89.3$_{{\scalebox{\s}}{.4}}$ & & 93.7$_{{\scalebox{\s}}{.2}}$ & 73.0$_{{\scalebox{\s}}{1.2}}$ & 57.4$_{{\scalebox{\s}}{1.8}}$ & 76.9$_{{\scalebox{\s}}{.9}}$ & & 53.9$_{{\scalebox{\s}}{1.2}}$ & 46.3$_{{\scalebox{\s}}{1.5}}$ & 13.3$_{{\scalebox{\s}}{1.4}}$ & 27.1$_{{\scalebox{\s}}{1.0}}$\
& BERT & & 93.2$_{{\scalebox{\s}}{.3}}$ & 85.8$_{{\scalebox{\s}}{.4}}$ & 73.7$_{{\scalebox{\s}}{.8}}$ & 86.2$_{{\scalebox{\s}}{.4}}$ & & 93.5$_{{\scalebox{\s}}{.2}}$ & 77.8$_{{\scalebox{\s}}{.5}}$ & 67.8$_{{\scalebox{\s}}{.9}}$ & 80.9$_{{\scalebox{\s}}{.4}}$ & & 57.4$_{{\scalebox{\s}}{.3}}$ & 53.5$_{{\scalebox{\s}}{2.6}}$ & 33.9$_{{\scalebox{\s}}{.6}}$ & 38.4$_{{\scalebox{\s}}{.4}}$\
& ELMo & & 93.7$_{{\scalebox{\s}}{.2}}$ & 87.2$_{{\scalebox{\s}}{.6}}$ & 80.1$_{{\scalebox{\s}}{.3}}$ & **88.7**$_{{\scalebox{\s}}{.2}}$ & & 93.6$_{{\scalebox{\s}}{.1}}$ & 79.1$_{{\scalebox{\s}}{.5}}$ & 69.5$_{{\scalebox{\s}}{.4}}$ & **82.2**$_{{\scalebox{\s}}{.3}}$ & & 61.1$_{{\scalebox{\s}}{.7}}$ & 53.0$_{{\scalebox{\s}}{.9}}$ & 37.5$_{{\scalebox{\s}}{.7}}$ & **42.4**$_{{\scalebox{\s}}{.6}}$\
& Flair & & 94.3$_{{\scalebox{\s}}{.1}}$ & 85.1$_{{\scalebox{\s}}{.3}}$ & 78.6$_{{\scalebox{\s}}{.3}}$ & 88.1$_{{\scalebox{\s}}{.03}}$ & & 93.2$_{{\scalebox{\s}}{.1}}$ & 74.0$_{{\scalebox{\s}}{.3}}$ & 59.6$_{{\scalebox{\s}}{.2}}$ & 77.5$_{{\scalebox{\s}}{.2}}$ & & 52.5$_{{\scalebox{\s}}{1.2}}$ & 50.6$_{{\scalebox{\s}}{.4}}$ & 28.8$_{{\scalebox{\s}}{.5}}$ & 33.7$_{{\scalebox{\s}}{.5}}$\
& ELMo\[0\] & & 92.2$_{{\scalebox{\s}}{.3}}$ & 80.5$_{{\scalebox{\s}}{1.0}}$ & 68.6$_{{\scalebox{\s}}{.4}}$ & 83.4$_{{\scalebox{\s}}{.4}}$ & & 91.6$_{{\scalebox{\s}}{.4}}$ & 69.6$_{{\scalebox{\s}}{1.0}}$ & 56.8$_{{\scalebox{\s}}{1.5}}$ & 75.0$_{{\scalebox{\s}}{1.0}}$ & & 51.9$_{{\scalebox{\s}}{1.1}}$ & 42.6$_{{\scalebox{\s}}{.9}}$ & 32.4$_{{\scalebox{\s}}{.3}}$ & 35.8$_{{\scalebox{\s}}{.4}}$\
& G + char & & 93.1$_{{\scalebox{\s}}{.3}}$ & 80.7$_{{\scalebox{\s}}{.9}}$ & 69.8$_{{\scalebox{\s}}{.7}}$ & 84.4$_{{\scalebox{\s}}{.4}}$ & & 91.8$_{{\scalebox{\s}}{.3}}$ & 69.3$_{{\scalebox{\s}}{.3}}$ & 55.6$_{{\scalebox{\s}}{1.1}}$ & 74.8$_{{\scalebox{\s}}{.5}}$ & & 50.6$_{{\scalebox{\s}}{.9}}$ & 42.5$_{{\scalebox{\s}}{1.4}}$ & 20.6$_{{\scalebox{\s}}{2.8}}$ & 28.7$_{{\scalebox{\s}}{2.5}}$\
& GloVe & & 92.2$_{{\scalebox{\s}}{.1}}$ & 77.0$_{{\scalebox{\s}}{.4}}$ & 61.7$_{{\scalebox{\s}}{.3}}$ & 81.5$_{{\scalebox{\s}}{.05}}$ & & 89.6$_{{\scalebox{\s}}{.3}}$ & 62.8$_{{\scalebox{\s}}{.6}}$ & 38.5$_{{\scalebox{\s}}{.4}}$ & 68.1$_{{\scalebox{\s}}{.4}}$ & & 46.8$_{{\scalebox{\s}}{.8}}$ & 41.3$_{{\scalebox{\s}}{.5}}$ & 3.2$_{{\scalebox{\s}}{.2}}$ & 18.9$_{{\scalebox{\s}}{.7}}$\

\[table:results\]

General Observations {#general}
--------------------

### ELMo, BERT and Flair

Drawing conclusions from the comparison of ELMo, BERT and Flair is difficult because there is no clear hierarchy accross datasets and they differ in dimensions, tokenization, contextualization levels and pretraining corpora. However, although BERT is particularly effective on the WNUT dataset in-domain, probably due to its subword tokenization, ELMo yields the most stable results in and out-of-domain.

Furthermore, Flair globally underperforms ELMo and BERT, particularly for unseen mentions and out-of-domain. This suggests that LM pretraining at a lexical level (word or subword) is more robust for generalization than at a character level. In fact, Flair only beats the non contextual ELMo\[0\] baseline with Map-CRF which indicates that character-level contextualization is less beneficial than word-level contextualization with character-level representations.

### ELMo\[0\] vs GloVe+char

Overall, ELMo\[0\] outperforms the GloVe+char baseline, particularly on unseen mentions, out-of-domain and on WNUT$^\ast$. The main difference is the incorporation of morphological features: in ELMo\[0\] they are learned jointly with the LM on a huge dataset whereas the char-BiLSTM is only trained on the source NER training set. Yet, morphology is crucial to represent words never encountered during pretraining and in WNUT$^\ast$ around 20% of words in test mentions are out of GloVe vocabulary against 5% in CoNLL03 and 3% in OntoNotes$^\ast$. This explains the poor performance of GloVe baselines on WNUT$^\ast$, all the more out-of-domain, and why a model trained on CoNLL03 with ELMo outperforms one trained on WNUT$^\ast$ with GloVe+char. Thus, ELMo’s improvement over previous state-of-the-art does not only stem from contextualization but also an effective non-contextual word representation.

### Seen Mentions Bias

In every configuration, $F1_{exact} > F1_{partial} > F1_{new}$ with more than 10 points difference. This gap is wider out-of-domain where the context differs more from training data than in-domain. NER models thus poorly generalize to unseen mentions, and datasets with high lexical overlap only encourage this behavior. However, this generalization gap is reduced by two types of contextualization described hereafter.

LM and NER Contextualizations {#analysis}
-----------------------------

The ELMo\[0\] and Map-CRF baselines enable to strictly distinguish contextualization due to LM pretraining ($C_{LM}$: ELMo\[0\] to ELMo) from task supervised contextualization induced by the BiLSTM network ($C_{NER}$: Map to BiLSTM). In both cases, a BiLSTM incorporates syntactic information which improves generalization to unseen mentions for which context is decisive, as shown in Table \[table:results\].

### Comparison

However, because ${C_{NER}}$ is specific to the source dataset, it is more effective in-domain whereas $C_{LM}$ is particularly helpful out-of-domain. In the latter setting, the benefits from $C_{LM}$ even surpass those from ${C_{NER}}$, specifically on domains further from source data such as web text in OntoNotes$^\ast$ (see Table \[table:genres\]) or WNUT$^\ast$. This is again explained by the difference in quantity and quality of the corpora on which these contextualizations are learned. The much larger and more generic unlabeled corpora on which LM are pretrained lead to contextual representations more robust to domain adaptation than ${C_{NER}}$ learned on a small and specific NER corpus.

Similar behaviors can be observed when comparing BERT and Flair to the GloVe baselines, although we cannot separate the effects of representation and contextualization.

### Complementarity

Both in-domain and out-of-domain on OntoNotes$^\ast$, the two types of contextualization transfer complementary syntactic features leading to the best configuration. However, in the most difficult case of zero-shot domain adaptation from CoNLL03 to WNUT$^\ast$, ${C_{NER}}$ is detrimental with ELMo and BERT. This is probably due to the specificity of the target domain, excessively different from source data.

[0.75]{}[@l\*[7]{}[Y]{}@]{} & bc & bn & nw & mz & tc & wb & All\
BERT & 87.2$_{{\scalebox{\s}}{.5}}$ & 88.4$_{{\scalebox{\s}}{.4}}$ & 84.7$_{{\scalebox{\s}}{.2}}$ & 82.4$_{{\scalebox{\s}}{1.2}}$ & 84.5$_{{\scalebox{\s}}{1.1}}$ & 79.5$_{{\scalebox{\s}}{1.0}}$ & **85.0**$_{{\scalebox{\s}}{.3}}$\
ELMo & 85.0$_{{\scalebox{\s}}{.6}}$ & 88.6$_{{\scalebox{\s}}{.3}}$ & 82.9$_{{\scalebox{\s}}{.3}}$ & 78.1$_{{\scalebox{\s}}{.7}}$ & 84.0$_{{\scalebox{\s}}{.8}}$ & 79.9$_{{\scalebox{\s}}{.5}}$ & 83.4$_{{\scalebox{\s}}{.2}}$\
Flair & 78.0$_{{\scalebox{\s}}{1.1}}$ & 86.5$_{{\scalebox{\s}}{.4}}$ & 80.4$_{{\scalebox{\s}}{.6}}$ & 71.1$_{{\scalebox{\s}}{.4}}$ & 73.5$_{{\scalebox{\s}}{1.8}}$ & 72.1$_{{\scalebox{\s}}{.8}}$ & 79.0$_{{\scalebox{\s}}{.5}}$\
ELMo\[0\] & 82.6$_{{\scalebox{\s}}{.5}}$ & 88.0$_{{\scalebox{\s}}{.3}}$ & 79.6$_{{\scalebox{\s}}{.5}}$ & 73.4$_{{\scalebox{\s}}{.6}}$ & 79.2$_{{\scalebox{\s}}{1.2}}$ & 75.1$_{{\scalebox{\s}}{.3}}$ & 80.5$_{{\scalebox{\s}}{.2}}$\
GloVe + char & 80.4$_{{\scalebox{\s}}{.8}}$ & 86.3$_{{\scalebox{\s}}{.4}}$ & 77.0$_{{\scalebox{\s}}{1.0}}$ & 70.7$_{{\scalebox{\s}}{.4}}$ & 79.7$_{{\scalebox{\s}}{1.8}}$ & 69.2$_{{\scalebox{\s}}{.8}}$ & 77.9$_{{\scalebox{\s}}{.5}}$\

\[table:genres\]

Related Work
============

Augenstein et al. [@Augenstein2017GeneralisationAnalysis] perform a quantitative study of two CRF-based models and a CNN with classical word embeddings [@Collobert2011NaturalScratch] over seven NER datasets including CoNLL03 and OntoNotes. They separate performance on seen (*exact match*) and unseen mentions and show a drop in F1 on unseen mentions and out-of-domain. Although comprehensive in experiments, this analysis is limited to models dating back from 2005 to 2011. We use a similar experimental setting to draw new insights on state-of-the art architectures and word representations. We limit to the two main English NER benchmarks as well as WNUT which was specifically designed to tackle this generalization problem in the Twitter domain. These three datasets cover all the domains studied in [@Augenstein2017GeneralisationAnalysis]. Moosavi and Strube raise a similar lexical overlap issue in Coreference Resolution on the CoNLL2012 dataset. They first show that for out-of-domain evaluation the performance gap between Deep Learning models and a rule-based system fades away [@Moosavi2017LexicalCaution]. They then add linguistic features (such as gender, NER, POS...) to improve out-of-domain generalization [@Moosavi2018UsingResolvers]. Nevertheless, such features are obtained using models in turn based on lexical features and at least for NER the same lexical overlap issue arises.

Finally, Pires et al. [@Pires2019HowBERT] concurrently evaluate the cross-lingual generalization capability of Multilingual BERT for NER and POS tagging. Our work on monolingual generalization to unseen mentions and domains naturally complements this study.

Conclusion
==========

NER benchmarks are biased towards seen mentions, at the opposite of real-life applications. Hence the necessity to disentangle performance on seen and unseen mentions and test out-of-domain. In such setting, we show that contextualization from LM pretraining is particularly beneficial for generalization to unseen mentions, all the more out-of-domain where it surpasses supervised contextualization. Despite this improvement, unseen mentions detection remains challenging and further work could explore attention or regularization mechanisms to better incorporate context and improve generalization. Furthermore, we can investigate how to best incorporate target data to improve this LM pretraining zero-shot domain adaptation baseline.
