🚀 TiC-CLIP-bestpool-cumulative模型卡片
本仓库包含基于TiC-DataComp-Yearly(xlarge,最佳池过滤)数据集训练的TiC-CLIP模型,使用了2014年至2022年的数据,并借助我们改进后的OpenCLIP代码进行训练。如需更多信息,请参考我们的GitHub仓库。
📚 详细文档
模型描述
保持大型基础模型与最新数据同步本质上成本高昂。为避免持续重新训练带来的高昂成本,持续训练这些模型势在必行。而缺乏大规模的持续学习基准或基线,使这一问题更加严峻。
我们推出了第一套网络规模的时间连续(TiC)基准,用于训练视觉语言模型:TiC-DataComp、TiC-YFCC和TiC-Redcaps。其中,TiC-DataComp是我们最大的数据集,包含超过127亿个带时间戳的图像-文本对,时间跨度为9年(2014 - 2022年)。
我们首先利用这些基准进行各种动态评估,以衡量现有模型的时间鲁棒性。结果显示,与OpenCLIP仓库中最近训练的模型相比,OpenAI的CLIP(基于2020年以前的数据训练)在我们精心设计的2021 - 2022年检索任务中,零样本准确率下降了约8%。
随后,我们研究了如何在时间连续的数据上高效训练模型。我们证明,一种基于简单排练的方法(即从最后一个检查点继续训练并回放旧数据)与从头开始重新训练的标准做法相比,可将计算量减少2.5倍。相关代码可在此链接获取。
模型来源
- 仓库:ml-tic-clip GitHub仓库
- 论文:TiC-CLIP: Continual Training of CLIP Models, Garg, S., Farajtabar, M., Pouransari, H., Vemulapalli, R., Mehta, S., Tuzel, O., Shankar, V. and Faghri, F., International Conference on Learning Representations (ICLR), 2024.
🎯 用途
研究人员可以使用TiC-CLIP预训练模型,从预训练检查点开始,在次年或次月的数据上继续训练,从而更快地设计持续学习方法。
🚀 快速开始
这些模型与DataComp评估套件以及我们为TiC-DataComp-Retrieval和TiC-DataCompNet评估而修改的DataComp版本兼容。模型还可用于恢复训练或作为使用OpenCLIP代码进行新训练的初始化。
请按照我们GitHub仓库中的说明创建评估集,或按照DataComp的说明对38个数据集进行标准评估。
以下代码片段假设TiC-DataComp数据已准备好,并遵循了GitHub仓库中的说明。
💻 使用示例
基础用法
YEAR=2016
REPO="apple/TiC-CLIP-bestpool-cumulative"
huggingface-cli download $REPO checkpoints/$YEAR.pt
pushd datacomp
final_data_dir=$TIC_DATACOMP_Y_PATH/train/$YEAR/
torchrun --nproc_per_node 8 --nnodes 1 \
train.py \
--scale "tic_medium" \
--dataset_resampled \
--data_dir $final_data_dir \
--output_dir "./results/" \
--exp_name "datacomp_medium-basic_cumulative" \
--imagenet_val $IMAGENET_VAL_PATH \
--save_frequency 1 \
--resume
popd
高级用法
pushd datacomp
python ../dataset_creation/tic-datacomp/generate_tasklist.py --yaml-path tasklist.yml --sample-eval --eval-tasks retrieval/yearly,datacompnet/yearly
python evaluate.py --data_dir data/ --train_output_dir ./results --use_model "ViT-B-16 $YEAR.pt" --skip_hf --skip_db --skip_notification
OpenCLIP加载和推理示例
import open_clip
from huggingface_hub import hf_hub_download
filename = hf_hub_download(repo_id="apple/TiC-CLIP-bestpool-cumulative", filename="checkpoints/2016.pt")
model, _, preprocess = open_clip.create_model_and_transforms('ViT-B-16', filename)
tokenizer = open_clip.get_tokenizer('ViT-B-16')
image = preprocess(Image.open("image.png").convert('RGB')).unsqueeze(0)
text = tokenizer(["a diagram", "a dog", "a cat"])
with torch.no_grad(), torch.cuda.amp.autocast():
image_features = model.encode_image(image)
text_features = model.encode_text(text)
image_features /= image_features.norm(dim=-1, keepdim=True)
text_features /= text_features.norm(dim=-1, keepdim=True)
text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
print("Label probs:", text_probs)
🔧 技术细节
训练数据
请参考TiC-DataComp。
训练过程
请参考我们TiC-CLIP论文的第2 - 3节。
📄 许可证
本模型使用自定义苹果许可证,详情请见LICENSE。
📖 引用
TiC-CLIP: Continual Training of CLIP Models. (ICLR 2024)
Garg, S., Farajtabar, M., Pouransari, H., Vemulapalli, R., Mehta, S., Tuzel, O., Shankar, V. and Faghri, F..
@inproceedings{garg2024tic,
title={TiC-CLIP: Continual Training of CLIP Models},
author={Garg, Saurabh and Farajtabar, Mehrdad and Pouransari, Hadi and Vemulapalli, Raviteja and Mehta, Sachin and Tuzel, Oncel and Shankar, Vaishaal and Faghri, Fartash},
booktitle={The Twelfth International Conference on Learning Representations (ICLR)},
year={2024},
url={https://openreview.net/forum?id=TLADT8Wrhn}
}
属性 |
详情 |
模型类型 |
TiC-CLIP |
训练数据 |
apple/TiC-DataComp |