BAAI / AltCLIP-m18

huggingface.co
Total runs: 405
24-hour runs: -55
7-day runs: -121
30-day runs: -622
Model's Last Updated: April 18 2023
zero-shot-image-classification

Introduction of AltCLIP-m18

Model Details of AltCLIP-m18

AltCLIP-m18

名称 Name 任务 Task 语言 Language(s) 模型 Model Github
AltCLIP-m18 Text-Image Multilingual CLIP FlagAI
简介 Brief Introduction

继双语模型AltCLIP与9语模型AltCLIP-m9之后,我们训练了18语CLIP模型。命名为AltCLIP-m18。它支持英语、中文、日语、泰语、韩语、印地语、乌克兰语、阿拉伯语、土耳其语、越南语、波兰语、荷兰语、葡萄牙语、意大利语、西班牙语、德语、法语和俄语。

AltCLIP-m18模型可以为AltDiffusion-m18模型提供支持,关于AltDiffusion模型的具体信息可查看 此教程

模型代码已经在 FlagAI 上开源,权重位于我们搭建的 modelhub 上。我们还提供了微调,推理,验证的脚本,欢迎试用。

Following the bilingual model AltCLIP and the nine-language model AltCLIP-m9, we trained the eighteen-language CLIP model, Named AltCLIP-m18. It supports English, Chinese, Japanese, Thai, Korean, Hindi, Ukrainian, Arabic, Turkish, Vietnamese, Polish, Dutch, Portuguese, Italian, Spanish, German, French, and Russian.

The AltCLIP-m18 model can provide support for the AltDiffusion-m18 model. Specific information on the AltDiffusion modle can be found in this tutorial .

The model code has been open sourced on FlagAI and the weights are located on modelhub . We also provide scripts for fine-tuning, inference, and validation, so feel free to try them out.

训练数据集 Training datasets
No Language Stage1(LAION400M)(MIT)
1 En
2 th CCAligned
3 ko WikiMatrix ( CC-BY-SA 4.0 )
4 hi CCAligned
5 uk CCMatrix
6 ar WikiMatrix ( CC-BY-SA 4.0 ), OpenSubtitles
7 tr WikiMatrix ( CC-BY-SA 4.0 ), CCMatrix
8 vi CCMatrix
9 pl CCMatrix , WikiMatrix ( CC-BY-SA 4.0 )
10 nl CCMatrix
11 pt CCAligned
12 it WikiMatrix ( CC-BY-SA 4.0 ), Wikipedia
13 ja MultiParaCrawl ( Creative Commons CC0 license )
14 zh WikiMatrix ( CC-BY-SA 4.0 ), TSL2019
15 es WikiMatrix ( CC-BY-SA 4.0 )
16 de WikiMatrix ( CC-BY-SA 4.0 ), EUbookshop
17 fr WikiMatrix ( CC-BY-SA 4.0 ), EuroPat ( Creative Commons CC0 license )
18 ru WikiMatrix ( CC-BY-SA 4.0 ), CCMatrix

[1] WuDaoMM数据集仅用于学术研究,任何使用该数据集都应该遵循以下要求。WuDaoMM不拥有这些图片的版权。 图片的使用必须遵守 Flickr使用条款 。 图像的用户对使用数据集承担全部责任,不私自传播上面的图片。 如果图片的版权受到侵犯,请联系我们,我们将立即删除。

[1] WuDaoMMdataset is only used for academic research, any use of this dataset should follow the following requirements. WuDaoMM does not own the copyright of these pictures. Use of images is subject to the Flickr term of use . Users of the images take full responsibility for using the dataset and do not distribute the above images privately. If the copyright of the image is violated, please contact us and it will be removed immediately.

阶段1使用平行语料库数据。

阶段2和3主要使用Laion-Aesthetics的一个子集。中文数据集采用wudaoMM数据集(CC-BY-SA 4.0)。

Stage 1 uses parallel corpus data.

Stage2&3 mainly use a subset of Laion-Aesthetics. The wudaoMM data set (CC-BY-SA 4.0) is used as a Chinese data set.

引用 Citation

关于AltCLIP,我们已经推出了相关报告,有更多细节可以查阅,如对您的工作有帮助,欢迎引用。

If you find this work helpful, please consider to cite

@article{https://doi.org/10.48550/arxiv.2211.06679,
  doi = {10.48550/ARXIV.2211.06679},
  url = {https://arxiv.org/abs/2211.06679},
  author = {Chen, Zhongzhi and Liu, Guang and Zhang, Bo-Wen and Ye, Fulong and Yang, Qinghong and Wu, Ledell},
  keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences},
  title = {AltCLIP: Altering the Language Encoder in CLIP for Extended Language Capabilities},
  publisher = {arXiv},
  year = {2022},
  copyright = {arXiv.org perpetual, non-exclusive license}
}
AltCLIP-m18评测 AltCLIP-m18 evaluation

