DuckBERT-base / README.md
rickchoi85's picture
Model card: explain the DuckBERT name
d638fcc verified
|
Raw History Blame Contribute Delete
13.8 kB
metadata
license: mit
language:
  - ko
  - zh
  - ja
  - en
  - multilingual
library_name: transformers
pipeline_tag: fill-mask
base_model: jhu-clsp/mmBERT-base
datasets:
  - HuggingFaceFW/fineweb-2
  - wikimedia/wikipedia
  - HPLT/HPLT2.0_cleaned
  - mlfoundations/dclm-baseline-1.0
  - HuggingFaceFW/fineweb-edu-score-2
tags:
  - modernbert
  - mmbert
  - encoder
  - masked-lm
  - cjk
  - korean
  - chinese
  - japanese
  - multilingual
  - continued-pretraining
  - tokenizer-swap
  - duckbert

DuckBERT-base

DuckBERT-base is a 312M-parameter encoder for Korean, Chinese, Japanese and English. It starts from jhu-clsp/mmBERT-base (ModernBERT architecture), replaces the Gemma 2 tokenizer with the Gemma 3 tokenizer (262K vocab), and continues masked-language-model pre-training for 132B tokens. Korean text takes 27% fewer tokens, and the model is ahead of mmBERT-base on 12 of 14 Korean, Japanese and Chinese fine-tuning tasks (see Evaluation).

The name stands for Domain-augmented Understanding via Continued Knowledge transfer: the knowledge of the original model is carried over to a new tokenizer by continued pre-training, then extended with domain text.

mmBERT-base (original) DuckBERT-base
Tokenizer Gemma 2 (256K) Gemma 3 (262K)
Korean tokens for the same text 44 32 (โˆ’27.3%)
Chinese tokens for the same text 25 22 (โˆ’12.0%)
Japanese / English 31 / 25 31 / 25 (unchanged)
Korean + Japanese + Chinese, 14 fine-tuning tasks (avg ร—100) 81.6 82.3
KLUE-NER F1 (Korean) 89.7 91.2
KoBEST COPA (Korean commonsense) 72.9 76.7
JCommonsenseQA (Japanese) 78.8 82.2
Parameters 307M 312M
Max positions 8,192 8,192

Developed by Warp Space Inc. (CaveduckAI). The model is the backbone for the lightweight classification, moderation and sequence-labeling models that run inside the Caveduck AI character platform. This repository was previously named CaveduckAI/mmBERT-cjke-base; the old id redirects here.

Why swap the tokenizer?

mmBERT-base is a strong multilingual encoder, but it inherits the Gemma 2 tokenizer, which inserts a prefix space in front of tokens. Chinese and Japanese have no spaces, and Korean spacing differs from English, so token boundaries end up misaligned with word boundaries. This hurts tasks where boundaries matter (NER, span detection, segmentation) and wastes context on Korean text. The mmBERT authors note this limitation and recommend the Gemma 3 tokenizer.

Swapping a tokenizer breaks the embedding table, so the new embeddings are initialized from overlapping tokens and sub-token averages and the model is then pre-trained further, embeddings first and the full model afterwards, until the knowledge of the original model is carried over to the new vocabulary.

Training

Stage 1 (embedding stabilization) Stage 2 (full adaptation) Stage 3 (domain-augmented)
Trainable token embeddings + MLM head all parameters all parameters
Tokens 2B 30B 100B
LR 1e-4, cosine 8e-5, cosine 8e-5, then decayed over the last 20B
Mask rate 30% 30% 30%, then 15% over the last 20B
  • Objective: masked language modeling, sequence length 512, about 1M tokens per step, bf16 autocast, FlashAttention-2.
  • Hardware: 4ร— NVIDIA H200 (DDP) on kt cloud AI Nexus, about 600k tokens/s.
  • Held-out MLM loss (mean over the four languages): 1.65 after stage 2, 1.22 after stage 3.
  • Framework: PyTorch, ๐Ÿค— Transformers, ๐Ÿค— Datasets.

Data

Stage Sources
Stage 1โ€“2 (32B) FineWeb2 (kor_Hang, cmn_Hani, jpn_Jpan), Wikipedia (ko/zh/ja), FineWeb-edu (English)
Stage 3 (100B) FineWeb2 and HPLT v2 (Korean, Chinese, Japanese web), DCLM-baseline (English), AI Hub Korean corpora (books, stories, classical literature)

