7
stars
43
commits
6
repos using this model
5
linked in READMEs
Sep 6, 2026
updated
Hayai is a lightweight (~150M parameter) vision-to-text OCR model designed for fast, crop-level transcription across Japanese, Chinese, Korean, and English.
By pairing Google’s SigLIP2 NaFlex vision encoder with a 12-layer custom causal transformer decoder, Hayai reads dense, stylized, horizontal, and vertical text directly from images in a single forward pass without requiring a separate text detection stage (e.g., DBNet/YOLO). (Doesn't work for full pages though. Only crops)
In prior versions, compact OCR models struggled with visually ambiguous CJK radicals and homoglyphs (e.g., confusing 銀 vs. 高 or 校 vs. 枚) because a pure image-trained decoder lacked statistical language priors.
Hayai v2.1 introduces Joint Multi-Task Training:
google/siglip2-base-patch16-naflex (~86M params)
d_model = 512, d_ffn = 2048).import torch
from PIL import Image
from transformers import AutoModel, AutoProcessor, PreTrainedTokenizerFast
# Load Model, Processor & Tokenizer
MODEL_ID = "JustANormalTinkerer/hayai-ocr-v2"
model = AutoModel.from_pretrained(MODEL_ID, trust_remote_code=True).cuda().eval()
tokenizer = PreTrainedTokenizerFast.from_pretrained(MODEL_ID)
processor = AutoProcessor.from_pretrained("google/siglip2-base-patch16-naflex")
# Load and Preprocess Image
image = Image.open("example.png").convert("RGB")
# Use max_num_patches=256 for standard lines; 384 or 512 for dense/complex panels
inputs = processor(images=[image], max_num_patches=256, return_tensors="pt").to("cuda")
with torch.no_grad():
texts = model.generate(
pixel_values=inputs["pixel_values"],
pixel_attention_mask=inputs["pixel_attention_mask"],
spatial_shapes=inputs["spatial_shapes"],
tokenizer=tokenizer,
max_new_tokens=128,
repetition_penalty=1.0, # Keep at 1.0 (disabled) for OCR accuracy
)
print(texts[0])
Note:
trust_remote_code=Trueis required because the model utilizes custom block-causal attention and 2D mRoPE definitions (configuration_hayai.py,modeling_hayai.py). Also the previous version of the model card recommended setting num_beams to 4, ignore that. Greedy search will give the best results for Japanese, HOWEVER, tweak it as needed.
There also exists this python library that is recommended for python apps: hayai-ocr
| Model | CER ↓ | Exact Match ↑ | Text-only CER ↓ | Text-only Exact Match ↑ |
|---|---|---|---|---|
| MangaOCR | 4.683% | 73.524% | 2.700% | 82.867% |
| HayaiOCR | 6.738% | 71.272% | 4.967% | 80.949% |
| HayaiOCR-v2 | 4.534% | 73.645% | 2.872% | 82.227% |
| HayaiOCR-v2.1 | 3.225% | 79.671% | 1.896% | 87.461% |
| BaberuOCR | 4.589% | 72.246% | 2.603% | 81.649% |
| PaddleOCR-VL-0.9B-For-Manga | 2.910% | 78.911% | 1.866% | 84.662% |
| Model Name | Mean CER ↓ | Throughput on L4 GPU (FPS) ↑ |
|---|---|---|
| Hayai OCR v2 | 8.52% | 37.25 |
| PaddleOCR-VL-For-Manga | 24.66% | 3.60 |
| Model Name | Mean CER ↓ | Throughput on L4 GPU (FPS) ↑ |
|---|---|---|
| Hayai OCR v2 | 10.56% | 31.95 |
| Hayai OCR v2.1 | 12.94% | 54.22* |
| PaddleOCR-VL-For-Manga | 38.69% | 2.22 |
*Throughput gain in v2.1 is due to optimized decoding batching.
Hayai OCR matches or outperforms 0.9B parameter models while delivering 10× higher throughput and operating within a ~300MB VRAM footprint in FP16.
Training was conducted in two coordinated phases (for v2.1, for v2 refer to the older model card) using Kaggle 2× NVIDIA T4 GPUs.
JustANormalTinkerer/hayai-dataset-merged (~1M images) streamed and sharded across GPUs.L_total = L_ocr + 0.30 * L_text
8e-5 (Muon / Decoder AdamW) and 1e-5 (Vision AdamW), decayed via cosine schedule with a 5% linear warmup.For consistent Character Error Rate (CER) reproduction and downstream evaluation, text should be normalized as follows:
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)
# Remove space only between CJK characters
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()
repetition_penalty = 1.0. Penalties > 1.0 force the model to avoid valid repeated characters (e.g., 2校 ... 1校 or 学校).# current Manga109
@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 × AI Workshop at ICML 2026},
year = {2026},
}
# introducing Manga109 annotations
@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},
doi={10.1109/mmul.2020.2987895},
year={2020}
}
# introducing Manga109 image collection
@article{mtap_matsui_2017,
author={Yusuke Matsui and Kota Ito and Yuji Aramaki and Azuma Fujimoto and Toru Ogawa and Toshihiko Yamasaki and Kiyoharu Aizawa},
title={Sketch-based Manga Retrieval using Manga109 Dataset},
journal={Multimedia Tools and Applications},
volume={76},
number={20},
pages={21811--21838},
doi={10.1007/s11042-016-4020-z},
year={2017}
}
@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}
}
43 commits
7
stars
43
commits
6
repos using this model
5
linked in READMEs
Sep 6, 2026
updated
Hayai is a lightweight (~150M parameter) vision-to-text OCR model designed for fast, crop-level transcription across Japanese, Chinese, Korean, and English.
By pairing Google’s SigLIP2 NaFlex vision encoder with a 12-layer custom causal transformer decoder, Hayai reads dense, stylized, horizontal, and vertical text directly from images in a single forward pass without requiring a separate text detection stage (e.g., DBNet/YOLO). (Doesn't work for full pages though. Only crops)
In prior versions, compact OCR models struggled with visually ambiguous CJK radicals and homoglyphs (e.g., confusing 銀 vs. 高 or 校 vs. 枚) because a pure image-trained decoder lacked statistical language priors.
Hayai v2.1 introduces Joint Multi-Task Training:
google/siglip2-base-patch16-naflex (~86M params)
d_model = 512, d_ffn = 2048).import torch
from PIL import Image
from transformers import AutoModel, AutoProcessor, PreTrainedTokenizerFast
# Load Model, Processor & Tokenizer
MODEL_ID = "JustANormalTinkerer/hayai-ocr-v2"
model = AutoModel.from_pretrained(MODEL_ID, trust_remote_code=True).cuda().eval()
tokenizer = PreTrainedTokenizerFast.from_pretrained(MODEL_ID)
processor = AutoProcessor.from_pretrained("google/siglip2-base-patch16-naflex")
# Load and Preprocess Image
image = Image.open("example.png").convert("RGB")
# Use max_num_patches=256 for standard lines; 384 or 512 for dense/complex panels
inputs = processor(images=[image], max_num_patches=256, return_tensors="pt").to("cuda")
with torch.no_grad():
texts = model.generate(
pixel_values=inputs["pixel_values"],
pixel_attention_mask=inputs["pixel_attention_mask"],
spatial_shapes=inputs["spatial_shapes"],
tokenizer=tokenizer,
max_new_tokens=128,
repetition_penalty=1.0, # Keep at 1.0 (disabled) for OCR accuracy
)
print(texts[0])
Note:
trust_remote_code=Trueis required because the model utilizes custom block-causal attention and 2D mRoPE definitions (configuration_hayai.py,modeling_hayai.py). Also the previous version of the model card recommended setting num_beams to 4, ignore that. Greedy search will give the best results for Japanese, HOWEVER, tweak it as needed.
There also exists this python library that is recommended for python apps: hayai-ocr
| Model | CER ↓ | Exact Match ↑ | Text-only CER ↓ | Text-only Exact Match ↑ |
|---|---|---|---|---|
| MangaOCR | 4.683% | 73.524% | 2.700% | 82.867% |
| HayaiOCR | 6.738% | 71.272% | 4.967% | 80.949% |
| HayaiOCR-v2 | 4.534% | 73.645% | 2.872% | 82.227% |
| HayaiOCR-v2.1 | 3.225% | 79.671% | 1.896% | 87.461% |
| BaberuOCR | 4.589% | 72.246% | 2.603% | 81.649% |
| PaddleOCR-VL-0.9B-For-Manga | 2.910% | 78.911% | 1.866% | 84.662% |
| Model Name | Mean CER ↓ | Throughput on L4 GPU (FPS) ↑ |
|---|---|---|
| Hayai OCR v2 | 8.52% | 37.25 |
| PaddleOCR-VL-For-Manga | 24.66% | 3.60 |
| Model Name | Mean CER ↓ | Throughput on L4 GPU (FPS) ↑ |
|---|---|---|
| Hayai OCR v2 | 10.56% | 31.95 |
| Hayai OCR v2.1 | 12.94% | 54.22* |
| PaddleOCR-VL-For-Manga | 38.69% | 2.22 |
*Throughput gain in v2.1 is due to optimized decoding batching.
Hayai OCR matches or outperforms 0.9B parameter models while delivering 10× higher throughput and operating within a ~300MB VRAM footprint in FP16.
Training was conducted in two coordinated phases (for v2.1, for v2 refer to the older model card) using Kaggle 2× NVIDIA T4 GPUs.
JustANormalTinkerer/hayai-dataset-merged (~1M images) streamed and sharded across GPUs.L_total = L_ocr + 0.30 * L_text
8e-5 (Muon / Decoder AdamW) and 1e-5 (Vision AdamW), decayed via cosine schedule with a 5% linear warmup.For consistent Character Error Rate (CER) reproduction and downstream evaluation, text should be normalized as follows:
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)
# Remove space only between CJK characters
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()
repetition_penalty = 1.0. Penalties > 1.0 force the model to avoid valid repeated characters (e.g., 2校 ... 1校 or 学校).# current Manga109
@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 × AI Workshop at ICML 2026},
year = {2026},
}
# introducing Manga109 annotations
@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},
doi={10.1109/mmul.2020.2987895},
year={2020}
}
# introducing Manga109 image collection
@article{mtap_matsui_2017,
author={Yusuke Matsui and Kota Ito and Yuji Aramaki and Azuma Fujimoto and Toru Ogawa and Toshihiko Yamasaki and Kiyoharu Aizawa},
title={Sketch-based Manga Retrieval using Manga109 Dataset},
journal={Multimedia Tools and Applications},
volume={76},
number={20},
pages={21811--21838},
doi={10.1007/s11042-016-4020-z},
year={2017}
}
@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}
}
43 commits