Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- NeelNanda/pile-10k
|
5 |
+
base_model:
|
6 |
+
- allenai/Molmo-7B-D-0924
|
7 |
+
---
|
8 |
+
|
9 |
+
## Model Details
|
10 |
+
|
11 |
+
This model is an int4 model with group_size 128 and symmetric quantization of [allenai/Molmo-7B-D-0924](https://huggingface.co/allenai/Molmo-7B-D-0924) generated by [intel/auto-round](https://github.com/intel/auto-round). Load the model with revision="e64d453" to use AutoGPTQ format.
|
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-7B-D-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 |
+
# process the image and text
|
42 |
+
inputs = processor.process(
|
43 |
+
images=[Image.open(requests.get(image_url, stream=True).raw)],
|
44 |
+
text="Describe this image."
|
45 |
+
)
|
46 |
+
|
47 |
+
# move inputs to the correct device and make a batch of size 1
|
48 |
+
inputs = {k: v.to(model.device).unsqueeze(0) for k, v in inputs.items()}
|
49 |
+
inputs["images"] = inputs["images"].to(model.dtype)
|
50 |
+
|
51 |
+
# generate output; maximum 200 new tokens; stop generation when <|endoftext|> is generated
|
52 |
+
# with torch.autocast(device_type="cuda", enabled=True, dtype=torch.bfloat16):
|
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 serene beach scene, a woman with long, dark hair sits on the sandy shore, facing left. She is dressed in a plaid shirt with rolled-up sleeves, black pants, and sandals. Her eyes are closed, and she is smiling warmly as she reaches out to high-five a large, light brown dog. The dog, possibly a Labrador or a similar breed, sits on its hind legs with its front paws raised, eagerly engaging in the friendly gesture. The dog is adorned with a blue harness featuring a pattern of pink and blue flowers, and a red leash lies on the sand beside it. The beach is calm, with gentle waves lapping at the shore, and the sky above is a clear, light blue. The sun is setting, casting a soft, warm glow over the scene, enhancing the tranquil and joyful atmosphere.
|
67 |
+
|
68 |
+
##BF16:
|
69 |
+
## In this serene beach scene, a woman and her dog share a tender moment. The woman, with long dark hair, is seated on the sandy shore, her legs crossed as she faces the ocean. She is wearing a plaid shirt with rolled-up sleeves, black pants, and sandals. Her eyes are closed, and she is smiling warmly at her canine companion. The dog, a light brown Labrador, sits beside her with its front paws raised, eagerly reaching out to touch her hand. The dog is adorned with a blue harness decorated with pink and green flowers, and a red leash lies on the sand nearby. The beach is calm, with gentle waves lapping at the shore, and the sky above is a clear, light blue. The sun is setting, casting a soft, golden glow over the scene, enhancing the peaceful and joyful atmosphere.
|
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 |
+
## The image captures a lively scene on a baseball field, where a man in a blue shirt and khaki shorts is teaching a young girl how to play baseball. The girl, dressed in a white shirt and blue pants, is intently focused on holding a baseball bat. Nearby, a woman in a light blue shirt and blue jeans is bending down, likely offering guidance. The field is a mix of green grass and brown dirt, with a white line marking the edge of the grass. In the foreground, a man in a blue shirt stands observing the lesson, while two other individuals, one in a white shirt and another in a blue shirt, are seated on the ground, watching the interaction. The scene is set against the backdrop of a baseball diamond, with the pitcher's mound and base paths visible, adding context to the baseball lesson taking place.
|
76 |
+
|
77 |
+
##BF16:
|
78 |
+
## The image captures a lively scene on a baseball field, where a man, woman, and child are engaged in a game of baseball. The man, dressed in a black and white striped polo shirt, khaki cargo shorts, and sneakers, stands on the right side of the image. He is holding a microphone and appears to be calling out, possibly acting as an umpire or coach. The woman, wearing a light blue shirt and blue jeans, is bending over to hand a bat to the child, who is dressed in a white shirt and gray pants. The child is positioned in the middle of the field, ready to take a swing. In the foreground, a man in a blue shirt stands on the edge of the dirt area, observing the scene. Additionally, two other individuals are visible in the bottom left corner, also watching the action unfold. The background features the green grass of the outfield and the dirt of the infield, with a white line marking the edge of the grass.
|
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 features a rectangular Intel logo set against a gradient blue background. The background transitions from a dark blue in the upper left corner to a lighter blue in the bottom right. The logo itself is composed of three nested squares. The outermost square is a light blue, followed by a slightly darker blue square, and finally, a medium blue square at the center. The medium blue square contains the text "Intel Inside" in white, with "Intel" positioned above "Inside." The word "Intel" is in a larger font, while "Inside" is slightly smaller. Additionally, there is a small trademark symbol (™) next to the "E" in "Intel." The overall design is clean and professional, emphasizing the brand's identity through its consistent use of blue tones and the iconic Intel logo.
|
85 |
+
|
86 |
+
##BF16:
|
87 |
+
## The image features a rectangular Intel logo set against a gradient blue background. The background transitions from a dark blue in the top left corner to a lighter blue in the bottom right. The logo itself is composed of three nested squares. The outermost square is a light blue rectangle with a smaller square missing from the bottom right corner. Inside this rectangle is a darker blue square, and within that is the smallest square, which contains the text "Intel Inside" in white. The word "Intel" is positioned above "Inside," with "Intel" being slightly larger. The overall design is clean and minimalistic, emphasizing the iconic Intel branding.
|
88 |
+
```
|
89 |
+
|
90 |
+
### Generate the model
|
91 |
+
Here is the sample command to reproduce the model.
|
92 |
+
```bash
|
93 |
+
pip install auto-round
|
94 |
+
auto-round-mllm
|
95 |
+
--model allenai/Molmo-7B-D-0924 \
|
96 |
+
--device 0 \
|
97 |
+
--group_size 128 \
|
98 |
+
--bits 4 \
|
99 |
+
--iters 1000 \
|
100 |
+
--nsample 512 \
|
101 |
+
--seqlen 2048 \
|
102 |
+
--format 'auto_gptq,auto_round' \
|
103 |
+
--output_dir "./tmp_autoround"
|
104 |
+
```
|
105 |
+
|
106 |
+
## Ethical Considerations and Limitations
|
107 |
+
|
108 |
+
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.
|
109 |
+
|
110 |
+
Therefore, before deploying any applications of the model, developers should perform safety testing.
|
111 |
+
|
112 |
+
## Caveats and Recommendations
|
113 |
+
|
114 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
|
115 |
+
|
116 |
+
Here are a couple of useful links to learn more about Intel's AI software:
|
117 |
+
|
118 |
+
- Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
|
119 |
+
|
120 |
+
## Disclaimer
|
121 |
+
|
122 |
+
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.
|
123 |
+
|
124 |
+
## Cite
|
125 |
+
|
126 |
+
@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} }
|
127 |
+
|
128 |
+
[arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)
|