The AI Hub corpora were built through projects of the National Information Society Agency of Korea (NIA). (AI Hub ๋ฐ์ดํ„ฐ๋Š” ํ•œ๊ตญ์ง€๋Šฅ์ •๋ณด์‚ฌํšŒ์ง„ํฅ์›(NIA)์˜ ์‚ฌ์—… ๊ฒฐ๊ณผ๋กœ ๊ตฌ์ถ•๋œ ๋ฐ์ดํ„ฐ๋ฅผ ํ™œ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.)

Evaluation

Both models were measured with one protocol: load the weights in fp32, fine-tune with the tokenizer files shipped in each repository, 20k training samples per task, 3 epochs, batch 32, best of two learning rates (3e-5, 5e-5), inputs truncated at 512 tokens, evaluated on up to 3k held-out samples. Scores are ร—100 and come from a single seed, so differences below about 0.5 on one task are noise. These are model-to-model comparisons under a reduced protocol and are not comparable to leaderboard numbers. Raw results are in evaluation/.

Averages

mmBERT-base DuckBERT-base ฮ”
Korean (5 tasks) 87.1 87.9 +0.8
Japanese (4 tasks) 87.0 87.6 +0.6
Chinese (5 tasks) 71.7 72.5 +0.8
Korean + Japanese + Chinese (14 tasks) 81.6 82.3 +0.7
English (2 tasks) 83.6 82.3 -1.3

Per task

Task Lang Metric mmBERT-base DuckBERT-base ฮ”
KLUE-TC (topic classification) ko macro F1 81.3 82.3 +1.0
KLUE-NLI ko acc 84.4 85.8 +1.4
KLUE-STS ko Pearson 91.5 92.5 +1.0
KLUE-NER ko F1 89.7 91.2 +1.5
WikiAnn ko (NER) ko F1 88.5 87.9 -0.6
JGLUE MARC-ja ja acc 95.9 96.1 +0.2
JGLUE JNLI ja acc 91.1 92.1 +1.0
JGLUE JSTS ja Pearson 92.2 91.9 -0.3
WikiAnn ja (NER) ja F1 68.8 70.2 +1.4
CLUE TNEWS zh acc 54.6 55.8 +1.2
CLUE OCNLI zh acc 74.3 74.6 +0.3
CLUE CMNLI zh acc 78.5 79.0 +0.5
CLUE AFQMC zh acc 74.0 75.0 +1.0
WikiAnn zh (NER) zh F1 77.2 78.2 +1.0
XNLI en en acc 84.1 82.9 -1.2
WikiAnn en (NER) en F1 83.1 81.8 -1.3

All four KLUE tasks, all five Chinese tasks and three of four Japanese tasks are above the base model. English is about 1 point lower: the last training stage is weighted toward Korean, Chinese and Japanese.

Commonsense reasoning and reading comprehension

A second suite with inputs up to 8,192 tokens (multiple choice scored per option, extractive QA scored over whole documents). Training sets were sub-sampled and each task was run once, so treat it as indicative.

Task Lang Metric mmBERT-base DuckBERT-base ฮ”
KoBEST COPA ko macro F1 72.9 76.7 +3.8
KoBEST HellaSwag ko macro F1 80.0 80.5 +0.5
KoBEST BoolQ ko macro F1 78.0 77.9 -0.1
KoBEST WiC ko macro F1 73.5 77.1 +3.6
KoBEST SentiNeg ko macro F1 90.1 89.6 -0.5
KorQuAD 2.0 (full documents, 8,192 tokens) ko F1 70.1 69.2 -0.9
KLUE-MRC ko F1 66.1 65.9 -0.2
JCommonsenseQA ja acc 78.8 82.2 +3.4
JaQuAD ja F1 85.5 85.8 +0.3
C3 (multiple-choice reading) zh acc 72.6 73.8 +1.2
CMRC 2018 zh F1 87.9 88.9 +1.0

The largest gains are on commonsense reasoning (KoBEST COPA, KoBEST WiC, JCommonsenseQA), which we attribute to the book and story corpora added in stage 3. Korean extractive QA is slightly below the base model: the Gemma 3 tokenizer saves Korean tokens partly by merging a noun with the particle that follows it, so a span model cannot always cut the answer exactly at a token boundary.

Downstream example: sequence labeling vs. LLMs and other encoders

