Instructions to use Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited") model = AutoModelForMultimodalLM.from_pretrained("Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited
- SGLang
How to use Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited with Docker Model Runner:
docker model run hf.co/Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited
Llama-3.2-11B-Vision-Instruct โ gradient-free safety weight edit (WSP / VLGuard)
Built with Llama. This is meta-llama/Llama-3.2-11B-Vision-Instruct (revision
9eb2daaa8597bf192a8b0e73f848f3a102794df5) with a direct, gradient-free weight edit that makes the model
refuse multimodal jailbreak attacks more reliably (harmful images, harmful requests hidden in images,
adversarial text wrappers) while leaving benign behaviour unchanged. No fine-tuning, no gradients and no
optimizer were used; the edit was designed by an LLM editing agent (Claude Fable 5.1) from activation
statistics using at most 500 forward passes of the model.
The edit
30 rank-1 updates of the form W โ W + r rแต W on the attention-output (self_attn.o_proj /
cross_attn.o_proj) and MLP-output (mlp.down_proj) matrices of decoder layers 6โ11 and 16โ24 of the
language model, where r is the unit difference-of-means "harm direction" (harmful โ benign prompts,
final prompt position) at the residual boundary each matrix writes to. Each update doubles the component of
that matrix's output along the harm/refusal direction. All other tensors are bit-identical to the original
checkpoint; tensor names, shapes, dtypes (bf16) and shard layout are unchanged, so the model loads exactly
like the original. EDIT_REPORT.json lists every edited tensor with its change magnitude (1.7โ8.9 %
relative Frobenius change per matrix, 3.5 % overall).
Results on the VLGuard test set (1,558 records, greedy decoding, 256 new tokens, single run)
| metric | original | edited |
|---|---|---|
| attack success rate (keyword judge), unsafe image + instruction | 0.600 | 0.333 |
| attack success rate (keyword judge), safe image + unsafe instruction | 0.235 | 0.088 |
| attack success rate (keyword judge), all harmful | 0.396 | 0.196 |
| attack success rate (LLM judge), all harmful | 0.471 | 0.283 |
| over-refusal on safe inputs (keyword judge) | 0.000 | 0.000 |
| judged helpfulness on safe inputs | 0.842 | 0.799 |
| NLL of reference safe answers (nats/token) | 1.931 | 1.953 |
Known limitations: slightly shorter / less detailed descriptions on some benign image questions (the helpfulness drop above); raised refusal tendency on benign images that only contain rendered text; descriptive requests about explicit or violent images are still often answered. Evaluated with greedy decoding only.
Usage
import torch
from transformers import AutoProcessor, MllamaForConditionalGeneration
model = MllamaForConditionalGeneration.from_pretrained("Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited", dtype=torch.bfloat16, device_map="cuda")
processor = AutoProcessor.from_pretrained("Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited")
Use the model's own chat template with the image first and the text second; no system prompt is needed.
License and attribution
The Llama 3.2 Community License (LICENSE.txt) and Acceptable Use Policy (USE_POLICY.md) of the base
model apply; this repository redistributes modified Llama 3.2 weights under those terms. The original
model card is reproduced in ORIGINAL_README.md. The VLGuard dataset (Zong et al., ICML 2024) was used
for development and evaluation.
- Downloads last month
- 26
Model tree for Adeely93/Llama-3.2-11B-Vision-Instruct-WSP-VLGuard-edited
Base model
meta-llama/Llama-3.2-11B-Vision-Instruct