Japanese Pretraining Data Quality Score Regressor
This model predicts the continuous filter_result.fs quality score, from 0 to
10, for Japanese web documents intended for language-model pretraining. It is
a regression model, not the earlier KH/K/KL/D/R/X decision classifier.
Model
- Base:
sbintuitions/modernbert-ja-130m - Architecture:
ModernBertForSequenceClassification, one regression output - Context length used for training: 2,048 tokens
- Output: normalized internally, then multiplied by 10 and clamped to
[0, 10] - Training precision: BF16
Data
Source data:
/mnt/data/commoncrawl_ja_2025_present/data/filtered_random_10k
The source contained 198,874 LLM-filtered Common Crawl Japanese records in 20 JSONL shards. Records without valid text or score were removed, then exact normalized-text duplicates were removed.
| Split | Documents |
|---|---|
| Valid unique | 197,762 |
| Train | 177,985 |
| Test | 19,777 |
| Exact duplicates removed | 1,112 |
The split is deterministic with seed 20260610, uses a 90/10 ratio, and is
stratified by the integer floor of the score. Each input contains URL, script
statistics, and a deterministic document excerpt of up to 12,000 characters.
Input format
[URL]
https://example.jp/article
[SCRIPT_STATS]
{"ja":0.95,"latin":0.05}
[TEXT]
Japanese document text...
The training target is filter_result.fs / 10. Model predictions must be
multiplied by config.score_scale (10.0) and clamped to [0, 10].
Hyperparameter tuning
All sweep runs used 60,000 train and 5,000 test examples, one epoch, eight NVIDIA H100 80GB GPUs, global batch size 128, and a regression head initialized at the train-label mean.
| Loss | Learning rate | MAE | RMSE | R2 |
|---|---|---|---|---|
| Huber | 1e-5 | 0.4045 | 0.5402 | 0.6700 |
| Huber | 2e-5 | 0.3621 | 0.4863 | 0.7327 |
| MSE | 1e-5 | 0.3968 | 0.5271 | 0.6859 |
Final training
- Loss: Huber, delta 0.1 on normalized labels
- Learning rate: 2e-5
- Scheduler: cosine
- Epochs: 2
- Weight decay: 0.01
- Warmup ratio: 0.06
- Per-device batch size: 16
- Global batch size: 128
- GPUs: 8 x NVIDIA H100 80GB
- Throughput: 559.3 samples/s
- Runtime: 636.4 seconds
Test results
| Metric | Result |
|---|---|
| MAE | 0.3069 |
| RMSE | 0.4161 |
| R2 | 0.7988 |
| Pearson | 0.8938 |
| Spearman | 0.8730 |
| Error <= 0.5 | 81.91% |
| Error <= 1.0 | 97.80% |
Inference
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_id = "minhhien0811/ja-filter-score-regressor-modernbert-ja-130m"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
document = """[URL]
https://example.jp/article
[SCRIPT_STATS]
{}
[TEXT]
日本語の文書本文"""
inputs = tokenizer(document, return_tensors="pt", truncation=True, max_length=2048)
with torch.inference_mode():
normalized = model(**inputs).logits.squeeze().item()
score = max(0.0, min(10.0, normalized * model.config.score_scale))
print(score)
The included predict.py also accepts a raw text file or a JSON document with
url, script_stats, and text fields.
Limitations
- Labels are generated quality judgments, not human gold annotations.
- The score distribution is concentrated around 4 to 6; extreme scores have substantially fewer training examples.
- The score alone does not reproduce hard reject rules based on language, safety, copyright, or duplication. Those fields require separate models or deterministic checks.
- This model is intended to rank or weight Japanese pretraining documents. It should not be used as a general safety classifier.
Reproduction
The repository includes:
prepare_score_dataset.py: deduplication, formatting, stratified splittokenize_dataset.py: offline tokenization and Arrow dataset creationtrain_score_regressor.py: regression training and metricsrun_sweep_8gpu.sh: three-run hyperparameter sweeprun_final_8gpu.sh: final eight-GPU trainingpredict.py: single-document inference