🚀 TiC-CLIP-bestpool-oracle 模型卡片
本仓库包含在 TiC-DataComp-Yearly(xlarge,最佳池过滤)上训练的 TiC-CLIP 模型,使用了 2014 年至 2022 年的数据,通过我们修改后的 OpenCLIP 代码进行训练。更多信息请参考我们的 GitHub 仓库。
🚀 快速开始
模型与 DataComp 评估套件以及我们为 TiC-DataComp-Retrieval 和 TiC-DataCompNet 评估而打补丁的 DataComp 版本兼容。这些模型还可以使用 OpenCLIP 代码来恢复训练或作为新训练的初始化。请按照我们 GitHub 仓库 中的说明创建评估集,或按照 DataComp 进行 38 个数据集的标准评估。
以下代码片段假设已准备好 TiC-DataComp 数据并遵循了 GitHub 仓库中的说明。
训练
YEAR=2016
REPO="apple/TiC-CLIP-bestpool-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-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)基准,用于训练视觉语言模型:TiC-DataComp、TiC-YFCC 和 TiC-Redcaps。我们最大的数据集 TiC-DataComp 包含超过 127 亿个带时间戳的图像 - 文本对,跨度为 9 年(2014 - 2022 年)。
我们首先使用我们的基准进行各种动态评估,以衡量现有模型的时间鲁棒性。我们发现,与 OpenCLIP 仓库中最近训练的模型相比,OpenAI 的 CLIP(在 2020 年之前的数据上训练)在我们精心策划的 2021 - 2022 年检索任务中零样本准确率下降了约 8%。然后,我们研究如何在时间连续的数据上高效训练模型。我们证明,一种基于简单排练的方法,即从最后一个检查点继续训练并回放旧数据,与从头开始重新训练的标准做法相比,计算量减少了 2.5 倍。代码可在 此链接 获取。
📦 安装指南
文档中未提及具体安装步骤,可参考 GitHub 仓库 中的说明。
📚 详细文档
模型详情
模型来源
- 仓库: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-bestpool-oracle |
训练数据 |
TiC-DataComp-Yearly(xlarge,最佳池过滤),使用 2014 年至 2022 年的数据 |
许可证 |
custom-apple-license,详情见 LICENSE |
标签 |
vision, zero-shot-image-classification |
数据集 |
apple/TiC-DataComp |
库名称 |
tic-clip |