/ Модель

Характеристики

Контекст
8 192 токена
Параметры
132 млн
Лицензия
MIT
Архитектура
modernbert · dense
Библиотека
transformers
Опубликована
6 фев 2025

modernbert-ja-130m

Заполнение пропусковТекст → текст4 профессии

Двуязычная японско-английская модель ModernBERT с контекстом 8 192 токена для заполнения пропусков и дообучения под задачи анализа текста.

51 850скачиваний за 30 дней51лайквеса обновлены1 мая 2025

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

ModernBERT-Ja-130M — двуязычная японско-английская модель SB Intuitions на архитектуре ModernBERT для предсказания замаскированных токенов и дообучения под задачи обработки естественного языка. Она содержит 132,1 млн параметров, использует 19 слоёв Transformer и поддерживает контекст до 8 192 токенов. В архитектуре сочетаются локальное и глобальное внимание, а позиционные представления используют RoPE. Токенизатор SentencePiece с моделью unigram и словарём на 102 400 элементов позволяет подавать исходный японский текст без предварительной токенизации.

Модель обучена на японских и английских текстовых корпусах; README указывает общий объём обучения около 4,39 трлн токенов и два этапа расширения контекста до 8 192 токенов. Её можно дообучать для классификации, языковых и семантических задач. Модель не предназначена для генерации текста; из-за несовпадения границ токенов с морфемами качество задач разметки токенов, например распознавания именованных сущностей и извлечения фрагментов, может быть низким. Лицензия — MIT.

Сценарии применения

  • предсказание замаскированных слов в японском тексте
  • дообучение для классификации японских текстов
  • оценка семантического сходства японских предложений
  • дообучение для распознавания логических отношений между предложениями
  • анализ японского текста с длинным контекстом

Ограничения

Не предназначена для генерации текста. Может показывать низкое качество в задачах разметки токенов, включая распознавание именованных сущностей и извлечение фрагментов, поскольку границы токенов не всегда совпадают с морфемами.

Для каких профессий подходит4

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

ModernBERT-Ja-130M

This repository provides Japanese ModernBERT trained by SB Intuitions.

ModernBERT is a new variant of the BERT model that combines local and global attention, allowing it to handle long sequences while maintaining high computational efficiency. It also incorporates modern architectural improvements, such as RoPE.

Our ModernBERT-Ja-130M is trained on a high-quality corpus of Japanese and English text comprising 4.39T tokens, featuring a vocabulary size of 102,400 and a sequence length of 8,192 tokens.

How to Use

You can use our models directly with the transformers library v4.48.0 or higher:

pip install -U "transformers>=4.48.0"

Additionally, if your GPUs support Flash Attention 2, we recommend using our models with Flash Attention 2.

pip install flash-attn --no-build-isolation

Example Usage

import torch
from transformers import AutoModelForMaskedLM, AutoTokenizer, pipeline

model = AutoModelForMaskedLM.from_pretrained("sbintuitions/modernbert-ja-130m", torch_dtype=torch.bfloat16)
tokenizer = AutoTokenizer.from_pretrained("sbintuitions/modernbert-ja-130m")
fill_mask = pipeline("fill-mask", model=model, tokenizer=tokenizer)

results = fill_mask("おはようございます、今日の天気は<mask>です。")

for result in results:
    print(result)
# {'score': 0.5078125, 'token': 16416, 'token_str': '晴れ', 'sequence': 'おはようございます、今日の天気は晴れです。'}
# {'score': 0.240234375, 'token': 28933, 'token_str': '曇り', 'sequence': 'おはようございます、今日の天気は曇りです。'}
# {'score': 0.078125, 'token': 92339, 'token_str': 'くもり', 'sequence': 'おはようございます、今日の天気はくもりです。'}
# {'score': 0.078125, 'token': 2988, 'token_str': '雨', 'sequence': 'おはようございます、今日の天気は雨です。'}
# {'score': 0.0223388671875, 'token': 52525, 'token_str': '快晴', 'sequence': 'おはようございます、今日の天気は快晴です。'}

Model Series

We provide ModernBERT-Ja in several model sizes. Below is a summary of each model.

ID#Param.#Param.w/o Emb.Dim.Inter. Dim.#Layers
sbintuitions/modernbert-ja-30m37M10M256102410
sbintuitions/modernbert-ja-70m70M31M384153613
sbintuitions/modernbert-ja-130m132M80M512204819
sbintuitions/modernbert-ja-310m315M236M768307225

For all models, the vocabulary size is 102,400, the head dimension is 64, and the activation function is GELU.
The configuration for global attention and sliding window attention consists of 1 layer + 2 layers (global–local–local).
The sliding window attention window context size is 128, with global_rope_theta set to 160,000 and local_rope_theta set to 10,000.

