Views
No views yet

Qwen3-VL-4B-Instruct-abliterated is an abliterated (v1.0) variant of Qwen3-VL-4B-Instruct, tailored for Abliterated Reasoning and Captioning. This model is designed to generate detailed and descriptive captions, as well as reasoning outputs, across a wide range of visual and multimodal contexts—including complex, sensitive, or nuanced content—while supporting diverse aspect ratios and resolutions.

1from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
2from qwen_vl_utils import process_vision_info
3import torch
4
5model = Qwen3VLForConditionalGeneration.from_pretrained(
6 "prithivMLmods/Qwen3-VL-4B-Instruct-abliterated-v1", torch_dtype="auto", device_map="auto"
7)
8
9processor = AutoProcessor.from_pretrained("prithivMLmods/Qwen3-VL-4B-Instruct-abliterated-v1")
10
11messages = [
12 {
13 "role": "user",
14 "content": [
15 {
16 "type": "image",
17 "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
18 },
19 {"type": "text", "text": "Provide a detailed caption and reasoning for this image."},
20 ],
21 }
22]
23
24text = processor.apply_chat_template(
25 messages, tokenize=False, add_generation_prompt=True
26)
27image_inputs, video_inputs = process_vision_info(messages)
28inputs = processor(
29 text=[text],
30 images=image_inputs,
31 videos=video_inputs,
32 padding=True,
33 return_tensors="pt",
34)
35inputs = inputs.to("cuda")
36
37generated_ids = model.generate(**inputs, max_new_tokens=128)
38generated_ids_trimmed = [
39 out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
40]
41output_text = processor.batch_decode(
42 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
43)
44print(output_text)