A sequence labeler (DuckBERT-base + Linear + CRF) that segments AI character responses into dialogue, narration and speaker-prefix spans was compared on the same 120 held-out responses (30 each in Korean, English, Japanese and Traditional Chinese) with 21 general-purpose LLMs (2-shot prompts) and with seven public multilingual encoders fine-tuned on the same data with the same recipe.

Model span F1 (micro, 120 samples) span F1 (validation set, 3,322 samples) Max input
DuckBERT-base 0.994 0.966 8,192
mmBERT-base 0.992 0.965 8,192
mDeBERTa-v3 base 0.989 0.959 512
XLM-R large 0.989 0.957 512
XLM-R base 0.986 0.956 512
mBERT 0.988 0.946 512
Best LLM (DeepSeek V4 Pro, 2-shot) 0.970 n/a n/a
GPT-5.5 (2-shot) 0.966 n/a n/a

Inference cost of the labeler is about USD 0.001 per 1,000 responses on a single RTX A5000, against USD 0.06 for the cheapest LLM tested and USD 18.5 for GPT-5.5.

Tokenizer efficiency

Measured on identical texts (tokens per text, lower is better):

Language Gemma 2 (mmBERT-base) Gemma 3 (this model) Change
Korean 44 32 โˆ’27.3%
Chinese 25 22 โˆ’12.0%
Japanese 31 31 0%
English 25 25 0%

Fewer tokens means more Korean text fits in the same context window and faster inference on Korean inputs.

Usage

from transformers import AutoTokenizer, AutoModelForMaskedLM
import torch

repo = "CaveduckAI/DuckBERT-base"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForMaskedLM.from_pretrained(repo)

text = "์„œ์šธ์€ ๋Œ€ํ•œ๋ฏผ๊ตญ์˜ <mask>์ด๋‹ค."
inputs = tok(text, return_tensors="pt")
with torch.no_grad():
    logits = model(**inputs).logits
mask_idx = (inputs.input_ids == tok.mask_token_id).nonzero(as_tuple=True)[1]
print(tok.decode(logits[0, mask_idx].argmax(-1)))

For downstream tasks use AutoModelForSequenceClassification / AutoModelForTokenClassification as with any ModernBERT checkpoint. Install flash-attn for the fastest path; the model falls back to SDPA otherwise. The checkpoint is stored in fp32; the MLM head is tied to the input embeddings.

Intended use and limitations

  • Intended as a base encoder for fine-tuning (classification, NER, span detection, cross-encoder scoring, embeddings after contrastive training) on Korean, Chinese, Japanese and English text.
  • Not a sentence-embedding model out of the box; it was trained with MLM only.
  • Continued pre-training used sequence length 512. The architecture supports 8,192 positions and the model runs at that length.
  • English fine-tuning accuracy is about 1 point below the base model.
  • Languages other than Korean, Chinese, Japanese and English were not part of continued pre-training; on a mixed 15-language XNLI input the model scores 79.7 against 82.1 for mmBERT-base. Use mmBERT-base for broad multilingual coverage.
  • Korean extractive QA is slightly below the base model because of the coarser Korean tokenization (see Evaluation).
  • Chinese web data is Simplified; Traditional Chinese was not specifically targeted.
  • The web corpora may contain biased or offensive content; apply your own filtering for sensitive applications.

License

  • Model weights and code: MIT, the same license as the base model jhu-clsp/mmBERT-base.
  • Tokenizer: derived from google/gemma-3-4b-pt. The tokenizer files are subject to the Gemma Terms of Use. mmBERT-base itself redistributes the Gemma 2 tokenizer under the same arrangement.

Acknowledgements

This model was trained on GPU resources provided through the 2026 High-Performance Computing Support Program of the National IT Industry Promotion Agency (NIPA), operated by the Korea Association for ICT Promotion (KAIT), on kt cloud AI Nexus (4ร— H200). (๋ณธ ๋ชจ๋ธ์€ ์ •๋ณดํ†ต์‹ ์‚ฐ์—…์ง„ํฅ์›(NIPA) ใ€Œ2026๋…„ ๊ณ ์„ฑ๋Šฅ์ปดํ“จํŒ… ์ง€์›์‚ฌ์—…ใ€์˜ ์ง€์›(์šด์˜๊ธฐ๊ด€ ํ•œ๊ตญ์ •๋ณดํ†ต์‹ ์ง„ํฅํ˜‘ํšŒ, kt cloud AI Nexus H200 4์žฅ)์„ ๋ฐ›์•„ ํ•™์Šต๋˜์—ˆ์Šต๋‹ˆ๋‹ค.)

