Views
No views yet
d_model 1024, depth 32, banded attention: three of every four blocks attend within a
256-character window, the fourth globally). Its input is factored into five aligned planes --
letters, word/sentence boundaries, diacritics, capitalization, punctuation -- each of which can
be masked independently to an explicit unknown state at inference. That is what lets one model
read an edited text, scriptio continua, and a lacuna of unknown length without changing
anything but its input.Stoicheia-doc_clean to restore damaged inscriptions and papyri, on every
document except those whose PHI/TM identifier ends in 2.- per missing character when the extent of the break is known, or [N±M] when
its width is uncertain, and let restore_respaced do the reading.1import torch
2from transformers import AutoModel
3from huggingface_hub import hf_hub_download
4
5REPO = "Ericu950/Stoicheia-restoration-test2"
6model = AutoModel.from_pretrained(REPO, trust_remote_code=True).eval()
7
8hf_hub_download(repo_id=REPO, filename="processing_char_bert.py", local_dir=".")
9from processing_char_bert import CharBertProcessor
10
11proc = CharBertProcessor()
12
13# note the input: no accents on τηβου, and no word division either -- the model
14# recovers the missing letters, the accents and the spacing together
15print(proc.restore_respaced(model, "ἔδοξεν τηβου-- καὶ τῷ δήμῳ"))
16# ἔδοξεν τῇ βουλῇ καὶ τῷ δήμῳ
17
18print(proc.restore_respaced(model, "στεφανῶσαι αὐτὸν χρυσῷ στεφα[3±1]ετης ἕνεκα"))
19# στεφανῶσαι αὐτὸν χρυσῷ στεφάνῳ ἀρετῆς ἕνεκαrestore_respaced works in the order an editor would: it fills the letters first, then throws
the spacing away and runs the model again over the resulting scriptio continua with word
division and accents unknown everywhere -- the regime it was pretrained on. Nothing in the
input has to be normalized first: accents and word division are predictions, not requirements,
so a bare majuscule transcript is as readable to this model as a modern critical text, and the
gap is filled in the same pass that decides where the words end. Deciding the letters
and the segmentation in a single pass, which decode_restoration does, leaves the boundary head
hedging against a half-known segmentation, and a correctly restored word can come back cut in
two. The evaluation harness in the code repository goes further still, enumerating the division
inside the gap and scoring it jointly with the letters; that is the decoder behind the paper's
numbers.