Views
No views yet
transformers and peft.1pip install torch transformers peft pillow datasets
2# If you want to use Unsloth for faster inference, install it via:
3# pip install unsloth1from unsloth import FastVisionModel
2import torch
3from datasets import load_dataset
4
5# Load model and processor
6model, processor = FastVisionModel.from_pretrained(
7 model_name="GRAI-UNSTPB/Llama-3.2-11B-Vision-Instruct-RoVQA-lora-v1",
8 load_in_4bit=True
9)
10FastVisionModel.for_inference(model)
11
12# Load a test sample directly from the Flickr30K-RoQA-v1 dataset
13dataset = load_dataset("GRAI-UNSTPB/Flickr30K-RoQA-v1", split="test")
14sample = dataset[0]
15image = sample["image"]
16question = sample["question"]
17
18messages = [
19 {
20 "role": "user",
21 "content": [
22 {"type": "image", "image": image},
23 {"type": "text", "text": f"Răspunde la întrebare: {question}"}
24 ]
25 }
26]
27
28input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
29inputs = processor(images=image, text=input_text, return_tensors="pt").to("cuda")
30
31# Generate response
32outputs = model.generate(**inputs, max_new_tokens=64)
33# Decode only the generated response (excluding the prompt)
34prompt_len = inputs.input_ids.shape[1]
35response = processor.decode(outputs[0][prompt_len:], skip_special_tokens=True)
36print(response)1from transformers import MllamaForConditionalGeneration, AutoProcessor
2from peft import PeftModel
3import torch
4from PIL import Image
5
6# Load base model and processor
7base_model_id = "unsloth/llama-3.2-11b-vision-instruct-unsloth-bnb-4bit"
8processor = AutoProcessor.from_pretrained(base_model_id)
9
10model = MllamaForConditionalGeneration.from_pretrained(
11 base_model_id,
12 torch_dtype=torch.bfloat16,
13 device_map="auto"
14)
15
16# Load LoRA adapter
17model = PeftModel.from_pretrained(model, "GRAI-UNSTPB/Llama-3.2-11B-Vision-Instruct-RoVQA-lora-v1")
18
19# Inference setup follows the same structure as above...| Model | BERTScore F1 (%) | ROUGE-L F1 (%) | BLEU |
|---|---|---|---|
| LLaMA 3.2 11B Vision (Base) | 56.37 | 11.58 | 0.90 |
| LLaMA 3.2 11B Vision + RoVQA LoRA (Ours) | 70.32 | 38.70 | 21.14 |
| Model | BERTScore F1 (%) | ROUGE-L F1 (%) | BLEU |
|---|---|---|---|
| LLaMA 3.2 11B Vision (Base) | 57.22 | 14.00 | 1.53 |
| LLaMA 3.2 11B Vision + RoVQA LoRA (Ours) | 66.69 | 28.60 | 6.99 |
1@article{dima2025parameter,
2 title={Parameter-Efficient Multimodal Instruction Tuning for Romanian Vision--Language Models},
3 author={Dima, George-Andrei and Smădu, Răzvan-Alexandru and Cercel, Dumitru-Clementin},
4 journal={arXiv preprint arXiv:2512.14926},
5 year={2025}
6}