Views
No views yet
| Base model | unsloth/Qwen3-VL-8B-Instruct |
| Finetuning method | LoRA (rank 16, alpha 16, dropout 0.1), then merged to bf16 |
| Trainable params during LoRA | 43.6M / 8.81B (0.50%) |
| Layers finetuned | Language (attention + MLP). Vision tower frozen. |
| Dataset | DangIT02/flowchart-to-mermaid_v2 |
| Split sizes | Train 4,511 / Val 655 / Test 662 |
| Training | 2 epochs, 564 steps, ~3h 37m on A100 80GB |
| Effective batch size | 16 (per-device 2 × grad-accum 8) |
| Learning rate | 5e-5, cosine schedule, 5% warmup |
| Final train loss | 0.070 |
| Final eval loss | 0.172 (monotonic decrease) |
| Peak VRAM | 31.9 GB |
A, B, C, ..., Z, AA, AB, ... in order of first appearance. This is because training data was canonicalized for tool-use compatibility and deterministic output.Start, ProcessPayment), apply a post-processing step to rename nodes based on their labels.| Metric | Overall | Small (<10) | Medium (10-20) | Large (20+) |
|---|---|---|---|---|
| node_f1 | 0.677 | 0.506 | 0.796 | 0.719 |
| edge_f1 | 0.289 | 0.257 | 0.359 | 0.256 |
| labeled_edge_f1 | 0.220 | 0.220 | 0.284 | 0.164 |
| direction_match | 0.964 | 1.000 | 1.000 | 0.901 |
| parse_success | 1.000 | 1.000 | 1.000 | 1.000 |
graph TD when the image uses BT or LR.1from transformers import AutoProcessor, AutoModelForImageTextToText
2from PIL import Image
3import torch
4
5model_id = "DangIT02/qwen3vl-flowchart-to-mermaid_v2"
6model = AutoModelForImageTextToText.from_pretrained(
7 model_id, torch_dtype=torch.bfloat16, device_map="auto"
8)
9processor = AutoProcessor.from_pretrained(model_id)
10
11image = Image.open("flowchart.png").convert("RGB")
12if max(image.size) > 1024:
13 image.thumbnail((1024, 1024), Image.LANCZOS)
14
15messages = [{"role": "user", "content": [
16 {"type": "image", "image": image},
17 {"type": "text", "text": "Convert this flowchart to Mermaid code."},
18]}]
19
20inputs = processor.apply_chat_template(
21 messages, add_generation_prompt=True, tokenize=True,
22 return_tensors="pt", return_dict=True,
23).to(model.device)
24
25with torch.no_grad():
26 out = model.generate(
27 **inputs,
28 max_new_tokens=2048,
29 do_sample=False,
30 repetition_penalty=1.15,
31 )
32
33mermaid_code = processor.decode(
34 out[0][inputs["input_ids"].shape[1]:],
35 skip_special_tokens=True,
36)
37print(mermaid_code)1from vllm import LLM, SamplingParams
2from PIL import Image
3
4llm = LLM(
5 model="DangIT02/qwen3vl-flowchart-to-mermaid_v2",
6 dtype="bfloat16",
7 max_model_len=8192,
8 limit_mm_per_prompt={"image": 1},
9)
10
11sampling = SamplingParams(max_tokens=2048, temperature=0.0, repetition_penalty=1.15)
12
13image = Image.open("flowchart.png").convert("RGB")
14prompt = {
15 "prompt": "<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Convert this flowchart to Mermaid code.<|im_end|>\n<|im_start|>assistant\n",
16 "multi_modal_data": {"image": image},
17}
18output = llm.generate([prompt], sampling)[0]
19print(output.outputs[0].text)Convert this flowchart diagram to Mermaid code.Generate the Mermaid code for the provided flowchart.Analyze this flowchart and output the equivalent Mermaid code.What is the Mermaid representation of this flowchart?Transcribe this flowchart into Mermaid syntax.graph TD when the true direction is BT or LR. Workaround: include the expected direction in the prompt.SFTTrainer.1lora_rank=16, lora_alpha=16, lora_dropout=0.1
2finetune_vision_layers=False
3finetune_language_layers=True
4finetune_attention_modules=True
5finetune_mlp_modules=True
6
7num_epochs=2
8per_device_train_batch_size=2
9gradient_accumulation_steps=8 # effective batch = 16
10learning_rate=5e-5
11weight_decay=0.001
12warmup_ratio=0.05
13lr_scheduler_type="cosine"
14max_grad_norm=1.0
15optim="adamw_8bit"
16
17max_seq_length=4096
18seed=34071@misc{qwen3vl_flowchart_mermaid_v2,
2 title={Qwen3-VL-8B Flowchart-to-Mermaid (v2)},
3 author={DangIT02},
4 year={2026},
5 howpublished={\url{https://huggingface.co/DangIT02/qwen3vl-flowchart-to-mermaid_v2}},
6}