andito HF Staff commited on
Commit
312a110
·
verified ·
1 Parent(s): 3665b36

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +186 -184
README.md CHANGED
@@ -1,199 +1,201 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
 
11
 
12
- ## Model Details
 
 
 
 
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
 
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
  ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  library_name: transformers
3
+ license: apache-2.0
4
+ datasets:
5
+ - HuggingFaceM4/the_cauldron
6
+ - HuggingFaceM4/Docmatix
7
+ - lmms-lab/LLaVA-OneVision-Data
8
+ - lmms-lab/M4-Instruct-Data
9
+ - HuggingFaceFV/finevideo
10
+ - MAmmoTH-VL/MAmmoTH-VL-Instruct-12M
11
+ - lmms-lab/LLaVA-Video-178K
12
+ - orrzohar/Video-STaR
13
+ - Mutonix/Vript
14
+ - TIGER-Lab/VISTA-400K
15
+ - Enxin/MovieChat-1K_train
16
+ - ShareGPT4Video/ShareGPT4Video
17
+ pipeline_tag: image-text-to-text
18
+ tags:
19
+ - video-text-to-text
20
+ language:
21
+ - en
22
+ base_model:
23
+ - HuggingFaceTB/SmolVLM-Base
24
  ---
25
 
 
26
 
27
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/SmolVLM2_banner.png" width="800" height="auto" alt="Image description">
28
 
29
+ # SmolVLM2 2.2B
30
 
31
+ This is the base model for SmolVLM2-2.2B, a lightweight multimodal model designed to analyze video content. The model processes videos, images, and text inputs to generate text outputs - whether answering questions about media files, comparing visual content, or transcribing text from images. Despite its compact size, requiring only 5.2GB of GPU RAM for video inference, it delivers robust performance on complex multimodal tasks. This efficiency makes it particularly well-suited for on-device applications where computational resources may be limited.
32
+ ## Model Summary
33
 