Model Description

We constructed the ModernBERT-Ja-130M model through a three-stage training process, which follows the original ModernBERT.

First, we performed pre-training using a large corpus. Next, we conducted two phases of context length extension.

  1. Pre-training
  • Training with 3.51T tokens, including Japanese and English data extracted from web corpora.
  • The sequence length is 1,024 with naive sequence packing.
  • Masking rate is 30% (with 80-10-10 rule).
  1. Context Extension (CE): Phase 1
  • Training with 430B tokens, comprising high-quality Japanese and English data.
  • The sequence length is 8,192 with best-fit packing.
  • Masking rate is 30% (with 80-10-10 rule).
  1. Context Extension (CE): Phase 2
  • Training with 450B tokens, comprising high-quality Japanese data.
    • The data consists of 150B tokens, and we trained it for 3 epochs.
    • This is because the overall performance of the Japanese language task improved with 3 epochs compared to just 1 epoch.
  • The sequence length is 8,192 without sequence packing.
  • Masking rate is 15% (with 80-10-10 rule).

The key differences from the original ModernBERT are:

  1. It is pre-trained on Japanese and English corpora, leading to a total of approximately 4.39T training tokens.
  2. We observed that decreasing the mask rate in Context Extension Phase 2 from 30% to 15% improved the model's performance.
  3. Our model boasts a large vocabulary size of 102,400, which is larger than most existing Japanese models. To align the number of parameters with existing models, we set the hidden size to 512 and the number of hidden layers to 19. Finally, the model has 52M parameters in the embedding layer, 80M parameters in the Transformer layers, and a total of 132M parameters.

Tokenization and Vocabulary

We use the tokenizer and vocabulary from sbintuitions/sarashina2-13b.
Specifically, we employ a SentencePiece tokenizer with a unigram language model and byte fallback.

We do not apply pre-tokenization using a Japanese tokenizer.
Therefore, users can directly input raw sentences into the tokenizer without any additional preprocessing.

Intended Uses and Limitations

You can use this model for masked language modeling, but it's mostly intended to be fine-tuned on a downstream task. Note that this model is not designed for text generation. When you want to generate a text, please use a text generation model such as Sarashina.

Since the unigram language model is used as a tokenizer, the token boundaries often do not align with the morpheme boundaries, resulting in poor performance in token classification tasks such as named entity recognition and span extraction.

Evaluation

We evaluated our model on 12 datasets, including JGLUE, across various tasks:

These tasks are short-sequence evaluation tasks, and we aligned our settings with those of existing models.
While the maximum sequence length varies across tasks, it does not exceed 512.
We set the sequence length and other experimental configurations per task, ensuring that the settings remain consistent across models.

For hyperparameters, we explored the following ranges:

  • Learning rate: {5e-6, 1e-5, 2e-5, 3e-5, 5e-5, 1e-4}
  • Number of epochs:
    • Tasks with a large number of instances: {1, 2}
    • Tasks with fewer instances: {3, 5, 10}

In the experiments, we loaded several Japanese models that are publicly available on HuggingFace using AutoModel and constructed classification models by appending a classification head consisting of a linear layer, a GELU activation function, and another linear layer. This was done because HuggingFace's AutoModelForSequenceClassification comes with different implementations for each model, and using them directly would result in classification heads that differ from one model to another.

For the embeddings fed into the classification layer, we used the embedding of the special token at the beginning of the sentence. That is, [CLS] in BERT and <s> in RoBERTa. Note that our model does not perform the next sentence prediction (NSP) task during pretraining, so <s> is added at the beginning of the sentence, not <cls>. Therefore, we used the <s> token for classification.

We conducted evaluations using 5-fold cross-validation. That is, we trained the model on the train set and evaluated it on the validation set. After determining the optimal hyperparameters (learning rate, epochs) based on the average performance on the validation sets, we report the average performance on the test sets with the hyperparameters.

For datasets without predefined splits, we first set aside 10% of the data as the test set and then performed 5-fold cross-validation on the remaining data. For datasets such as some tasks in JGLUE, where only train and validation sets are publicly available, we treated the validation set as the test set and performed 5-fold cross-validation on the remaining data.
For datasets with predefined train, validation, and test sets, we simply trained and evaluated the model five times with different random seeds and used the model with the best average evaluation score on the validation set to measure the final score on the test set.

Evaluation Results

