Saltar al contenido
ModelPublicadoExterno
Browse files

Qwen3vl Flowchart To Mermaid v5

Fine-tuned Qwen3-VL-8B-Instruct for converting flowchart images into Mermaid code.

TipoOtherModelo baseunsloth/Qwen3-VL-8B-InstructVersiónRevision fc8aa89Bcalidad

Fuente del modelo

Tipo
Other
Tamaño del archivo
2,53–4,66 GB
Modelo base
unsloth/Qwen3-VL-8B-Instruct
Versión
vRevision fc8aa89
Actualizado
2 nov 2026
Descargas
36
Fuente
Hugging Face

Descripción de la fuente

Qwen3-VL-8B Flowchart → Mermaid (v5)

Fine-tuned Qwen3-VL-8B-Instruct for converting flowchart images into Mermaid code.

TL;DR

MetricV5
node_f10.964
edge_f10.689
labeled_edge_f10.609
direction_match1.000
parse_success1.000

Quick start (vLLM)

vllm serve DangIT02/qwen3vl-flowchart-to-mermaid-v5 \
    --port 8000 \
    --max-model-len 8192 \
    --limit-mm-per-prompt image=1 \
    --gpu-memory-utilization 0.85
from openai import OpenAI
import base64

client = OpenAI(base_url="http://localhost:8000/v1", api_key="empty")

with open("flowchart.png", "rb") as f:
    img_b64 = base64.b64encode(f.read()).decode()

response = client.chat.completions.create(
    model="DangIT02/qwen3vl-flowchart-to-mermaid-v5",
    messages=[{
        "role": "user",
        "content": [
            {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_b64}"}},
            {"type": "text", "text": "Convert this flowchart diagram to Mermaid code."},
        ],
    }],
    temperature=0.0,
    max_tokens=2048,
)
print(response.choices[0].message.content)

Quick start (transformers)

from transformers import AutoModelForImageTextToText, AutoProcessor
import torch
from PIL import Image

model_id = "DangIT02/qwen3vl-flowchart-to-mermaid-v5"
model = AutoModelForImageTextToText.from_pretrained(model_id, dtype=torch.bfloat16, device_map="auto")
processor = AutoProcessor.from_pretrained(model_id)

image = Image.open("flowchart.png").convert("RGB")
messages = [{
    "role": "user",
    "content": [
        {"type": "image", "image": image},
        {"type": "text", "text": "Convert this flowchart diagram to Mermaid code."},
    ],
}]
inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True, return_tensors="pt", return_dict=True).to("cuda")
output = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
print(processor.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))

Model details

  • Base model: unsloth/Qwen3-VL-8B-Instruct
  • Task: Image-to-code (flowchart image → Mermaid syntax)
  • Output direction: TD (top-down only)
  • Output syntax: 100% pipe syntax A -->|label| B (no alternate A -- label --> B)
  • Node ID style: Descriptive (Start, CheckInput) — not canonicalized

Training

Dataset

DangIT02/flowchart-to-mermaid_v2_2 (private, 2,872 samples):

  • Train: 2,304 (587 easy / 906 medium / 811 hard)
  • Val: 284 (70/113/101)
  • Test: 284 (68/114/102)
  • 100% TD direction, 100% pipe syntax

Hyperparameters

ParamValue
LoRA rank32
LoRA alpha32 (α=r)
LoRA dropout0.05
Vision layersunfrozen (trained)
Language layersunfrozen (trained)
Learning rate5e-5
LR schedulercosine
Warmup ratio0.05
Weight decay0.01
Max grad norm0.3
Optimizeradamw_8bit
Effective batch size8 (2 × 4 grad_accum)
Epochs2
Max sequence length8192
Precisionbf16
HardwareNVIDIA A100 80GB
Training time98 min
Final train loss0.286

Framework

  • Unsloth for memory-efficient fine-tuning (2× faster, 60% less VRAM)
  • TRL SFTTrainer with UnslothVisionDataCollator
  • transformers 4.57.1, trl 0.22.2

Evaluation

Test set metrics (n=284, V2.2 clean test)

MetricMeanStd
node_f10.9640.073
edge_f10.6890.313
labeled_edge_f10.6090.368
direction_match1.0000.000
parse_success1.0000.000

Per-complexity breakdown

Bucketnnode_f1edge_f1labeled_edge_f1
small (<10 nodes)910.9760.8970.863
medium (10-20 nodes)980.9740.7810.710
large (20+ nodes)950.9410.3960.262

Comparison with prior versions

Versionnode_f1edge_f1labeled_edge_f1Notes
V10.1780.1120.062Baseline (V1.0 dataset)
V30.8250.3360.267V2.0 dataset (BT-inflated test)
V40.8260.4510.382V2.1 dataset (canonicalize bug)
V50.9640.6890.609V2.2 clean dataset, no canonicalize

V5 improves edge_f1 by +53% and labeled_edge_f1 by +59% over V4 by:

  1. Using V2.2 dataset (alt-syntax normalized to pipe syntax)
  2. Disabling canonicalize_mermaid (model learns descriptive IDs from raw data)

Intended use

  • Convert flowchart screenshots/diagrams to executable Mermaid code
  • Build AI-assisted flowchart editing tools
  • Document understanding for technical diagrams
  • Pipeline component for diagram-to-text question answering

