OpenYumi-130M (saivansoft/openyumi-130m)

Live Demo on Hugging Face Spaces License: Apache 2.0

OpenYumi-130M (saivansoft/openyumi-130m) is a standalone 130M-parameter Japanese contextual kanji reading prediction (Grapheme-to-Phoneme / G2P), furigana annotation, and kana/romaji conversion toolkit published by Saivansoft.

Given raw Japanese text mixing kanji, kana, numerals, and symbols, OpenYumi-130M resolves intra-sentence context-dependent heteronyms (such as 人気: hitoke vs. ninki, 辛い: tsurai vs. karai, 生物: seibutsu vs. namamono, 空く: suku vs. aku, 市場: ichiba vs. shijō, 下手: heta vs. shitate, 大人気 daininki vs. 大人気ない otonagenai), dual-reading proper nouns (日本橋: Tokyo Nihonbashi vs. Osaka Nipponbashi), sequential voicing (rendaku), numeral-counter euphony (一日 tsuitachi vs. 一日中 ichinichijū, 24時間 nijūyojikan, 10回 jukkai), and special compound readings (jukujikun) while preserving every source character (0.0% character loss).

The repository bundles both a zero-PyTorch openyumi Python SDK (featuring WanaKana-compatible synchronous kana/romaji utilities, a 1-line Kuroshiro drop-in adapter, boundary-safe custom dictionary overrides, precision selection across INT8/FP32 ONNX weights, and a local HTTP JSON server) and OpenYumiEngine for ONNX Runtime or PyTorch (Safetensors) inference.

Try it directly in your browser on Hugging Face Spaces (saivansoft/openyumi-130m).

Intended Uses

  • Contextual Furigana & Reading Assistance: Automatically annotate Japanese articles, e-books, subtitles, educational materials, and web applications in HTML <ruby> (with automatic XSS escaping), parenthetical 漢字(かな), or Aozora Bunko |漢字《かな》 notation while preserving exact source characters and okurigana stems.
  • Text-to-Speech (TTS) & Speech Synthesis Front-End (G2P): Convert unsegmented Japanese text into dual-track Span ASTs containing both orthographic Hiragana (おうさま, おう) and phonological Katakana (オーサマ, オウ), including particle pronunciations (は → ワ, へ → エ, におかれましては → …ワ), rendaku, and numeral-counter sandhi.
  • Search Indexing, Romanization & Legacy Migration: Normalize mixed Japanese text into Hiragana, Katakana, or multi-system Romaji (hepburn, macron, passport, nippon, kunrei), apply sub-morpheme boundary-safe user_dict overrides for domain terms without corrupting longer compounds, or migrate existing Kuroshiro pipelines in one line.

Basic Usage

1. Installation

For fast zero-PyTorch CPU/GPU inference via ONNX Runtime and SudachiPy:

pip install numpy sudachipy sudachidict_full onnxruntime tokenizers huggingface_hub

You can also install the bundled openyumi package and yumi CLI directly from a local checkout:

git clone https://huggingface.co/saivansoft/openyumi-130m
cd openyumi-130m
pip install -e ".[full]"

(Optional) For the PyTorch backend (model.safetensors):

pip install torch transformers safetensors

2. Python SDK (openyumi)

import openyumi as yumi

# 1) Instant synchronous kana / romaji utilities (0 MB model load)
print(yumi.to_kana("TOFUGUnosushi"))  # トフグのすし
print(yumi.to_romaji("おうさま", system="macron", track="phonological"))  # ōsama
print(yumi.strip_okurigana("申し込む"))  # 申し込

# 2) One-line contextual furigana (precision="auto" | "int8" | "fp32")
html = yumi.convert(
    "人気のない通りにある店で、一番人気のラーメンを食べた。",
    mode="furigana",
    to="hiragana",
    model="saivansoft/openyumi-130m",
    precision="auto",
)
print(html)
# <ruby>人気<rt>ひとけ</rt></ruby>のない<ruby>通<rt>とお</rt></ruby>りにある<ruby>店<rt>みせ</rt></ruby>で、<ruby>一番<rt>いちばん</rt></ruby><ruby>人気<rt>にんき</rt></ruby>のラーメンを<ruby>食<rt>た</rt></ruby>べた。

