Skip to main content
QUICK REVIEW

[Paper Review] ERNIE-Gram: Pre-Training with Explicitly N-Gram Masked Language Modeling for Natural Language Understanding

Dongling Xiao, Yukun Li|arXiv (Cornell University)|Oct 23, 2020
Topic ModelingComputer Science45 references8 citations
TL;DR

ERNIE-Gram proposes an explicitly n-gram masked language modeling approach that enhances pre-training by directly predicting n-gram identities rather than contiguous token sequences, using a generator to sample plausible n-grams and enabling comprehensive coarse- and fine-grained prediction. It achieves state-of-the-art performance on 19 NLU tasks, outperforming XLNet and RoBERTa by large margins, and sets new SOTA on GLUE and SQuAD benchmarks with a 300K n-gram lexicon.

ABSTRACT

Coarse-grained linguistic information, such as named entities or phrases, facilitates adequately representation learning in pre-training. Previous works mainly focus on extending the objective of BERT's Masked Language Modeling (MLM) from masking individual tokens to contiguous sequences of n tokens. We argue that such contiguously masking method neglects to model the intra-dependencies and inter-relation of coarse-grained linguistic information. As an alternative, we propose ERNIE-Gram, an explicitly n-gram masking method to enhance the integration of coarse-grained information into pre-training. In ERNIE-Gram, n-grams are masked and predicted directly using explicit n-gram identities rather than contiguous sequences of n tokens. Furthermore, ERNIE-Gram employs a generator model to sample plausible n-gram identities as optional n-gram masks and predict them in both coarse-grained and fine-grained manners to enable comprehensive n-gram prediction and relation modeling. We pre-train ERNIE-Gram on English and Chinese text corpora and fine-tune on 19 downstream tasks. Experimental results show that ERNIE-Gram outperforms previous pre-training models like XLNet and RoBERTa by a large margin, and achieves comparable results with state-of-the-art methods. The source codes and pre-trained models have been released at https://github.com/PaddlePaddle/ERNIE.

Motivation & Objective

  • To address the limitation of BERT-style masked language modeling in capturing coarse-grained linguistic information such as named entities and phrases.
  • To overcome the inefficiency of contiguous n-gram masking, which treats tokens in a masked span independently and neglects intra-dependencies.
  • To enhance representation learning by explicitly modeling n-gram identities in a dense prediction space rather than a sparse token space.
  • To improve semantic modeling of n-grams through comprehensive prediction (coarse- and fine-grained) and explicit n-gram relation learning.
  • To achieve state-of-the-art performance on diverse NLU benchmarks through improved pre-training.

Proposed method

  • ERNIE-Gram masks n-grams using a single [MASK] token and predicts them via explicit n-gram identities from a pre-constructed n-gram lexicon, reducing the prediction space from |V_F|^n to |V_N|.
  • It employs a generator model to sample plausible n-gram identities as optional masks, enabling more robust and diverse training signals.
  • The model performs comprehensive n-gram prediction by simultaneously predicting both the explicit n-gram identity and the individual token identities of the masked span using a shared attention mask mechanism.
  • An enhanced n-gram relation modeling mechanism is introduced, where the model learns to recover original n-grams from plausible ones, explicitly modeling semantic relationships between n-grams.
  • The replaced token detection (RTD) objective is adapted to distinguish original n-grams from generated ones, improving interaction between n-gram and token-level representations.
  • Pre-training is conducted on 16GB and 160GB English and Chinese text corpora using BERT-base and BERT-large settings, with fine-tuning on 19 downstream tasks.

Experimental results

Research questions

  • RQ1Can explicitly masking and predicting n-gram identities improve representation learning compared to masking individual tokens or contiguous token spans?
  • RQ2Does modeling n-gram identities in a dense, finite space (V_N) lead to better performance than predicting from a sparse, exponential space (V_F^n)?
  • RQ3To what extent does comprehensive prediction of both n-gram identities and constituent tokens enhance semantic modeling of phrases and named entities?
  • RQ4How does explicit n-gram relation modeling—learning to recover original n-grams from plausible alternatives—improve contextual representation learning?
  • RQ5What is the optimal size of the n-gram lexicon for balancing coverage and performance in pre-training?

Key findings

  • ERNIE-Gram outperforms XLNet and RoBERTa by a large margin on 19 downstream NLU tasks, achieving state-of-the-art results on GLUE and SQuAD benchmarks.
  • On the GLUE benchmark, ERNIE-Gram achieves a 78.9 F1 score on SQuAD1.1 and 87.4 F1 on SQuAD2.0, significantly outperforming previous models.
  • The ablation study shows that removing comprehensive n-gram prediction reduces performance by 0.3–0.6 points, while removing enhanced n-gram relation modeling reduces it by 0.4–1.3 points.
  • Performance degrades when the n-gram lexicon size exceeds 300K, indicating that including low-frequency n-grams harms learning, with a 400K lexicon causing significant performance drops.
  • Case studies show ERNIE-Gram maintains higher recall for longer named entities and exhibits stronger attention coherence across entire named entities, confirming better modeling of intra-dependencies.
  • Visualization of attention heads reveals bright, coherent blocks over named entities in ERNIE-Gram, indicating that tokens attend to each other within the same entity, unlike the diagonal self-attention patterns in baselines.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.