--- license: other license_name: qwen license_link: https://huggingface.co/huihui-ai/QVQ-72B-Preview-abliterated/blob/main/LICENSE language: - en pipeline_tag: image-text-to-text base_model: Qwen/QVQ-72B-Preview tags: - abliterated - uncensored - chat library_name: transformers --- # huihui-ai/QVQ-72B-Preview-abliterated This is an uncensored version of [Qwen/QVQ-72B-Preview](https://huggingface.co/Qwen/QVQ-72B-Preview) created with abliteration (see [remove-refusals-with-transformers](https://github.com/Sumandora/remove-refusals-with-transformers) to know more about it). This is a crude, proof-of-concept implementation to remove refusals from an LLM model without using TransformerLens. It was only the text part that was processed, not the image part. ## 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", torch_dtype="auto", device_map="auto" ) # default processer processor = AutoProcessor.from_pretrained("huihui-ai/QVQ-72B-Preview-abliterated") # 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", 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) ```