Views
No views yet
| Metric | Value |
|---|---|
| Original (FP16) | ~14.0 GB |
| Quantized (W4A16) | ~5.18 GB |
| Reduction | ~63.0% |
| Memory Saved | ~8.8 GB |
1from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig
2from PIL import Image
3import requests
4
5# Load model and processor
6processor = AutoProcessor.from_pretrained(
7 "ronantakizawa/molmo-7b-d-awq-w4a16",
8 trust_remote_code=True,
9 torch_dtype='auto',
10 device_map='auto'
11)
12
13model = AutoModelForCausalLM.from_pretrained(
14 "ronantakizawa/molmo-7b-d-awq-w4a16",
15 trust_remote_code=True,
16 torch_dtype='auto',
17 device_map='auto'
18)
19
20# Process the image and text
21inputs = processor.process(
22 images=[Image.open(requests.get("https://picsum.photos/id/237/536/354", stream=True).raw)],
23 text="Describe this image."
24)
25
26# Move inputs to the correct device and make a batch of size 1
27inputs = {k: v.to(model.device).unsqueeze(0) for k, v in inputs.items()}
28
29# Generate output
30output = model.generate_from_batch(
31 inputs,
32 GenerationConfig(max_new_tokens=200, stop_strings="<|endoftext|>"),
33 tokenizer=processor.tokenizer
34)
35
36# Decode the generated tokens
37generated_tokens = output[0, inputs['input_ids'].size(1):]
38generated_text = processor.tokenizer.decode(generated_tokens, skip_special_tokens=True)
39print(generated_text)1from vllm import LLM, SamplingParams
2
3llm = LLM(
4 model="ronantakizawa/molmo-7b-d-awq-w4a16",
5 trust_remote_code=True,
6 max_model_len=2048
7)
8
9# vLLM will automatically use GPTQ quantization for faster inference1from PIL import Image
2image = Image.open(...)
3if image.mode != "RGB":
4 image = image.convert("RGB")1@article{molmo,
2 title={Molmo and PixMo: Open Weights and Open Data for State-of-the-Art Multimodal Models},
3 author={Deitke, Matt and Clark, Christopher and Lee, Sangho and others},
4 journal={arXiv preprint arXiv:2409.17146},
5 year={2024}
6}1@misc{molmo-7b-d-awq,
2 title={Molmo-7B-D AWQ 4-bit},
3 author={Quantized by ronantakizawa},
4 year={2025},
5 url={https://huggingface.co/ronantakizawa/molmo-7b-d-awq-w4a16}
6}