模型简介
模型特点
模型能力
使用案例
🚀 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}
}









