Tiberian Biblical Hebrew → IPA (ByT5)
Authors: John Locke, Teodor Bors
Org: Tiberian AI
Fine-tuned google/byt5-small that maps Masoretic Biblical Hebrew (niqqud and teʿamim / cantillation) to Tiberian IPA, following Geoffrey Khan’s reconstruction of the Tiberian reading tradition.
This is a distillation of a rule-based teacher (native port of Charles Loder’s Tiberian schema on top of havarot syllabification), trained on BHS-aligned verse pairs — not a model that invents a new phonology.
This release was trained on cleaned BHS text/labels (HTML/[ch:vs] notes, puncta extraordinaria, and petucha/setuma markers stripped before teacher IPA and before encode).
Intended input (important)
| Accepted | Rejected / unsupported |
|---|---|
| Fully pointed Biblical Hebrew | Bare consonantal text |
| With teʿamim (cantillation) | Niqqud-only without accents (stress/length will be wrong) |
Optional sof pasuq ׃ / BHS markup (stripped in prep) | Modern Hebrew orthography |
The teacher and this model need cantillation for faithful stress, length, and related Tiberian detail. Do not send unpointed or teʿamim-free text and expect Tiberian-quality IPA.
Evaluation
Chapter-held-out validation and test splits (whole chapters held out; same Tiberian teacher as the train labels). Model selection used val_cer (minimise) with early stopping (patience 5). Best weights are from epoch 27 of run 20260924-093807 (best in-training val_cer ≈ 0.000173). Reported metrics below are a final decode of that HF checkpoint (beam 4, max 768 new tokens) on 2,333 val and 2,318 test verses.
| Metric | Validation | Test |
|---|---|---|
| CER | 0.000182 | 0.000163 |
| chrF | 99.955 | 99.960 |
| chrF++ | 99.921 | 99.925 |
| BLEU | 99.966 | 99.970 |
| WER | 0.00126 | 0.00125 |
| Exact match | 98.67% | 98.71% |
High scores mean the model matches the teacher, not independent human transcription. Held-out chapters still share the same rule system as the train set.
Training
| Setting | Value |
|---|---|
| Run | 20260924-093807 |
| Base model | google/byt5-small |
| Precision | bf16-mixed |
| Batch | 4 × gradient accumulation 2 (effective 8) |
| Max length (src / tgt) | 768 / 768 |
| Learning rate | 1e-4 (warmup 200), weight decay 0.01 |
| Epochs | 30 scheduled; best @ epoch 27 (val_cer) |
| Seed | 42 |
| Data | ~18.3k train / ~2.3k val / ~2.3k test verses |
Quick start
Requires: torch, transformers. Prep below matches training (strip BHS markup, NFD, holem/waw, sof pasuq, optional pointing fixes).
import re
import unicodedata
import torch
from transformers import AutoTokenizer, T5ForConditionalGeneration
MODEL_ID = "tiberianai/tiberian-hebrew-ipa-byt5"
_VOWELS = re.compile(r"[\u05B0-\u05BB\u05C7]")
_NOISE = re.compile(r"[\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff\u00ad\u0323]")
_HTML_TAG = re.compile(r"<[^>]+>", re.IGNORECASE)
_VERSE_NOTE = re.compile(r"\[\s*\d+\s*:\s*\d+\s*\]")
_SECTION_BRACE = re.compile(r"\s*\{[פס]\}")
_PETUCHA_SETUMA = re.compile(r"(?:׃|\.)\s*[פס]\s*$")
_PETUCHA_SETUMA_SPACE = re.compile(r"\s+[פס]\s*$")
_WS = re.compile(r"\s+")
_WAW, _HOLAM, _HOLAM_HASER = "\u05D5", "\u05B9", "\u05BA"
_SOF_PASUQ = "\u05C3"
_PUNCTA = "\u05C4"
BHS_POINTING_FIXES = (
("וְהתְהַלֵּ֥ךְ", "וְהִתְהַלֵּ֥ךְ"),
("וַיִּקְבְֹּ֥ר", "וַיִּקְבֹּ֥ר"),
("קְוּצֹּותָיו֙", "קְוֻצֹּותָיו֙"),
)
def holem_waw(word: str) -> str:
if _HOLAM_HASER in word:
word = word.replace(_HOLAM_HASER, _HOLAM)
if _WAW not in word or _HOLAM not in word or (_WAW + _HOLAM) not in word:
return word
return re.compile(rf"(?<!{_VOWELS.pattern}){_WAW}{_HOLAM}").sub(
f"{_HOLAM}{_WAW}", word
)
def prepare_masoretic(text: str) -> str:
"""Must run before encode — same contract as training."""
text = _NOISE.sub("", text)
text = _HTML_TAG.sub("", text)
text = _VERSE_NOTE.sub("", text)
text = text.replace(_PUNCTA, "")
text = _SECTION_BRACE.sub("", text)
text = _PETUCHA_SETUMA.sub("׃", text)
text = _PETUCHA_SETUMA_SPACE.sub("", text)
for bad, good in BHS_POINTING_FIXES:
text = text.replace(bad, good)
text = text.replace(_SOF_PASUQ, "")
text = unicodedata.normalize("NFD", text)
parts = re.split(r"(\s+)", text)
text = "".join(
part if (not part or part.isspace()) else holem_waw(part) for part in parts
)
return _WS.sub(" ", text).strip()
def has_teamin(text: str) -> bool:
return bool(re.search(r"[\u0591-\u05AF]", text))
def transcribe(text: str, model, tokenizer, device=None) -> str:
if not has_teamin(text):
raise ValueError(
"Input needs teʿamim (cantillation). Consonantal or niqqud-only "
"Hebrew is not supported for Tiberian IPA."
)
device = device or next(model.parameters()).device
src = prepare_masoretic(text)
enc = tokenizer(
src, return_tensors="pt", truncation=True, max_length=768
).to(device)
with torch.no_grad():
out = model.generate(**enc, max_new_tokens=768, num_beams=4, do_sample=False)
return tokenizer.decode(out[0], skip_special_tokens=True)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = T5ForConditionalGeneration.from_pretrained(MODEL_ID)
model.eval()
if torch.cuda.is_available():
model = model.cuda()
verse = "בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ"
print(transcribe(verse, model, tokenizer))
# ≈ baʀ̟eːˈʃiːiθ bɔːˈʀ̟ɔː ʔɛloːˈhiːim ˈʔeːeθ haʃʃɔːˈmaːjim veˈʔeːeθ hɔːˈʔɔːʀ̟ɛsˁ
Training data
- Source: Biblia Hebraica Stuttgartensia (BHS) / WLC-style pointed text with teʿamim.
- Targets: Tiberian IPA from the project’s rule engine (
tiberian-ipa), forte–lene stream, verse-aligned, chapter-held-out splits. - Prep: Strip HTML /
[ch:vs]notes / puncta extraordinaria / petucha–setuma; Unicode NFD; holem/waw sequencing; sof pasuq removed; small table of known defective BHS pointing fixes.
Limitations
- Matches the teacher IPA, including perpetual Qere for the Tetragrammaton (Adonai / Elohim by pointing cue), not a phonetic “YHWH” reading.
- Not for Modern Hebrew, unpointed Bible text, or liturgical traditions other than Tiberian as encoded by the teacher.
- Rare / contested allophones (e.g. voiced ṣade [zˁ]) follow the teacher defaults, not every historical citation in Khan.
Credits & acknowledgements
- Geoffrey Khan, The Tiberian Pronunciation Tradition of Biblical Hebrew (Open Book Publishers) — linguistic source of truth for the Tiberian reconstruction used by the teacher labels.
- Charles Loder — hebrew-transliteration and havarotjs; the Tiberian schema / syllabifier lineage distilled into the teacher.
- Biblia Hebraica Stuttgartensia (BHS) and the underlying Masoretic / WLC text tradition — Hebrew sources for training pairs.
- Google —
google/byt5-smallbase model (ByT5).
Citation
@misc{locke_bors_tiberian_ipa_byt5,
title = {Tiberian Biblical Hebrew to IPA (ByT5)},
author = {Locke, John and Bors, Teodor},
year = {2026},
howpublished = {\url{https://huggingface.co/tiberianai/tiberian-hebrew-ipa-byt5}},
note = {Distilled from a Khan/Loder-aligned Tiberian rule engine on cleaned BHS text}
}
Please also cite Khan’s volumes and credit BHS / the Masoretic text tradition, and Loder’s open-source packages where appropriate.
License
MIT for the fine-tuned weights and training code, subject to upstream licenses for BHS/WLC text, Khan’s publications, ByT5, and Loder’s packages when redistributing data or derivatives.