HuggingFaceM4/ChartQA
Viewer β’ Updated β’ 32.7k β’ 34.5k β’ 71
How to use lognat0704/qwen2-7b-instruct-trl-sft-ChartQA with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
model = PeftModel.from_pretrained(base_model, "lognat0704/qwen2-7b-instruct-trl-sft-ChartQA")A PEFT LoRA adapter that fine-tunes
Qwen/Qwen2-VL-7B-Instruct for chart
understanding and visual question answering on the
ChartQA dataset, trained with the
TRL SFTTrainer.
Given a chart image and a natural-language question, the model reasons over the chart's visual elements (bars, lines, axes, labels) to produce an answer.
| Setting | Value |
|---|---|
| Base model | Qwen/Qwen2-VL-7B-Instruct |
| Method | Supervised fine-tuning (TRL SFTTrainer) |
| Adapter | LoRA (PEFT) |
Rank (r) |
8 |
lora_alpha |
16 |
| Target modules | q_proj, v_proj |
| Dataset | ChartQA |
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
from peft import PeftModel
import torch
base = Qwen2VLForConditionalGeneration.from_pretrained(
"Qwen/Qwen2-VL-7B-Instruct", torch_dtype=torch.bfloat16, device_map="auto"
)
model = PeftModel.from_pretrained(base, "lognat0704/qwen2-7b-instruct-trl-sft-ChartQA")
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
messages = [{
"role": "user",
"content": [
{"type": "image", "image": "chart.png"},
{"type": "text", "text": "What is the highest value in the chart?"},
],
}]
# See the Qwen2-VL docs for full multimodal preprocessing.
Qwen/Qwen2-VL-7B-Instruct.