README.md
11.1 KB · 232 lines · markdown Raw
1 ---
2 license: mit
3 widget:
4 - src: >-
5 https://huggingface.co/datasets/mishig/sample_images/resolve/main/cat-dog-music.png
6 candidate_labels: playing music, playing sports
7 example_title: Cat & Dog
8 library_name: open_clip
9 pipeline_tag: zero-shot-image-classification
10 ---
11 # Model Card for CLIP ViT-L/14 - LAION-2B
12
13 # Table of Contents
14
15 1. [Model Details](#model-details)
16 2. [Uses](#uses)
17 3. [Training Details](#training-details)
18 4. [Evaluation](#evaluation)
19 5. [Acknowledgements](#acknowledgements)
20 6. [Citation](#citation)
21 7. [How To Get Started With the Model](#how-to-get-started-with-the-model)
22
23
24 # Model Details
25
26 ## Model Description
27
28 A CLIP ViT L/14 model trained with the LAION-2B English subset of LAION-5B (https://laion.ai/blog/laion-5b/) using OpenCLIP (https://github.com/mlfoundations/open_clip).
29
30 Model training ('babysitting') done by Ross Wightman on the [JUWELS Booster](https://apps.fz-juelich.de/jsc/hps/juwels/booster-overview.html) supercomputer. See acknowledgements below.
31
32 # Uses
33
34 As per the original [OpenAI CLIP model card](https://github.com/openai/CLIP/blob/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1/model-card.md), this model is intended as a research output for research communities. We hope that this model will enable researchers to better understand and explore zero-shot, arbitrary image classification. We also hope it can be used for interdisciplinary studies of the potential impact of such model.
35
36 The OpenAI CLIP paper includes a discussion of potential downstream impacts to provide an example for this sort of analysis. Additionally, the LAION-5B blog (https://laion.ai/blog/laion-5b/) and upcoming paper include additional discussion as it relates specifically to the training dataset.
37
38 ## Direct Use
39
40 Zero-shot image classification, image and text retrieval, among others.
41
42 ## Downstream Use
43
44 Image classification and other image task fine-tuning, linear probe image classification, image generation guiding and conditioning, among others.
45
46 ## Out-of-Scope Use
47
48 As per the OpenAI models,
49
50 **Any** deployed use case of the model - whether commercial or not - is currently out of scope. Non-deployed use cases such as image search in a constrained environment, are also not recommended unless there is thorough in-domain testing of the model with a specific, fixed class taxonomy. This is because our safety assessment demonstrated a high need for task specific testing especially given the variability of CLIP’s performance with different class taxonomies. This makes untested and unconstrained deployment of the model in any use case currently potentially harmful.
51
52 Certain use cases which would fall under the domain of surveillance and facial recognition are always out-of-scope regardless of performance of the model. This is because the use of artificial intelligence for tasks such as these can be premature currently given the lack of testing norms and checks to ensure its fair use.
53
54 Since the model has not been purposefully trained in or evaluated on any languages other than English, its use should be limited to English language use cases.
55
56 Further the above notice, the LAION-5B dataset used in training of these models has additional considerations, see below.
57
58 # Training Details
59
60 ## Training Data
61
62 This model was trained with the 2 Billion sample English subset of LAION-5B (https://laion.ai/blog/laion-5b/).
63
64 **IMPORTANT NOTE:** The motivation behind dataset creation is to democratize research and experimentation around large-scale multi-modal model training and handling of uncurated, large-scale datasets crawled from publically available internet. Our recommendation is therefore to use the dataset for research purposes. Be aware that this large-scale dataset is uncurated. Keep in mind that the uncurated nature of the dataset means that collected links may lead to strongly discomforting and disturbing content for a human viewer. Therefore, please use the demo links with caution and at your own risk. It is possible to extract a “safe” subset by filtering out samples based on the safety tags (using a customized trained NSFW classifier that we built). While this strongly reduces the chance for encountering potentially harmful content when viewing, we cannot entirely exclude the possibility for harmful content being still present in safe mode, so that the warning holds also there. We think that providing the dataset openly to broad research and other interested communities will allow for transparent investigation of benefits that come along with training large-scale models as well as pitfalls and dangers that may stay unreported or unnoticed when working with closed large datasets that remain restricted to a small community. Providing our dataset openly, we however do not recommend using it for creating ready-to-go industrial products, as the basic research about general properties and safety of such large-scale models, which we would like to encourage with this release, is still in progress.
65
66 ## Training Procedure
67
68 The model was trained on 384 A100 GPUs using 200M sample 'virtual' epochs where dataset shards were sampled with replacement. The model was trained with 160 virtual epochs for a total of 32B samples seen.
69
70 The first 68 epochs were trained with float16 AMP, global batch size 79K (208 per GPU). Initially running to epoch 75, where the loss spiked and training failed with NaN.
71
72 Romain Beaumont was training H/14 and g/14 models at the same time on Stability cluster and hit similar instabilities. Collectively we tried restarts with,
73 * different dataset shuffle seed
74 * different LR
75 * gradient clipping
76 * modifications to the architecture
77 * Norm modifications (stable norm for final, post embed norm for text transformer) as per https://github.com/mlfoundations/open_clip/pull/153 thanks to Phil Wang
78 * Extra attention block norms ala Normformer (https://arxiv.org/abs/2110.09456)
79 * Scaled cosine attention ala Swin-V2 (https://arxiv.org/abs/2111.09883)
80
81 None of the above ended up working. Most blew up within the same epoch as original, with the exception of architecture mods.
82 * Normformer mods signifcantly altered the network such that resuming did not quickly converge to previous performance, this was abandoned but might be worth trying from start.
83 * Scaled cosine attn initially looked promising and lasted until epoch 90 before loss suddenly increased and appeared to remain 'stuck'.
84
85 In the end, restarting at epoch 69 with `float32` precision solved all instabilities and training continued from there with global batch size 86k (224 per GPU). On A100 GPUs, `float32` had a minimal impact on the throughput once `tf32` matmuls were enabled in PyTorch. Approximately 10% slower than `float16 AMP`. Romain similary changed the precision but ended up using `bfloat16 AMP` to resolve issues.
86
87 ### Slum Script
88
89 ```
90 #SBATCH --nodes=96
91 #SBATCH --gres=gpu:4
92 #SBATCH --ntasks-per-node=4
93 #SBATCH --cpus-per-task=6
94 #SBATCH --wait-all-nodes=1
95 #SBATCH --job-name=open_clip_laion2b
96
97 # load low-level libraries
98 ml purge
99 source /conda/bin/activate pytorch-112
100
101 export NCCL_ASYNC_ERROR_HANDLING=1
102 export CUDA_VISIBLE_DEVICES=0,1,2,3
103 export MASTER_PORT=12802
104
105 ### get the first node name as master address - customized for vgg slurm
106 ### e.g. master(gnodee[2-5],gnoded1) == gnodee2
107 echo "NODELIST="${SLURM_NODELIST}
108 master_addr=$(scontrol show hostnames "$SLURM_JOB_NODELIST" | head -n 1)
109 export MASTER_ADDR=$master_addr"i"
110 echo "MASTER_ADDR="$MASTER_ADDR
111
112 cd /home/me/open_clip
113 export PYTHONPATH="$PYTHONPATH:$PWD/src"
114
115 srun --cpu_bind=none,v --accel-bind=gn python -u src/training/main.py \
116 --save-frequency 1 \
117 --zeroshot-frequency 1 \
118 --train-data="/data/laion2B-en/{00000..23295}.tar" \
119 --train-num-samples=200000000 \
120 --warmup 10000 \
121 --lr "1e-3" \
122 --batch-size=224 \
123 --epochs=160 \
124 --workers=6 \
125 --model ViT-L-14 \
126 --name "L14-laion2B" \
127 --report-to "tensorboard" \
128 --seed 0 \
129 --precision 'fp32' \
130 --ddp-static-graph \
131 --local-loss \
132 --dataset-resampled \
133 --gather-with-grad \
134 --grad-checkpointing
135 ```
136
137 # Evaluation
138
139 Evaluation done with code in the [LAION CLIP Benchmark suite](https://github.com/LAION-AI/CLIP_benchmark).
140
141 ## Testing Data, Factors & Metrics
142
143 ### Testing Data
144
145 The testing is performed with VTAB+ (A combination of VTAB (https://arxiv.org/abs/1910.04867) w/ additional robustness datasets) for classification and COCO and Flickr for retrieval.
146
147 **TODO** - more detail
148
149 ## Results
150
151 The model achieves a 75.3 zero-shot top-1 accuracy on ImageNet-1k.
152
153 An initial round of benchmarks have been performed on a wider range of datasets, currently viewable at https://github.com/LAION-AI/CLIP_benchmark/blob/main/benchmark/results.ipynb
154
155 **TODO** - create table for just this model's metrics.
156
157 # Acknowledgements
158
159 Acknowledging the Gauss Centre for Supercomputing e.V. (http://gauss-centre.eu) for funding this part of work by providing computing time through the John von Neumann Institute for Computing (NIC) on the GCS Supercomputer JUWELS Booster at Jülich Supercomputing Centre (JSC).
160
161 # Citation
162
163 **BibTeX:**
164
165 LAION-5B
166 ```bibtex
167 @inproceedings{schuhmann2022laionb,
168 title={{LAION}-5B: An open large-scale dataset for training next generation image-text models},
169 author={Christoph Schuhmann and
170 Romain Beaumont and
171 Richard Vencu and
172 Cade W Gordon and
173 Ross Wightman and
174 Mehdi Cherti and
175 Theo Coombes and
176 Aarush Katta and
177 Clayton Mullis and
178 Mitchell Wortsman and
179 Patrick Schramowski and
180 Srivatsa R Kundurthy and
181 Katherine Crowson and
182 Ludwig Schmidt and
183 Robert Kaczmarczyk and
184 Jenia Jitsev},
185 booktitle={Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track},
186 year={2022},
187 url={https://openreview.net/forum?id=M3Y74vmsMcY}
188 }
189 ```
190
191 OpenAI CLIP paper
192 ```
193 @inproceedings{Radford2021LearningTV,
194 title={Learning Transferable Visual Models From Natural Language Supervision},
195 author={Alec Radford and Jong Wook Kim and Chris Hallacy and A. Ramesh and Gabriel Goh and Sandhini Agarwal and Girish Sastry and Amanda Askell and Pamela Mishkin and Jack Clark and Gretchen Krueger and Ilya Sutskever},
196 booktitle={ICML},
197 year={2021}
198 }
199 ```
200
201 OpenCLIP software
202 ```
203 @software{ilharco_gabriel_2021_5143773,
204 author = {Ilharco, Gabriel and
205 Wortsman, Mitchell and
206 Wightman, Ross and
207 Gordon, Cade and
208 Carlini, Nicholas and
209 Taori, Rohan and
210 Dave, Achal and
211 Shankar, Vaishaal and
212 Namkoong, Hongseok and
213 Miller, John and
214 Hajishirzi, Hannaneh and
215 Farhadi, Ali and
216 Schmidt, Ludwig},
217 title = {OpenCLIP},
218 month = jul,
219 year = 2021,
220 note = {If you use this software, please cite it as below.},
221 publisher = {Zenodo},
222 version = {0.1},
223 doi = {10.5281/zenodo.5143773},
224 url = {https://doi.org/10.5281/zenodo.5143773}
225 }
226 ```
227
228 # How to Get Started with the Model
229
230 Use the code below to get started with the model.
231
232 ** TODO ** - Hugging Face transformers, OpenCLIP, and timm getting started snippets