GitHub

LoRA Adapter - Vietnamese Textbook (SGK) Narration Captioning

This repository provides LoRA adapter weights only finetuned from 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

Contents

  • adapter_model.safetensors, adapter_config.json: LoRA adapter weights (PEFT)
  • run_config.json: prompt + generation config used in our pipeline (reproducibility)

Benchmark (test split)

Dataset: 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

Quickstart (load adapter)

Open In Colab

pip install -U transformers accelerate peft safetensors pillow qwen-vl-utils
import torch
from peft import PeftModel
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor

BASE_ID = "Qwen/Qwen2-VL-2B-Instruct"
ADAPTER_ID = "hoangphann/LoRA-Qwen2-VL-2B-Instruct-captioning"

model = Qwen2VLForConditionalGeneration.from_pretrained(
    BASE_ID,
    torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
    device_map="auto" if torch.cuda.is_available() else None,
)
model = PeftModel.from_pretrained(model, ADAPTER_ID)
model.eval()

processor = AutoProcessor.from_pretrained(BASE_ID)
print("Loaded LoRA adapter (RUN_ID=A).")

For the exact prompt/generation setup used in evaluation, see run_config.json and the Kaggle/GitHub pipeline.

Example (Textbook page → narration-style caption)

  • SGK_CanhDieu_TuNhienVaXaHoi_3_page_063.png

    SGK example page
Model output

Phía trên cùng là câu hỏi bài tập số 2: "2. Cây nào có rễ cọc, cây nào có rễ chìm trong các hình dưới đây?". Bên dưới là 4 hình minh họa được đánh số thứ tự: - Hình 1 ở góc trên bên trái: Vẽ một cây xoài. Cây có thân và lá, thân cây có rễ. Bên dưới hình là nhãn: "1 Cây xoài". - Hình 2 ở góc trên bên phải: Vẽ một cây lúa. Cây có thân và lá, thân cây có rễ. Bên dưới hình là nhãn: "2 Cây lúa". - Hình 3 ở góc dưới bên trái: Vẽ một cây ngô. Cây có thân và lá, thân cây có rễ. Bên dưới hình là nhãn: "3 Cây ngô". - Hình 4 ở góc dưới bên phải: Vẽ một cây cam. Cây có thân và lá, thân cây có rễ. Bên dưới hình là nhãn: "4 Cây cam". Phía dưới các hình minh họa là biểu tượng dấu hỏi chấm màu đỏ cam kèm câu hỏi: "Kể tên một số cây khác có rễ cọc, rễ chìm mà em biết.". Góc dưới cùng bên trái trang sách có số trang "62". Dưới cùng là dòng chữ mờ "Đọc sách tại hoc10.vn".

Kaggle notebooks (final pipeline 01→05)

# Notebook Open in Kaggle Output
1 Finetune Open in Kaggle vn-textbook-qwen2vl-01-adapters
2 Inference Open in Kaggle vn-textbook-qwen2vl-02-predictions
3a Metrics (Light) Open in Kaggle vn-textbook-qwen2vl-03-metrics
3b Metrics (Heavy) Open in Kaggle vn-textbook-qwen2vl-03-metrics
4 Merge results Open in Kaggle vn-textbook-qwen2vl-04-results
5 Demo (Gradio) Open in Kaggle -

Tip: Put these datasets as Kaggle inputs when running the corresponding notebooks.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for hoangphann/LoRA-Qwen2-VL-2B-Instruct-captioning

Base model

Qwen/Qwen2-VL-2B
Adapter
(108)
this model

Dataset used to train hoangphann/LoRA-Qwen2-VL-2B-Instruct-captioning