mfarre HF staff commited on
Commit
f93dfb6
·
verified ·
1 Parent(s): 017ae74

Update README.md

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