All models

ZEN

A BERT-based Chinese text encoder that adds n-gram representations to its character encoder.

Language · 1,015 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (36 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
224.7M
Operations
1,015
Framework
PyTorch
Recurrent
No
Published
Findings of EMNLP 2020
Cited by
140 (as of 28 October 2026)
Authors
Shizhe Diao, Jiaxin Bai, Yan Song and others
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m21571
Graph hash
c2c81e59c750b95aa6666255d25aea3b7513d6b8ae770cae0763fd6e699d9f16
Skeleton hash
98c78630fecfedd8ce503211eec667764fb3faa44aba29213e7a715e6d743056
Architecture hash
7767b8b1644419f9fa2dd97899e013c3f6b2bc6573d7b8b15258c5ecac3e10d5
Diagram SHA-256
e2f88327f83868ac91a0a8ea5bb2bb5afe49f90964cd6ba8debeb1f4d933ee25
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

ZEN is a BERT-based text encoder for Chinese that is enhanced by n-gram representations, so that different combinations of characters are considered during training. The paper's motivation is that encoding text only as small units loses semantic information, which is especially problematic for Chinese because the language has no explicit word boundaries.

Beside the BERT character encoder, ZEN runs a second multi-layer Transformer encoder that models the interactions among the n-grams found in the input. This n-gram encoder does not encode positions, because all n-grams are treated equally without a sequential order. The n-gram representations are incorporated into the character encoder by an addition operation. This is repeated for each layer of the BERT backbone except the last one. The model still outputs only character-level encodings consistent with BERT, so downstream tasks are not affected.

The BERT backbone has 12 layers with 12 self-attention heads and 768 dimensions for hidden states. The n-gram encoder uses the same settings except that it has only 6 layers and sets 128 as the maximum length of n-grams. The paper's main experiments use a lexicon of 104K n-grams.

Key idea. ZEN enhances a BERT character encoder with n-gram representations, so that potential word or phrase boundaries are pre-trained and fine-tuned together with the characters.

  • ZEN
  • Chinese text encoder
  • n-gram representations
  • n-gram enhanced encoder
  • Chinese pre-trained language model
  • Chinese NLP

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{diao2019zenpretrainingchinesetext,
      title={ZEN: Pre-training Chinese Text Encoder Enhanced by N-gram Representations}, 
      author={Shizhe Diao and Jiaxin Bai and Yan Song and Tong Zhang and Yonggang Wang},
      year={2019},
      eprint={1911.00720},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/1911.00720}, 
}