玩模型开放模型 · 清晰来源 · 自主选择
返回模型目录
natong19 /

Qwen2-VL-7B-Instruct-abliterated

HF 源站

natong19/Qwen2-VL-7B-Instruct-abliterated is an uncensored open-source model hosted on Hugging Face.

Image-Text-to-TextsafetensorsEnglishLicense: apache-2.07Btransformersqwen2_vlmultimodalconversationaltext-generation-inference
README.md说明 / 使用方法

license: apache-2.0 language:

  • en pipeline_tag: image-text-to-text tags:
  • multimodal library_name: transformers

Qwen2-VL-7B-Instruct-abliterated

Introduction

Abliterated version of Qwen2-VL-7B-Instruct, an advanced multimodal large language model. Weight orthogonalization has been applied to inhibit the model's ability to express refusals while preserving the model's text and multimodal capabilities. Nonetheless, the model may still refuse your request, misunderstand your intent, or provide unsolicited advice regarding ethics or safety.

Requirements

If you encounter errors such as KeyError: 'qwen2_vl' or ImportError: cannot import name 'Qwen2VLForConditionalGeneration' from 'transformers', you can try building transformers from source with command pip install git+https://github.com/huggingface/transformers

Quickstart

from PIL import Image
import requests
import torch
from torchvision import io
from typing import Dict
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor

path = "natong19/Qwen2-VL-7B-Instruct-abliterated"

# Load the model in half-precision on the available device(s)
model = Qwen2VLForConditionalGeneration.from_pretrained(
    path, torch_dtype="auto", device_map="auto"
)

min_pixels = 256*28*28
max_pixels = 1280*28*28
processor = AutoProcessor.from_pretrained(path, min_pixels=min_pixels, max_pixels=max_pixels)

# Image
url = "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
image = Image.open(requests.get(url, stream=True).raw)

conversation = [
    {
        "role": "user",
        "content": [
            {
                "type": "image",
            },
            {"type": "text", "text": "Describe this image."},
        ],
    }
]

# Preprocess the inputs
text_prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
# Excepted output: '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Describe this image.<|im_end|>\n<|im_start|>assistant\n'

inputs = processor(
    text=[text_prompt], images=[image], padding=True, return_tensors="pt"
)
inputs = inputs.to("cuda")

# Inference: Generation of the output
output_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids = [
    output_ids[len(input_ids) :]
    for input_ids, output_ids in zip(inputs.input_ids, output_ids)
]
output_text = processor.batch_decode(
    generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
)
print(output_text)

The above code can be run on 24GB VRAM. For more usage examples, such as multi-image inference, video inference and batch inference, please refer to the Qwen2-VL-7B-Instruct repo.

Evaluation

Evaluation framework: lm-evaluation-harness 0.4.2 and lmms-eval 0.2.1

DatasetsQwen2-VL-7B-InstructQwen2-VL-7B-Instruct-abliterated
Text benchmarks
ARC (25-shot)57.857.8
MMLU (5-shot)69.768.4
TruthfulQA (0-shot)49.545.4
Winogrande (5-shot)72.672.8
Multimodal benchmarks
AI2D (lite)78.879.8
GQA (lite)73.273.6
MMBench (EN dev, lite)84.182.6
MMMU (val)50.851.6
OCRBench77.778.1
VQAv2 (val, lite)79.979.8
HUGGING FACE

上游数据

HF 下载量105
HF 点赞量0

HF 下载量为源站最近 30 天统计,与本站点击分开。

SITE STATS

本站统计

下载点击—
请求数—
匿名去重—最近 7 天—

本站下载量记录按钮点击,不代表下载完成;短时连点会去重。

来源与版本

作者
natong19
最近更新
2024/09/18
最新创建
2024/09/18
HF 趋势
未知
数据快照
2026/09/17
版本
未知
许可证
apache-2.0