Downloads · 30 days
10
23% of all-time downloads
zodiac2525/Qwen2.5-VL-Diagrams2SQL-v2
Qwen2.5-VL-Diagrams2SQL-v2 is a text generation model from zodiac2525. Use it when you need the model to write or continue text. It is set up for peft.
A fine-tuned Qwen2.5-VL-3B-Instruct model specialized for converting database schema diagrams into structured JSON format. This model dramatically improves upon the base model's ability to understand and extract infor…
Downloads · 30 days
10
23% of all-time downloads
All-time downloads
43
Public
Parameters
3.8B
7.6 GB on disk
Likes
3
Public
Click a slice to open those files.
.safetensors7.5 GB · 100%
From the Hugging Face model README
A fine-tuned Qwen2.5-VL-3B-Instruct model specialized for converting database schema diagrams into structured JSON format. This model dramatically improves upon the base model's ability to understand and extract information from ER diagrams, database schemas, and other structured database documentation.
This model addresses a common pain point in database documentation and migration projects: manually transcribing database schema diagrams is time-consuming and error-prone. While the base Qwen2.5-VL model struggled with structured diagram interpretation (often missing tables, incorrectly identifying relationships, or producing malformed outputs), this fine-tuned version shows significant improvements across all metrics.
The model uses LoRA (Low-Rank Adaptation) for parameter-efficient fine-tuning, targeting attention layers for optimal performance while maintaining efficiency.
The fine-tuned model shows significant improvements over the base model:
| Metric | Base Qwen2.5-VL | Fine-tuned Model | Improvement |
|---|---|---|---|
| Table Detection Accuracy | 65.2% | 89.7% | +24.5% |
| Relationship Accuracy | 58.9% | 84.3% | +25.4% |
| Overall Schema Score | 62.1% | 87.0% | +24.9% |
| JSON Format Compliance | 78.1% | 96.2% | +18.1% |
This model is designed to:
The model has been trained on diverse schema types including:
pip install transformers torch pillow
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
from PIL import Image
import torch
import json
# Load the fine-tuned model
model_id = "zodiac2525/Qwen2.5-VL-Diagrams2SQL-v2"
processor = AutoProcessor.from_pretrained(model_id)
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Load your ER diagram
image = Image.open("path/to/your/diagram.png").convert("RGB")
# Prepare the input
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "Extract data in JSON format"}
]
}
]
# Process and generate
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[image], return_tensors="pt").to("cuda")
# Generate schema
with torch.no_grad():
generated_ids = model.generate(
**inputs,
max_new_tokens=1024,
do_sample=False,
temperature=0.0
)
# Extract and parse JSON
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
json_start = generated_text.find('{')
if json_start != -1:
schema_json = json.loads(generated_text[json_start:])
print(json.dumps(schema_json, indent=2))
The model outputs JSON schemas in the following structure:
{
"tables": [
{
"name": "users",
"columns": [
{
"name": "id",
"type": "INT",
"constraints": ["PRIMARY KEY", "AUTO_INCREMENT"]
},
{
"name": "email",
"type": "VARCHAR(255)",
"constraints": ["UNIQUE", "NOT NULL"]
}
]
}
],
"relationships": [
{
"from_table": "orders",
"from_column": "user_id",
"to_table": "users",
"to_column": "id",
"relationship_type": "FOREIGN KEY"
}
]
}
The model was fine-tuned on a custom dataset of 400+ database schema diagrams with corresponding JSON annotations, covering various domains and complexity levels.
Fine-tuning Method: LoRA (Low-Rank Adaptation)
Training Hyperparameters:
The model was evaluated on a held-out test set using multiple metrics:
Limitations:
Recommendations:
If you use this model in your research or applications, please cite:
@misc{qwen25vl-diagrams2sql,
title={Qwen2.5-VL-Diagrams2SQL: Fine-tuned Vision-Language Model for Database Schema Extraction},
author={David Nguyen},
year={2024},
howpublished={\url{https://huggingface.co/zodiac2525/Qwen2.5-VL-Diagrams2SQL-v2}}
}
For questions, issues, or collaboration opportunities, please: