Image-Text-to-Text
Transformers
GGUF
English
conversational
Mungert commited on
Commit
1a6f35c
·
verified ·
0 Parent(s):

Super-squash history to reclaim storage

Browse files
.gitattributes ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ SmolVLM-256M-Instruct-f16.gguf filter=lfs diff=lfs merge=lfs -text
37
+ SmolVLM-256M-Instruct-f16_q8_0.gguf filter=lfs diff=lfs merge=lfs -text
38
+ SmolVLM-256M-Instruct-bf16_q8_0.gguf filter=lfs diff=lfs merge=lfs -text
39
+ SmolVLM-256M-Instruct-f16_q6_k.gguf filter=lfs diff=lfs merge=lfs -text
40
+ SmolVLM-256M-Instruct-bf16_q6_k.gguf filter=lfs diff=lfs merge=lfs -text
41
+ SmolVLM-256M-Instruct-f16_q4_k.gguf filter=lfs diff=lfs merge=lfs -text
42
+ SmolVLM-256M-Instruct-bf16_q4_k.gguf filter=lfs diff=lfs merge=lfs -text
43
+ SmolVLM-256M-Instruct-q3_k_l.gguf filter=lfs diff=lfs merge=lfs -text
44
+ SmolVLM-256M-Instruct-q4_k_l.gguf filter=lfs diff=lfs merge=lfs -text
45
+ SmolVLM-256M-Instruct-q5_k_l.gguf filter=lfs diff=lfs merge=lfs -text
46
+ SmolVLM-256M-Instruct-q6_k_l.gguf filter=lfs diff=lfs merge=lfs -text
47
+ SmolVLM-256M-Instruct-q3_k_m.gguf filter=lfs diff=lfs merge=lfs -text
48
+ SmolVLM-256M-Instruct-q3_k_s.gguf filter=lfs diff=lfs merge=lfs -text
49
+ SmolVLM-256M-Instruct-q4_k_m.gguf filter=lfs diff=lfs merge=lfs -text
50
+ SmolVLM-256M-Instruct-q4_k_s.gguf filter=lfs diff=lfs merge=lfs -text
51
+ SmolVLM-256M-Instruct-q5_k_m.gguf filter=lfs diff=lfs merge=lfs -text
52
+ SmolVLM-256M-Instruct-q5_k_s.gguf filter=lfs diff=lfs merge=lfs -text
53
+ SmolVLM-256M-Instruct-q6_k_m.gguf filter=lfs diff=lfs merge=lfs -text
54
+ SmolVLM-256M-Instruct-q8_0.gguf filter=lfs diff=lfs merge=lfs -text
55
+ SmolVLM-256M-Instruct-q4_0.gguf filter=lfs diff=lfs merge=lfs -text
56
+ SmolVLM-256M-Instruct-q4_1.gguf filter=lfs diff=lfs merge=lfs -text
57
+ SmolVLM-256M-Instruct-q4_0_l.gguf filter=lfs diff=lfs merge=lfs -text
58
+ SmolVLM-256M-Instruct-q4_1_l.gguf filter=lfs diff=lfs merge=lfs -text
59
+ SmolVLM-256M-Instruct-q5_0.gguf filter=lfs diff=lfs merge=lfs -text
60
+ SmolVLM-256M-Instruct-q5_1.gguf filter=lfs diff=lfs merge=lfs -text
61
+ SmolVLM-256M-Instruct-q5_0_l.gguf filter=lfs diff=lfs merge=lfs -text
62
+ SmolVLM-256M-Instruct-q5_1_l.gguf filter=lfs diff=lfs merge=lfs -text
63
+ SmolVLM-256M-Instruct-iq3_xs.gguf filter=lfs diff=lfs merge=lfs -text
64
+ SmolVLM-256M-Instruct-iq3_xxs.gguf filter=lfs diff=lfs merge=lfs -text
65
+ SmolVLM-256M-Instruct-iq3_s.gguf filter=lfs diff=lfs merge=lfs -text
66
+ SmolVLM-256M-Instruct-iq3_m.gguf filter=lfs diff=lfs merge=lfs -text
67
+ SmolVLM-256M-Instruct-iq4_xs.gguf filter=lfs diff=lfs merge=lfs -text
68
+ SmolVLM-256M-Instruct-iq4_nl.gguf filter=lfs diff=lfs merge=lfs -text
69
+ SmolVLM-256M-Instruct.imatrix filter=lfs diff=lfs merge=lfs -text
70
+ SmolVLM-256M-Instruct-f32.mmproj filter=lfs diff=lfs merge=lfs -text
71
+ SmolVLM-256M-Instruct-bf16.mmproj filter=lfs diff=lfs merge=lfs -text
72
+ SmolVLM-256M-Instruct-q8_0.mmproj filter=lfs diff=lfs merge=lfs -text
73
+ SmolVLM-256M-Instruct-f16.mmproj filter=lfs diff=lfs merge=lfs -text
74
+ SmolVLM-256M-Instruct-bf16.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,514 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ language:
9
+ - en
10
+ base_model:
11
+ - HuggingFaceTB/SmolLM2-135M-Instruct
12
+ - google/siglip-base-patch16-512
13
+ ---
14
+
15
+ # <span style="color: #7FFF7F;">SmolVLM-256M-Instruct GGUF Models</span>
16
+
17
+
18
+ ## <span style="color: #7F7FFF;">Model Generation Details</span>
19
+
20
+ This model was generated using [llama.cpp](https://github.com/ggerganov/llama.cpp) at commit [`7f4fbe51`](https://github.com/ggerganov/llama.cpp/commit/7f4fbe5183b23b6b2e25fd1ccc5d1fa8bb010cb7).
21
+
22
+
23
+
24
+
25
+
26
+
27
+ ## **Choosing the Right Model Format**
28
+
29
+ Selecting the correct model format depends on your **hardware capabilities** and **memory constraints**.
30
+
31
+ ### **BF16 (Brain Float 16) – Use if BF16 acceleration is available**
32
+ - A 16-bit floating-point format designed for **faster computation** while retaining good precision.
33
+ - Provides **similar dynamic range** as FP32 but with **lower memory usage**.
34
+ - Recommended if your hardware supports **BF16 acceleration** (check your device's specs).
35
+ - Ideal for **high-performance inference** with **reduced memory footprint** compared to FP32.
36
+
37
+ 📌 **Use BF16 if:**
38
+ ✔ Your hardware has native **BF16 support** (e.g., newer GPUs, TPUs).
39
+ ✔ You want **higher precision** while saving memory.
40
+ ✔ You plan to **requantize** the model into another format.
41
+
42
+ 📌 **Avoid BF16 if:**
43
+ ❌ Your hardware does **not** support BF16 (it may fall back to FP32 and run slower).
44
+ ❌ You need compatibility with older devices that lack BF16 optimization.
45
+
46
+ ---
47
+
48
+ ### **F16 (Float 16) – More widely supported than BF16**
49
+ - A 16-bit floating-point **high precision** but with less of range of values than BF16.
50
+ - Works on most devices with **FP16 acceleration support** (including many GPUs and some CPUs).
51
+ - Slightly lower numerical precision than BF16 but generally sufficient for inference.
52
+
53
+ 📌 **Use F16 if:**
54
+ ✔ Your hardware supports **FP16** but **not BF16**.
55
+ ✔ You need a **balance between speed, memory usage, and accuracy**.
56
+ ✔ You are running on a **GPU** or another device optimized for FP16 computations.
57
+
58
+ 📌 **Avoid F16 if:**
59
+ ❌ Your device lacks **native FP16 support** (it may run slower than expected).
60
+ ❌ You have memory limitations.
61
+
62
+ ---
63
+
64
+ ### **Hybrid Precision Models (e.g., `bf16_q8_0`, `f16_q4_K`) – Best of Both Worlds**
65
+ These formats selectively **quantize non-essential layers** while keeping **key layers in full precision** (e.g., attention and output layers).
66
+
67
+ - Named like `bf16_q8_0` (meaning **full-precision BF16 core layers + quantized Q8_0 other layers**).
68
+ - Strike a **balance between memory efficiency and accuracy**, improving over fully quantized models without requiring the full memory of BF16/F16.
69
+
70
+ 📌 **Use Hybrid Models if:**
71
+ ✔ You need **better accuracy than quant-only models** but can’t afford full BF16/F16 everywhere.
72
+ ✔ Your device supports **mixed-precision inference**.
73
+ ✔ You want to **optimize trade-offs** for production-grade models on constrained hardware.
74
+
75
+ 📌 **Avoid Hybrid Models if:**
76
+ ❌ Your target device doesn’t support **mixed or full-precision acceleration**.
77
+ ❌ You are operating under **ultra-strict memory limits** (in which case use fully quantized formats).
78
+
79
+ ---
80
+
81
+ ### **Quantized Models (Q4_K, Q6_K, Q8, etc.) – For CPU & Low-VRAM Inference**
82
+ Quantization reduces model size and memory usage while maintaining as much accuracy as possible.
83
+ - **Lower-bit models (Q4_K)** → **Best for minimal memory usage**, may have lower precision.
84
+ - **Higher-bit models (Q6_K, Q8_0)** → **Better accuracy**, requires more memory.
85
+
86
+ 📌 **Use Quantized Models if:**
87
+ ✔ You are running inference on a **CPU** and need an optimized model.
88
+ ✔ Your device has **low VRAM** and cannot load full-precision models.
89
+ ✔ You want to reduce **memory footprint** while keeping reasonable accuracy.
90
+
91
+ 📌 **Avoid Quantized Models if:**
92
+ ❌ You need **maximum accuracy** (full-precision models are better for this).
93
+ ❌ Your hardware has enough VRAM for higher-precision formats (BF16/F16).
94
+
95
+ ---
96
+
97
+ ### **Very Low-Bit Quantization (IQ3_XS, IQ3_S, IQ3_M, Q4_K, Q4_0)**
98
+ These models are optimized for **very high memory efficiency**, making them ideal for **low-power devices** or **large-scale deployments** where memory is a critical constraint.
99
+
100
+ - **IQ3_XS**: Ultra-low-bit quantization (3-bit) with **very high memory efficiency**.
101
+ - **Use case**: Best for **ultra-low-memory devices** where even Q4_K is too large.
102
+ - **Trade-off**: Lower accuracy compared to higher-bit quantizations.
103
+
104
+ - **IQ3_S**: Small block size for **maximum memory efficiency**.
105
+ - **Use case**: Best for **low-memory devices** where **IQ3_XS** is too aggressive.
106
+
107
+ - **IQ3_M**: Medium block size for better accuracy than **IQ3_S**.
108
+ - **Use case**: Suitable for **low-memory devices** where **IQ3_S** is too limiting.
109
+
110
+ - **Q4_K**: 4-bit quantization with **block-wise optimization** for better accuracy.
111
+ - **Use case**: Best for **low-memory devices** where **Q6_K** is too large.
112
+
113
+ - **Q4_0**: Pure 4-bit quantization, optimized for **ARM devices**.
114
+ - **Use case**: Best for **ARM-based devices** or **low-memory environments**.
115
+
116
+ ### **Ultra Low-Bit Quantization (IQ1_S IQ1_M IQ2_S IQ2_M IQ2_XS IQ2_XSS)**
117
+ - *Ultra-low-bit quantization (1 2-bit) with **extreme memory efficiency**.
118
+ - **Use case**: Best for cases were you have to fit the model into very constrained memory
119
+ - **Trade-off**: Very Low Accuracy. May not function as expected. Please test fully before using.
120
+
121
+ ---
122
+
123
+ ### **Summary Table: Model Format Selection**
124
+
125
+
126
+ | Model Format | Precision | Memory Usage | Device Requirements | Best Use Case |
127
+ |--------------------------|------------------|------------------|----------------------------------|--------------------------------------------------------------|
128
+ | **BF16** | Very High | High | BF16-supported GPU/CPU | High-speed inference with reduced memory |
129
+ | **F16** | High | High | FP16-supported GPU/CPU | Inference when BF16 isn’t available |
130
+ | **Q4_K** | Medium-Low | Low | CPU or Low-VRAM devices | Memory-constrained inference |
131
+ | **Q6_K** | Medium | Moderate | CPU with more memory | Better accuracy with quantization |
132
+ | **Q8_0** | High | Moderate | GPU/CPU with moderate VRAM | Highest accuracy among quantized models |
133
+ | **IQ3_XS** | Low | Very Low | Ultra-low-memory devices | Max memory efficiency, low accuracy |
134
+ | **IQ3_S** | Low | Very Low | Low-memory devices | Slightly more usable than IQ3_XS |
135
+ | **IQ3_M** | Low-Medium | Low | Low-memory devices | Better accuracy than IQ3_S |
136
+ | **Q4_0** | Low | Low | ARM-based/embedded devices | Llama.cpp automatically optimizes for ARM inference |
137
+ | **Ultra Low-Bit (IQ1/2_*)** | Very Low | Extremely Low | Tiny edge/embedded devices | Fit models in extremely tight memory; low accuracy |
138
+ | **Hybrid (e.g., `bf16_q8_0`)** | Medium–High | Medium | Mixed-precision capable hardware | Balanced performance and memory, near-FP accuracy in critical layers |
139
+
140
+ ---
141
+
142
+
143
+
144
+
145
+
146
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/SmolVLM_256_banner.png" width="800" height="auto" alt="Image description">
147
+
148
+ # SmolVLM-256M
149
+
150
+ SmolVLM-256M is the smallest multimodal model in the world. It accepts arbitrary sequences of image and text inputs to produce text outputs. It's designed for efficiency. SmolVLM can answer questions about images, describe visual content, or transcribe text. Its lightweight architecture makes it suitable for on-device applications while maintaining strong performance on multimodal tasks. It can run inference on one image with under 1GB of GPU RAM.
151
+
152
+ ## Model Summary
153
+
154
+ - **Developed by:** Hugging Face 🤗
155
+ - **Model type:** Multi-modal model (image+text)
156
+ - **Language(s) (NLP):** English
157
+ - **License:** Apache 2.0
158
+ - **Architecture:** Based on [Idefics3](https://huggingface.co/HuggingFaceM4/Idefics3-8B-Llama3) (see technical summary)
159
+
160
+ ## Resources
161
+
162
+ - **Demo:** [SmolVLM-256 Demo](https://huggingface.co/spaces/HuggingFaceTB/SmolVLM-256M-Demo)
163
+ - **Blog:** [Blog post](https://huggingface.co/blog/smolvlm)
164
+
165
+ ## Uses
166
+
167
+ SmolVLM can be used for inference on multimodal (image + text) tasks where the input comprises text queries along with one or more images. Text and images can be interleaved arbitrarily, enabling tasks like image captioning, visual question answering, and storytelling based on visual content. The model does not support image generation.
168
+
169
+ To fine-tune SmolVLM on a specific task, you can follow [the fine-tuning tutorial](https://github.com/huggingface/smollm/blob/main/vision/finetuning/Smol_VLM_FT.ipynb).
170
+
171
+ ### Technical Summary
172
+
173
+ SmolVLM leverages the lightweight SmolLM2 language model to provide a compact yet powerful multimodal experience. It introduces several changes compared to the larger SmolVLM 2.2B model:
174
+
175
+ - **Image compression:** We introduce a more radical image compression compared to Idefics3 and SmolVLM-2.2B to enable the model to infer faster and use less RAM.
176
+ - **Visual Token Encoding:** SmolVLM-256 uses 64 visual tokens to encode image patches of size 512×512. Larger images are divided into patches, each encoded separately, enhancing efficiency without compromising performance.
177
+ - **New special tokens:** We added new special tokens to divide the subimages. This allows for more efficient tokenization of the images.
178
+ - **Smoller vision encoder:** We went from a 400M parameter siglip vision encoder to a much smaller 93M encoder.
179
+ - **Larger image patches:** We are now passing patches of 512x512 to the vision encoder, instead of 384x384 like the larger SmolVLM. This allows the information to be encoded more efficiently.
180
+
181
+ More details about the training and architecture are available in our technical report.
182
+
183
+ ### How to get started
184
+
185
+ You can use transformers to load, infer and fine-tune SmolVLM.
186
+
187
+ ```python
188
+ import torch
189
+ from PIL import Image
190
+ from transformers import AutoProcessor, AutoModelForVision2Seq
191
+ from transformers.image_utils import load_image
192
+
193
+ DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
194
+
195
+ # Load images
196
+ image = load_image("https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg")
197
+
198
+ # Initialize processor and model
199
+ processor = AutoProcessor.from_pretrained("HuggingFaceTB/SmolVLM-256M-Instruct")
200
+ model = AutoModelForVision2Seq.from_pretrained(
201
+ "HuggingFaceTB/SmolVLM-256M-Instruct",
202
+ torch_dtype=torch.bfloat16,
203
+ _attn_implementation="flash_attention_2" if DEVICE == "cuda" else "eager",
204
+ ).to(DEVICE)
205
+
206
+ # Create input messages
207
+ messages = [
208
+ {
209
+ "role": "user",
210
+ "content": [
211
+ {"type": "image"},
212
+ {"type": "text", "text": "Can you describe this image?"}
213
+ ]
214
+ },
215
+ ]
216
+
217
+ # Prepare inputs
218
+ prompt = processor.apply_chat_template(messages, add_generation_prompt=True)
219
+ inputs = processor(text=prompt, images=[image], return_tensors="pt")
220
+ inputs = inputs.to(DEVICE)
221
+
222
+ # Generate outputs
223
+ generated_ids = model.generate(**inputs, max_new_tokens=500)
224
+ generated_texts = processor.batch_decode(
225
+ generated_ids,
226
+ skip_special_tokens=True,
227
+ )
228
+
229
+ print(generated_texts[0])
230
+ """
231
+ Assistant: The image depicts a large, historic statue of liberty, located in New York City. The statue is a green, cylindrical structure with a human figure at the top, holding a torch. The statue is situated on a pedestal that resembles the statue of liberty, which is located on a small island in the middle of a body of water. The water surrounding the island is calm, reflecting the blue sky and the statue.
232
+ In the background, there are several tall buildings, including the Empire State Building, which is visible in the distance. These buildings are made of glass and steel, and they are positioned in a grid-like pattern, giving them a modern look. The sky is clear, with a few clouds visible, indicating fair weather.
233
+ The statue is surrounded by trees, which are green and appear to be healthy. There are also some small structures, possibly houses or buildings, visible in the distance. The overall scene suggests a peaceful and serene environment, typical of a cityscape.
234
+ The image is taken during the daytime, likely during the day of the statue's installation. The lighting is bright, casting a strong shadow on the statue and the water, which enhances the visibility of the statue and the surrounding environment.
235
+ To summarize, the image captures a significant historical statue of liberty, situated on a small island in the middle of a body of water, surrounded by trees and buildings. The sky is clear, with a few clouds visible, indicating fair weather. The statue is green and cylindrical, with a human figure holding a torch, and is surrounded by trees, indicating a peaceful and well-maintained environment. The overall scene is one of tranquility and historical significance.
236
+ """
237
+ ```
238
+
239
+ We also provide ONNX weights for the model, which you can run with ONNX Runtime as follows:
240
+ <details>
241
+
242
+ <summary>Click here to see the sample code</summary>
243
+
244
+ ```python
245
+ from transformers import AutoConfig, AutoProcessor
246
+ from transformers.image_utils import load_image
247
+ import onnxruntime
248
+ import numpy as np
249
+
250
+ # 1. Load models
251
+ ## Load config and processor
252
+ model_id = "HuggingFaceTB/SmolVLM-256M-Instruct"
253
+ config = AutoConfig.from_pretrained(model_id)
254
+ processor = AutoProcessor.from_pretrained(model_id)
255
+
256
+ ## Load sessions
257
+ ## !wget https://huggingface.co/HuggingFaceTB/SmolVLM-256M-Instruct/resolve/main/onnx/vision_encoder.onnx
258
+ ## !wget https://huggingface.co/HuggingFaceTB/SmolVLM-256M-Instruct/resolve/main/onnx/embed_tokens.onnx
259
+ ## !wget https://huggingface.co/HuggingFaceTB/SmolVLM-256M-Instruct/resolve/main/onnx/decoder_model_merged.onnx
260
+ vision_session = onnxruntime.InferenceSession("vision_encoder.onnx")
261
+ embed_session = onnxruntime.InferenceSession("embed_tokens.onnx")
262
+ decoder_session = onnxruntime.InferenceSession("decoder_model_merged.onnx")
263
+
264
+ ## Set config values
265
+ num_key_value_heads = config.text_config.num_key_value_heads
266
+ head_dim = config.text_config.head_dim
267
+ num_hidden_layers = config.text_config.num_hidden_layers
268
+ eos_token_id = config.text_config.eos_token_id
269
+ image_token_id = config.image_token_id
270
+
271
+
272
+ # 2. Prepare inputs
273
+ ## Create input messages
274
+ messages = [
275
+ {
276
+ "role": "user",
277
+ "content": [
278
+ {"type": "image"},
279
+ {"type": "text", "text": "Can you describe this image?"}
280
+ ]
281
+ },
282
+ ]
283
+
284
+ ## Load image and apply processor
285
+ image = load_image("https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg")
286
+ prompt = processor.apply_chat_template(messages, add_generation_prompt=True)
287
+ inputs = processor(text=prompt, images=[image], return_tensors="np")
288
+
289
+ ## Prepare decoder inputs
290
+ batch_size = inputs['input_ids'].shape[0]
291
+ past_key_values = {
292
+ f'past_key_values.{layer}.{kv}': np.zeros([batch_size, num_key_value_heads, 0, head_dim], dtype=np.float32)
293
+ for layer in range(num_hidden_layers)
294
+ for kv in ('key', 'value')
295
+ }
296
+ image_features = None
297
+ input_ids = inputs['input_ids']
298
+ attention_mask = inputs['attention_mask']
299
+ position_ids = np.cumsum(inputs['attention_mask'], axis=-1)
300
+
301
+
302
+ # 3. Generation loop
303
+ max_new_tokens = 1024
304
+ generated_tokens = np.array([[]], dtype=np.int64)
305
+ for i in range(max_new_tokens):
306
+ inputs_embeds = embed_session.run(None, {'input_ids': input_ids})[0]
307
+
308
+ if image_features is None:
309
+ ## Only compute vision features if not already computed
310
+ image_features = vision_session.run(
311
+ ['image_features'], # List of output names or indices
312
+ {
313
+ 'pixel_values': inputs['pixel_values'],
314
+ 'pixel_attention_mask': inputs['pixel_attention_mask'].astype(np.bool_)
315
+ }
316
+ )[0]
317
+
318
+ ## Merge text and vision embeddings
319
+ inputs_embeds[inputs['input_ids'] == image_token_id] = image_features.reshape(-1, image_features.shape[-1])
320
+
321
+ logits, *present_key_values = decoder_session.run(None, dict(
322
+ inputs_embeds=inputs_embeds,
323
+ attention_mask=attention_mask,
324
+ position_ids=position_ids,
325
+ **past_key_values,
326
+ ))
327
+
328
+ ## Update values for next generation loop
329
+ input_ids = logits[:, -1].argmax(-1, keepdims=True)
330
+ attention_mask = np.ones_like(input_ids)
331
+ position_ids = position_ids[:, -1:] + 1
332
+ for j, key in enumerate(past_key_values):
333
+ past_key_values[key] = present_key_values[j]
334
+
335
+ generated_tokens = np.concatenate([generated_tokens, input_ids], axis=-1)
336
+ if (input_ids == eos_token_id).all():
337
+ break
338
+
339
+ ## (Optional) Streaming
340
+ print(processor.decode(input_ids[0]), end='')
341
+ print()
342
+
343
+ # 4. Output result
344
+ print(processor.batch_decode(generated_tokens))
345
+ ```
346
+
347
+ Example output:
348
+ ```
349
+ The image depicts a large, historic statue of Liberty situated on a small island in a body of water. The statue is a green, cylindrical structure with a human figure at the top, which is the actual statue of Liberty. The statue is mounted on a pedestal that is supported by a cylindrical tower. The pedestal is rectangular and appears to be made of stone or a similar material. The statue is surrounded by a large, flat, rectangular area that is likely a base for the statue.
350
+
351
+ In the background, there is a cityscape with a variety of buildings, including skyscrapers and high-rise buildings. The sky is clear with a gradient of colors, transitioning from a pale blue at the top to a deeper blue at the bottom. The buildings are mostly modern, with a mix of glass and concrete. The buildings are densely packed, with many skyscrapers and high-rise buildings visible.
352
+
353
+ There are trees and greenery visible on the left side of the image, indicating that the statue is located near a park or a park area. The water in the foreground is calm, with small ripples indicating that the statue is in the water.
354
+
355
+ The overall scene suggests a peaceful and serene environment, likely a public park or a park area in a city. The statue is likely a representation of liberty, representing the city's commitment to freedom and democracy.
356
+
357
+ ### Analysis and Description:
358
+
359
+ #### Statue of Liberty:
360
+ - **Location**: The statue is located on a small island in a body of water.
361
+ - **Statue**: The statue is a green cylindrical structure with a human figure at the top, which is the actual statue of Liberty.
362
+ - **Pedestal**: The pedestal is rectangular and supports the statue.
363
+ - **Pedestrian**: The pedestal is surrounded by a flat rectangular area.
364
+ - **Water**: The water is calm, with small ripples indicating that the statue is in the water.
365
+
366
+ #### Cityscape:
367
+ - **Buildings**: The buildings are modern, with a mix of glass and concrete.
368
+ - **Sky**: The sky is clear with a gradient of colors, transitioning from a pale blue at the top to a deeper blue at the bottom.
369
+ - **Trees**: There are trees and greenery visible on the left side of the image, indicating that the statue is located near a park or a park area.
370
+
371
+ #### Environment:
372
+ - **Water**: The water is calm, with small ripples indicating that the statue is in the water.
373
+ - **Sky**: The sky is clear with a gradient of colors, transitioning from a pale blue at the top to a deeper blue at the bottom.
374
+
375
+ ### Conclusion:
376
+ The image depicts a peaceful and serene public park or park area in a city, with the statue of Liberty prominently featured. The cityscape in the background includes modern buildings and a clear sky, suggesting a well-maintained public space.<end_of_utterance>
377
+ ```
378
+
379
+ </details>
380
+
381
+ ### Model optimizations
382
+
383
+ **Precision**: For better performance, load and run the model in half-precision (`torch.bfloat16`) if your hardware supports it.
384
+
385
+ ```python
386
+ from transformers import AutoModelForVision2Seq
387
+ import torch
388
+
389
+ model = AutoModelForVision2Seq.from_pretrained(
390
+ "HuggingFaceTB/SmolVLM-Instruct",
391
+ torch_dtype=torch.bfloat16
392
+ ).to("cuda")
393
+ ```
394
+
395
+ 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.
396
+
397
+ ```python
398
+ from transformers import AutoModelForVision2Seq, BitsAndBytesConfig
399
+ import torch
400
+
401
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
402
+ model = AutoModelForVision2Seq.from_pretrained(
403
+ "HuggingFaceTB/SmolVLM-Instruct",
404
+ quantization_config=quantization_config,
405
+ )
406
+ ```
407
+
408
+ **Vision Encoder Efficiency**: Adjust the image resolution by setting `size={"longest_edge": N*512}` when initializing the processor, where N is your desired value. The default `N=4` works well, which results in input images of
409
+ size 2048×2048. Decreasing N can save GPU memory and is appropriate for lower-resolution images. This is also useful if you want to fine-tune on videos.
410
+
411
+
412
+ ## Misuse and Out-of-scope Use
413
+
414
+ SmolVLM is not intended for high-stakes scenarios or critical decision-making processes that affect an individual's well-being or livelihood. The model may produce content that appears factual but may not be accurate. Misuse includes, but is not limited to:
415
+
416
+ - Prohibited Uses:
417
+ - Evaluating or scoring individuals (e.g., in employment, education, credit)
418
+ - Critical automated decision-making
419
+ - Generating unreliable factual content
420
+ - Malicious Activities:
421
+ - Spam generation
422
+ - Disinformation campaigns
423
+ - Harassment or abuse
424
+ - Unauthorized surveillance
425
+
426
+ ### License
427
+
428
+ SmolVLM is built upon [SigLIP](https://huggingface.co/google/siglip-base-patch16-512) as image encoder and [SmolLM2](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct) for text decoder part.
429
+
430
+ We release the SmolVLM checkpoints under the Apache 2.0 license.
431
+
432
+ ## Training Details
433
+
434
+ ### Training Data
435
+
436
+ The training data comes from [The Cauldron](https://huggingface.co/datasets/HuggingFaceM4/the_cauldron) and [Docmatix](https://huggingface.co/datasets/HuggingFaceM4/Docmatix) datasets, with emphasis on document understanding (25%) and image captioning (18%), while maintaining balanced coverage across other crucial capabilities like visual reasoning, chart comprehension, and general instruction following.
437
+ <img src="https://huggingface.co/HuggingFaceTB/SmolVLM-Instruct/resolve/main/mixture_the_cauldron.png" alt="Example Image" style="width:90%;" />
438
+
439
+
440
+
441
+ ## Evaluation
442
+
443
+ | Size | Mathvista | MMMU | OCRBench | MMStar | AI2D | ChartQA_Test | Science_QA | TextVQA Val | DocVQA Val |
444
+ |-------|-----------|------|----------|--------|-------|--------------|------------|-------------|------------|
445
+ | 256M | 35.9 | 28.3 | 52.6 | 34.6 | 47 | 55.8 | 73.6 | 49.9 | 58.3 |
446
+ | 500M | 40.1 | 33.7 | 61 | 38.3 | 59.5 | 63.2 | 79.7 | 60.5 | 70.5 |
447
+ | 2.2B | 43.9 | 38.3 | 65.5 | 41.8 | 64 | 71.6 | 84.5 | 72.1 | 79.7 |
448
+
449
+
450
+ # Citation information
451
+ You can cite us in the following way:
452
+ ```bibtex
453
+ @article{marafioti2025smolvlm,
454
+ title={SmolVLM: Redefining small and efficient multimodal models},
455
+ author={Andrés Marafioti and Orr Zohar and Miquel Farré and Merve Noyan and Elie Bakouch and Pedro Cuenca and Cyril Zakka and Loubna Ben Allal and Anton Lozhkov and Nouamane Tazi and Vaibhav Srivastav and Joshua Lochner and Hugo Larcher and Mathieu Morlon and Lewis Tunstall and Leandro von Werra and Thomas Wolf},
456
+ journal={arXiv preprint arXiv:2504.05299},
457
+ year={2025}
458
+ }
459
+ ```
460
+
461
+ # <span id="testllm" style="color: #7F7FFF;">🚀 If you find these models useful</span>
462
+
463
+ Help me test my **AI-Powered Quantum Network Monitor Assistant** with **quantum-ready security checks**:
464
+
465
+ 👉 [Quantum Network Monitor](https://readyforquantum.com/?assistant=open&utm_source=huggingface&utm_medium=referral&utm_campaign=huggingface_repo_readme)
466
+
467
+
468
+ The full Open Source Code for the Quantum Network Monitor Service available at my github repos ( repos with NetworkMonitor in the name) : [Source Code Quantum Network Monitor](https://github.com/Mungert69). You will also find the code I use to quantize the models if you want to do it yourself [GGUFModelBuilder](https://github.com/Mungert69/GGUFModelBuilder)
469
+
470
+ 💬 **How to test**:
471
+ Choose an **AI assistant type**:
472
+ - `TurboLLM` (GPT-4.1-mini)
473
+ - `HugLLM` (Hugginface Open-source models)
474
+ - `TestLLM` (Experimental CPU-only)
475
+
476
+ ### **What I’m Testing**
477
+ I’m pushing the limits of **small open-source models for AI network monitoring**, specifically:
478
+ - **Function calling** against live network services
479
+ - **How small can a model go** while still handling:
480
+ - Automated **Nmap security scans**
481
+ - **Quantum-readiness checks**
482
+ - **Network Monitoring tasks**
483
+
484
+ 🟡 **TestLLM** – Current experimental model (llama.cpp on 2 CPU threads on huggingface docker space):
485
+ - ✅ **Zero-configuration setup**
486
+ - ⏳ 30s load time (slow inference but **no API costs**) . No token limited as the cost is low.
487
+ - 🔧 **Help wanted!** If you’re into **edge-device AI**, let’s collaborate!
488
+
489
+ ### **Other Assistants**
490
+ 🟢 **TurboLLM** – Uses **gpt-4.1-mini** :
491
+ - **It performs very well but unfortunatly OpenAI charges per token. For this reason tokens usage is limited.
492
+ - **Create custom cmd processors to run .net code on Quantum Network Monitor Agents**
493
+ - **Real-time network diagnostics and monitoring**
494
+ - **Security Audits**
495
+ - **Penetration testing** (Nmap/Metasploit)
496
+
497
+ 🔵 **HugLLM** – Latest Open-source models:
498
+ - 🌐 Runs on Hugging Face Inference API. Performs pretty well using the lastest models hosted on Novita.
499
+
500
+ ### 💡 **Example commands you could test**:
501
+ 1. `"Give me info on my websites SSL certificate"`
502
+ 2. `"Check if my server is using quantum safe encyption for communication"`
503
+ 3. `"Run a comprehensive security audit on my server"`
504
+ 4. '"Create a cmd processor to .. (what ever you want)" Note you need to install a Quantum Network Monitor Agent to run the .net code from. This is a very flexible and powerful feature. Use with caution!
505
+
506
+ ### Final Word
507
+
508
+ I fund the servers used to create these model files, run the Quantum Network Monitor service, and pay for inference from Novita and OpenAI—all out of my own pocket. All the code behind the model creation and the Quantum Network Monitor project is [open source](https://github.com/Mungert69). Feel free to use whatever you find helpful.
509
+
510
+ If you appreciate the work, please consider [buying me a coffee](https://www.buymeacoffee.com/mahadeva) ☕. Your support helps cover service costs and allows me to raise token limits for everyone.
511
+
512
+ I'm also open to job opportunities or sponsorship.
513
+
514
+ Thank you! 😊
SmolVLM-256M-Instruct-bf16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62ccb3c3cbc505be38901653d67a2211e27c2d864e53d138b2efba08140915cc
3
+ size 327809888
SmolVLM-256M-Instruct-bf16.mmproj ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09e12be1ef94b9cb13b303be3d82525eb49c74f98179807aa27347ae33cc2cd8
3
+ size 190031616
SmolVLM-256M-Instruct-bf16_q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d3490230d26dd5ae451462810d03a13cbd750101316c1f475e5c6f9f29e05ec
3
+ size 265601888
SmolVLM-256M-Instruct-f16.mmproj ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0671eac970aee8b43aeb9604cd0294af86122abbed50fc05b363fad7c0005343
3
+ size 190031616
SmolVLM-256M-Instruct-f16_q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4022b743f3b72296bee168e2db6a3b11969d1463a21ea60121e4bd8261ae8fd
3
+ size 265601888
SmolVLM-256M-Instruct-f32.mmproj ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45fe6617a0bce33ea12fbadef9c7ad86d8e611764b75459b173a831b636773f3
3
+ size 374056704
SmolVLM-256M-Instruct-iq3_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c15615bff71c5d1d55c716a8875467e5a68fb881e050c47256f639b1bf6e0bc2
3
+ size 102032032
SmolVLM-256M-Instruct-iq3_s.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05333c4942657f4a1ebe02a19899a06ff6fd5fb03100f380a17b0c5aa84ebf6f
3
+ size 100704928
SmolVLM-256M-Instruct-iq3_xs.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:df629dc7183f5760b8f87ef883608e6064c2e24f2fe209561bcc1a8ef2893a8d
3
+ size 100704928
SmolVLM-256M-Instruct-iq3_xxs.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e654dafb5465ffc9a00ebd93a425256e48a170cee51f7a3c5ceff33711cd0380
3
+ size 99709600
SmolVLM-256M-Instruct-iq4_nl.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64445264e2300475be49dbcb8d79331c31fcb54ce33e8b8a75bdd32e3649ed76
3
+ size 107778208
SmolVLM-256M-Instruct-iq4_xs.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2966b2883655aeb67b3c8c1c9514b189fd8b5af769bf7d0d86d8db95bba36016
3
+ size 106948768
SmolVLM-256M-Instruct-q3_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77589704ddd905c95b111a7d9c2bf721168f24cbcda27f99e179d8cb0605287d
3
+ size 105391264
SmolVLM-256M-Instruct-q3_k_s.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8bc5d6c1181ad7fbf436c6f2fd8d73bda6dc4a47ceb813719aa1e005a65b50cd
3
+ size 101244064
SmolVLM-256M-Instruct-q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1fc7b5db6a25ede72d707a14679c6b21804b213c95c809514f3315c8feaf4179
3
+ size 93585568
SmolVLM-256M-Instruct-q4_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28302b09b5c1c9355b4d3d10da0d66139413035f2bb15b4742ee312ad18f02f6
3
+ size 103769248
SmolVLM-256M-Instruct-q4_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f30cd2828abe9f42c606e95fc5c97eb4660bc7340c20dbfcce3c7cb04efd1cfc
3
+ size 117169312
SmolVLM-256M-Instruct-q4_k_s.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2fa808c5635b8a477273036cf91a0c6080f2bdea6d60b09bd946765f248cbb15
3
+ size 115019680
SmolVLM-256M-Instruct-q5_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ba541fdd7bc7d2e7f0539ba0d12e27e006cc9e7f741090b0f39b360f21fa0c8
3
+ size 113952928
SmolVLM-256M-Instruct-q5_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22f7252bd90d0773506a32b55353b1a2472b82470303c8ea20aa1e369300dd3e
3
+ size 124136608
SmolVLM-256M-Instruct-q5_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:268055da3b334d39c615c24b106f3f40ad661b2fcfe36891dab0a625e6478cca
3
+ size 125228704
SmolVLM-256M-Instruct-q5_k_s.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a0656014e606993ecef77e20d77c6dc0f40fa91221cbc4feffaaf37bd5004a0
3
+ size 124012192
SmolVLM-256M-Instruct-q6_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:30c72865e13b83e010b761750b89b2e75c0ccd0acf7836b7178e350a2f9f4c5e
3
+ size 168626848
SmolVLM-256M-Instruct-q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aae9358a0a5df8e9f7ec47ec21185d77aa4c0aa8c84c695778b3974afac4156e
3
+ size 175054688
SmolVLM-256M-Instruct-q8_0.mmproj ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f0a81b8fa88671e1f4a3094356667775452a1d47c6c7214070fcab606ee51f9
3
+ size 103769856
SmolVLM-256M-Instruct.imatrix ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e82fefbd81867b85e43dcf8db7d7bb67e6e747a39f8222af30286938091ae613
3
+ size 606042