File size: 3,210 Bytes
7f37a60 f3b955d 7f37a60 f3b955d 7f37a60 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
---
license: other
license_name: qwen
license_link: https://huggingface.co/huihui-ai/QVQ-72B-Preview-abliterated-GPTQ-Int4/blob/main/LICENSE
language:
- en
pipeline_tag: image-text-to-text
base_model: huihui-ai/QVQ-72B-Preview-abliterated
tags:
- abliterated
- uncensored
- chat
library_name: transformers
---
This is a GPTQ-quantized 4-bit version of [huihui-ai/QVQ-72B-Preview-abliterated](https://huggingface.co/huihui-ai/QVQ-72B-Preview-abliterated).
This is just the quantification test for GPTQ, with only one dataset: "gptqmodel is an easy-to-use model quantization library with user-friendly apis, based on GPTQ algorithm.".
If you need your own dataset, please contact us: support@huihui.ai
## Usage
We offer a toolkit to help you handle various types of visual input more conveniently. This includes base64, URLs, and interleaved images and videos. You can install it using the following command:
```bash
pip install qwen-vl-utils
```
Here we show a code snippet to show you how to use the chat model with `transformers` and `qwen_vl_utils`:
```python
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
from qwen_vl_utils import process_vision_info
# default: Load the model on the available device(s)
model = Qwen2VLForConditionalGeneration.from_pretrained(
"huihui-ai/QVQ-72B-Preview-abliterated-GPTQ-Int4", torch_dtype="auto", device_map="auto"
)
# default processer
processor = AutoProcessor.from_pretrained("huihui-ai/QVQ-72B-Preview-abliterated-GPTQ-Int4")
# The default range for the number of visual tokens per image in the model is 4-16384. You can set min_pixels and max_pixels according to your needs, such as a token count range of 256-1280, to balance speed and memory usage.
# min_pixels = 256*28*28
# max_pixels = 1280*28*28
# processor = AutoProcessor.from_pretrained("huihui-ai/QVQ-72B-Preview-abliterated-GPTQ-Int4", min_pixels=min_pixels, max_pixels=max_pixels)
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step."}
],
},
{
"role": "user",
"content": [
{
"type": "image",
"image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/QVQ/demo.png",
},
{"type": "text", "text": "What value should be filled in the blank space?"},
],
}
]
# Preparation for inference
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=8192)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
```
|