模型简介
模型特点
模型能力
使用案例
标签:
- 零样本图像分类
- CLIP 库标签: open_clip 许可证: mit 库名称: open_clip 管道标签: 零样本图像分类
CLIP-convnext_xxlarge-laion2B-s34B-b82K-augreg-rewind 模型卡片
目录
模型详情
模型描述
一系列基于LAION-2B(英语,LAION-5B的子集)训练的CLIP ConvNeXt-XXLarge(自定义timm
ConvNeXt尺寸)模型,使用OpenCLIP。
模型 | 数据集 | 分辨率 | 数据增强 | 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预训练模型(847M参数,256x256分辨率下198 GMAC和125 MActs)
- 首个非ViT图像塔CLIP模型(无先前图像塔预训练)实现>79% ImageNet top-1零样本准确率
模型采用:
- 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超级计算机上完成。详见下文致谢部分。
用途
根据原始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个检查点间隔,每个间隔135.6M样本,总计约340亿样本。
训练该模型时遇到了模型数值稳定性和集群稳定性及性能方面的许多困难。最初尝试使用float16 AMP和默认adam beta2训练导致损失峰值和最终NaN爆炸。将beta2
降低至0.97有所帮助,但损失/零样本曲线未达预期。切换到PyTorch nightly版本后,可以使用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上实现了79.1至79.4的top-1零样本准确率。
最后10%重新训练的放大视图:
已在更广泛的数据集上进行了初步基准测试,可在https://github.com/LAION-AI/CLIP_benchmark/blob/main/benchmark/results.ipynb查看
致谢
感谢stability.ai和高斯超级计算中心e.V.(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}
}