Limitations

  1. TD direction only. Model trained exclusively on top-down flowcharts. Bottom-top, left-right, right-left flows may have lower accuracy.
  2. Edge accuracy drops on large flowcharts (≥20 nodes): edge_f1 drops to 0.40 vs 0.90 for small. Use complexity-aware confidence thresholds in production.
  3. Synthetic training data. All 2,872 training images are LLM-generated + Mermaid-rendered. Real-world handwritten or scanned flowcharts may show domain gap.
  4. English labels only. Training labels are 100% English. Other languages not tested.
  5. Mermaid output only. Does not support PlantUML, Graphviz, or other diagram DSLs.
  6. No subgraph support. Training data has minimal subgraph usage; complex hierarchical diagrams may flatten.

Training pipeline

Qwen3-VL-8B base model
    ↓
LoRA r=32 α=32 (vision + language unfrozen)
    ↓
Train on V2.2 dataset (2,304 samples, 2 epochs, ~98 min on A100)
    ↓
Merged 16-bit checkpoint (~16 GB)
    ↓
This model

Output format

graph TD
    Start([Start]) --> CheckInput{Is input valid?}
    CheckInput -->|Yes| ProcessData[Process data]
    CheckInput -->|No| ShowError[Show error]
    ProcessData --> End([End])
    ShowError --> End

Format characteristics:

  • graph TD direction (top-down)
  • Descriptive node IDs (Start, CheckInput, not A, B)
  • Pipe-style edge labels: -->|label|
  • Standard shapes: [rect], {rhombus}, (rounded), ([stadium])

Citation

@misc{qwen3vl-flowchart-mermaid-v5,
  title={Qwen3-VL-8B Fine-tuned for Flowchart-to-Mermaid Generation},
  author={Nguyen Hai Dang},
  year={2026},
  howpublished={\url{https://huggingface.co/DangIT02/qwen3vl-flowchart-to-mermaid-v5}},
}

License

Apache 2.0 (inherited from Qwen3-VL base).

Acknowledgments

  • Qwen team for Qwen3-VL-8B base model
  • Unsloth for efficient fine-tuning framework
  • Mermaid.js for the diagram syntax specification

Fuentes

1 fuente
Hugging FacePrincipalVersión fc8aa8973afcdc67892b8809a761e4d283122ad0
huggingface.co/DangIT02/qwen3vl-flowchart-to-mermaid-v5/tree/fc8aa8973afcdc67892b8809a761e4d283122ad0

Verificado 2 nov

Download files

Model · 4 weight files

All files listed in the provider index are present.

Artefactos del modelo

4 artefactos

model-00001-of-00004.safetensors

safetensors · 4,57 GB · SHA-256 72d5c8d26133…fd1c · Hugging Face

Download shard

model-00002-of-00004.safetensors

safetensors · 4,58 GB · SHA-256 955327be3718…bff9 · Hugging Face

Download shard

model-00003-of-00004.safetensors

safetensors · 4,66 GB · SHA-256 28a3c99ab6bd…f90a · Hugging Face

Download shard

model-00004-of-00004.safetensors

safetensors · 2,53 GB · SHA-256 35799bc5c5a5…b502 · Hugging Face

Download shard

Extractos de fuentes

3 extractos

--- license: apache-2.0 base_model: unsloth/Qwen3-VL-8B-Instruct tags: - vision-language - image-to-text - flowchart - mermaid - diagram-understanding - fine-tuned - qwen3-vl - lora - unsloth - vllm language: - en pipeline_tag: image-to-text library_name: transformers datasets: - DangIT02/flowchart-to-mermaid_v2_2 --- # Qwen3-VL-8B Flowchart → Mermaid (v5) Fine-tuned **Qwen3-VL-8B-Instruct** for converting flowchart images into Mermaid code. ## TL;DR | Metric | V5 | |--------|-----| | **node_f1** | **0.964** | | **edge_f1** | **0.689** | | labeled_edge_f1 | 0.609 | | direction_match | 1.000 | | parse_success | 1.000 | ## Quick start (vLLM) ```bash vllm serve DangIT02/qwen3vl-flowchart-to-mermaid-v5 \ --port 8000 \ --max-model-len 8192 \ --limit-mm-per-prompt image=1 \ --gpu-memory-utilization 0.85 ``` ```python from openai import OpenAI import base64 client = OpenAI(base_url="http://localhost:8000/v1", api_key="empty") with open("flowchart.png", "rb") as f: img_b64 = base64.b64encode(f.read()).decode() response = client.chat.completions.create( model="DangIT02/qwen3vl-flowchart-to-mermaid-v5", messages=[{ "role": "user", "content": [ {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_b64}"}}, {"type": "text", "text": "Convert this flowchart diagram to Mermaid code."}, ], }], temperature=0.0, max_tokens=2048, ) print(response.choices[0].message.content) ``` ## Quick start (transformers) ```python from transformers import AutoModelForImageTextToText, AutoProcessor import torch from PIL import Image model_id = "DangIT02/qwen3vl-flowchart-to-mermaid-v5" model = AutoModelForImageTextToText.from_pretrained(model_id, dtype=torch.bfloat16, device_map="auto") processor = AutoProcessor.from_pretrained(model_id) image = Image.open("flowchart.png").convert("RGB") messages = [{ "role": "user", "content": [ {"type": "image", "image": image}, {"type": "text", "text": "Convert this flowchart diagram to Mermaid code."}, ], }] inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True, return_tensors="pt", return_dict=True).to("cuda") output = model.generate(**inputs, max_new_tokens=2048, do_sample=False) print(processor.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)) ``` ## Model details - **Base model:** [unsloth/Qwen3-VL-8B-Instruct](https://h...

Source context: 36 downloads · 0 likes · Pipeline image-to-text · Library transformers · Repo DangIT02/qwen3vl-flowchart-to-mermaid-v5

Source context: 25 downloads · 0 likes · Pipeline image-to-text · Library transformers · Repo DangIT02/qwen3vl-flowchart-to-mermaid-v5