部分数据集评测结果展示:

Partial dataset evaluation results are displayed:

ImageNet
ImageNet-adv ImageNet-adv-cn ImageNet-adv-es ImageNet-adv-fr ImageNet-adv-it ImageNet-adv-jp ImageNet-adv-ko ImageNet-adv-ru ImageNet-ren ImageNet-ren-cn imageNet-ren-es ImageNet-ren-fr ImageNet-ren-it ImageNet-ren-jp ImageNet-ren-ko ImageNet-ren-ru ImageNet-ske ImageNet-ske-cn ImageNet-ske-es ImageNet-ske-fr ImageNet-ske-it ImageNet-ske-jp ImageNet-ske-ko ImageNet-ske-ru ImageNet-1k ImageNet-1k-cn ImageNet-1k-es ImageNet-1k-fr ImageNet-1k-it ImageNet-1k-jp ImageNet-1k-ko ImageNet-1k-ru ImageNet-v2 ImageNet-v2-cn ImageNet-v2-es ImageNet-v2-fr ImageNet-v2-it ImageNet-v2-jp ImageNet-v2-ko ImageNet-v2-ru
AltCLIP-M18 58 50.35 43.56 44.07 48.25 36.48 38.48 40.57 89.53 81.36 71.78 74.96 76.44 67.68 69.27 75.53 65.42 51.26 97.44 84.83 30.52 68.62 67.46 54.4 76.71 57.12 54.22 54.84 52.29 51.71 53.65 51.53 65.45 51.76 48.91 49.24 47.27 46.76 48.1 46.53
其他分类 Other classification
caltech101 cars cifar10 cifar100 country211 dtd eurosat fer2013 Fgvc-aircraft flowers food101 gtsrb Hateful-memes Kitti-distance Mnist pcam pets Renderedsst2 Resisc45 Voc2007
AltCLIP-M18 88.25 92.75 97.44 84.83 30.52 68.62 67.46 54.4 40.41 71.64 92.49 56.35 50.8 14.91 78.46 54.76 94.11 65.95 70.83 81.62
检索 Retrieval
Multi30k-de-I2T Multi30k-de-T2I Multi30k-en-I2T Multi30k-en-T2I Multi30k-fr-I2T Multi30k-fr-I2T Xtd-de-I2T Xtd-de-T2I Xtd-en-I2T Xtd-en-T2I Xtd-es-I2T Xtd-es-T2I Xtd-fr-I2T Xtd-fr-T2I Xtd- it- I2T Xtd-it- T2I Xtd-jp-I2T Xtd-jp-T2I Xtd-ko-I2T Xtd-ko-T2I Xtd-pl-I2T Xtd-pl-T2I Xtd-ru-I2T Xtd-ru-T2I Xtd-tr-I2T Xtd-tr-T2I Xtd-zh-I2T Xtd-zh-T2I
AltCLIP-M18 84.4 65.82 91.1 77.76 74.5 75.4 64.76 66.57 72.17 72.67 65.83 65.03 67.17 67.47 66.63 66.03 58.96 62.96 61.42 64.43 67.23 69.14 60.22 61.02 65.03 64.23 64.53 65.43
Cifar10 dataset evaluation code
# Copyright © 2022 BAAI. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License")
import torch
from flagai.auto_model.auto_loader import AutoLoader
import zeroshot_classification
import json 
import os 
from torchvision.datasets import CIFAR10

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
maxlen = 256

dataset_root = "./clip_benchmark_datasets/"
dataset_name = "cifar10"

auto_loader = AutoLoader(
    task_name="txt_img_matching",
    model_dir="./checkpoints/",
    model_name="AltCLIP-XLMR-L-m18"   # Load the checkpoints from Modelhub(model.baai.ac.cn/models)
)

model = auto_loader.get_model()
model.to(device)
model.eval()
tokenizer = auto_loader.get_tokenizer()
transform = auto_loader.get_transform()

dataset = CIFAR10(root=os.path.join(dataset_root, dataset_name), 
                transform=transform,   
                download=True)
batch_size = 128
num_workers = 4

