--- license: cc-by-nc-sa-4.0 base_model: Qwen/Qwen3.5-9B library_name: transformers pipeline_tag: image-text-to-text tags: - church-slavonic - old-church-slavonic - serbian - translation - ocr - htr - manuscripts - qwen3.5 - lora language: - cu - sr --- # Princip V0.2 Reads lines of Church Slavonic manuscript and translates them into Serbian. Three tasks: transcription from an image, translation from an image, and translation from text. ## Languages Source is **Church Slavonic of the Russian recension**, the language of the service books in current liturgical use in the Serbian Orthodox Church, together with **Old Church Slavonic** from the 10th-11th century canon. Target is Serbian in the register of the 1868 Daničić translation. Serbian-recension Church Slavonic (srpskoslovenski) is not represented. See Limitations. ## Tasks | task | input | output | |---|---|---| | `i2t` | image of a single text line | transcription | | `i2s` | image of a single text line | Serbian translation | | `t2s` | Church Slavonic text | Serbian translation | Trained on **single-line crops**, not whole pages. Segment a folio into lines first. ## Usage ```python import torch from transformers import AutoProcessor, AutoModelForImageTextToText model = AutoModelForImageTextToText.from_pretrained( "jolovicdev/princip-v0.2", dtype=torch.bfloat16, device_map="cuda" ) processor = AutoProcessor.from_pretrained("jolovicdev/princip-v0.2") ``` Prompts, used verbatim: - `Prevedi sledeci tekst sa staroslovenskog na srpski:\n{text}` - image + `Transkribuj staroslovenski tekst sa ove slike.` - image + `Prevedi tekst sa ove slike na srpski.` **Close the thinking block before generating.** The chat template opens one and leaves it open; if you do not close it the model writes reasoning instead of the answer. ```python text = processor.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True) if text.rstrip().endswith(""): text += "\n\n\n" ``` This applies to llama.cpp and any OpenAI-compatible server too. ## Results Held-out data, greedy decoding. | task | metric | score | |---|---|---| | translation from text | chrF | 46.9 | | translation from image | chrF | 44.8 | | transcription, real manuscript folios | CER | 0.117 | | transcription, rendered lines | CER | 0.023 | On manuscripts absent from training (Codex Assemanianus, Savvina kniga) translation scores chrF 52.6, so the model generalises beyond the hands it was trained on. Roughly 36% of rare words, mostly proper nouns, survive into the translation. The model can produce fluent Serbian that misstates the source; verify anything that matters. ## Training LoRA fine-tune of `Qwen/Qwen3.5-9B`, r=32, 1 epoch, bf16, on 4x RTX 5090. 96.9M trainable parameters covering the attention and MLP projections, the vision merger, and both embedding matrices. Data: 81k samples across the three tasks, drawn from a parallel corpus of biblical, psalter and liturgical Church Slavonic aligned to Serbian, plus 49.7k line images combining real folio crops with rendered lines. Images are split by folio, so no page appears in both training and evaluation. ## Sources and licensing | source | licence | |---|---| | Daničić-Karadžić Serbian Bible 1868 | public domain | | Elizabeth Bible 1757 | public domain | | PROIEL Codex Marianus | CC BY-NC-SA 4.0 | | TOROT (Zographensis, Psalterium Sinaiticum, Suprasliensis, Euchologium, Kiev Missal) | CC BY-NC-SA 4.0 | | cu-books liturgical texts | MIT | | Serbian Mineja, SPC edition (svetosavlje.org) | no explicit licence, research use | | Codex Suprasliensis folio images (suprasliensis.obdurodon.org) | CC BY-NC-SA 3.0 | | Menaion, Monomakh, Fedorovsk, Pomorsky fonts | SIL OFL | The PROIEL and TOROT treebanks are non-commercial, so this model is released under **CC BY-NC-SA 4.0**. ## Limitations - **Serbian recension is absent.** Medieval Serbian manuscripts such as Miroslavljevo jevanđelje use orthographic conventions the model has not seen. Expect degraded results. - **Line crops only.** Whole pages are out of distribution. - **Parchment and print only.** Carved stone, epigraphy and heavily degraded surfaces are outside the training distribution. - **Glagolitic is not supported.** The Old Church Slavonic sources are Glagolitic manuscripts in Cyrillic transcription; the model has not seen Glagolitic script. - **It does not reliably refuse out-of-domain input.** Shown Cyrillic that is not Church Slavonic, it will usually attempt a transcription rather than decline. - **Serbian register** follows the 1868 Daničić translation, not contemporary Serbian. - **Non-commercial use only.**