ADAPT-Qwen2.5-VL-7B-DPEv3
LoRA adapter for safety alignment of multimodal language models
2 min readupdated
This adapter solves the problem of misevolution, where autonomously learning multimodal models lose safety, robustness, and privacy. The model is based on hongruijia/Qwen2.5-VL-7B-Instruct_DPE_v3 and trained using the ADAPT framework based on Direct Preference Optimization (fine-tuning method using human or model preferences) with a reflexive margin signal from Skywork Reward. Unlike standard DPO, the new release uses only 1,000 multimodal preference pairs for targeted safety recovery without degrading general capabilities. The adapter will be useful for researchers and developers working on the safety of vision-language AI agents.
Key features
- Base model: Built on the Qwen2.5-VL-7B vision-language model with a Vision-Language format architecture (image-text-to-text).
- Training method: Uses Intent-Aware Margin-DPO (preference optimization method considering intent margin) with a gamma coefficient of 0.9.
- Efficiency: Trained on just 1,000 pairs from the SPA-VL safety dataset, showing superiority over baseline models on benchmarks.
- Integration: Released in PEFT LoRA format with an adaptation rank of r=16 and support for major projection modules.
What you can do
- Secure image analysis: Apply the model in computer vision pipelines and text multimodal tasks with strict response safety control.
- Run via Transformers: Connect the adapter on top of the base model using the
transformersandpeftlibraries to generate descriptions and answers from images. - Serving in vLLM: Deploy the model in a production environment with support for dynamic LoRA module loading via the
vLLMbackend. - Safety research: Use the checkpoint for scientific experiments on minimizing hallucinations and vulnerabilities in multimodal agents.
Example
import torch
from PIL import Image
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
from peft import PeftModel
base_model_id = "hongruijia/Qwen2.5-VL-7B-Instruct_DPE_v3"
adapter_id = "ADAPT-sea/ADAPT-Qwen2.5-VL-7B-DPEv3"
processor = AutoProcessor.from_pretrained(adapter_id)
base_model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
base_model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()
image = Image.open("example.jpg").convert("RGB")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "Describe what you see in this image."},
],
}
]
prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[prompt], images=[image], return_tensors="pt").to(model.device)
with torch.no_grad():
output_ids = model.generate(**inputs, max_new_tokens=256)
generated_ids = output_ids[:, inputs["input_ids"].shape[1]:]
print(processor.batch_decode(generated_ids, skip_special_tokens=True)[0])
Read more
DetailsBenchmarks: on HarmBench-Multimodal, it outperforms the base model and standard DPO (Pass@1: 0.45 vs 0.30 for base; TRACER Safety: 0.58 vs 0.44).
Training: 3 epochs, batch size 8, learning rate 1e-5, maximum sequence length 6144 tokens.
Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj.
License: Apache-2.0.










Comments