ERNIE-Gram: Pre-Training with Explicitly N-Gram Masked Language Modeling for Natural Language Understanding

Dongling Xiao, Yu-Kun Li, Han Zhang, Yu Sun, Hao Tian +2 more
10/23/2020
45 citations
cs.CLcs.LG

Official code: PaddlePaddle/ERNIE (7,738 stars, Python, Apache-2.0, last commit 2026-07-24). Most starred: PaddlePaddle/PaddleNLP, a community implementation (12,998 stars, Python, Apache-2.0, last commit 2025-12-17, 1.7× the official stars). 1 more implementation below.

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
PaddlePaddle/ERNIEOfficial7,738PythonApache-2.02026-07-24
PaddlePaddle/PaddleNLPCommunity12,998PythonApache-2.02025-12-17
PaddlePaddle/ERNIEOfficial100%
Apache-2.0

The official repository for ERNIE 4.5 and ERNIEKit – its industrial-grade development toolkit based on PaddlePaddle.

7,7381,445Python, Jupyter NotebookMar 3, 20194 months agoApache-2.0
ernieernie-45ernie-45-vlerniekitllm+1 more
Apache-2.0

Easy-to-use and powerful LLM and SLM library with awesome model zoo.

12,9983,013Python, CudaFeb 5, 202111 months agoApache-2.0
bertcompressiondistributed-trainingdocument-intelligenceembedding+14 more

Similar Papers

Cite this paper

@article{xiao2020erniegram,
  title  = {ERNIE-Gram: Pre-Training with Explicitly N-Gram Masked Language Modeling for Natural Language Understanding},
  author = {Dongling Xiao and Yu-Kun Li and Han Zhang and Yu Sun and Hao Tian and Hua Wu and Haifeng Wang},
  year   = {2020},
  eprint = {2010.12148},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2010.12148}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2010.12148.svg)](https://codeofpaper.com/paper/2010.12148)

Discussion