mfarre HF Staff commited on
Commit
920ac89
·
verified ·
1 Parent(s): 8d39814

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +198 -180
README.md CHANGED
@@ -1,199 +1,217 @@
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: video-text-to-text
18
+ language:
19
+ - en
20
+ base_model:
21
+ - HuggingFaceTB/SmolVLM-Instruct
22
  ---
23
 
 
24
 
25
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/SmolVLM2_banner.png" width="800" height="auto" alt="Image description">
26
 
27
+ # SmolVLM2 2.2B
28
 
29
+ SmolVLM2-500M-Video is 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 1.8GB 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.
30
+ ## Model Summary
31
 
32
+ - **Developed by:** Hugging Face 🤗
33
+ - **Model type:** Multi-modal model (image/multi-image/video/text)
34
+ - **Language(s) (NLP):** English
35
+ - **License:** Apache 2.0
36
+ - **Architecture:** Based on [Idefics3](https://huggingface.co/HuggingFaceM4/Idefics3-8B-Llama3) (see technical summary)
37
 
38
+ ## Resources
39
 
40
+ - **Demo:** [Video Highlight Generator](https://huggingface.co/spaces/HuggingFaceTB/SmolVLM2-HighlightGenerator)
41
+ - **Blog:** [Blog post](https://huggingface.co/blog/smolvlm2)
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  ## Uses
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
+ 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.
48
+
49
+ To fine-tune SmolVLM2 on a specific task, you can follow [the fine-tuning tutorial](UPDATE).
50
+
51
+ ## Evaluation
52
+
53
+ ### Vision Evaluation
54
 
55
+ | Size | Mathvista | MMM U | OCRBench | MMStar | AI2D | ChartQA_Test | Science_QA | TextVQA Val | DocVQA Val |
56
+ |-------|----------|-------|----------|--------|------|--------------|------------|-------------|------------|
57
+ | 2.2B | 51.5 | 42 | 72.9 | 46 | 70 | 68.84 | 90 | 73.21 | 79.98 |
58
 
 
59
 
60
+ ### Video Evaluation
61
+ We evaluated the performance of the SmolVLM2 family on the following scientific benchmarks:
62
 
63
+ | Size | Video-MME | MLVU | MVBench |
64
+ |----------|-----------------|----------|---------------|
65
+ | 2.2B | 52.1 | 55.2 | 46.27 |
66
+ | 500M | 42.2 | 47.3 | 39.73 |
67
+ | 256M | 33.7 | 40.6 | 32.7 |
68
+
69
+
70
+ ### How to get started
71
+
72
+ You can use transformers to load, infer and fine-tune SmolVLM. Make sure you have num2words, flash-attn and latest transformers installed.
73
+ You can load the model as follows.
74
+
75
+ ```python
76
+ from transformers import AutoProcessor, AutoModelForImageTextToText
77
+
78
+ model_path = "HuggingFaceTB/SmolVLM2-2.2B-Instruct"
79
+ processor = AutoProcessor.from_pretrained(model_path)
80
+ model = AutoModelForImageTextToText.from_pretrained(
81
+ model_path,
82
+ torch_dtype=torch.bfloat16,
83
+ _attn_implementation="flash_attention_2"
84
+ ).to("cuda")
85
+ ```
86
+
87
+ #### Simple Inference
88
+
89
+ You preprocess your inputs directly using chat templates and directly passing them
90
+
91
+ ```python
92
+ messages = [
93
+ {
94
+ "role": "user",
95
+ "content": [
96
+ {"type": "text", "text": "What is in this image?"},
97
+ {"type": "image", "path": "path_to_img.png"},
98
+
99
+ ]
100
+ },
101
+ ]
102
+
103
+ inputs = processor.apply_chat_template(
104
+ messages,
105
+ add_generation_prompt=True,
106
+ tokenize=True,
107
+ return_dict=True,
108
+ return_tensors="pt",
109
+ ).to(model.device)
110
+
111
+ generated_ids = model.generate(**inputs, do_sample=False, max_new_tokens=64)
112
+ generated_texts = processor.batch_decode(
113
+ generated_ids,
114
+ skip_special_tokens=True,
115
+ )
116
+ print(generated_texts[0])
117
+ ```
118
+
119
+ #### Video Inference
120
+
121
+ To use SmolVLM2 for video inference, make sure you have decord installed.
122
+
123
+ ```python
124
+ messages = [
125
+ {
126
+ "role": "user",
127
+ "content": [
128
+ {"type": "video", "path": "path_to_video.mp4"},
129
+ {"type": "text", "text": "Describe this video in detail"}
130
+ ]
131
+ },
132
+ ]
133
+
134
+ inputs = processor.apply_chat_template(
135
+ messages,
136
+ add_generation_prompt=True,
137
+ tokenize=True,
138
+ return_dict=True,
139
+ return_tensors="pt",
140
+ ).to(model.device)
141
+
142
+ generated_ids = model.generate(**inputs, do_sample=False, max_new_tokens=64)
143
+ generated_texts = processor.batch_decode(
144
+ generated_ids,
145
+ skip_special_tokens=True,
146
+ )
147
+
148
+ print(generated_texts[0])
149
+ ```
150
+ #### Multi-image Interleaved Inference
151
+
152
+ You can interleave multiple media with text using chat templates.
153
+
154
+ ```python
155
+ import torch
156
+
157
+
158
+ messages = [
159
+ {
160
+ "role": "user",
161
+ "content": [
162
+ {"type": "text", "text": "What is the similarity between this image <image>"},
163
+
164
+ {"type": "image", "path": "image_1.png"},
165
+ {"type": "text", "text": "and this image <image>"},
166
+ {"type": "image", "path": "image_2.png"},
167
+ ]
168
+ },
169
+ ]
170
+ inputs = processor.apply_chat_template(
171
+ messages,
172
+ add_generation_prompt=True,
173
+ tokenize=True,
174
+ return_dict=True,
175
+ return_tensors="pt",
176
+ ).to(model.device)
177
+
178
+ generated_ids = model.generate(**inputs, do_sample=False, max_new_tokens=64)
179
+ generated_texts = processor.batch_decode(
180
+ generated_ids,
181
+ skip_special_tokens=True,
182
+ )
183
+ print(generated_texts[0])
184
+ ```
185
+
186
+
187
+ ### Model optimizations
188
+
189
+ ## Misuse and Out-of-scope Use
190
+
191
+ 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:
192
+
193
+ - Prohibited Uses:
194
+ - Evaluating or scoring individuals (e.g., in employment, education, credit)
195
+ - Critical automated decision-making
196
+ - Generating unreliable factual content
197
+ - Malicious Activities:
198
+ - Spam generation
199
+ - Disinformation campaigns
200
+ - Harassment or abuse
201
+ - Unauthorized surveillance
202
+
203
+ ### License
204
+
205
+ 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.
206
+
207
+ We release the SmolVLM2 checkpoints under the Apache 2.0 license.
208
+
209
+ ## Training Data
210
+ SmolVLM2 used 3.3M samples for training originally from ten different datasets: [LlaVa Onevision](https://huggingface.co/datasets/lmms-lab/LLaVA-OneVision-Data), [M4-Instruct](https://huggingface.co/datasets/lmms-lab/M4-Instruct-Data), [Mammoth](https://huggingface.co/datasets/MAmmoTH-VL/MAmmoTH-VL-Instruct-12M), [LlaVa Video 178K](https://huggingface.co/datasets/lmms-lab/LLaVA-Video-178K), [FineVideo](https://huggingface.co/datasets/HuggingFaceFV/finevideo), [VideoStar](https://huggingface.co/datasets/orrzohar/Video-STaR), [VRipt](https://huggingface.co/datasets/Mutonix/Vript), [Vista-400K](https://huggingface.co/datasets/TIGER-Lab/VISTA-400K), [MovieChat](https://huggingface.co/datasets/Enxin/MovieChat-1K_train) and [ShareGPT4Video](https://huggingface.co/datasets/ShareGPT4Video/ShareGPT4Video).
211
+ In the following plots we give a general overview of the samples across modalities and the source of those samples.
212
+
213
+ <center><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/smolvlm2_data_split.png" width="auto" height="auto" alt="Image description">
214
+ </center>
215
+
216
+ ### Details
217
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/smolvlm2_datadetails.png" width="auto" height="auto" alt="Image description">