Downloads · 30 days
10
13% of all-time downloads
Susant-Achary/SmolVLM2-500M-Video-Instruct-vqav2
SmolVLM2-500M-Video-Instruct-vqav2 is a visual question answering model from Susant-Achary. Use it for the visual question answering task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
This model is a fine-tuned version of HuggingFaceTB/SmolVLM2-500M-Video-Instruct on the jinaai/table-vqa dataset.
Downloads · 30 days
10
13% of all-time downloads
All-time downloads
76
Public
Repo size
19.2 MB
Likes
0
Public
Click a slice to open those files.
.safetensors19.2 MB · 100%
From the Hugging Face model README
This model is a fine-tuned version of HuggingFaceTB/SmolVLM2-500M-Video-Instruct on the jinaai/table-vqa dataset.
This model is a SmolVLM2-500M-Video-Instruct model fine-tuned for Visual Question Answering on table images using the jinaai/table-vqa dataset. It was fine-tuned using QLoRA for efficient training on consumer GPUs.
This model is intended for Visual Question Answering tasks specifically on images containing tables. It can be used to answer questions about the content of tables within images.
Limitations:
The model was trained on a subset of the jinaai/table-vqa dataset. The training dataset size is 800 examples, and the test dataset size is 200 examples.
The model was fine-tuned using the QLoRA method with the following configuration:
r=8lora_alpha=8lora_dropout=0.1target_modules=['down_proj','o_proj','k_proj','q_proj','gate_proj','up_proj','v_proj']use_dora=Falseinit_lora_weights="gaussian"bnb_4bit_use_double_quant=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.bfloat16)The following hyperparameters were used during training:
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoProcessor, Idefics3ForConditionalGeneration, BitsAndBytesConfig
from PIL import Image
import requests
# Define the base model and the fine-tuned adapter repository
base_model_id = "HuggingFaceTB/SmolVLM2-500M-Video-Instruct"
adapter_model_id = "Susant-Achary/SmolVLM2-500M-Video-Instruct-vqav2"
# Load the processor from the base model
processor = AutoProcessor.from_pretrained(base_model_id)
# Load the base model with quantization
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
model = Idefics3ForConditionalGeneration.from_pretrained(
base_model_id,
quantization_config=bnb_config,
device_map="auto"
)
# Load the adapter and add it to the base model
model = PeftModel.from_pretrained(model, adapter_model_id)
# Prepare an example image and question
# You can replace this with your own image and question
url = "/content/VQA-20-standard-test-set-results-comparison-of-state-of-the-art-methods.png"
image = Image.open(url)
question = "What is in the image?"
# Prepare the input for the model
messages = [
{
"role": "user",
"content": [
{"type": "text", "text": "Answer briefly."},
{"type": "image"},
{"type": "text", "text": question}
]
},
{
"role": "assistant",
"content": [
{"type": "text", "text": None}
]
}
]
prompt = processor.apply_chat_template(messages, add_generation_prompt=False)
inputs = processor(text=[prompt], images=[image], return_tensors="pt").to(model.device) # Move inputs to model device
# Generate a response
generated_ids = model.generate(**inputs, max_new_tokens=100)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
# Print the generated response
print(generated_text)