Hayai OCR v2.7 Supernova
Hayai OCR v2.7 Supernova is a ~157M-parameter crop-level OCR model for Japanese, Chinese, Korean, and English text. It pairs a SigLIP2 NaFlex vision encoder with a 12-layer causal GQA decoder to transcribe dense, stylized, vertical, horizontal, and curved text in a single pass without a separate line detector.
This checkpoint updates v2.7 with an additional 8,000-step fine-tuning run on the edgecases split of JustANormalTinkerer/hayai-synth-multilingual, merged back into the Stage 3 base weights using WiSE-FT (weight-space ensembling). Merging instead of replacing the weights improves long-text and dense-crop recognition while preserving accuracy on standard dialogue and sound effects.
Key Results
- JMangaBench_Read v1.3.3: 98.84 composite (99.21 1-NED, 95.70% EM, 0.81% CER) with
max_patches="auto" at 92.01 images/s wall throughput. Fixed p256 reaches 98.82 composite (95.78% EM, 0.88% CER) at 99.06 images/s, and even p128 reaches 98.61 composite at 148.78 images/s.
- JMangaBench_Hard v1.0: 96.36 score (3.98% CER, 89.19% EM) with
max_patches="auto" at 112.07 images/s, and 96.36 score at fixed p256. All evaluated patch tiers (p128, p256, p384, auto) exceed the previous #1 ranked leaderboard entry (95.98).
- Long-text gains from WiSE-FT: On
len_>32 crops in JMangaBench_Read, auto achieves 98.28 1-NED, 83.43% EM, and 3.53% CER; p256 reaches 81.66% EM (4.67% CER); and p512 reaches 84.62% EM (3.56% CER).
- Single-pass adaptive routing (
max_patches="auto"): Assigns each crop to a patch tier in {128, 192, 256, 384} directly from NaFlex scaling geometry (max_scale=4.0), sorting and batching by patch count with no second-pass re-runs.
Scope: Hayai is built for cropped text regions (speech bubbles, narration boxes, SFX crops). For full pages, run a text or bubble detector first.
Benchmarks
All JMangaBench results below were evaluated with RIN v1.2 (manga_nar_semantic_r10_20261020) with zero missing predictions. Higher is better for Composite, 1-NED, Score, EM, and EM NFKC; lower is better for CER.
1. JMangaBench_Read v1.3.3 (Dialogue, Narration, and Asides)
Evaluated on 7,789 crops from 1,847 pages (JMangaBench_Read):
JMangaBench_Read v1.3.3 subset breakdown — auto (n = 7,789)
JMangaBench_Read v1.3.3 subset breakdown — p256 (n = 7,789)
JMangaBench_Read v1.3.3 subset breakdown — p384 (n = 7,789)
JMangaBench_Read v1.3.3 subset breakdown — p512 (n = 7,789)
JMangaBench_Read v1.3.3 subset breakdown — p128 (n = 7,789)
2. JMangaBench_Hard v1.0 (SFX, Stylized Lettering, and Handwriting)
Evaluated on 3,015 difficult crops from 1,339 pages (JMangaBench_Hard):
JMangaBench_Hard v1.0 subset breakdown — auto (n = 3,015)
JMangaBench_Hard v1.0 subset breakdown — p256 (n = 3,015)
JMangaBench_Hard v1.0 subset breakdown — p384 (n = 3,015)
JMangaBench_Hard v1.0 subset breakdown — p128 (n = 3,015)
3. Throughput
Measured on a single Tesla T4 in fp16 with CUDA Graphs enabled (auto runs single-pass without escalation). Average transcription length is 11.9 characters/image on JMangaBench_Read (7,789 crops) and 4.1 characters/image on JMangaBench_Hard (3,015 crops).
Quickstart
from PIL import Image
from transformers import AutoModel, AutoProcessor
MODEL_ID = "JustANormalTinkerer/hayai-ocr-v2.7-supernova"
model = AutoModel.from_pretrained(MODEL_ID, trust_remote_code=True).cuda().eval()
processor = AutoProcessor.from_pretrained(MODEL_ID, trust_remote_code=True)
# Single crop (Japanese, Chinese, Korean, or English) -> str
image = Image.open("example.png").convert("RGB")
text = model.ocr(
image,
processor,
max_patches="auto",
max_new_tokens=128,
use_cuda_graph=True,
)
print(text)
# Batched crops -> automatically bucketed and sorted by patch count
texts = model.ocr(
[image] * 128,
processor,
max_patches="auto",
batch_size=64,
escalate=False,
max_new_tokens=128,
)
trust_remote_code=True is required for the custom projector, depth fusion, split block-causal attention, 2D mRoPE, and NaFlex patch routing.
model.generate(...) is also supported for custom pipelines. Keep greedy decoding and repetition_penalty=1.0.
- Choosing
max_patches: "auto" is the best general default, giving the lowest overall CER and strong long-text accuracy. Fixed 256 is nearly identical on standard dialogue while running slightly faster; fixed 128 maximizes speed and keeps memory minimal when crops are short; fixed 384 or 512 is useful if your workload is dominated by dense, multi-line text blocks.
- Set
HAYAI_DISABLE_COMPILE=1 if you want to disable torch.compile(dynamic=True) on custom kernels (inference already runs eagerly inside inference_mode).
- Additional utilities are available at hayai-ocr on GitHub.
Optional: Lightweight NFKC post-processing snippet
Official JMangaBench scoring uses RIN v1.2. For simple local cleanup:
import re
import unicodedata
def normalize_text(text: str) -> str:
if not text:
return ""
text = unicodedata.normalize("NFKC", str(text))
text = re.sub(r"[\r\n\t]+", " ", text)
cjk_char = r"[\u4e00-\u9fff\u3040-\u30ff\u3400-\u4dbf\uac00-\ud7af]"
text = re.sub(f"({cjk_char})\\s+({cjk_char})", r"\1\2", text)
return re.sub(r"\s+", " ", text).strip()
Architecture
v2.7 Supernova combines a SigLIP2 NaFlex vision encoder (d_vision=768, 12 layers) with a 12-layer GQA decoder (d_model=512, d_ffn=2048, 8 query heads, 2 KV heads, d_head=64, SwiGLU, QK RMSNorm).
A few design choices carry most of the accuracy and speed improvements over v2.5:
- Dual-order
VisualCausalFlow: Inside DSCProjector, a zero-initialized 3x3 depthwise spatial mixer captures local stroke continuity, followed by an 8-head gated attention block over the compressed 2D grid. Four heads run row-major left-to-right (for English, Chinese, Korean, and horizontal Japanese) and four run column-major right-to-left, top-to-bottom (for vertical manga layouts).
- Multi-depth feature fusion (
StaticDepthFusion): Instead of using only the final SigLIP2 layer, all 12 encoder depths are 2x2 average-pooled to match the unshuffle grid, normalized with per-depth RMSNorm, projected to d_model, and combined with learned per-decoder-layer softmax weights and per-channel gains. Earlier layers retain sharp stroke details (helpful for dense kanji/hanzi, dakuten/handakuten, and tight kerning), while deeper layers carry broader context.
- IDS supervision and offset 2D mRoPE: A 226-class Ideographic Description Sequence auxiliary head at decoder layer 6 sharpens character structure during training (
drop_ids_head() removes it for pure inference). Text rotary indices are offset by text_rope_offset=64.0 to separate them from 2D visual coordinates, paired with antialiased bilinear interpolation of SigLIP2 position embeddings.
- Fused inference engine (
_FastEngine): During prefill, the final decoder layer prunes vision queries so only text tokens run attention and FFN. Attention is split into vision-to-vision and causal text paths with KV-head-folded GQA, fused QKV/SwiGLU projections, fused QK-norm + RoPE, and pre-folded residual scales. plan_batches buckets crops by patch tier and sorts by (m_vis, nh * nw), packing ragged batches whenever padding exceeds 5% and running decode steps inside CUDA Graphs.
Version Comparison
Training
Training started from the v2.5 checkpoint, with all newly added v2.7 modules (StaticDepthFusion, VisualCausalFlow, and the 3x3 depthwise mixer) zero-initialized as residual branches so optimization began cleanly from v2.5 weights.
The base stages ran on Kaggle using 2x NVIDIA Tesla T4 GPUs (micro-batch size 64 per GPU with gradient accumulation to an effective batch size of 128):
- Stage 1 — Japanese and Manga Corpus (2 epochs):
JustANormalTinkerer/animetext-ocr-jp-only-v2 + JustANormalTinkerer/hayai-synth-dataset-v2
- Stage 2 — Multilingual CJK + English Expansion (1 epoch): Stage 1 datasets +
JustANormalTinkerer/hayai-synth-multilingual
- Stage 3 — Multilingual Refinement (2 epochs):
JustANormalTinkerer/animetext-ocr-jp-only-v2 + JustANormalTinkerer/hayai-synth-multilingual
- Stage 4 — Long-Text Edgecase Fine-Tuning and WiSE-FT Merge: To strengthen transcription on long passages and dense multi-line crops without regressing on standard manga dialogue or SFX, the Stage 3 checkpoint was fine-tuned for 8,000 steps on the
edgecases split of JustANormalTinkerer/hayai-synth-multilingual and then combined back with the Stage 3 weights via WiSE-FT.
Best Practices and Limitations
- Keep
repetition_penalty=1.0: Repeated characters are common and valid in CJK text (such as onomatopoeia like ドキドキ, reduplication, and repeated numbers). Any penalty above 1.0 hurts accuracy.
- Use
max_patches="auto" for mixed workloads: It matches each crop to the right patch budget in a single pass. If you need strictly uniform tensor shapes or want slightly higher speed on mostly short dialogue crops, max_patches=256 is a strong alternative.
- Crop-level input only: Passing full comic pages without cropping text regions will not work.
- Short-text sensitivity: Many manga crops contain only 1 to 4 characters, where a single misread glyph drops Exact Match immediately.
- Multilingual domain gap: Chinese, Korean, and English recognition is trained primarily on synthetic data, so accuracy on noisy real-world non-Japanese crops may vary.
Citations
@inproceedings{baek2026mangav26,
title = {{Manga109-v2026: Revisiting Manga109 Annotations for Modern Manga Understanding}},
author = {Baek, Jeonghun and Miyai, Atsuyuki and Onohara, Shota and Ikuta, Hikaru and Aizawa, Kiyoharu},
booktitle = {Culture x AI Workshop at ICML 2026},
year = {2026},
}
@article{multimedia_aizawa_2020,
author = {Kiyoharu Aizawa and Azuma Fujimoto and Atsushi Otsubo and Toru Ogawa and Yusuke Matsui and Koki Tsubota and Hikaru Ikuta},
title = {Building a Manga Dataset "Manga109" with Annotations for Multimedia Applications},
journal = {IEEE MultiMedia},
volume = {27},
number = {2},
pages = {8--18},
year = {2020}
}
@inproceedings{baek2022COO,
title = {COO: Comic Onomatopoeia Dataset for Recognizing Arbitrary or Truncated Texts},
author = {Baek, Jeonghun and Matsui, Yusuke and Aizawa, Kiyoharu},
booktitle = {Proceedings of the European Conference on Computer Vision (ECCV)},
year = {2022}
}