This model converts a photograph or scan of a
handwritten UML class or activity diagram into compilable
PlantUML code. It is a fine-tuned variant of
Qwen3.5-4B, adapted in two stages:
Full methodology, training details, and evaluation are described in the accompanying
NIER paper.
1from transformers import AutoModelForImageTextToText, AutoProcessor
2
3model_id = "Seym0n/uml-to-plantuml-qwen3.5-4b"
4model = AutoModelForImageTextToText.from_pretrained(model_id, dtype="bfloat16", device_map="auto")
5processor = AutoProcessor.from_pretrained(model_id)
6
7messages = [
8 {"role": "user", "content": [
9 {"type": "image", "image": "path/or/url/to/sketch.jpg"},
10 {"type": "text", "text": "Convert this handwritten UML diagram to PlantUML code."}
11 ]}
12]
13
14inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True, return_tensors="pt", return_dict=True).to(model.device)
15output = model.generate(**inputs, max_new_tokens=1024)
16print(processor.decode(output[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
Trained on
CAS2UML, 557 hand-drawn UML diagrams (271 class, 286 activity) paired with manually validated PlantUML, released under CC-BY 4.0. Train/test split: 527 train, 30 held out (15 class, 15 activity).
Evaluated against the untuned Qwen3.5-4B base, GPT-4.1 Mini, and Gemini 3 Flash Preview on the 30-diagram held-out set, using both automatic formalism-aware metrics and a human ranking study (N=26). The fine-tuned model moves from last to second overall among the four, ahead of GPT-4.1 Mini and behind Gemini 3 Flash, with the largest gains in first-attempt compilation rate (class: 73.3% → 100%; activity: 20.0% → 86.7%). Full results, error analysis, and metric-validity discussion are in the
paper.
This model is released under
Apache-2.0, matching its base model,
Qwen3.5-4B. Note that the training dataset (
CAS2UML) is released separately under
CC-BY 4.0, and the PlantUML processing tooling used during training is released under
GPL-3.0 — see the
Zenodo archive for full artifact and license details.
1@inproceedings{sadeghi2026formalism,
2 title = {A Formalism-Aware Reward Loop for Handwritten UML-to-PlantUML Generation},
3 author = {Sadeghi, Mersedeh and Scholz, Simon and Psoch-Bajraktari, Adrian},
4 booktitle = {Proceedings of the ACM/IEEE 29th International Conference on Model Driven Engineering Languages and Systems (MODELS 2026), NIER Track},
5 year = {2026}
6}