模型概述
模型特點
模型能力
使用案例
🚀 CLIP-convnext_xxlarge-laion2B-s34B-b82K-augreg-soup模型卡片
本模型是一系列基於CLIP的ConvNeXt-XXLarge模型,旨在解決零樣本圖像分類問題,為研究人員提供了更強大的工具來探索多模態學習和圖像分類技術。
🚀 快速開始
模型詳情
一系列基於CLIP的ConvNeXt-XXLarge(一種自定義的timm
ConvNeXt尺寸)模型,使用OpenCLIP在LAION-2B(英文)數據集上進行訓練,該數據集是LAION-5B的一個子集。
模型 | 數據集 | 分辨率 | 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分辨率下有8.47億參數,198 GMAC和1.25億激活值)
- 非ViT圖像塔的CLIP模型(無需圖像塔預訓練)在ImageNet零樣本Top-1準確率上達到79%以上
模型結構
- 圖像塔:使用timm的ConvNeXt-XXLarge模型 (
convnext_xxlarge
) - 投影層:圖像塔末端的標準投影層
- 文本塔:與ViT-H-14和ViT-g-14模型相同大小(維度1024,頭數16,深度24)
模型在256x256圖像分辨率下進行訓練。圖像+文本CLIP模型的總參數為12億,222 GMAC和1.46億激活值。在256x256分辨率下,ConvNext-XXLarge在FLOPS和參數數量上略高於ViT-H-14 CLIP配置,但激活值數量較低。其性能介於g-14和G-14之間。
模型 | 圖像尺寸 | 嵌入維度 | GMACs | MActs | 參數數量(百萬) | 圖像GMACs | 圖像MActs | 圖像參數數量(百萬) | 文本GMACs | 文本MActs | 文本參數數量(百萬) |
---|---|---|---|---|---|---|---|---|---|---|---|
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超級計算機上完成。更多信息請參考下方致謝部分。
✨ 主要特性
- 零樣本圖像分類:無需額外訓練即可對未見類別的圖像進行分類。
- 圖像和文本檢索:支持基於圖像或文本的檢索任務。
- 多模態學習:結合圖像和文本信息,提升模型的理解能力。
📦 安裝指南
文檔未提供具體安裝步驟,因此跳過此章節。
💻 使用示例
文檔未提供代碼示例,因此跳過此章節。
📚 詳細文檔
用途
根據原始OpenAI CLIP模型卡片,本模型旨在作為研究成果供研究社區使用。我們希望該模型能幫助研究人員更好地理解和探索零樣本、任意圖像分類技術,同時也可用於跨學科研究,探討此類模型的潛在影響。
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個檢查點間隔,每個間隔包含1.356億樣本,訓練過程中總共處理約340億樣本。
訓練過程中遇到了模型數值穩定性、集群穩定性和性能等諸多問題。最初嘗試使用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基準套件中的代碼進行評估。
測試數據、因素和指標
- 測試數據:分類任務使用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查看。
🔧 技術細節
文檔未提供足夠技術細節(少於50字),因此跳過此章節。
📄 許可證
本項目採用MIT許可證。
致謝
感謝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}
}









