CoolFace
Modelpublic

feynmanzhao/chinese-modernbert-large-wwm

sourceHugging Faceapache-2.0updated 10mo agoView on Hugging Face
14likes596downloads
Model Card

Chinese ModernBERT

Model Description

Chinese ModernBERT is an encoder-only transformer model pre-trained from scratch on 1.2 trillion Chinese tokens. It is designed to be a modern, efficient, and powerful foundation model for Chinese NLP tasks.

The model incorporates several key architectural and training advancements:

  • —Modern Architecture: Based on the ModernBERT structure, it features a 28-layer, 1024-hidden dimension pre-norm Transformer with RMSNorm, GeGLU activations, and bias-free linear layers.
  • —Efficient Long Context: The model supports a native context window of 8,192 tokens. This is achieved through a two-stage pre-training process and an alternating local/global attention mechanism coupled with RoPE, making it highly efficient for long sequence tasks.
  • —Chinese-Centric Tokenizer: It uses a custom 32k BPE vocabulary trained on high-quality Chinese text. This improves tokenization efficiency (chars/token) and reduces the embedding parameter budget, allocating more capacity to the compute core.
  • —Advanced Masking Strategy: The model was pre-trained using Whole-Word Masking (WWM) with a dynamic masking curriculum. The masking rate starts high (30%) to encourage global reasoning and gradually decreases to 15% for local refinement.

Intended Uses & Limitations

Intended Use

The model is primarily intended to be used as a text encoder for a variety of downstream tasks, especially where latency and long-context capabilities are important.

  • —Text Embeddings: Generating embeddings for retrieval, ranking, and semantic search.
  • —Sentence Similarity: Calculating the similarity between pairs of sentences.
  • —Fine-tuning: Serving as a base model for classification, clustering, and other Chinese NLP tasks.

Limitations

  • —The model was pre-trained exclusively on Chinese text. Its performance on other languages, code, or mathematical reasoning is limited.
  • —The reported STS benchmark results were achieved by fine-tuning on open-source contrastive datasets. Performance may vary depending on the fine-tuning data and procedure.

How to Use

Training Data

The model was pre-trained on approximately 1.2 trillion Chinese tokens from a mixture of high-quality, deduplicated sources: | Dataset | Ratio | |-----------------------------|-------| | Baike (custom) | 0.03 | | CCI3-HQ | 0.57 | | CCI4 Chinese (FinWeb 34) | 0.10 | | CCI4 Chinese (FinWeb 45) | 0.10 | | OpenCSG Cosmopedia-Chinese | 0.20 |

Evaluation Results

CLUE Benchmark

The model shows competitive performance on the CLUE (Chinese Language Understanding Evaluation) benchmark dev set. Fine-tuning protocol: 3 epochs, peak LR 3e-5, linear decay.

ModelAFQMCTNEWSIFLYTEKCMNLIWSCCSLOCNLIC3
Chinese ModernBERT73.8756.9060.1583.9652.1086.2079.1082.65
RoBERTa-wwm-large76.5558.6162.9882.1274.6082.1378.2073.82
ALBERT-xxlarge75.6059.4662.8983.1461.5483.6377.7073.28

Inference Throughput

The model demonstrates excellent throughput, especially for long sequences, due to its alternating local/global attention and efficient architecture. Benchmark run on a single NVIDIA A100 GPU with bfloat16.

Sequence LengthBatch SizeThroughput (tokens/sec)
≤ 8,1928180,100
≤ 51232172,046

Semantic Textual Similarity (SimCLUE)

The model was fine-tuned on open contrastive datasets to evaluate its potential for semantic similarity tasks. It achieves strong results and surpasses comparable models like Qwen-0.6B-embedding in this open-data setting.

Fine-tuning DataContrastive PairsPearson rSpearman ρ
SimCLUE only~3M0.48820.5219
SimCLUE + T2Ranking~5M0.50500.5367
Qwen-0.6B-embedding~169M0.49650.5211
jina-embeddings-v2-base-zh>800M0.51880.5501
gte-large-zh~803M0.55430.5829

Model Architecture

AspectDetails
Layers / Hidden / Heads28 / 1024 / 16
Vocabulary32k BPE
MaskingDynamic Whole-Word Masking (30%→15%)
Positional EncodingRoPE (θglobal=80,000; θlocal=10,000)
Attention PatternAlternating local/global
Context Window8,192 tokens
OptimizerStableAdamW
LR ScheduleDamped Cosine
Pre-training Data~1.2T Chinese tokens
Key FeaturesUnpadding, FlashAttention v2

How to Get Started With the Model

python
from transformers import AutoTokenizer,AutoModel
tokenizer = AutoTokenizer.from_pretrained("feynmanzhao/chinese-modernbert-large-wwm", trust_remote_code=True)
model = AutoModel.from_pretrained("feynmanzhao/chinese-modernbert-large-wwm")

Citation

bibtex
@misc{zhao2025chinesemodernbert,
      title={Chinese ModernBERT with Whole-Word Masking}, 
      author={Zeyu Zhao and Ningtao Wang and Xing Fu and Yu Cheng},
      year={2025},
      eprint={2510.12285},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}