A model trained from scratch on Old East Slavic and Church Slavonic texts that restores damaged text, attributes its dialect and date, and puts word boundaries back. It reads scriptio continua — text without spaces.
·.
Each position also gets the id of the character 3-gram starting there
(3-grams touching a gap or damage marker are blanked, so nothing leaks).
Char (768) and 3-gram (192) embeddings are concatenated and projected to 768.# gap
expansion (expand / stop), word boundary after each character, date (20
bins of 50 years, 800-1799), dialect (OES / CS / NW / SW). Date and dialect
read a learned attention pool over all text positions.import sys
from huggingface_hub import snapshot_download
path = snapshot_download("BeRestoral/ContinuaRoformer-slav")
sys.path.insert(0, path)
from inference import ContinuaRestorer
r = ContinuaRestorer(path, f"{path}/char_vocab.json", f"{path}/ngram_vocab.json")
# `-` one missing character, `#` a gap of unknown length, `?` damage not to restore
print(r.restore_text("поклоноѿд-выдакъмат#ию")) # with predicted spaces
print(r.restore_text("поклоноѿд-выдакъмат#ию", segment=False)) # continua
print(r.attribute("поклоноѿдавыдакъматѳию")) # dialect and date distributions
Requires torch and transformers.
The model was trained on normalized text, so input should already use the model's alphabet (char_vocab.json). Any other character is read as damage ([UNK]).
# and decoded iteratively): exact match by length 1: 28.1%, 2: 12.7%, 3: 0.8%; 16.1% keep expanding until the step limit.# and decoded iteratively): exact match by length 1: 46.2%, 2: 21.7%, 3: 14.3%; 8.3% keep expanding until the step limit.[UNK] damage markers in birchbark letters.