Image-Text-to-Text
Transformers
Safetensors
qwen3_5
awq
4bit
quantized
compressed-tensors
abliterated
W4A16
conversational
Instructions to use nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit") 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)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit") model = AutoModelForMultimodalLM.from_pretrained("nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit", 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit", "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/nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit
- SGLang
How to use nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit 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 "nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit" \ --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": "nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit", "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 "nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit" \ --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": "nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit", "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 nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit with Docker Model Runner:
docker model run hf.co/nemozxy123/Huihui-Qwen3.5-9B-abliterated-AWQ-4bit
| import os | |
| import shutil | |
| import torch | |
| from datasets import load_dataset | |
| from transformers import AutoTokenizer | |
| os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True" | |
| os.environ["TOKENIZERS_PARALLELISM"] = "false" | |
| if hasattr(torch, "accelerator") and not hasattr(torch.accelerator, "get_memory_info"): | |
| torch.accelerator.get_memory_info = lambda idx=0: torch.cuda.mem_get_info(idx) | |
| try: | |
| from transformers import AutoModelForImageTextToText | |
| AutoModelClass = AutoModelForImageTextToText | |
| except ImportError: | |
| from transformers import AutoModelForCausalLM | |
| AutoModelClass = AutoModelForCausalLM | |
| from llmcompressor import oneshot | |
| from llmcompressor.modifiers.awq import AWQModifier | |
| MODEL_ID = "/root/autodl-tmp/Huihui-Qwen3.5-9B-abliterated" | |
| SAVE_DIR = "/root/autodl-tmp/Huihui-Qwen3.5-9B-abliterated-AWQ-W4A16-vLLM" | |
| DATASET_DIR = "/root/autodl-tmp/pile-val-backup" | |
| MAX_SEQ_LENGTH = 2048 | |
| NUM_CALIBRATION_SAMPLES = 128 | |
| recipe = [ | |
| AWQModifier( | |
| config_groups={ | |
| "group_1": { | |
| "targets": ["Linear"], | |
| "weights": { | |
| "num_bits": 4, | |
| "type": "int", | |
| "symmetric": True, | |
| "group_size": 32, | |
| "strategy": "group", | |
| "observer": "mse", | |
| "dynamic": False, | |
| }, | |
| "input_activations": None, | |
| "output_activations": None, | |
| } | |
| }, | |
| targets=["Linear"], | |
| ignore=[ | |
| "re:.*embed_tokens", | |
| "re:.*linear_attn[.]in_proj_a", | |
| "re:.*linear_attn[.]in_proj_b", | |
| "re:model[.]visual.*", | |
| "re:mtp.*", | |
| "lm_head", | |
| ], | |
| mappings=[ | |
| { | |
| "smooth_layer": r"re:model.*layers[.](3|7|11|15|19|23|27|31)[.]input_layernorm", | |
| "balance_layers": [ | |
| r"re:model.*layers[.](3|7|11|15|19|23|27|31)[.]self_attn[.]q_proj", | |
| r"re:model.*layers[.](3|7|11|15|19|23|27|31)[.]self_attn[.]k_proj", | |
| r"re:model.*layers[.](3|7|11|15|19|23|27|31)[.]self_attn[.]v_proj", | |
| ], | |
| }, | |
| { | |
| "smooth_layer": r"re:model.*layers[.](3|7|11|15|19|23|27|31)[.]self_attn[.]v_proj", | |
| "balance_layers": [ | |
| r"re:model.*layers[.](3|7|11|15|19|23|27|31)[.]self_attn[.]o_proj", | |
| ], | |
| }, | |
| { | |
| "smooth_layer": r"re:model.*post_attention_layernorm", | |
| "balance_layers": [ | |
| r"re:model.*mlp[.]gate_proj", | |
| r"re:model.*mlp[.]up_proj", | |
| ], | |
| }, | |
| ], | |
| duo_scaling=True, | |
| n_grid=20, | |
| ) | |
| ] | |
| print("Loading model...") | |
| model = AutoModelClass.from_pretrained( | |
| MODEL_ID, | |
| dtype="auto", | |
| device_map="auto", | |
| trust_remote_code=True, | |
| ) | |
| print("Loading tokenizer...") | |
| tokenizer = AutoTokenizer.from_pretrained( | |
| MODEL_ID, | |
| trust_remote_code=True, | |
| ) | |
| print("Loading calibration dataset...") | |
| dataset = load_dataset( | |
| DATASET_DIR, | |
| split=f"validation[:{NUM_CALIBRATION_SAMPLES}]", | |
| ) | |
| print("Starting AWQ quantization...") | |
| oneshot( | |
| model=model, | |
| tokenizer=tokenizer, | |
| dataset=dataset, | |
| recipe=recipe, | |
| output_dir=SAVE_DIR, | |
| max_seq_length=MAX_SEQ_LENGTH, | |
| num_calibration_samples=NUM_CALIBRATION_SAMPLES, | |
| ) | |
| # 补齐多模态 processor 文件,但不要覆盖 config.json | |
| extra_files = [ | |
| "preprocessor_config.json", | |
| "processor_config.json", | |
| "video_preprocessor_config.json", | |
| "chat_template.jinja", | |
| "generation_config.json", | |
| "tokenizer.json", | |
| "tokenizer_config.json", | |
| "vocab.json", | |
| "merges.txt", | |
| ] | |
| for name in extra_files: | |
| src = os.path.join(MODEL_ID, name) | |
| dst = os.path.join(SAVE_DIR, name) | |
| if os.path.exists(src) and not os.path.exists(dst): | |
| shutil.copy2(src, dst) | |
| print(f"Saved vLLM-compatible AWQ W4A16 model to: {SAVE_DIR}") |