# 3) Dual-reading place names, idioms & batched conversion
batch = yumi.convert_batch(
    [
        "出張で東京の日本橋を訪れ、週末は大阪の日本橋で遊んだ。",
        "大人気の俳優が、ネットで大人気ない発言をして炎上した。",
    ],
    mode="okurigana",
    model="saivansoft/openyumi-130m",
)
for line in batch:
    print(line)

# 4) Boundary-safe custom dictionary (`user_dict`) & dual-track Span AST
# Sub-morpheme boundary checking prevents "人気=ヒトケ" from corrupting "大人気" (だいにんき)
spans = yumi.parse(
    "大人気の俳優が私市駅の月極駐車場を訪れた。",
    model="saivansoft/openyumi-130m",
    user_dict={"人気": "ヒトケ", "私市": "キサイチ", "月極": "ツキギメ"},
)
for m in spans:
    print(m.surface, "->", m.reading_hira, "|", m.pron_kata, "|", m.romaji)

# 5) 1-line Kuroshiro drop-in compatibility
from openyumi import Kuroshiro

kuro = Kuroshiro(model="saivansoft/openyumi-130m")
kuro.init()
print(kuro.convert("交渉が下手な彼は、いつも下手に出て相手の機嫌を取る。", {"mode": "furigana", "to": "hiragana"}))

3. Direct OpenYumiEngine API (ONNX or PyTorch)

import sys
from huggingface_hub import snapshot_download

model_dir = snapshot_download("saivansoft/openyumi-130m")
sys.path.insert(0, model_dir)

from infer import OpenYumiEngine

# Choose backend="onnx" (precision="auto" | "int8" | "fp32") or backend="pytorch"
engine = OpenYumiEngine.from_pretrained(model_dir, backend="onnx", precision="auto")

print(engine.convert("辛い経験をした日に、わざと辛いカレーを食べた。", mode="furigana"))
print(engine.convert("お腹が空いたので、空いている席を急いで探した。", mode="aozora"))
print(engine.convert("地元の魚市場を視察してから、海外市場への進出を決めた。", mode="romaji"))

4. CLI & Local HTTP API Server (yumi)

# Convert directly in terminal
python -m openyumi.cli "一月一日に二十歳の弟が、一日中部屋で寝ていた。" --model saivansoft/openyumi-130m -m furigana --precision int8

# Start local CORS-enabled HTTP JSON API server (/api/health, /api/convert, /api/convert_batch, /api/parse, /api/parse_batch)
python -m openyumi.cli --model saivansoft/openyumi-130m --serve --host 127.0.0.1 --port 8787

Supported Output Modes

Mode Example Output Description
furigana / ruby <ruby>人気<rt>ひとけ</rt></ruby>のない HTML <ruby> markup with okurigana alignment & XSS escaping
okurigana / paren 人気(ひとけ)のない Parenthetical reading annotation on kanji stems
aozora |人気《ひとけ》のない Aozora Bunko ruby notation
normal / hiragana ひとけのない Full-sentence Hiragana (or set to="katakana" / to="romaji")
katakana ヒトケノナイ Full-sentence Katakana
romaji hitokenonai Romanization (hepburn, macron, passport, nippon, kunrei)
spaced ひとけ の ない Morpheme-spaced reading output
json [{"surface": "人気", ...}] Structured lossless dual-track Span AST JSON

License

This model and its accompanying runtime and SDK files are licensed under the Apache License, Version 2.0.

Downloads last month
76
Safetensors
Model size
0.1B params
Tensor type
F32
·
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for saivansoft/openyumi-130m

Quantized
(10)
this model

Space using saivansoft/openyumi-130m 1