Views
No views yet
Qwen/Qwen2-VL-2B-Instruct for Vietnamese textbook image captioning in a narration-style format that is screen-reader friendly aiming to support visually impaired learners.This repo contains only the adapter (not the base model).
Full documentation + end-to-end pipeline (01→05) are on GitHub:
https://github.com/itshoang2024/vi-textbook-caption-qwen2vl
adapter_model.safetensors, adapter_config.json: LoRA adapter weights (PEFT)run_config.json: prompt + generation config used in our pipeline (reproducibility)bbdontcry/vietnamese-image-captioning (test)| Model | Quote-CER ↓ | Concept-Rec ↑ | LLM-Score ↑ | BERTScore ↑ | BLEU-4 ↑ | METEOR ↑ |
|---|---|---|---|---|---|---|
| Qwen2-VL-2B (Zero-shot) | 0.995 | 0.222 | 3.36/10 | 0.671 | 6.30 | 0.142 |
| Qwen2-VL-2B + LoRA (RUN_ID=A) | 0.385 | 0.632 | 5.09/10 | 0.837 | 43.73 | 0.521 |
pip install -U transformers accelerate peft safetensors pillow qwen-vl-utils1import torch
2from peft import PeftModel
3from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
4
5BASE_ID = "Qwen/Qwen2-VL-2B-Instruct"
6ADAPTER_ID = "hoangphann/LoRA-Qwen2-VL-2B-Instruct-captioning"
7
8model = Qwen2VLForConditionalGeneration.from_pretrained(
9 BASE_ID,
10 torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
11 device_map="auto" if torch.cuda.is_available() else None,
12)
13model = PeftModel.from_pretrained(model, ADAPTER_ID)
14model.eval()
15
16processor = AutoProcessor.from_pretrained(BASE_ID)
17print("Loaded LoRA adapter (RUN_ID=A).")For the exact prompt/generation setup used in evaluation, seerun_config.jsonand the Kaggle/GitHub pipeline.
SGK_CanhDieu_TuNhienVaXaHoi_3_page_063.png
| # | Notebook | Open in Kaggle | Output |
|---|---|---|---|
| 1 | Finetune | vn-textbook-qwen2vl-01-adapters | |
| 2 | Inference | vn-textbook-qwen2vl-02-predictions | |
| 3a | Metrics (Light) | vn-textbook-qwen2vl-03-metrics | |
| 3b | Metrics (Heavy) | vn-textbook-qwen2vl-03-metrics | |
| 4 | Merge results | vn-textbook-qwen2vl-04-results | |
| 5 | Demo (Gradio) | - |
Tip: Put these datasets as Kaggle inputs when running the corresponding notebooks.