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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: Qwen/Qwen3-VL-4B-Instruct
|
| 4 |
+
tags:
|
| 5 |
+
- qwen3_vl
|
| 6 |
+
- vision-language
|
| 7 |
+
- multimodal
|
| 8 |
+
- fine-tuned
|
| 9 |
+
- qlora
|
| 10 |
+
- safetensors
|
| 11 |
+
- coding
|
| 12 |
+
- design
|
| 13 |
+
language:
|
| 14 |
+
- id
|
| 15 |
+
- en
|
| 16 |
+
pipeline_tag: image-text-to-text
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
official website snapgate AI : www.snapgate.tech
|
| 20 |
+
|
| 21 |
+
# snapgate-VL-4B
|
| 22 |
+
|
| 23 |
+
**snapgate-VL-4B** adalah model vision-language multimodal hasil fine-tuning dari [Qwen/Qwen3-VL-4B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct) menggunakan metode **QLoRA**, yang dioptimalkan untuk domain **coding** dan **UI/UX design**.
|
| 24 |
+
|
| 25 |
+
Model ini dikembangkan oleh **Snapgate** sebagai asisten AI multimodal yang mampu memahami gambar sekaligus teks, khususnya untuk kebutuhan developer dan desainer.
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## π§ Kemampuan Utama
|
| 30 |
+
|
| 31 |
+
- **Code Generation & Review** β Menulis, menganalisis, debug, dan mengoptimalkan kode (Python, JavaScript, TypeScript, HTML/CSS, SQL, dll.)
|
| 32 |
+
- **UI/UX Design Analysis** β Menganalisis screenshot antarmuka, memberikan saran desain, mengidentifikasi masalah UX
|
| 33 |
+
- **Design to Code** β Mengkonversi mockup, wireframe, atau screenshot UI menjadi kode HTML/CSS/React/Tailwind
|
| 34 |
+
- **Diagram & Architecture** β Memahami diagram alur, arsitektur sistem, ERD
|
| 35 |
+
- **Code from Image** β Membaca dan menjelaskan kode dari screenshot atau foto
|
| 36 |
+
- **Technical Documentation** β Membuat dokumentasi teknis yang jelas dan terstruktur
|
| 37 |
+
- **Bilingual** β Mendukung Bahasa Indonesia dan Inggris
|
| 38 |
+
|
| 39 |
+
---
|
| 40 |
+
|
| 41 |
+
## π§ Detail Training
|
| 42 |
+
|
| 43 |
+
| Parameter | Value |
|
| 44 |
+
|-----------|-------|
|
| 45 |
+
| Base Model | Qwen/Qwen3-VL-4B-Instruct |
|
| 46 |
+
| Method | QLoRA (4-bit NF4) |
|
| 47 |
+
| LoRA Rank | 16 |
|
| 48 |
+
| LoRA Alpha | 32 |
|
| 49 |
+
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
|
| 50 |
+
| Trainable Params | 33,030,144 (0.74%) |
|
| 51 |
+
| Epochs | 3 |
|
| 52 |
+
| Learning Rate | 1e-4 |
|
| 53 |
+
| Batch Size | 1 (grad accum: 8) |
|
| 54 |
+
| Optimizer | paged_adamw_8bit |
|
| 55 |
+
| Precision | bfloat16 |
|
| 56 |
+
| Hardware | NVIDIA T4 (Google Colab) |
|
| 57 |
+
|
| 58 |
+
---
|
| 59 |
+
|
| 60 |
+
## π Cara Penggunaan
|
| 61 |
+
|
| 62 |
+
### Install Dependencies
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
pip install transformers>=4.51.0 accelerate>=0.30.0 qwen-vl-utils
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
### Inference dengan Gambar
|
| 69 |
+
|
| 70 |
+
```python
|
| 71 |
+
from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
|
| 72 |
+
from qwen_vl_utils import process_vision_info
|
| 73 |
+
import torch
|
| 74 |
+
|
| 75 |
+
model_id = "kadalicious22/snapgate-VL-4B"
|
| 76 |
+
|
| 77 |
+
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
| 78 |
+
model = Qwen3VLForConditionalGeneration.from_pretrained(
|
| 79 |
+
model_id,
|
| 80 |
+
torch_dtype=torch.bfloat16,
|
| 81 |
+
device_map="auto",
|
| 82 |
+
trust_remote_code=True,
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
SYSTEM_PROMPT = """Kamu adalah Snapgate AI, asisten AI multimodal milik Snapgate yang ahli dalam bidang coding dan design."""
|
| 86 |
+
|
| 87 |
+
messages = [
|
| 88 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 89 |
+
{
|
| 90 |
+
"role": "user",
|
| 91 |
+
"content": [
|
| 92 |
+
{"type": "image", "image": "path/to/your/image.png"},
|
| 93 |
+
{"type": "text", "text": "Analisis UI dari gambar ini dan buat kode HTML/CSS-nya."},
|
| 94 |
+
],
|
| 95 |
+
},
|
| 96 |
+
]
|
| 97 |
+
|
| 98 |
+
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 99 |
+
image_inputs, video_inputs = process_vision_info(messages)
|
| 100 |
+
inputs = processor(
|
| 101 |
+
text=[text],
|
| 102 |
+
images=image_inputs,
|
| 103 |
+
videos=video_inputs,
|
| 104 |
+
return_tensors="pt",
|
| 105 |
+
).to(model.device)
|
| 106 |
+
|
| 107 |
+
with torch.no_grad():
|
| 108 |
+
output_ids = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
|
| 109 |
+
|
| 110 |
+
generated = output_ids[:, inputs["input_ids"].shape[1]:]
|
| 111 |
+
response = processor.batch_decode(generated, skip_special_tokens=True)[0]
|
| 112 |
+
print(response)
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
### Inference Teks Saja
|
| 116 |
+
|
| 117 |
+
```python
|
| 118 |
+
messages = [
|
| 119 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 120 |
+
{"role": "user", "content": "Buatkan fungsi Python untuk validasi email."},
|
| 121 |
+
]
|
| 122 |
+
|
| 123 |
+
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 124 |
+
inputs = processor(text=[text], return_tensors="pt").to(model.device)
|
| 125 |
+
|
| 126 |
+
with torch.no_grad():
|
| 127 |
+
output_ids = model.generate(**inputs, max_new_tokens=1024)
|
| 128 |
+
|
| 129 |
+
response = processor.batch_decode(output_ids[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0]
|
| 130 |
+
print(response)
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
---
|
| 134 |
+
|
| 135 |
+
## π Training Loss
|
| 136 |
+
|
| 137 |
+
| Step | Loss |
|
| 138 |
+
|------|------|
|
| 139 |
+
| 5 | 2.419 |
|
| 140 |
+
| 10 | 2.132 |
|
| 141 |
+
| 15 | 1.918 |
|
| 142 |
+
| 20 | 1.736 |
|
| 143 |
+
| 25 | 1.640 |
|
| 144 |
+
| 30 | 1.663 |
|
| 145 |
+
| 35 | 1.584 |
|
| 146 |
+
|
| 147 |
+
Loss turun konsisten dari **2.42 β 1.58** selama training.
|
| 148 |
+
|
| 149 |
+
---
|
| 150 |
+
|
| 151 |
+
## β οΈ Limitasi
|
| 152 |
+
|
| 153 |
+
- Model di-training pada dataset internal Snapgate yang relatif kecil β performa akan meningkat seiring bertambahnya data training
|
| 154 |
+
- Dioptimalkan untuk Bahasa Indonesia dan Inggris
|
| 155 |
+
- Performa terbaik pada task coding dan analisis UI; kurang optimal untuk domain lain
|
| 156 |
+
|
| 157 |
+
---
|
| 158 |
+
|
| 159 |
+
## π Lisensi
|
| 160 |
+
|
| 161 |
+
Model ini mengikuti lisensi **Apache 2.0** sesuai dengan base model Qwen3-VL-4B-Instruct.
|
| 162 |
+
|
| 163 |
+
---
|
| 164 |
+
|
| 165 |
+
## π Links
|
| 166 |
+
|
| 167 |
+
- π Website: [snapgate.tech](https://snapgate.tech)
|
| 168 |
+
- π€ Base Model: [Qwen/Qwen3-VL-4B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct)
|
| 169 |
+
|
| 170 |
+
---
|
| 171 |
+
|
| 172 |
+
*Dibuat dengan β€οΈ oleh tim Snapgate*
|