模型简介
模型特点
模型能力
使用案例
🚀 TiC-CLIP-basic-cumulative模型卡
本仓库包含使用修改后的OpenCLIP代码,在TiC-DataComp-Yearly(xlarge,基本过滤)数据集上训练的TiC-CLIP模型,训练数据时间跨度为2014年至2022年。更多信息请参考我们的GitHub仓库。
🚀 快速开始
本模型与DataComp评估套件以及我们为TiC-DataComp-Retrieval和TiC-DataCompNet评估任务打补丁后的版本兼容。模型也可以使用OpenCLIP代码,从之前的检查点继续训练或作为新训练的初始化。请按照我们GitHub仓库中的说明创建评估集,或参考DataComp进行38个数据集的标准评估。
以下代码片段假设已经按照GitHub仓库中的说明准备好TiC-DataComp数据。
训练
YEAR=2016 # 由于2014 - 2016年的数据合并为一年,因此2016年之前没有模型
REPO="apple/TiC-CLIP-basic-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
评估
# 在TiC/Retrieval/Yearly/$YEAR和TiC/DataCompNet/Yearly/$YEAR上评估ViT-B/16模型
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-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年)。
- 评估现有模型的时间鲁棒性:使用这些基准进行各种动态评估,以衡量现有模型的时间鲁棒性。例如,OpenAI的CLIP(在2020年之前的数据上训练)在2021 - 2022年的检索任务中,与OpenCLIP仓库中最近训练的模型相比,零样本准确率下降了约8%。
- 高效训练方法:研究了如何在时间连续的数据上高效训练模型,证明了一种基于简单排练的方法,即从最后一个检查点继续训练并回放旧数据,与从头开始重新训练的标准做法相比,可将计算量减少2.5倍。
📦 安装指南
文档未提及具体安装步骤,可参考GitHub仓库获取相关信息。
💻 使用示例
基础用法
import open_clip
from huggingface_hub import hf_hub_download
filename = hf_hub_download(repo_id="apple/TiC-CLIP-basic-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)
高级用法
文档未提及高级用法相关代码,可参考GitHub仓库获取更多信息。
📚 详细文档
模型详情
模型描述
保持大型基础模型与最新数据同步本质上是昂贵的。为避免不断重新训练的高昂成本,持续训练这些模型至关重要。由于缺乏任何大规模的持续学习基准或基线,这个问题更加严重。
我们引入了第一组网络规模的时间连续(TiC)基准,用于训练视觉语言模型:TiC-DataComp、TiC-YFCC和TiC-Redcaps。我们最大的数据集TiC-DataComp包含超过127亿个带时间戳的图像-文本对,时间跨度为9年(2014 - 2022年)。
我们首先使用这些基准进行各种动态评估,以衡量现有模型的时间鲁棒性。我们发现,OpenAI的CLIP(在2020年之前的数据上训练)在我们精心策划的2021 - 2022年检索任务中,与OpenCLIP仓库中最近训练的模型相比,零样本准确率下降了约8%。
然后,我们研究了如何在时间连续的数据上高效训练模型。我们证明了一种基于简单排练的方法,即从最后一个检查点继续训练并回放旧数据,与从头开始重新训练的标准做法相比,可将计算量减少2.5倍。代码可在this https URL获取。
- 开发者:Apple
- 许可证:请参阅LICENSE
模型来源
- 仓库: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-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-DataComp-Yearly数据集训练的TiC-CLIP模型 |
训练数据 | TiC-DataComp,包含超过127亿个带时间戳的图像-文本对,时间跨度为9年(2014 - 2022年) |
开发者 | Apple |
许可证 | 自定义苹果许可证,见LICENSE |
仓库 | ml-tic-clip GitHub仓库 |
论文 | TiC-CLIP: Continual Training of CLIP Models |









