Views
No views yet
qwen2-vl-pagoda-lora/
├── qwen3_vl_lora_finetuning.ipynb # Main training notebook
├── README.md # This file
├── LICENSE # Apache 2.0 License
├── .gitignore # Git ignore file
└── qwen3-vl-2b-pagoda-lora/ # Output directory (after training)
├── adapter_config.json # LoRA configuration
├── adapter_model.safetensors # LoRA weights
├── README.md # Model card
└── ... # Other model files| Parameter | Value |
|---|---|
| Base Model | Qwen2-VL-2B-Instruct |
| Dataset | 1000 samples from Pagoda dataset |
| Train/Val Split | 900 / 100 (90% / 10%) |
| LoRA Rank | 8 |
| LoRA Alpha | 16 |
| Batch Size | 1 (effective: 8 with gradient accumulation) |
| Learning Rate | 2e-4 |
| Epochs | 1 |
| Optimizer | PagedAdamW 8-bit |
| Precision | bfloat16 |
| Training Time | ~15-20 minutes |
1git clone https://github.com/YOUR_USERNAME/qwen2-vl-pagoda-lora.git
2cd qwen2-vl-pagoda-lorapip install -r requirements.txt1pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
2pip install transformers accelerate datasets peft bitsandbytes pillow qwen-vl-utilshuggingface-cli loginjupyter notebook qwen3_vl_lora_finetuning.ipynb1from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
2from peft import PeftModel
3from PIL import Image
4
5# Load model
6base_model = Qwen2VLForConditionalGeneration.from_pretrained(
7 "Qwen/Qwen2-VL-2B-Instruct",
8 device_map="auto",
9 trust_remote_code=True
10)
11model = PeftModel.from_pretrained(base_model, "./qwen3-vl-2b-pagoda-lora")
12processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct", trust_remote_code=True)
13
14# Process image
15image = Image.open("your_image.jpg")
16conversation = [{
17 "role": "user",
18 "content": [
19 {"type": "image", "image": image},
20 {"type": "text", "text": "Describe this image."}
21 ]
22}]
23
24text = processor.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
25inputs = processor(text=[text], images=[[image]], return_tensors="pt").to(model.device)
26
27output = model.generate(**inputs, max_new_tokens=256)
28print(processor.batch_decode(output, skip_special_tokens=True)[0])1@misc{qwen2vl-pagoda-lora,
2 author = {Your Name},
3 title = {Fine-tuning Qwen2-VL-2B on Pagoda Dataset with LoRA},
4 year = {2025},
5 publisher = {GitHub},
6 howpublished = {\url{https://github.com/YOUR_USERNAME/qwen2-vl-pagoda-lora}}
7}