template = {"cifar10": [
        "a photo of a {c}.",
        "a blurry photo of a {c}.",
        "a black and white photo of a {c}.",
        "a low contrast photo of a {c}.",
        "a high contrast photo of a {c}.",
        "a bad photo of a {c}.",
        "a good photo of a {c}.",
        "a photo of a small {c}.",
        "a photo of a big {c}.",
        "a photo of the {c}.",
        "a blurry photo of the {c}.",
        "a black and white photo of the {c}.",
        "a low contrast photo of the {c}.",
        "a high contrast photo of the {c}.",
        "a bad photo of the {c}.",
        "a good photo of the {c}.",
        "a photo of the small {c}.",
        "a photo of the big {c}."
    ],
}
def evaluate():
    if dataset:
        dataloader = torch.utils.data.DataLoader(
            dataset,
            batch_size=batch_size,
            shuffle=False,
            num_workers=num_workers,
        )

        zeroshot_templates = template["cifar10"]
        classnames = dataset.classes if hasattr(dataset, "classes") else None

        metrics = zeroshot_classification.evaluate(
            model,
            dataloader,
            tokenizer,
            classnames, 
            zeroshot_templates,
            device=device,
            amp=True,
        )
       
        dump = {
            "dataset": dataset_name,
            "metrics": metrics
        }

        print(dump)
        with open("./result.txt", "w") as f:
            json.dump(dump, f)
        return metrics

if __name__ == "__main__":
    evaluate()
推理脚本 inference
import torch
from PIL import Image
from flagai.auto_model.auto_loader import AutoLoader

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

loader = AutoLoader(
    task_name="txt_img_matching",
    model_name="AltCLIP-XLMR-L-m18",   # Load the checkpoints from Modelhub(model.baai.ac.cn/models)
    model_dir="./checkpoints"
)

model = loader.get_model()
tokenizer = loader.get_tokenizer()
transform = loader.get_transform()

model.eval()
model.to(device)
tokenizer = loader.get_tokenizer()

def inference():
    image = Image.open("./dog.jpeg")
    image = transform(image)
    image = torch.tensor(image["pixel_values"]).to(device)
    tokenizer_out = tokenizer(["a rat", "a dog", "a cat"], 
                                padding=True,
                                truncation=True,
                                max_length=77,
                                return_tensors='pt')

    text = tokenizer_out["input_ids"].to(device)
    attention_mask = tokenizer_out["attention_mask"].to(device)
    with torch.no_grad():
        image_features = model.get_image_features(image)
        text_features = model.get_text_features(text, attention_mask=attention_mask)
        text_probs = (image_features @ text_features.T).softmax(dim=-1)

    print(text_probs.cpu().numpy()[0].tolist())

if __name__=="__main__":
    inference()
微调 fintuning

Cifar10 dataset

# Copyright © 2022 BAAI. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License")
import torch
from flagai.auto_model.auto_loader import AutoLoader
import os 
from flagai.trainer import Trainer
from torchvision.datasets import (
    CIFAR10
)

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

dataset_root = "./clip_benchmark_datasets"
dataset_name = "cifar10"

batch_size = 4
classes = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']

auto_loader = AutoLoader(
    task_name="txt_img_matching",
    model_dir="./checkpoints",
    model_name="AltCLIP-XLMR-L-m18"   # Load the checkpoints from Modelhub(model.baai.ac.cn/models)
)

model = auto_loader.get_model()
model.to(device)
model.eval()
tokenizer = auto_loader.get_tokenizer()
transform = auto_loader.get_transform()

trainer = Trainer(env_type="pytorch",
                pytorch_device=device,
                experiment_name="clip_finetuning",
                batch_size=4,
                lr=1e-4,
                epochs=10,
                log_interval=10)

dataset = CIFAR10(root=os.path.join(dataset_root, dataset_name), 
                transform=transform,   
                download=True)

def cifar10_collate_fn(batch):
    # image shape is (batch, 3, 224, 224)
    images = torch.tensor([b[0]["pixel_values"][0] for b in batch])
    # text_id shape is (batch, n)
    input_ids = torch.tensor([tokenizer(f"a photo of a {b[1]}",
                                padding=True,
                                truncation=True,
                                max_length=77)["input_ids"] for b in batch])    

    attention_mask = torch.tensor([tokenizer(f"a photo of a {b[1]}",
                                padding=True,
                                truncation=True,
                                max_length=77)["attention_mask"] for b in batch])

    return {
        "pixel_values": images,
        "input_ids": input_ids,
        "attention_mask": attention_mask,
    }
    
if __name__ == "__main__":
    trainer.train(model=model, train_dataset=dataset, collate_fn=cifar10_collate_fn)

Runs of BAAI AltCLIP-m18 on huggingface.co

405
Total runs
-55
24-hour runs
-87
3-day runs
-121
7-day runs
-622
30-day runs

More Information About AltCLIP-m18 huggingface.co Model

