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









