🚀 TiC - CLIP基础预言模型卡
本仓库包含在TiC - DataComp - Yearly(超大型,基础过滤)数据集上训练的TiC - CLIP模型,该数据集使用了2014年至2022年的数据,并采用了我们改进后的OpenCLIP代码。更多信息请参考我们的GitHub仓库。
🚀 快速开始
本模型与DataComp评估套件以及我们为TiC - DataComp - Retrieval和TiC - DataCompNet评估而修改的DataComp版本兼容。模型也可用于恢复训练或作为使用OpenCLIP代码进行新训练的初始化。请按照我们GitHub仓库中的说明创建评估集,或参考DataComp在38个数据集上进行标准评估。
训练
YEAR=2016
REPO="apple/TiC-CLIP-basic-oracle"
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-basic-oracle", 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)基准,用于训练视觉语言模型,包括TiC - DataComp、TiC - YFCC和TiC - Redcaps。其中最大的数据集TiC - DataComp包含超过127亿个带时间戳的图像 - 文本对,时间跨度为9年(2014 - 2022年)。
- 研究表明,OpenAI的CLIP(在2020年之前的数据上训练)在我们精心策划的2021 - 2022年检索任务中,与OpenCLIP仓库中最近训练的模型相比,零样本准确率下降了约8%。
- 展示了一种基于简单排练的方法,该方法从最后一个检查点继续训练并回放旧数据,与从头开始重新训练的标准做法相比,计算量减少了2.5倍。
📚 详细文档
模型详情
模型描述
保持大型基础模型与最新数据同步本质上成本高昂。为避免不断重新训练带来的高昂成本,持续训练这些模型势在必行。而缺乏任何大规模的持续学习基准或基线加剧了这个问题。
我们引入了第一套网络规模的时间连续(TiC)基准,用于训练视觉语言模型:TiC - DataComp、TiC - YFCC和TiC - Redcaps。我们最大的数据集TiC - DataComp包含超过127亿个带时间戳的图像 - 文本对,时间跨度为9年(2014 - 2022年)。
我们首先使用这些基准进行各种动态评估,以衡量现有模型的时间鲁棒性。我们发现OpenAI的CLIP(在2020年之前的数据上训练)在我们精心策划的2021 - 2022年检索任务中,与OpenCLIP仓库中最近训练的模型相比,零样本准确率下降了约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预训练模型,从预训练检查点开始,在次年或次月的数据上持续训练,从而更快地设计持续学习方法。
训练详情
训练数据
请参考TiC - DataComp。
训练过程
请参考我们TiC - CLIP论文的第2 - 3节。
引用
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基础预言模型 |
训练数据 |
TiC - DataComp - Yearly(超大型,基础过滤),使用了2014年至2022年的数据 |
标签 |
视觉、零样本图像分类 |
数据集 |
apple/TiC - DataComp |
库名称 |
tic - clip |