File size: 14,790 Bytes
20bd3f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1e846f
20bd3f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35c19d8
20bd3f1
 
 
 
 
 
 
 
 
 
 
 
 
da93e4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20bd3f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35c19d8
20bd3f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
---
license: cc-by-4.0
datasets:
- CATMuS/medieval
- magistermilitum/Tridis
metrics:
- cer
- wer
pipeline_tag: image-to-text
tags:
- htr
- handwritten-text-recognition
- manuscripts
- medieval
- vision-language-model
- catmus
- qwen
---

# MEDUSA 0.1 — Medieval European Documents Unified System for Automated text recognition

MEDUSA is a family of Vision Language Models (VLMs) fine-tuned for **multilingual medieval handwritten text recognition (HTR)** at the **line level**. 
These models were developed at the [École nationale des chartes – PSL](https://www.chartes.psl.eu/) and submitted 
to the [ICDAR 2026 Competition on Multilingual Medieval Handwritten Text Recognition (CMMHWR)](https://cmmhwr26.inria.fr/).

This repository contains two model variants:

| Model | Base | Version | Notes |
|---|---|---|---|
| `MEDUSA-4B-0.1` | Qwen3.5-4B | 0.1 | Model used at competition submission |
| `MEDUSA-9B-0.1` | Qwen3.5-9B | 0.1 | Best model at competition submission |


> **Note on versioning.** The `0.1` variants correspond exactly to the models evaluated in the ICDAR 2026 competition.

---

## System report

For full details on data, training procedure, and results, see the [accompanying system report](https://enc.hal.science/hal-05600991).

---

## Languages and scripts

MEDUSA was trained on a corpus of over **640,000 lines** spanning more than twenty repositories, covering the following language families and scripts:

- **Romance / Latin**: Old French (`fro`), Occitan (`pro`), Old Italian (`ita`), Old Spanish (`osp`), Catalan (`cat`), Old Portuguese (`opor`), Navarrese (`nav`), Latin (`lat`), Venetian (`vec`), Galician (`glg`)
- **Germanic**: Middle High German (`gmh`), Middle Low German (`gml`), Old Icelandic (`ice`), Middle English (`enm`), Middle Dutch (`dum`), Old English (`ang`), Old Norwegian (`non`), Swedish (`swe`)
- **Celtic**: Welsh (`wlm`), Old Irish (`gle`)
- **Slavic**: Old Czech (`cze`), Old Polish (`pol`)

Manuscripts dated roughly from the 9th to the 15th century.

---

## Results (ICDAR 2026 CMMHWR)

Unweighted average CER (%) and WER (%) on internal and official competition test sets. Lower is better.

| Model | Internal CER | Internal WER | Task 1 CER | Task 2 CER | Task 3 CER |
|---|---|---|---|---|---|
| kraken-CATMuS 1.6.0 *(baseline)* | 17.3 | 53.5 | 9.29 | 7.91 | 25.9 |
| **MEDUSA-4B 0.1** | **14.7** | **44.5** | 8.15 | 5.60 | 12.0 |
| **MEDUSA-9B 0.1** | **13.2** | **42.6** | 8.03 | **5.24** | **10.8** |


---

## Training data

MEDUSA 0.1 is trained on two tiers of image–text data:

- **Gold** — paired image–text data following heterogeneous transcription conventions, used for visual adaptation across manuscript styles and editorial traditions.
- **Platinum** — image–text pairs aligned with the [CATMuS](https://catmus-guidelines.github.io/) diplomatic transcription guidelines, used for final specialization toward the target task.

The total training pool amounts to approximately **645,000 line-level image–text pairs**.

### Gold datasets

| Dataset | Language | Level | Lines |
|---|---|---|---|
| Original data | Multilingual | Page | 18,352 |
| COMETA [[1]](#ref-cometa) | Occitan | Page | 118,105 |
| Torino L-II-14 [[2]](#ref-torino) | Old French | Page | 36,823 |
| Tridis [[3]](#ref-tridis) | Multilingual | Line | 166,784 |
| FROC-MSS [[4]](#ref-froc) | Old French / Occitan | Page | 3,636 |
| iForal [[5]](#ref-iforal) | Latin / Old Portuguese | Page | 8,009 |
| DISTINGUO [[6]](#ref-distinguo) | Latin | Page | 15,190 |
| AMSMB [[7]](#ref-amsmb) | Latin / Catalan | Page | 3,369 |
| HTR-School-Vienna-2025 [[8]](#ref-vienna25) | Latin | Page | 7,477 |
| Paris Bible Project [[9]](#ref-pbp) | Latin | Page | 1,606 |
| St-Victor (M. Vernet) [[10]](#ref-stvictor) | Latin | Page | 10,736 |
| Wien ÖNB Cod. 2160 f. 164-184 [[11]](#ref-wien) | Latin | Page | 2,681 |
| Bifrost [[12]](#ref-bifrost) | Old Norse | Page | 873 |
| Klosterneuburg [[13]](#ref-klosterneuburg) | Middle High German | Page | 4,758 |
| Faithful transcriptions [[14]](#ref-faithful) | Multilingual | Page | 8,001 |
| StABS Ratsbücher [[15]](#ref-stabs) | Middle High German | Page | 8,371 |
| Inzigkofen [[16]](#ref-inzigkofen) | Middle High German | Page | 8,321 |
| **Total (Gold)** | | | **423,092** |

### Platinum datasets

| Dataset | Language | Level | Lines |
|---|---|---|---|
| Original data | Multilingual | Page | 10,506 |
| CMMHWR dataset [[17]](#ref-cmmhwr) | Multilingual | Page | 149,741 |
| CATMuS Medieval [[18]](#ref-catmus) | Middle Dutch, Old English | Line | 47,084 |
| GATMUZA [[19]](#ref-gatmuza) | Occitan | Page | 2,117 |
| TranscriboQuest 2025 [[20]](#ref-transcriboquest) | Multilingual | Page | 1,278 |
| HTR-School-Vienna-02 [[21]](#ref-vienna02) | Old Czech | Page | 1,336 |
| Padeřov-Bible [[22]](#ref-paderov) | Old Czech | Page | 7,177 |
| 2024–medieval-czech [[23]](#ref-czech24) | Old Czech | Page | 2,748 |
| **Total (Platinum)** | | | **221,987** |

### References

<a id="ref-cometa"></a>[1] Wiedner, M. *COMETA : Corpus de l'occitan médiéval comparatif et annoté*. https://zenodo.org/records/15300719

<a id="ref-torino"></a>[2] Camps, J.-B., O'Connor, P. *Torino_L-II-14: HTR Training Dataset for the manuscript Turin, Biblioteca nazionale universitaria, MS L. II. 14* (2024). https://github.com/RESCAPE-Biblissima/Torino_L-II-14

<a id="ref-tridis"></a>[3] Torres, S. *Tridis* (revision e8d811f) (2025). https://doi.org/10.57967/hf/5001

<a id="ref-froc"></a>[4] Camps, J.-B. *FROC-MSS: Old French and Old Occitan Medieval Manuscripts HTR Data and Models* (2018). https://github.com/Jean-Baptiste-Camps/FROC-MSS

<a id="ref-iforal"></a>[5] Projet iForal. *iForal Dataset: Medieval Portuguese Manuscripts HTR Data*. https://github.com/Arch-W/iForal-Dataset

<a id="ref-distinguo"></a>[6] Burghart, M., Yatsyk, S. *DISTINGUO: Ground truth for handwritten text recognition (HTR) on collections of distinctions (late 13th to late 15th century)* (2024). https://doi.org/10.34847/NKL.48AD8B8D

<a id="ref-amsmb"></a>[7] Coll Ardanuy, M., Cuadrada, C., Sarobe, R. *A Dataset for Handwritten Text Recognition in Medieval Notarial Charters Written on Parchment* (2025). https://dataverse.bsc.es/dataset.xhtml?persistentId=perma:BSC/0VB0MC

<a id="ref-vienna25"></a>[8] Odstrčilík, J. et al. *HTR Winter School in Vienna 2025 – Late Medieval Latin Group: Ground Truth Dataset for Late-Medieval Latin Scripts* (2025).

<a id="ref-pbp"></a>[9] Wrisley, D., The Paris Bible Project, Gueville, E. *parisbible/ground_truth: Ground truth v1.0.0 for the Paris Bible Project* (Feb 2023). https://doi.org/10.5281/zenodo.7653691

<a id="ref-stvictor"></a>[10] Vernet, M. *Saint Victor MS dataset (abbreviated and expanded ALTO)* (Jan 2023). https://doi.org/10.5281/zenodo.7510410

<a id="ref-wien"></a>[11] Attwood et al. *Wien ÖNB cod. 2160 f. 164-184 ground truth from HTR Winter School 2022* (Dec 2022). https://doi.org/10.5281/zenodo.7537204

<a id="ref-bifrost"></a>[12] Kapitan, K.A., Vidal-Gorène, C. *Crossing the Bifrost: Towards an open access FAIR HTR model for Old Norse manuscripts* (May 2025). https://doi.org/10.5281/zenodo.15366896

<a id="ref-klosterneuburg"></a>[13] Berger, M. et al. *Klosterneuburg, Stiftsbibl., Cod. 48 – Ground Truth: Initial release* (Dec 2022). https://doi.org/10.5281/zenodo.7466928

<a id="ref-faithful"></a>[14] Eichenberger, N., Suwelack, H. *Faithful Transcriptions Data Set: TEI/XML-encoded transcriptions of medieval theological manuscripts* (Oct 2021). https://doi.org/10.5281/zenodo.5582483

<a id="ref-stabs"></a>[15] Hodel, T., Schoch, D., Dängeli, P. *Handwritten text recognition ground truth set: StABS Ratsbücher O10, Urfehdenbuch X* (Aug 2021). https://doi.org/10.5281/zenodo.5153263

<a id="ref-inzigkofen"></a>[16] Eichenberger, N. *Transcriptions from medieval manuscripts related to the Augustinian canonesses in Inzigkofen* (Dec 2025). https://doi.org/10.5281/zenodo.17978574

<a id="ref-cmmhwr"></a>[17] Clérice, T., Kiessling, B. *ICDAR 2026 Competition on Multilingual Medieval Handwriting Recognition* (Jan 2026). https://doi.org/10.5281/zenodo.18270331

<a id="ref-catmus"></a>[18] Clérice, T. et al. *CATMuS Medieval: A multilingual large-scale cross-century dataset in Latin script for handwritten text recognition and beyond* (Feb 2024). https://inria.hal.science/hal-04453952

<a id="ref-gatmuza"></a>[19] Camps, J.-B. *Lo GAT MUZA: CATMuS-conformant HTR Ground-Truth Data for Medieval Occitan* (2026). https://github.com/LostMa-ERC/gatmuza

<a id="ref-transcriboquest"></a>[20] McDonough, C. et al. *TranscriboQuest 2025 Medieval Vernacular Religious Texts* (Sep 2025). https://doi.org/10.5281/zenodo.17062963

<a id="ref-vienna02"></a>[21] Veličkaitė, V. et al. *HTR Winter School 2025 – Medieval Czech – Biblioteka Jagiellonska BJ Rkp 441 IV* (Dec 2025).

<a id="ref-paderov"></a>[22] Michalcová, A. et al. *Padeřov-Bible-handwriting-ground-truth: Initial release* (Dec 2022). https://doi.org/10.5281/zenodo.7467034

<a id="ref-czech24"></a>[23] Plechatý, M. et al. *HTR Winter School 2024 – Medieval Czech – Prague Bible (1488)* (Dec 2024).


---

## Intended use

These models are designed for **line-level HTR** on pre-segmented medieval manuscript images. 
They are **not** page-level OCR systems: they expect a cropped image of a single text line as input and return the transcription of that line.

The models target **CATMuS transcription guidelines**, which govern abbreviation expansion, allograph normalisation, and the character set used.

---

## Usage with DocWorkflow

The recommended way to use MEDUSA is via **[DocWorkflow](https://github.com/Enceintes-Chartes/docworkflow)**, 
the document analysis framework developed at the École nationale des chartes. 
DocWorkflow handles ALTO XML input/output, line image extraction, batching, CATMuS post-processing, and scoring in a unified pipeline.

### Installation

```bash
git clone https://github.com/TheoMoins/DocWorkflow
cd docworkflow
pip install -e .
```

### Configuration file

Create a YAML config file (e.g., `medusa_inference.yml`):

```yaml
run_name: "Medusa0.1Line-9B"
output_dir: "results"
device: "cuda"
save_image: true

data:
  test: "path/to/your/alto/data"   # directory with ALTO XML + image pairs

tasks:
  htr:
    type: VLMLineHTR
    config:
      use_metadata: true
      model_name: 'outputs/Medusa0.1Line-9B'
      device_map: "auto"
      max_new_tokens: 128
      line_batch_size: 8
      max_pixels: 401408

      prompt: >
        Transcribe the handwritten text in this line image.
        Keep abbreviations as written, do not expand them.
        Modernize word segmentation (split or join words following modern usage).
        Use only u and i, never v and j, regardless of the original or modern usage.
        Do not record allographic variants, use standard letter forms.
        Output ONLY the transcription.

```

> **Tip.** If your dataset follows dataset-specific transcription conventions, you can provide a `conventions.yml` file alongside your ALTO data.
> DocWorkflow will automatically inject the conventions into the prompt via a `{conventions}` placeholder.

### Running inference

```bash
docworkflow -c Medusa0.1Line-9B.yml predict -t htr -d test
```

## Direct usage with `transformers`

The models can also be used directly outside of DocWorkflow, though the CATMuS post-processing step will need to be applied manually if desired.

```python
from transformers import AutoProcessor, AutoModelForImageTextToText
from PIL import Image

model_id = "ENC-PSL/Medusa0.1Line-9B"

processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(model_id, device_map="auto")

image = Image.open("path/to/line_image.jpg").convert("RGB")

prompt = "Transcribe the handwritten text in this line image.\nOutput ONLY the transcription."

messages = [
    {
        "role": "user",
        "content": [
            {"type": "text", "text": prompt},
            {"type": "image", "image": image},
        ],
    }
]

inputs = processor.apply_chat_template(
    [messages],
    tokenize=True,
    add_generation_prompt=True,
    return_dict=True,
    enable_thinking=False,
    return_tensors="pt",
).to(model.device)

with torch.no_grad():
    generated_ids = model.generate(**inputs, max_new_tokens=128, do_sample=False)

trimmed = generated_ids[0][inputs["input_ids"].shape[1]:]
transcription = processor.decode(trimmed, skip_special_tokens=True).strip()
print(transcription)
```

> **Important.** The model is optimised for the prompt given above. Results may degrade if the prompt is modified.
> The model outputs raw text; to enforce CATMuS compliance (character whitelist, allograph normalisation),
> apply the post-processing step provided in DocWorkflow (`src/tasks/htr/postprocessing.py`).

---

## CATMuS conventions

Transcriptions follow the [CATMuS guidelines](https://catmus-guidelines.github.io/). 

---

## Citation

If you use MEDUSA in your research, please cite:

```bibtex
@unpublished{moins:hal-05600991,
  TITLE = {{MEDUSA 0.1: Medieval European Documents Unified System for Automated text recognition System Report for the ICDAR 2026 Competition on Multilingual Medieval Handwritten Text Recognition}},
  AUTHOR = {Moins, Th{\'e}o and Cafiero, Florian and Camps, Jean-Baptiste and Conte, Lilla and Guidi, Emilie and Hensley, Brenna and Kapitan, Katarzyna and Macedo, Carolina and Peratello, Paola and Vermaas, Cecile and Vidal-Gor{\`e}ne, Chahan},
  URL = {https://enc.hal.science/hal-05600991},
  NOTE = {working paper or preprint},
  YEAR = {2026},
  MONTH = Apr,
  PDF = {https://enc.hal.science/hal-05600991v1/file/MEDUSA__MEDieval_Universal_Script_Analysis-6.pdf},
  HAL_ID = {hal-05600991},
  HAL_VERSION = {v3},
}
```

---

## Funding

Funded by the European Union (ERC, LostMA, 101117408). Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the
 European Research Council. Neither the European Union nor the granting authority can be held responsible for them.

This work has received support under the Major Research Program of PSL Research University ``CultureLab'' launched by PSL Research University and implemented by ANR with the references ANR-10-IDEX-0001.

Ce travail a bénéficié d'une aide de l’État gérée par l'Agence Nationale de la Recherche au titre de France 2030 portant la référence « ANR-23-IACL-0008»). 

Biblissima+ bénéficie d’une aide de l'Etat gérée par l'ANR au titre du Programme d’investissements d’avenir intégré à France 2030, portant la référence ANR-21-ESRE-0005.

This work was granted access to the HPC resources of IDRIS
 under the allocation 2026-AD011015914R1 made by GENCI.