Views
No views yet
pip install "transformers>=4.48.0"pip install flash-attn --no-build-isolation1from transformers import AutoTokenizer, AutoModelForMaskedLM
2
3model_id = "llm-jp/llm-jp-modernbert-base"
4tokenizer = AutoTokenizer.from_pretrained(model_id)
5model = AutoModelForMaskedLM.from_pretrained(model_id)
6
7text = "日本の首都は<MASK|LLM-jp>です。"
8inputs = tokenizer(text, return_tensors="pt")
9outputs = model(**inputs)
10
11# To get predictions for the mask:
12masked_index = inputs["input_ids"][0].tolist().index(tokenizer.mask_token_id)
13predicted_token_id = outputs.logits[0, masked_index].argmax(axis=-1)
14predicted_token = tokenizer.decode(predicted_token_id)
15print("Predicted token:", predicted_token)
16# Predicted token: 東京| Model | stage 1 | stage 2 |
|---|---|---|
| max_seq_len | 1024 | 8192 |
| max_steps | 500,000 | 200,000 |
| Total batch size | 3328 | 384 |
| Peak LR | 5e-4 | 5e-5 |
| warmup step | 24,000 | |
| LR schedule | Linear decay | |
| Adam beta 1 | 0.9 | |
| Adam beta 2 | 0.98 | |
| Adam eps | 1e-6 | |
| MLM prob | 0.30 | |
| Gradient clipping | 1.0 | |
| weight decay | 1e-5 | |
| line_by_line | True |
| Model | JSTS (pearson) | JNLI (accuracy) | JCoLA (accuracy) | Avg |
|---|---|---|---|---|
| tohoku-nlp/bert-base-japanese-v3 | 0.920 | 0.912 | 0.880 | 0.904 |
| sbintuitions/modernbert-ja-130m | 0.916 | 0.927 | 0.868 | 0.904 |
| sbintuitions/modernbert-ja-310m | 0.932 | 0.933 | 0.883 | 0.916 |
| llm-jp/llm-jp-modernbert-base | 0.918 | 0.913 | 0.844 | 0.892 |
@misc{sugiura2025llmjpmodernbertmodernbertmodeltrained,
title={llm-jp-modernbert: A ModernBERT Model Trained on a Large-Scale Japanese Corpus with Long Context Length},
author={Issa Sugiura and Kouta Nakayama and Yusuke Oda},
year={2025},
eprint={2504.15544},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2504.15544},
}