OPEA
/

Safetensors
molmo
custom_code
4-bit precision
intel/auto-round
cicdatopea commited on
Commit
ec39e10
·
verified ·
1 Parent(s): 6f8c00b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +130 -3
README.md CHANGED
@@ -1,3 +1,130 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - NeelNanda/pile-10k
5
+ base_model:
6
+ - allenai/Molmo-72B-0924
7
+ ---
8
+
9
+ ## Model Details
10
+
11
+ This model is an int4 model with group_size 128 and symmetric quantization of [allenai/Molmo-72B-0924](https://huggingface.co/allenai/Molmo-72B-0924) generated by [intel/auto-round](https://github.com/intel/auto-round).
12
+
13
+ ## How To Use
14
+ ### INT4 Inference
15
+ ```python
16
+ from auto_round import AutoRoundConfig ## must import for auto-round format
17
+ from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig
18
+ from PIL import Image
19
+ import requests
20
+
21
+ quantized_model_path = "OPEA/Molmo-72B-0924-int4-sym-inc"
22
+
23
+ # load the processor
24
+ processor = AutoProcessor.from_pretrained(
25
+ quantized_model_path,
26
+ trust_remote_code=True,
27
+ torch_dtype='auto',
28
+ device_map='auto'
29
+ )
30
+
31
+ # load the model
32
+ model = AutoModelForCausalLM.from_pretrained(
33
+ quantized_model_path,
34
+ trust_remote_code=True,
35
+ torch_dtype='auto',
36
+ device_map='auto',
37
+ )
38
+
39
+ image_url = "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
40
+ text = "Describe this image."
41
+
42
+ # process the image and text
43
+ inputs = processor.process(
44
+ images=[Image.open(requests.get(image_url, stream=True).raw)],
45
+ text=text
46
+ )
47
+
48
+ # move inputs to the correct device and make a batch of size 1
49
+ inputs = {k: v.to(model.device).unsqueeze(0) for k, v in inputs.items()}
50
+ inputs["images"] = inputs["images"].to(model.dtype)
51
+
52
+ # generate output; maximum 200 new tokens; stop generation when <|endoftext|> is generated
53
+ output = model.generate_from_batch(
54
+ inputs,
55
+ GenerationConfig(max_new_tokens=200, stop_strings="<|endoftext|>"),
56
+ tokenizer=processor.tokenizer
57
+ )
58
+
59
+ # only get generated tokens; decode them to text
60
+ generated_tokens = output[0,inputs['input_ids'].size(1):]
61
+ generated_text = processor.tokenizer.decode(generated_tokens, skip_special_tokens=True)
62
+
63
+ # print the generated text
64
+ print(generated_text)
65
+ ##INT4:
66
+ ## In this heartwarming photograph, a woman and her dog are captured sharing a tender moment on a sandy beach. The woman, with her long brown hair cascading down, is seated on the sand, her legs extended in front of her. She is dressed in a cozy flannel shirt and black pants, and she is barefoot, allowing the sand to embrace her feet. Her dog, a light brown canine with a white underbelly, sits upright on its hind legs, its front paws gently resting on the woman's hands. The dog is adorned with a harness that features a playful pattern of bones and fire hydrants. Both the woman and her furry companion are smiling warmly, their eyes locked in a loving gaze. The backdrop of the scene is a serene beach with gentle waves rolling in, and the sky above is a soft, light gray, adding a calm and peaceful ambiance to the moment.
67
+
68
+ ##FP32:
69
+ ## In this heartwarming photograph, a woman and her golden retriever are captured enjoying a serene moment on a sandy beach. The woman, with her long brown hair cascading down, is dressed in a blue and white plaid shirt paired with black pants. She sits barefoot on the sand, her right leg extended outward and her left leg bent at the knee, creating a relaxed posture. Her right hand gently holds the paw of her golden retriever, who is seated beside her, facing her with a joyful expression. The dog's left paw rests on the woman's extended leg, and its tail is stretched out behind it. The golden retriever sports a blue harness adorned with red and green paw prints, adding a splash of color to the scene. The sandy beach is marked with numerous footprints, hinting at the activity of other beachgoers. In the background, the tranquil ocean stretches out, with gentle waves rolling in, completing this picturesque and touching moment between a woman and her
70
+
71
+
72
+ image_url = "http://images.cocodataset.org/train2017/000000411975.jpg"
73
+ text = "How many people are there on the baseball field in the picture?"
74
+ ##INT4:
75
+ ## Counting the <points x1="10.2" y1="95.2" x2="47.7" y2="40.3" x3="57.1" y3="87.3" x4="58.6" y4="50.2" x5="76.1" y5="38.8" alt="people are there on the baseball field">people are there on the baseball field</points> shows a total of 5.
76
+
77
+ ##FP32:
78
+ ## Counting the <points x1="10.2" y1="94.9" x2="47.7" y2="40.3" x3="56.8" y3="87.1" x4="59.1" y4="50.0" x5="75.8" y5="37.8" alt="people are there on the baseball field">people are there on the baseball field</points> shows a total of 5.
79
+
80
+
81
+ image_url = "https://intelcorp.scene7.com/is/image/intelcorp/processor-overview-framed-badge:1920-1080?wid=480&hei=270"
82
+ text = "Which company does this image represent?"
83
+ ##INT4:
84
+ ## The image represents Intel Corporation. The logo prominently displays the word "intel" in lowercase letters, followed by "INSIDE" in uppercase letters, which is Intel's well-known branding slogan. This iconic logo design is instantly recognizable and has been associated with Intel's processors and computing technology for decades.
85
+
86
+ ##FP32:
87
+ ## The image represents Intel Corporation. The iconic "Intel Inside" logo is prominently displayed, featuring the distinctive blue color scheme and typography that has become synonymous with Intel's brand identity. This logo has been a hallmark of Intel's marketing strategy for decades, appearing on computer components and systems that use Intel processors.
88
+
89
+ ```
90
+
91
+
92
+ ### Generate the model
93
+ Here is the sample command to reproduce the model.
94
+ ```bash
95
+ pip install auto-round
96
+ auto-round-mllm
97
+ --model allenai/Molmo-72B-0924 \
98
+ --device 0 \
99
+ --group_size 128 \
100
+ --bits 4 \
101
+ --iters 1000 \
102
+ --nsamples 512 \
103
+ --seqlen 2048 \
104
+ --format 'auto_round' \
105
+ --output_dir "./tmp_autoround"
106
+ ```
107
+
108
+ ## Ethical Considerations and Limitations
109
+
110
+ The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
111
+
112
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
113
+
114
+ ## Caveats and Recommendations
115
+
116
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
117
+
118
+ Here are a couple of useful links to learn more about Intel's AI software:
119
+
120
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
121
+
122
+ ## Disclaimer
123
+
124
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
125
+
126
+ ## Cite
127
+
128
+ @article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }
129
+
130
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)