Model#Param.#Param.w/o Emb.Avg.JComQA(Acc.)RCQA(Acc.)JCoLA(Acc.)JNLI(Acc.)JSICK(Acc.)JSNLI(Acc.)KU RTE(Acc.)JSTS(Spearman's ρ)Livedoor(Acc.)Toxicity(Acc.)MARC-ja(Acc.)WRIME(Acc.)
ModernBERT-Ja-30M37M10M85.6780.9582.3578.8588.6984.3991.7961.1385.9497.2089.3395.8791.61
ModernBERT-Ja-70M70M31M86.7785.6583.5180.2690.3385.0192.7360.0887.5996.3491.0196.1392.59
ModernBERT-Ja-130M(this model)132M80M88.9591.0185.2884.1892.0386.6194.0165.5689.2097.4291.5796.4893.99
ModernBERT-Ja-310M315M236M89.8393.5386.1884.8192.9386.8794.4868.7990.5396.9991.2496.3995.23
LINE DistillBERT68M43M85.3276.3982.1781.0487.4983.6691.4260.2484.5797.2691.4695.9192.16
Tohoku BERT-base v3111M86M86.7482.8283.6581.5089.6884.9692.3260.5687.3196.9193.1596.1391.91
LUKE-japanese-base-lite133M107M87.1582.9583.5382.3990.3685.2692.7860.8986.6897.1293.4896.3094.05
Kyoto DeBERTa-v3160M86M88.3187.4484.9084.3591.9186.2293.4163.3188.5197.1092.5896.3293.64
KoichiYasuoka/modernbert-base-japanese-wikipedia160M110M82.4162.5981.1976.8084.1182.0190.5160.4881.7497.1090.3494.8587.25
llm-jp/llm-jp-modernbert-base187M110M86.7584.2983.9978.0090.2883.7693.4060.3287.7196.6492.1396.3394.09
Tohoku BERT-large char v2311M303M87.2385.0884.2081.7990.5585.2592.6361.2987.6496.5593.2696.2592.29
Tohoku BERT-large v2337M303M88.3686.9384.8182.8992.0585.3393.3264.6089.1197.6494.3896.4692.77
Waseda RoBERTa-large (Seq. 512)337M303M88.3788.8184.5082.3491.3785.4993.9761.5388.9596.9995.0696.3895.09
Waseda RoBERTa-large (Seq. 128)337M303M88.3689.3583.6384.2691.5385.3094.0562.8288.6795.8293.6096.0595.23
LUKE-japanese-large-lite414M379M88.9488.0184.8484.3492.3786.1494.3264.6889.3097.5393.7196.4995.59
RetrievaBERT1.30B1.15B86.7980.5584.3580.6789.8685.2493.4660.4887.3097.0492.7096.1893.61
hotchpotch/mMiniLMv2-L6-H384107M11M81.5360.3482.8378.6186.2477.9487.3260.4880.4895.5586.4094.9787.20
hotchpotch/mMiniLMv2-L12-H384118M21M82.5962.7083.7778.6187.6979.5887.6560.4881.5595.8890.0094.8988.28
mBERT178M86M83.4866.0882.7677.3288.1584.2091.2560.5684.1897.0189.2195.0585.99
XLM-RoBERTa-base278M86M84.3669.4482.8678.7188.1483.1791.2760.4883.3495.9391.9195.8291.20
XLM-RoBERTa-large560M303M86.9580.0784.4780.4292.1684.7493.8760.4888.0397.0193.3796.0392.72

The evaluation results are shown in the table. #Param. represents the number of parameters in both the input embedding layer and the Transformer layers, while #Param. w/o Emb. indicates the number of parameters in the Transformer layers only.

Our ModernBERT-Ja-130M, a base-sized model, outperformed Tohoku BERT-large and achieved performance comparable to LUKE-japanese-large-lite. Specifically, it demonstrated impressive results in knowledge-based tasks such as JCommonsenseQA and RCQA.

Despite being a long-context model capable of processing sequences of up to 8,192 tokens, our ModernBERT-Ja-130M also exhibited strong performance in short-sequence evaluations.

Ethical Considerations

ModernBERT-Ja-130M may produce representations that reflect biases.
When you use this model for masked language modeling, it may generate biases or harmful expressions.

License

MIT License

Citation

@misc{
    modernbert-ja,
	author = {Tsukagoshi, Hayato and Li, Shengzhe and Fukuchi, Akihiko and Shibata, Tomohide},
	title = {{ModernBERT-Ja}},
	howpublished = {\url{https://huggingface.co/collections/sbintuitions/modernbert-ja-67b68fe891132877cf67aa0a}},
    url = {https://huggingface.co/collections/sbintuitions/modernbert-ja-67b68fe891132877cf67aa0a},
	year = {2025},
}

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers · fill-mask

Можно запустить

Подбираем GPU…

Класс архитектуры
ModernBertForMaskedLM
Ревизия весов
28c180b

0 моделей