模型概述
模型特點
模型能力
使用案例
🚀 CLIP-convnext_xxlarge-laion2B-s34B-b82K-augreg模型卡片
本模型是一系列基於LAION-2B(英語)數據集訓練的CLIP ConvNeXt-XXLarge模型,旨在助力研究人員開展零樣本、任意圖像分類研究,為相關領域的探索提供有力支持。
🚀 快速開始
模型詳情
模型描述
一系列基於LAION-2B(英語)數據集訓練的CLIP ConvNeXt-XXLarge(自定義的timm
ConvNeXt大小)模型。LAION-2B是LAION-5B的一個子集,使用OpenCLIP進行訓練。
模型 | 數據集 | 分辨率 | AugReg | ImageNet零樣本Top-1準確率(%) |
---|---|---|---|---|
convnext_xxlarge.laion2b_s34b_b82k-augreg | LAION-2B | 256x256 | RRC (0.33, 1.0), RE (0.35), SD (0.1) | 79.1 |
convnext_xxlarge.laion2b_s34b_b82k-augreg-rewind | LAION-2B | 256x256 | RRC (0.3, 1.0), RE (0.4), SD (0.1) | 79.3 |
convnext_xxlarge.laion2b_s34b_b82k-augreg-soup | LAION-2B | 256x256 | N/A | 79.4 |
RRC = 隨機裁剪縮放 (裁剪比例), RE = 隨機擦除 (概率), SD = 隨機深度 (概率) -- 僅針對圖像塔
核心訓練過程分階段進行,歷時約2個月。核心訓練的全局批次大小為81920。最後約10%的訓練在全局批次大小為95744的情況下重新進行,使用了更高的學習率和更強的增強策略。最終將兩者的結果進行平均。更多細節見訓練詳情。
目標:
- 將最大的卷積CLIP圖像塔的性能提升到ViT - g到ViT - G的水平,並改善下游使用時的圖像尺寸縮放性能。
首次實現:
- 發佈了預訓練的最大ConvNeXt模型(圖像部分在256x256分辨率下有847M參數、198 GMAC和125 MActs)。
- 一個非ViT圖像塔的CLIP模型(沒有預先進行圖像塔預訓練)在ImageNet上的零樣本Top - 1準確率超過79%。
模型特性:
- 使用timm的ConvNeXt - XXLarge模型(
convnext_xxlarge
)作為圖像塔。 - 在圖像塔末尾使用標準投影。
- 文本塔的大小與ViT - H - 14和ViT - g - 14模型相同(維度1024,頭數16,深度24)。
模型在256x256的圖像分辨率下進行訓練。圖像 + 文本的CLIP模型總共有1.2B參數、222 GMAC和146 MActs。在256x256分辨率下,ConvNext - XXLarge在FLOPS和參數數量上略高於ViT - H - 14的CLIP配置,而激活計數更低。其性能介於g - 14和G - 14之間。
模型 | 圖像尺寸 | 嵌入維度 | GMACs | MActs | 參數數量(M) | 圖像GMACs | 圖像MActs | 圖像參數數量(M) | 文本GMACs | 文本MActs | 文本參數數量(M) |
---|---|---|---|---|---|---|---|---|---|---|---|
ViT - H - 16 | 224 | 1024 | 150.96 | 122.01 | 986.26 | 127.4 | 100.81 | 632.23 | 23.57 | 21.2 | 354.03 |
ViT - H - 14 | 224 | 1024 | 190.97 | 160.61 | 986.11 | 167.4 | 139.41 | 632.08 | 23.57 | 21.2 | 354.03 |
ViT - L - 14 - 336 | 336 | 768 | 197.76 | 278.19 | 427.94 | 191.1 | 270.24 | 304.29 | 6.66 | 7.95 | 123.65 |
convnext_xxlarge | 256 | 1024 | 221.66 | 145.66 | 1200.58 | 198.09 | 124.45 | 846.54 | 23.57 | 21.2 | 354.03 |
RN50x64 | 448 | 1024 | 276.8 | 249.73 | 623.26 | 265.02 | 239.13 | 420.38 | 11.78 | 10.6 | 202.88 |
ViT - g - 14 | 224 | 1024 | 290.74 | 213.84 | 1366.68 | 267.18 | 192.64 | 1012.65 | 23.57 | 21.2 | 354.03 |
convnext_xxlarge_320 | 320 | 1024 | 333.08 | 215.66 | 1200.58 | 309.52 | 194.46 | 846.54 | 23.57 | 21.2 | 354.03 |
ViT - H - 14 - 336 | 336 | 1024 | 414.53 | 428.74 | 986.52 | 390.97 | 407.54 | 632.49 | 23.57 | 21.2 | 354.03 |
ViT - bigG - 14 | 224 | 1280 | 532.92 | 310.71 | 2539.57 | 483.96 | 275.37 | 1844.91 | 48.96 | 35.34 | 694.66 |
模型訓練由Ross Wightman在stability.ai集群和[JUWELS Booster](https://apps.fz - juelich.de/jsc/hps/juwels/booster - overview.html)超級計算機上完成。詳情見下文致謝部分。
使用場景
根據原始的[OpenAI CLIP模型卡片](https://github.com/openai/CLIP/blob/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1/model - card.md),本模型是為研究社區提供的研究成果。我們希望該模型能幫助研究人員更好地理解和探索零樣本、任意圖像分類,也可用於跨學科研究,分析此類模型的潛在影響。
OpenAI CLIP論文中討論了模型可能產生的下游影響,為這類分析提供了示例。此外,LAION - 5B博客(https://laion.ai/blog/laion - 5b/)和即將發表的論文也針對訓練數據集進行了額外討論。
直接使用
- 零樣本圖像分類
- 圖像和文本檢索
下游使用
- 圖像分類和其他圖像任務的微調
- 線性探針圖像分類
- 圖像生成的引導和條件控制
不適用場景
與OpenAI模型一樣:
- 任何模型的部署應用場景(無論是否商業用途)目前都不在適用範圍內。非部署的使用場景,如在受限環境中的圖像搜索,除非對模型進行了針對特定、固定類別分類法的全面領域測試,否則也不建議使用。這是因為我們的安全評估表明,由於CLIP在不同類別分類法下的性能差異較大,需要針對具體任務進行測試。因此,在未經測試和不受限制的情況下部署模型可能會帶來潛在危害。
- 涉及監控和人臉識別領域的使用場景無論模型性能如何都不在適用範圍內。這是因為目前缺乏確保人工智能公平使用的測試規範和檢查機制,在這些任務中使用人工智能還為時過早。
- 由於模型僅在英語環境下進行訓練和評估,其使用應僅限於英語相關的場景。
此外,用於訓練這些模型的LAION - 5B數據集還有其他注意事項,詳見下文。
訓練詳情
訓練數據
本模型使用LAION - 2B數據集進行訓練,它是LAION - 5B(https://laion.ai/blog/laion - 5b/)的一個包含20億個英語樣本的子集。
⚠️ 重要提示
創建該數據集的目的是推動大規模多模態模型訓練和處理從公共互聯網爬取的未整理大規模數據集的研究和實驗。因此,我們建議僅將該數據集用於研究目的。請注意,這個大規模數據集是未整理的,其中收集的鏈接可能會指向令人不適和不安的內容。因此,請謹慎使用演示鏈接,並自行承擔風險。可以通過基於安全標籤過濾樣本(使用我們定製訓練的NSFW分類器)來提取一個“安全”子集。雖然這可以大大降低遇到潛在有害內容的可能性,但我們不能完全排除在安全模式下仍存在有害內容的可能性,因此警告仍然適用。我們認為,向廣大研究和其他感興趣的社區公開提供該數據集,有助於透明地研究訓練大規模模型帶來的好處,以及使用封閉的、僅限於小社區的大型數據集時可能未被報告或注意到的陷阱和危險。然而,我們不建議使用該數據集創建現成的工業產品,因為關於此類大規模模型的一般屬性和安全性的基礎研究仍在進行中。
訓練過程
主要訓練階段的全局批次大小為81920,共進行256個檢查點間隔的訓練,每個間隔有135.6M個樣本,訓練過程中總共處理了約34B個樣本。
在訓練過程中遇到了許多與模型數值穩定性、集群穩定性和性能相關的困難。最初嘗試使用float16 AMP和默認的adam beta2進行訓練時,出現了損失尖峰並最終導致NaN爆炸。將beta2
降低到0.97有所幫助,但損失/零樣本曲線未按預期變化。切換到PyTorch夜間版本後,可以使用bfloat16 + AMP進行訓練(與最近的H/14、g/14和G/14模型相同),將beta2恢復到0.98後,指標得到了改善。
檢查點間隔 | 集群 | GPU數量 | 節點數量 | GPU型號 | 本地批次大小 | 每秒樣本數 | 每個GPU每秒樣本數 | 精度 | adam beta2 |
---|---|---|---|---|---|---|---|---|---|
1 - 2 | Stability | 1024 | 128 | A100 40GB | 80 | 37 - 40k | 36 - 39 | amp + fp16 | 0.97 |
3 - 32 | Stability | 512 | 64 | A100 80GB | 160 | 27 - 32k | 52 - 62 | amp + fp16 | 0.97 |
33 - 75 | Booster | 1024 | 256 | A100 40GB | 80 | 48k | 47 | amp + fp16 | 0.97 |
76 - 165 | Booster | 1024 | 256 | A100 40GB | 80 | 51k | 50 | amp + bf16 | 0.98 |
166 - 232 | Stability | 320 | 40 | A100 80GB | 256 | 18 - 19k | 56 - 59 | amp + bf16 | 0.98 |
233 - 249 | Booster | 1024 | 256 | A100 40GB | 80 | 51k | 50 | amp + bf16 | 0.98 |
250 - 256 | Stability | 1024 | 128 | A100 40GB | 80 | 27 - 31k | 26 - 30 | amp + bf16 | 0.98 |
JUWELS Booster每個節點配備4個A100 GPU和4個HDR - 200 IB適配器(每個GPU 200Gbit/秒)。Stability集群每個節點配備8個A100 GPU和400Gbit/秒的EFA網絡(每個GPU 50 GBit/秒)。不同配置下的訓練效率(每個GPU的吞吐量)存在顯著差異。兩個集群中1024個GPU的配置特別容易崩潰(或者很難使用一組“良好”的GPU運行)。
以下是一個針對128個8 - GPU(40GB A100)配置的slurm srun命令行示例:
srun --cpu_bind=v --accel-bind=gn python -m training.main \
--save-frequency 1 \
--name "xxlarge-2b-81920-bf16" \
--resume "latest" \
--logs "/runs" \
--log-every-n-steps 50 \
--train-data="pipe:aws s3 cp s3://laion5b/laion2B-data/{000000..231349}.tar -" \
--train-num-samples 135646078 \
--dataset-type webdataset \
--warmup 10000 \
--batch-size=80 \
--epochs=256 \
--dataset-resampled \
--aug-cfg use_timm=True scale='(0.33, 1.0)' re_prob=0.35 \
--precision amp_bfloat16 \
--grad-clip-norm 5.0 \
--lr 1e-3 \
--workers=6 \
--beta2 0.98 \
--model "convnext_xxlarge" \
--seed 0 \
--ddp-static-graph \
--local-loss \
--gather-with-grad \
--grad-checkpointing \
--report-to "tensorboard"
在最後10%的訓練中,使用了更高的全局批次大小95744,並提高了學習率和增強策略的強度。
檢查點間隔 | 集群 | GPU數量 | 節點數量 | GPU型號 | 本地批次大小 | 每秒樣本數 | 每個GPU每秒樣本數 | 精度 | adam beta2 |
---|---|---|---|---|---|---|---|---|---|
231 - 256 | stability | 1088 | 136 | A100 40GB | 88 | 32 - 35k | 29 - 32 | amp + bf16 | 0.98 |
以下是針對136個8 - GPU(40GB A100)節點的slurm srun命令行示例:
srun --cpu_bind=v --accel-bind=gn python -m training.main \
--save-frequency 1 \
--name "xxlarge-2b-81920-r-bf16" \
--resume "latest" \
--logs "/runs" \
--log-every-n-steps 50 \
--train-data="pipe:aws s3 cp s3://laion5b/laion2B-data/{000000..231349}.tar -" \
--train-num-samples 135646078 \
--dataset-type webdataset \
--warmup 10000 \
--batch-size=88 \
--epochs=256 \
--dataset-resampled \
--aug-cfg use_timm=True scale='(0.3, 1.0)' re_prob=0.4 \
--precision amp_bfloat16 \
--grad-clip-norm 5.0 \
--lr 2e-3 \
--workers=6 \
--beta2 0.98 \
--model "convnext_xxlarge" \
--seed 0 \
--ddp-static-graph \
--local-loss \
--gather-with-grad \
--grad-checkpointing \
--report-to "tensorboard"
評估
使用[LAION CLIP Benchmark套件](https://github.com/LAION - AI/CLIP_benchmark)中的代碼進行評估。
測試數據、因素和指標
測試數據
分類任務使用VTAB + 數據集(VTAB(https://arxiv.org/abs/1910.04867)與額外的魯棒性數據集的組合),檢索任務使用COCO和Flickr數據集。
結果
這些模型在ImageNet - 1k上的零樣本Top - 1準確率在79.1%到79.4%之間。
最後10%訓練階段的放大圖:
已經在更廣泛的數據集上進行了初步基準測試,結果可在https://github.com/LAION - AI/CLIP_benchmark/blob/main/benchmark/results.ipynb查看。
致謝
感謝stability.ai和高斯超級計算中心(http://gauss - centre.eu)為這項工作提供資金支持,通過約翰·馮·諾依曼計算研究所(NIC)在於利希超級計算中心(JSC)的GCS超級計算機JUWELS Booster上提供計算時間。
引用
BibTeX格式:
LAION - 5B
@inproceedings{schuhmann2022laionb,
title={{LAION}-5B: An open large-scale dataset for training next generation image-text models},
author={Christoph Schuhmann and
Romain Beaumont and
Richard Vencu and
Cade W Gordon and
Ross Wightman and
Mehdi Cherti and
Theo Coombes and
Aarush Katta and
Clayton Mullis and
Mitchell Wortsman and
Patrick Schramowski and
Srivatsa R Kundurthy and
Katherine Crowson and
Ludwig Schmidt and
Robert Kaczmarczyk and
Jenia Jitsev},
booktitle={Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track},
year={2022},
url={https://openreview.net/forum?id=M3Y74vmsMcY}
}
OpenCLIP軟件
@software{ilharco_gabriel_2021_5143773,
author = {Ilharco, Gabriel and
Wortsman, Mitchell and
Wightman, Ross and
Gordon, Cade and
Carlini, Nicholas and
Taori, Rohan and
Dave, Achal and
Shankar, Vaishaal and
Namkoong, Hongseok and
Miller, John and
Hajishirzi, Hannaneh and
Farhadi, Ali and
Schmidt, Ludwig},
title = {OpenCLIP},
month = jul,
year = 2021,
note = {If you use this software, please cite it as below.},
publisher = {Zenodo},
version = {0.1},
doi = {10.5281/zenodo.5143773},
url = {https://doi.org/10.5281/zenodo.5143773}
}
OpenAI CLIP論文
@inproceedings{Radford2021LearningTV,
title={Learning Transferable Visual Models From Natural Language Supervision},
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},
booktitle={ICML},
year={2021}
}
@Article{liu2022convnet,
author = {Zhuang Liu and Hanzi Mao and Chao-Yuan Wu and Christoph Feichtenhofer and Trevor Darrell and Saining Xie},
title = {A ConvNet for the 2020s},
journal = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
year = {2022},
}
@misc{rw2019timm,
author = {Ross Wightman},
title = {PyTorch Image Models},
year = {2019},
publisher = {GitHub},
journal = {GitHub repository},
doi = {10.5281/zenodo.4414861},
howpublished = {\url{https://github.com/rwightman/pytorch-image-models}}
}
@InProceedings{pmlr-v162-wortsman22a,
title = {Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time},
author = {Wortsman, Mitchell and Ilharco, Gabriel and Gadre, Samir Ya and Roelofs, Rebecca and Gontijo-Lopes, Raphael and Morcos, Ari S and Namkoong, Hongseok and Farhadi, Ali and Carmon, Yair and Kornblith, Simon and Schmidt, Ludwig},
booktitle = {Proceedings of the 39th International Conference on Machine Learning},
pages = {23965--23998},
year = {2022},
editor = {Chaudhuri, Kamalika and Jegelka, Stefanie and Song, Le and Szepesvari, Csaba and Niu, Gang and Sabato, Sivan},
volume = {162},
series = {Proceedings of Machine Learning Research},
month = {17--23 Jul},
publisher = {PMLR},
pdf = {https://proceedings.mlr.press/v162/wortsman22a/wortsman22a.pdf},
url = {https://proceedings.mlr.press/v162/wortsman22a.html}
}