AltCLIP-m18 huggingface.co

AltCLIP-m18 huggingface.co is an AI model on huggingface.co that provides AltCLIP-m18's model effect (), which can be used instantly with this BAAI AltCLIP-m18 model. huggingface.co supports a free trial of the AltCLIP-m18 model, and also provides paid use of the AltCLIP-m18. Support call AltCLIP-m18 model through api, including Node.js, Python, http.

AltCLIP-m18 huggingface.co Url

https://huggingface.co/BAAI/AltCLIP-m18

BAAI AltCLIP-m18 online free

AltCLIP-m18 huggingface.co is an online trial and call api platform, which integrates AltCLIP-m18's modeling effects, including api services, and provides a free online trial of AltCLIP-m18, you can try AltCLIP-m18 online for free by clicking the link below.

BAAI AltCLIP-m18 online free url in huggingface.co:

https://huggingface.co/BAAI/AltCLIP-m18

AltCLIP-m18 install

AltCLIP-m18 is an open source model from GitHub that offers a free installation service, and any user can find AltCLIP-m18 on GitHub to install. At the same time, huggingface.co provides the effect of AltCLIP-m18 install, users can directly use AltCLIP-m18 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

AltCLIP-m18 install url in huggingface.co:

https://huggingface.co/BAAI/AltCLIP-m18

Url of AltCLIP-m18

AltCLIP-m18 huggingface.co Url

Provider of AltCLIP-m18 huggingface.co

BAAI
ORGANIZATIONS

Other API from BAAI

huggingface.co

Total runs: 64.3M
Run Growth: -6.6M
Growth Rate: -10.32%
Updated:February 22 2024
huggingface.co

Total runs: 37.8M
Run Growth: 3.7M
Growth Rate: 9.69%
Updated:July 03 2024
huggingface.co

Total runs: 12.8M
Run Growth: 622.5K
Growth Rate: 4.86%
Updated:February 21 2024
huggingface.co

Total runs: 10.6M
Run Growth: -274.5K
Growth Rate: -2.59%
Updated:February 21 2024
huggingface.co

Total runs: 2.2M
Run Growth: 1.7M
Growth Rate: 77.46%
Updated:April 17 2024
huggingface.co

Total runs: 795.3K
Run Growth: -726.2K
Growth Rate: -91.32%
Updated:October 12 2023
huggingface.co

Total runs: 228.9K
Run Growth: -1.3M
Growth Rate: -582.76%
Updated:December 13 2023
huggingface.co

Total runs: 59.2K
Run Growth: -116.7K
Growth Rate: -197.13%
Updated:October 12 2023
huggingface.co

Total runs: 51.4K
Run Growth: -43.1K
Growth Rate: -83.89%
Updated:October 12 2023
huggingface.co

Total runs: 46.2K
Run Growth: 22.7K
Growth Rate: 49.08%
Updated:November 14 2023
huggingface.co

Total runs: 42.7K
Run Growth: 25.1K
Growth Rate: 58.90%
Updated:October 12 2023
huggingface.co

Total runs: 37.4K
Run Growth: -24.8K
Growth Rate: -66.13%
Updated:January 15 2025
huggingface.co

Total runs: 15.9K
Run Growth: 1.3K
Growth Rate: 8.46%
Updated:April 16 2025
huggingface.co

Total runs: 11.1K
Run Growth: -15.2K
Growth Rate: -136.62%
Updated:October 12 2023
huggingface.co

Total runs: 5.5K
Run Growth: 4.9K
Growth Rate: 89.62%
Updated:April 19 2024
huggingface.co

Total runs: 4.6K
Run Growth: -9.3K
Growth Rate: -203.11%
Updated:May 20 2025
huggingface.co

Total runs: 3.4K
Run Growth: 2.4K
Growth Rate: 72.02%
Updated:September 11 2026
huggingface.co

Total runs: 1.8K
Run Growth: 1.2K
Growth Rate: 63.98%
Updated:December 31 2022
huggingface.co

Total runs: 1.7K
Run Growth: -13.5K
Growth Rate: -793.18%
Updated:January 15 2025
huggingface.co

Total runs: 1.5K
Run Growth: -791
Growth Rate: -53.92%
Updated:April 10 2026
huggingface.co

Total runs: 1.4K
Run Growth: -494
Growth Rate: -34.50%
Updated:April 10 2026
huggingface.co

Total runs: 1.2K
Run Growth: 285
Growth Rate: 22.84%
Updated:September 11 2026
huggingface.co

Total runs: 1.2K
Run Growth: 547
Growth Rate: 45.24%
Updated:October 23 2024
huggingface.co

