A tiny model that reads diagrams. Show Tadpole a flowchart, a UML diagram, a BPMN process or a logic circuit, whether it is hand-drawn on a whiteboard, scanned or exported from a tool. It hands back every box, every label and every arrow as structured text that converts losslessly to JSON, YAML or XML.
Why "Tadpole"? A tadpole is a dot with a tail, which is one node and one arrow: the smallest diagram there is.
A hand-drawn UML activity diagram from the CAS2UML test split (CC BY 4.0). The model never saw this image in training.
Tadpole's answer, exactly right:
diagram activity dir=TB
node n1 initial
node n2 action "Sign Contract"
node n3 fork
node n4 action "IT: Provision Laptop"
node n5 action "HR: Setup Benefits"
node n6 action "Legal: NDA Signature"
node n7 join
node n8 action "First Day Orientation"
node n9 final
edge n1 n2
edge n2 n3
edge n3 n4
edge n3 n5
edge n3 n6
edge n4 n7
edge n5 n7
edge n6 n7
edge n7 n8
edge n8 n9
Ask for boxes and every element also gets a position (0–1000 coordinates). Here they are drawn back onto a photo of a hand-drawn BPMN diagram (hdBPMN test split, CC BY 4.0):
Flowcharts, UML activity, sequence, class and state diagrams, BPMN processes, ER diagrams, logic circuits (gates and wires), and generic node-link graphs such as mind maps and architecture diagrams.
The output names each element's kind, such as decision, fork, interface or nand, and its text. It also gives every arrow with its direction and label, and containers such as lanes, pools, packages and composite states. Boxes are optional.
These are the test-set results on 580 images from 12 sources. "Never trained" marks sources kept out of training, so their style is completely new to the model.
| Source | Style | Edge F1 | Node F1 |
|---|---|---|---|
| FlowVQA | rendered flowcharts | 0.988 | 0.998 |
| CAS2UML | hand-drawn UML | 0.958 | 0.992 |
| Image-to-Mermaid v3 | rendered, 6 diagram types | 0.946 | 0.994 |
| rakitha (never trained) | rendered flowcharts | 0.921 | 0.955 |
| DiDi | hand-drawn ink flowcharts | 0.917 | 0.968 |
| FlowGen | 4 renderers, scanned copies | 0.899 | 0.981 |
| Flowchart-to-Mermaid | rendered flowcharts | 0.899 | 0.980 |
| The Stack v2 PlantUML | real-world UML | 0.790 | 0.842 |
| UML-in-the-Wild (never trained) | real-world UML | 0.746 | 0.711 |
| Handwritten FC/FA (never trained) | hand-drawn scans | 0.730 | 0.836 |
| hdBPMN | hand-drawn BPMN photos | 0.694 | 0.932 |
| LogicBench-1K | hand-drawn logic circuits | 0.525 | 0.867 |
| All 580 images | 0.846 | 0.930 |
import torch
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
repo = "Srinjoy99/tadpole-0.8b"
processor = AutoProcessor.from_pretrained(repo)
model = AutoModelForImageTextToText.from_pretrained(repo, dtype=torch.bfloat16, device_map="auto")
image = Image.open("diagram.png").convert("RGB")
messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "Convert this diagram to DGM."}]}]
prompt = processor.apply_chat_template(messages, add_generation_prompt=True, enable_thinking=False)
inputs = processor(text=[prompt], images=[image], return_tensors="pt",
images_kwargs={"size": {"shortest_edge": 65536, "longest_edge": 1254400}}).to(model.device)
output = model.generate(**inputs, max_new_tokens=1536, do_sample=False)
dgm = processor.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(dgm)
enable_thinking=False: the model was trained with an empty think block."Convert this diagram to DGM with boxes.".The answer is DGM, the compact line format of the Diagram IR. The diagram_ir package in the GitHub repo converts it losslessly:
python -m diagram_ir convert diagram.dgm --to json,yaml,xml -o exports/
Or, from Python:
from diagram_ir import dump, parse
diagram, problems = parse(dgm) # lenient: a cut-off answer still keeps every complete line
print(dump(diagram, "json"))
The repo also has a one-line CLI (python -m deploy.predict diagram.png --to json) and a demo notebook. The format is defined in SPEC.md.
Tadpole is a full fine-tune of Qwen3.5-0.8B on one RTX 3090, in about 24 GPU-hours:
The training data comes from 12 sources with about 137,000 image–target pairs, including 26,000 synthetic diagrams generated for the project. Every target comes from the source's own structured ground truth, never from OCR. The full story, including a metric bug the RL run exploited and how it was fixed, is in TRAINING.md. The datasets and cleaning are in DATASETS.md.
Training data:
Sets whose licenses do not allow training were used for testing only.
Apache-2.0, like the base model. The CC BY 4.0 training sets are credited above.