Misc improvements
#1
by
merve
HF staff
- opened
README.md
CHANGED
@@ -1,14 +1,16 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
SmolVLM is a compact open multimodal model that accepts arbitrary sequences of image and text inputs to produce text outputs. Designed for efficiency, SmolVLM can answer questions about images, describe visual content, create stories grounded on multiple images, or function as a pure language model without visual inputs. Its lightweight architecture makes it suitable for on-device applications while maintaining strong performance on multimodal tasks.
|
9 |
|
10 |
-
We release the checkpoints under the Apache 2.0 license.
|
11 |
-
|
12 |
## Model Details
|
13 |
|
14 |
### Model Description
|
@@ -28,7 +30,7 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
28 |
|
29 |
- **Repository:** [More Information Needed]
|
30 |
- **Paper [optional]:** [More Information Needed]
|
31 |
-
- **Demo [
|
32 |
|
33 |
## Uses
|
34 |
|
@@ -40,14 +42,16 @@ To fine-tune SmolVLM on a specific task, you can follow the fine-tuning tutorial
|
|
40 |
|
41 |
SmolVLM leverages the lightweight SmolLM2 language model to provide a compact yet powerful multimodal experience. It introduces several changes compared to previous models:
|
42 |
|
43 |
-
- Image compression
|
44 |
-
- Visual Token Encoding
|
45 |
|
46 |
More details about the training and architecture are available in our technical report.
|
47 |
|
48 |
|
49 |
### How to get started
|
50 |
|
|
|
|
|
51 |
```python
|
52 |
import torch
|
53 |
from PIL import Image
|
@@ -108,13 +112,29 @@ print(generated_texts[0])
|
|
108 |
**Precision**: For better performance, load and run the model in half-precision (`torch.float16` or `torch.bfloat16`) if your hardware supports it.
|
109 |
|
110 |
```python
|
|
|
|
|
|
|
111 |
model = AutoModelForVision2Seq.from_pretrained(
|
112 |
"HuggingFaceTB/SmolVLM-Instruct",
|
113 |
torch_dtype=torch.bfloat16
|
114 |
-
).to(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
```
|
116 |
|
117 |
-
**Vision Encoder Efficiency**: Adjust the image resolution by setting size={"longest_edge": N*384} when initializing the processor, where N is your desired value. The default N=4 works well, but for documents, N=5 might be beneficial. Decreasing N can save GPU memory for lower-resolution images. This is also useful if you want to fine-tune on videos.
|
118 |
|
119 |
|
120 |
## Misuse and Out-of-scope Use
|
@@ -133,10 +153,7 @@ SmolVLM is not intended for high-stakes scenarios or critical decision-making pr
|
|
133 |
|
134 |
### License
|
135 |
|
136 |
-
SmolVLM is built upon the
|
137 |
-
|
138 |
-
https://huggingface.co/google/siglip-so400m-patch14-384
|
139 |
-
https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B-Instruct
|
140 |
|
141 |
We release the SmolVLM checkpoints under the Apache 2.0 license.
|
142 |
|
@@ -155,5 +172,4 @@ TODO
|
|
155 |
|
156 |
## Evaluation
|
157 |
|
158 |
-
TODO
|
159 |
-
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
license: apache-2.0
|
4 |
+
datasets:
|
5 |
+
- HuggingFaceM4/the_cauldron
|
6 |
+
- HuggingFaceM4/Docmatix
|
7 |
+
pipeline_tag: image-text-to-text
|
8 |
---
|
9 |
|
10 |
# Model Card for Model ID
|
11 |
|
12 |
SmolVLM is a compact open multimodal model that accepts arbitrary sequences of image and text inputs to produce text outputs. Designed for efficiency, SmolVLM can answer questions about images, describe visual content, create stories grounded on multiple images, or function as a pure language model without visual inputs. Its lightweight architecture makes it suitable for on-device applications while maintaining strong performance on multimodal tasks.
|
13 |
|
|
|
|
|
14 |
## Model Details
|
15 |
|
16 |
### Model Description
|
|
|
30 |
|
31 |
- **Repository:** [More Information Needed]
|
32 |
- **Paper [optional]:** [More Information Needed]
|
33 |
+
- **Demo:** [SmolVLM Demo](https://huggingface.co/spaces/HuggingFaceTB/SmolVLM)
|
34 |
|
35 |
## Uses
|
36 |
|
|
|
42 |
|
43 |
SmolVLM leverages the lightweight SmolLM2 language model to provide a compact yet powerful multimodal experience. It introduces several changes compared to previous models:
|
44 |
|
45 |
+
- **Image compression:** We introduce a more radical image compression compared to Idefics3 to enable the model to infer faster and use less RAM.
|
46 |
+
- **Visual Token Encoding:** It uses 81 visual tokens to encode image patches of size 384*384. Larger images are divided into patches, each encoded separately, enhancing efficiency without compromising performance.
|
47 |
|
48 |
More details about the training and architecture are available in our technical report.
|
49 |
|
50 |
|
51 |
### How to get started
|
52 |
|
53 |
+
You can use transformers to load, infer and fine-tune SmolVLM.
|
54 |
+
|
55 |
```python
|
56 |
import torch
|
57 |
from PIL import Image
|
|
|
112 |
**Precision**: For better performance, load and run the model in half-precision (`torch.float16` or `torch.bfloat16`) if your hardware supports it.
|
113 |
|
114 |
```python
|
115 |
+
from transformers import AutoModelForVision2Seq
|
116 |
+
import torch
|
117 |
+
|
118 |
model = AutoModelForVision2Seq.from_pretrained(
|
119 |
"HuggingFaceTB/SmolVLM-Instruct",
|
120 |
torch_dtype=torch.bfloat16
|
121 |
+
).to("cuda")
|
122 |
+
```
|
123 |
+
|
124 |
+
You can also load SmolVLM with 4/8-bit quantization using bitsandbytes, torchao or Quanto. Refer to [this page](https://huggingface.co/docs/transformers/en/main_classes/quantization) for other options.
|
125 |
+
|
126 |
+
```python
|
127 |
+
from transformers import AutoModelForVision2Seq, BitsAndBytesConfig
|
128 |
+
import torch
|
129 |
+
|
130 |
+
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
131 |
+
model = AutoModelForVision2Seq.from_pretrained(
|
132 |
+
"HuggingFaceTB/SmolVLM-Instruct",
|
133 |
+
quantization_config=quantization_config
|
134 |
+
)
|
135 |
```
|
136 |
|
137 |
+
**Vision Encoder Efficiency**: Adjust the image resolution by setting `size={"longest_edge": N*384}` when initializing the processor, where N is your desired value. The default `N=4` works well, but for documents, `N=5` might be beneficial. Decreasing N can save GPU memory for lower-resolution images. This is also useful if you want to fine-tune on videos.
|
138 |
|
139 |
|
140 |
## Misuse and Out-of-scope Use
|
|
|
153 |
|
154 |
### License
|
155 |
|
156 |
+
SmolVLM is built upon [the shape-optimized SigLIP](https://huggingface.co/google/siglip-so400m-patch14-384) as image encoder and [SmolLM2](https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B-Instruct) for text decoder part.
|
|
|
|
|
|
|
157 |
|
158 |
We release the SmolVLM checkpoints under the Apache 2.0 license.
|
159 |
|
|
|
172 |
|
173 |
## Evaluation
|
174 |
|
175 |
+
TODO
|
|