Acknowledgements

This model was trained on GPU resources provided through the 2026 High-Performance Computing Support Program of the National IT Industry Promotion Agency (NIPA), operated by the Korea Association for ICT Promotion (KAIT), on kt cloud AI Nexus (4ร— H200). (๋ณธ ๋ชจ๋ธ์€ ์ •๋ณดํ†ต์‹ ์‚ฐ์—…์ง„ํฅ์›(NIPA) ใ€Œ2026๋…„ ๊ณ ์„ฑ๋Šฅ์ปดํ“จํŒ… ์ง€์›์‚ฌ์—…ใ€์˜ ์ง€์›(์šด์˜๊ธฐ๊ด€ ํ•œ๊ตญ์ •๋ณดํ†ต์‹ ์ง„ํฅํ˜‘ํšŒ, kt cloud AI Nexus H200 4์žฅ)์„ ๋ฐ›์•„ ํ•™์Šต๋˜์—ˆ์Šต๋‹ˆ๋‹ค.)

Citation

@misc{duckbert-base-2026,
  title  = {DuckBERT-base: a Korean/Chinese/Japanese/English encoder via tokenizer swap and continued pre-training of mmBERT},
  author = {Choi, Young and Warp Space Inc.},
  year   = {2026},
  url    = {https://huggingface.co/CaveduckAI/DuckBERT-base}
}

Please also cite the base model:

@misc{marone2025mmbert,
  title  = {mmBERT: A Modern Multilingual Encoder with Annealed Language Learning},
  author = {Marone, Marc and Weller, Orion and Fleshman, William and Yang, Eugene and Lawrie, Dawn and Van Durme, Benjamin},
  year   = {2025},
  url    = {https://arxiv.org/abs/2509.06888}
}

ํ•œ๊ตญ์–ด ์š”์•ฝ

DuckBERT-base๋Š” jhu-clsp/mmBERT-base์˜ Gemma 2 ํ† ํฌ๋‚˜์ด์ €๋ฅผ Gemma 3 ํ† ํฌ๋‚˜์ด์ €(262K vocab)๋กœ ๊ต์ฒดํ•˜๊ณ , ํ•œยท์ค‘ยท์ผยท์˜ 132B ํ† ํฐ์œผ๋กœ ์—ฐ์† ์‚ฌ์ „ํ•™์Šตํ•œ ์ธ์ฝ”๋”(312M)์ž…๋‹ˆ๋‹ค. ๋™์ผ ๋ฌธ์žฅ ๊ธฐ์ค€ ํ•œ๊ตญ์–ด ํ† ํฐ ์ˆ˜๊ฐ€ 27% ์ค„์—ˆ๊ณ (44โ†’32), ํ•œยท์ค‘ยท์ผ 14๊ฐœ ๋ฏธ์„ธ์กฐ์ • ๊ณผ์ œ ํ‰๊ท ์€ 81.6์—์„œ 82.3์œผ๋กœ ์˜ฌ๋ผ 14๊ฐœ ์ค‘ 12๊ฐœ ๊ณผ์ œ์—์„œ ์›๋ณธ์„ ๋„˜์—ˆ์Šต๋‹ˆ๋‹ค. KLUE-NER F1์€ 89.7์—์„œ 91.2๋กœ, KoBEST COPA๋Š” 72.9์—์„œ 76.7๋กœ ์˜ฌ๋ž์Šต๋‹ˆ๋‹ค. ์˜์–ด ๊ณผ์ œ๋Š” ์•ฝ 1์  ๋‚ฎ์Šต๋‹ˆ๋‹ค(์ž์„ธํ•œ ์ˆ˜์น˜๋Š” Evaluation). ๋ถ„๋ฅ˜ยท๊ฐœ์ฒด๋ช… ์ธ์‹ยท๊ตฌ๊ฐ„ ๊ฒ€์ถœยท๋ฆฌ๋žญํ‚น ๋“ฑ ํŒŒ์ธํŠœ๋‹์šฉ ๊ธฐ๋ฐ˜ ๋ชจ๋ธ๋กœ ์“ฐ๋„๋ก ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.