标签:
- clip
- llm-jp-clip
- 日语-clip
库名称: open_clip
管道标签: 零样本图像分类
许可证:
- apache-2.0
数据集:
- llm-jp/relaion2B-en-research-safe-japanese-translation
语言:
- ja
模型卡片:llm-jp-clip-vit-base-patch16
模型详情
日语CLIP模型,使用OpenCLIP在relaion2B-en-research-safe-japanese-translation数据集上训练,该数据集是ReLAION-5B英文子集的日语翻译版本(https://huggingface.co/datasets/laion/relaion2B-en-research-safe),由gemma-2-9b-it翻译完成。
该模型总参数量为248M。
使用方法
安装
$ pip install open_clip_torch
零样本图像分类
import open_clip
model, preprocess = open_clip.create_model_from_pretrained('hf-hub:llm-jp/llm-jp-clip-vit-base-patch16')
tokenizer = open_clip.get_tokenizer('hf-hub:llm-jp/llm-jp-clip-vit-base-patch16')
import torch
from PIL import Image
import requests
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
image = preprocess(image).unsqueeze(0)
text = tokenizer(["猫", "犬", "鳥"])
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("标签概率:", text_probs)
参考:
训练详情
模型架构
- 文本编码器: 基于RoBERTa base,使用llm-jp-tokenizer
- 图像编码器: ViT-B/16
训练数据
本模型在relaion2B-en-research-safe-japanese-translation数据集上训练。由于图像下载成功率为70%,数据集规模为14.5亿样本,我们进行了9个epoch的训练(总计130亿样本)。
评估
评估代码: https://github.com/llm-jp/clip-eval
表格: 各模型在零样本图像分类和图文检索任务中的表现。粗体表示第一名,_下划线_表示第二名。
许可证
Apache许可证 2.0版
请注意,训练数据是使用gemma-2-9b-it翻译的,请参考Gemma使用条款。我们仅将Gemma用于翻译目的。根据第1.1(e)节中"模型衍生品"的定义,我们的模型不属于"为了使该模型表现类似于Gemma"的范畴。因此,我们得出结论,无需继承Gemma许可证。
引用
Bibtex:
@inproceedings{sugiura-etal-2025-developing,
title = "开发日语{CLIP}模型:利用开源权重{LLM}进行大规模数据集翻译",
author = "杉浦, 一紗 and
栗田, 修平 and
小田, 悠介 and
河原, 大輔 and
岡崎, 直明",
editor = "Ebrahimi, Abteen and
Haider, Samar and
Liu, Emmy and
Haider, Sammar and
Leonor Pacheco, Maria and
Wein, Shira",
booktitle = "2025年美洲国家计算语言学会分会人类语言技术会议论文集(第四卷:学生研究研讨会)",
month = 4月,
year = "2025",
address = "美国阿尔伯克基",
publisher = "计算语言学协会",
url = "https://aclanthology.org/2025.naacl-srw.15/",
pages = "162--170",
ISBN = "979-8-89176-192-6",
abstract = "CLIP是连接图像和文本的基础模型,被广泛用作众多视觉语言模型的关键组件。然而,缺乏大规模开放的日语图文对数据集严重阻碍了日语视觉语言模型的发展。本研究通过使用开源权重LLM进行机器翻译,构建了包含15亿样本的日语图文对数据集,并在此数据集上预训练了日语CLIP模型。预训练模型在七个基准数据集上的评估显示,与同类规模模型相比取得了具有竞争力的平均分数,且无需大量数据筛选。然而,结果也表明在涉及日本文化特定任务上表现相对较低,凸显了基于翻译方法在捕捉文化细微差异方面的局限性。我们的数据集、模型和代码均已公开。"
}