Total runs: 1.2K
Run Growth: -283
Growth Rate: -23.98%
Updated:November 28 2024
huggingface.co

Total runs: 1.1K
Run Growth: -33
Growth Rate: -2.92%
Updated:February 07 2024
huggingface.co

Total runs: 1.0K
Run Growth: 782
Growth Rate: 75.05%
Updated:October 24 2024
huggingface.co

Total runs: 799
Run Growth: 37
Growth Rate: 4.63%
Updated:May 23 2025
huggingface.co

Total runs: 594
Run Growth: -175
Growth Rate: -29.46%
Updated:July 13 2026
huggingface.co

Total runs: 478
Run Growth: -87
Growth Rate: -18.20%
Updated:July 13 2026
huggingface.co

Total runs: 465
Run Growth: 181
Growth Rate: 38.92%
Updated:April 10 2026
huggingface.co

Total runs: 428
Run Growth: -134
Growth Rate: -31.31%
Updated:October 27 2023
huggingface.co

Total runs: 394
Run Growth: -783
Growth Rate: -198.73%
Updated:August 11 2026
huggingface.co

Total runs: 389
Run Growth: -230
Growth Rate: -59.13%
Updated:August 11 2026
huggingface.co

Total runs: 381
Run Growth: -265
Growth Rate: -69.55%
Updated:December 25 2025
huggingface.co

Total runs: 321
Run Growth: 59
Growth Rate: 18.38%
Updated:July 13 2026
huggingface.co

Total runs: 317
Run Growth: 131
Growth Rate: 41.32%
Updated:July 13 2026
huggingface.co

Total runs: 291
Run Growth: 211
Growth Rate: 72.51%
Updated:August 18 2026
huggingface.co

Total runs: 290
Run Growth: -149
Growth Rate: -51.38%
Updated:March 07 2024
huggingface.co

Total runs: 287
Run Growth: 97
Growth Rate: 33.80%
Updated:July 13 2026
huggingface.co

Total runs: 285
Run Growth: -848
Growth Rate: -297.54%
Updated:December 25 2025
huggingface.co

Total runs: 285
Run Growth: -3.8K
Growth Rate: -1338.60%
Updated:April 10 2026
huggingface.co

Total runs: 260
Run Growth: -35
Growth Rate: -13.46%
Updated:April 10 2026
huggingface.co

Total runs: 257
Run Growth: 21
Growth Rate: 8.17%
Updated:February 11 2025
huggingface.co

Total runs: 218
Run Growth: -106
Growth Rate: -48.62%
Updated:July 17 2026
huggingface.co

Total runs: 207
Run Growth: -98
Growth Rate: -47.34%
Updated:June 06 2025
huggingface.co

Total runs: 207
Run Growth: -71
Growth Rate: -34.30%
Updated:July 13 2026
huggingface.co

Total runs: 206
Run Growth: -103
Growth Rate: -50.00%
Updated:October 23 2024
huggingface.co

Total runs: 187
Run Growth: -59
Growth Rate: -31.55%
Updated:July 13 2026
huggingface.co

Total runs: 187
Run Growth: 39
Growth Rate: 20.86%
Updated:April 02 2024
huggingface.co

Total runs: 181
Run Growth: 66
Growth Rate: 36.46%
Updated:July 13 2026
huggingface.co

Total runs: 176
Run Growth: -170
Growth Rate: -96.59%
Updated:May 13 2024
huggingface.co

Total runs: 166
Run Growth: 67
Growth Rate: 40.36%
Updated:August 23 2023
huggingface.co

Total runs: 165
Run Growth: -30
Growth Rate: -18.18%
Updated:May 13 2024
huggingface.co

Total runs: 165
Run Growth: -50
Growth Rate: -30.30%
Updated:April 10 2026
huggingface.co

Total runs: 164
Run Growth: -28
Growth Rate: -17.07%
Updated:May 13 2024
huggingface.co

Total runs: 164
Run Growth: -33
Growth Rate: -20.12%
Updated:May 31 2024
huggingface.co

Total runs: 160
Run Growth: -993
Growth Rate: -620.63%
Updated:June 24 2024
huggingface.co

Total runs: 152
Run Growth: 152
Growth Rate: 100.00%
Updated:September 05 2026
huggingface.co

Total runs: 148
Run Growth: -45
Growth Rate: -30.41%
Updated:July 13 2026
huggingface.co

Total runs: 146
Run Growth: 34
Growth Rate: 23.29%
Updated:July 13 2026
huggingface.co

Total runs: 138
Run Growth: 49
Growth Rate: 35.51%
Updated:March 13 2026