34
+ - **Developed by:** Hugging Face 🤗
35
+ - **Model type:** Multi-modal model (image/multi-image/video/text)
36
+ - **Language(s) (NLP):** English
37
+ - **License:** Apache 2.0
38
+ - **Architecture:** Based on [Idefics3](https://huggingface.co/HuggingFaceM4/Idefics3-8B-Llama3) (see technical summary)
39
 
40
+ ## Resources
41
 
42
+ - **Demo:** [Video Highlight Generator](https://huggingface.co/spaces/HuggingFaceTB/SmolVLM2-HighlightGenerator)
43
+ - **Blog:** [Blog post](https://huggingface.co/blog/smolvlm2)
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  ## Uses
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
+ SmolVLM2 can be used for inference on multimodal (video / image / text) tasks where the input consists of text queries along with video or one or more images. Text and media files can be interleaved arbitrarily, enabling tasks like captioning, visual question answering, and storytelling based on visual content. The model does not support image or video generation.
50
+
51
+ To fine-tune SmolVLM2 on a specific task, you can follow [the fine-tuning tutorial](https://github.com/huggingface/smollm/blob/main/vision/finetuning/Smol_VLM_FT.ipynb).
52
+
53
+
54
+ ### How to get started
55
+
56
+ You can use transformers to load, infer and fine-tune SmolVLM. Make sure you have num2words, flash-attn and latest transformers installed.
57
+ You can load the model as follows.
58
+
59
+ ```python
60
+ from transformers import AutoProcessor, AutoModelForImageTextToText
61
+ import torch
62
+
63
+ model_path = "HuggingFaceTB/SmolVLM2-2.2B-Base"
64
+ processor = AutoProcessor.from_pretrained(model_path)
65
+ model = AutoModelForImageTextToText.from_pretrained(
66
+ model_path,
67
+ torch_dtype=torch.bfloat16,
68
+ _attn_implementation="flash_attention_2"
69
+ ).to("cuda")
70
+ ```
71
+
72
+ #### Simple Inference
73
+
74
+ You preprocess your inputs directly using chat templates and directly passing them
75
+
76
+ ```python
77
+ messages = [
78
+ {
79
+ "role": "user",
80
+ "content": [
81
+ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg"},
82
+ {"type": "text", "text": "Can you describe this image?"},
83
+ ]
84
+ },
85
+ ]
86
+
87
+ inputs = processor.apply_chat_template(
88
+ messages,
89
+ add_generation_prompt=True,
90
+ tokenize=True,
91
+ return_dict=True,
92
+ return_tensors="pt",
93
+ ).to(model.device, dtype=torch.bfloat16)
94
+
95
+ generated_ids = model.generate(**inputs, do_sample=False, max_new_tokens=64)
96
+ generated_texts = processor.batch_decode(
97
+ generated_ids,
98
+ skip_special_tokens=True,
99
+ )
100
+ print(generated_texts[0])
101
+ ```
102
+
103
+ #### Video Inference
104
+
105
+ To use SmolVLM2 for video inference, make sure you have decord installed.
106
+
107
+ ```python
108
+ messages = [
109
+ {
110
+ "role": "user",
111
+ "content": [
112
+ {"type": "video", "path": "path_to_video.mp4"},
113
+ {"type": "text", "text": "Describe this video in detail"}
114
+ ]
115
+ },
116
+ ]
117
+
118
+ inputs = processor.apply_chat_template(
119
+ messages,
120
+ add_generation_prompt=True,
121
+ tokenize=True,
122
+ return_dict=True,
123
+ return_tensors="pt",
124
+ ).to(model.device, dtype=torch.bfloat16)
125
+
126
+ generated_ids = model.generate(**inputs, do_sample=False, max_new_tokens=64)
127
+ generated_texts = processor.batch_decode(
128
+ generated_ids,
129
+ skip_special_tokens=True,
130
+ )
131
+
132
+ print(generated_texts[0])
133
+ ```
134
+ #### Multi-image Interleaved Inference
135
+
136
+ You can interleave multiple media with text using chat templates.
137
+
138
+ ```python
139
+ import torch
140
+
141
+
142
+ messages = [
143
+ {
144
+ "role": "user",
145
+ "content": [
146
+ {"type": "text", "text": "What is the similarity between these two images?"},
147
+ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg"},
148
+ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/0052a70beed5bf71b92610a43a52df6d286cd5f3/diffusers/rabbit.jpg"},
149
+ ]
150
+ },
151
+ ]
152
+
153
+ inputs = processor.apply_chat_template(
154
+ messages,
155
+ add_generation_prompt=True,
156
+ tokenize=True,
157
+ return_dict=True,
158
+ return_tensors="pt",
159
+ ).to(model.device, dtype=torch.bfloat16)
160
+
161
+ generated_ids = model.generate(**inputs, do_sample=False, max_new_tokens=64)
162
+ generated_texts = processor.batch_decode(
163
+ generated_ids,
164
+ skip_special_tokens=True,
165
+ )
166
+ print(generated_texts[0])
167
+ ```
168
+
169
+
170
+ ### Model optimizations
171
+
172
+ ## Misuse and Out-of-scope Use
173
+
174
+ 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:
175
+
176
+ - Prohibited Uses:
177
+ - Evaluating or scoring individuals (e.g., in employment, education, credit)
178
+ - Critical automated decision-making
179
+ - Generating unreliable factual content
180
+ - Malicious Activities:
181
+ - Spam generation
182
+ - Disinformation campaigns
183
+ - Harassment or abuse
184
+ - Unauthorized surveillance
185
+
186
+ ### License
187
+
188
+ SmolVLM2 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.
189
+
190
+ We release the SmolVLM2 checkpoints under the Apache 2.0 license.
191
+
192
+ ## Citation information
193
+ You can cite us in the following way:
194
+ ```bibtex
195
+ @article{marafioti2025smolvlm,
196
+ title={SmolVLM: Redefining small and efficient multimodal models},
197
+ 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},
198
+ journal={arXiv preprint arXiv:2504.05299},
199
+ year={2025}
200
+ }
201
+ ```