SAVRN
Search Contact SAVRN

Open-weight model · Zero-shot classification

LLM2CLIP-Openai-L-14-336

by Microsoft microsoft/LLM2CLIP-Openai-L-14-336

Weiquan Huang 1, Aoqi Wu 1, Yifan Yang 2†, Xufang Luo 2, Yuqing Yang 2, Liang Hu 1, Qi Dai 2, Xiyang Dai 2, Dongdong Chen 2, Chong Luo 2, Lili Qiu 2 In this paper, we propose LLM2CLIP, a novel approach that embraces the power of LLMs to unlock CLIP’s…

Parameters579M
Context
Weights2.3 GB
Licenseapache-2.0
AccessOpen weights
Monthly Downloads19.4k

Runs On

What it takes to serve LLM2CLIP-Openai-L-14-336 (579M parameters): the memory its weights need at each precision, and the cheapest way to rent enough data-center GPUs to hold them.

PrecisionWeightsMemory neededCheapest setupPer hourAlso fits
16-bit 1.2 GB 1.4 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00
8-bit 0.6 GB 0.7 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00
4-bit 0.3 GB 0.3 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00

Memory is the weights at that precision plus 20% for the runtime and a short context; a long context needs more. Prices are the lowest on-demand hourly rates in the SAVRN Index, read Sep 18, 2026.

Model Card

By Microsoft, published under apache-2.0, revision 92512331f393.

Weiquan Huang 1, Aoqi Wu 1, Yifan Yang 2†, Xufang Luo 2, Yuqing Yang 2, Liang Hu 1, Qi Dai 2, Xiyang Dai 2, Dongdong Chen 2, Chong Luo 2, Lili Qiu 2 In this paper, we propose LLM2CLIP, a novel approach that embraces the power of LLMs to unlock CLIP’s potential. By fine-tuning the LLM in the caption space with contrastive learning, we extract its textual capabilities into the output embeddings, significantly improving the output layer’s textual discriminability. We then design an efficient training process where the fine-tuned LLM acts as a powerful teacher for CLIP’s visual encoder. Thanks to the LLM’s presence, we can now incorporate longer and more complex captions without being…

Read Microsoft's full model card

LLM2CLIP: Extending the Capability Boundaries of CLIP through Large Language Models

Weiquan Huang1*, Aoqi Wu1*, Yifan Yang2†, Xufang Luo2, Yuqing Yang2, Liang Hu1, Qi Dai2, Xiyang Dai2, Dongdong Chen2, Chong Luo2, Lili Qiu2 1Tongji Universiy, 2Microsoft Corporation
*Equal contribution
Corresponding to: [email protected]

[ GitHub] [ Blog] [ LLM2CLIP]

In this paper, we propose LLM2CLIP, a novel approach that embraces the power of LLMs to unlock CLIP’s potential. By fine-tuning the LLM in the caption space with contrastive learning, we extract its textual capabilities into the output embeddings, significantly improving the output layer’s textual discriminability. We then design an efficient training process where the fine-tuned LLM acts as a powerful teacher for CLIP’s visual encoder. Thanks to the LLM’s presence, we can now incorporate longer and more complex captions without being restricted by vanilla CLIP text encoder’s context window and ability limitations. Our experiments demonstrate that this approach brings substantial improvements in cross-modal tasks. Our method directly boosted the performance of the previously SOTA EVA02 model by 16.5% on both long-text and short-text retrieval tasks, transforming a CLIP model trained solely on English data into a state-of-the-art cross-lingual model. Moreover, when integrated into mul- timodal training with models like Llava 1.5, it consistently outperformed CLIP across nearly all benchmarks, demonstrating comprehensive performance improvements.

LLM2CLIP performance

It's important to note that all results presented in the paper are evaluated using PyTorch weights. There may be differences in performance when using Hugging Face (hf) models.

Model Details

  • Model Type: vision foundation model, feature backbone
  • Pretrain Dataset: CC3M, CC12M, YFCC15M and Recap-DataComp-1B(30M subset)

Usage

Huggingface Version

Image Embeddings

from PIL import Image
from transformers import AutoModel
from transformers import CLIPImageProcessor
import torch

image_path = "CLIP.png"
model_name_or_path = "LLM2CLIP-Openai-L-14-336" # or /path/to/local/LLM2CLIP-Openai-L-14-336

processor = CLIPImageProcessor.from_pretrained("openai/clip-vit-large-patch14-336")
model = AutoModel.from_pretrained(
    model_name_or_path, 
    torch_dtype=torch.float16,
    trust_remote_code=True).to('cuda').eval()

image = Image.open(image_path)
input_pixels = processor(images=image, return_tensors="pt").pixel_values.to('cuda')

with torch.no_grad(), torch.cuda.amp.autocast():
    outputs = model.get_image_features(input_pixels)

Retrieval

from PIL import Image
from transformers import AutoModel, AutoConfig, AutoTokenizer
from transformers import CLIPImageProcessor
import torch
from llm2vec import LLM2Vec
import os

os.environ["CUDA_VISIBLE_DEVICES"] = "0"

processor = CLIPImageProcessor.from_pretrained("openai/clip-vit-large-patch14-336")
model_name_or_path = "microsoft/LLM2CLIP-Openai-L-14-336" # or /path/to/local/LLM2CLIP-Openai-L-14-336
model = AutoModel.from_pretrained(
    model_name_or_path, 
    torch_dtype=torch.bfloat16,
    trust_remote_code=True).to('cuda').eval()

llm_model_name = 'microsoft/LLM2CLIP-Llama-3-8B-Instruct-CC-Finetuned'
config = AutoConfig.from_pretrained(
    llm_model_name, trust_remote_code=True
)
llm_model = AutoModel.from_pretrained(llm_model_name, torch_dtype=torch.bfloat16, config=config, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(llm_model_name)
llm_model.config._name_or_path = 'meta-llama/Meta-Llama-3-8B-Instruct' #  Workaround for LLM2VEC
l2v = LLM2Vec(llm_model, tokenizer, pooling_mode="mean", max_length=512, doc_max_length=512)

captions = ["a diagram", "a dog", "a cat"]
image_path = "CLIP.png"

image = Image.open(image_path)
input_pixels = processor(images=image, return_tensors="pt").pixel_values.to('cuda')
text_features = l2v.encode(captions, convert_to_tensor=True).to('cuda')

with torch.no_grad(), torch.cuda.amp.autocast():
    image_features = model.get_image_features(input_pixels)
    text_features = model.get_text_features(text_features)

    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)

BibTeX & Citation

``` @misc{huang2024llm2clippowerfullanguagemodel, title={LLM2CLIP: Powerful Language Model Unlock Richer Visual Representation}, author={Weiquan Huang and Aoqi Wu and Yifan Yang and Xufang Luo and Yuqing Yang and Liang Hu and Qi Dai and Xiyang Dai and Dongdong Chen and Chong Luo and Lili Qiu}, year={2024}, eprint={2411.04997}, archivePrefix={arXiv}, primaryClass={cs.CV}, url={https://arxiv.org/abs/2411.04997}, }

Configuration

Architecture
LLM2CLIPModel
Stored precision
float32
Model type
clip

Identity and Version

Repository
microsoft/LLM2CLIP-Openai-L-14-336
Publisher
Microsoft
Task
Zero-shot classification
Modality
Text
Library
Not stated by the source
Parameters
579M parameters
Languages
Not stated by the source
Revision
92512331f393a003c3d98404677f991c188162c9
First published
2024-11-07
Last updated
2024-11-24

Files and Weights

8 files, 2.3 GB in total. The weights are 1 file totalling 2.3 GB in safetensors.

Weights1 file · 2.3 GB
Configuration3 files · 95.9 KB
Documentation1 file · 5.5 KB
Other2 files · 408.7 KB
Repository1 file · 1.6 KB
Every file
FileTypeSizeSHA-256
model.safetensorsWeights2.3 GB b735de584f32
config.jsonConfiguration2.7 KB
configuration_clip.pyConfiguration21.1 KB
modeling_clip.pyConfiguration72.2 KB
README.mdDocumentation5.5 KB
CLIP.pngOther252.4 KB
teaser.pngOther156.2 KB
.gitattributesRepository1.6 KB

License and Download

License
apache-2.0
Access
Open weights, no gate
Download size
2.3 GB
Download from Microsoft

Released by Microsoft through its official repository on Hugging Face. Read the license.

Built From

Memory Requirements

PrecisionWeights in memory
As published2.3 GB
16-bit1.2 GB
8-bit0.6 GB
4-bit0.3 GB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About LLM2CLIP-Openai-L-14-336

How much GPU memory does LLM2CLIP-Openai-L-14-336 need?

About 1.4 GB at 16-bit and 0.3 GB at 4-bit: the weights (579M parameters) plus a working margin. A long context needs more.

What is the cheapest GPU to run LLM2CLIP-Openai-L-14-336 on?

At 16-bit, 1x MI300X from $1.85 an hour; at 4-bit, 1x MI300X from $1.85 an hour, at the lowest on-demand prices the SAVRN Index lists.

Can I use LLM2CLIP-Openai-L-14-336 commercially?

Yes. LLM2CLIP-Openai-L-14-336 is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.

Similar Models

Models in this series are designed for efficient zeroshot classification with the Hugging Face pipeline. These models can do classification without training data and run on both GPUs and CPUs. An overview of the latest zeroshot classifiers is available in my Zeroshot Classifier Collection. The main update of this zeroshot-v2.0 series of models is that several models are trained on fully commercially-friendly data for users with strict license requirements. These models can do one universal classification task: determine whether a hypothesis is "true" or "not true" given a text (entailment vs. notentailment). This task format is based on the Natural Language Inference task (NLI). The task is…

Open weights mit 568M parameters 8,194 tokens transformers

Model · Zero-shot classification

xlm-roberta-large-xnli

Joe Davison

This model takes xlm-roberta-large and fine-tunes it on a combination of NLI data in 15 languages. It is intended to be used for zero-shot text classification, such as with the Hugging Face ZeroShotClassificationPipeline. This model is intended to be used for zero-shot text classification, especially in languages other than English. It is fine-tuned on XNLI, which is a multilingual NLI dataset. The model can therefore be used with any of the languages in the XNLI corpus: Since the base model was pre-trained trained on 100 different languages, the model has shown some effectiveness in languages beyond those listed above as well. See the full list of pre-trained languages in appendix A of the…

Open weights mit 561M parameters 514 tokens transformers

This model was fine-tuned on the MultiNLI, Fever-NLI, Adversarial-NLI (ANLI), LingNLI and WANLI datasets, which comprise 885 242 NLI hypothesis-premise pairs. This model is the best performing NLI model on the Hugging Face Hub as of 06.06.22 and can be used for zero-shot classification. It significantly outperforms all other large models on the ANLI benchmark. The foundation model is DeBERTa-v3-large from Microsoft. DeBERTa-v3 combines several recent innovations compared to classical Masked Language Models like BERT, RoBERTa etc., see the paper DeBERTa-v3-large-mnli-fever-anli-ling-wanli was trained on the MultiNLI, Fever-NLI, Adversarial-NLI (ANLI), LingNLI and WANLI datasets, which…

Open weights mit 435M parameters 512 tokens transformers

This model was trained using SentenceTransformers Cross-Encoder class. This model is based on microsoft/deberta-v3-large The model was trained on the SNLI and MultiNLI datasets. For a given sentence pair, it will output three scores corresponding to the labels: contradiction, entailment, neutral. For futher evaluation results, see SBERT.net - Pretrained Cross-Encoder. Pre-trained models can be used like this: You can use the model also directly with Transformers library (without SentenceTransformers library): This model can also be used for zero-shot-classification

Open weights apache-2.0 435M parameters 512 tokens sentence-transformers

Model · Zero-shot classification

deberta-v3-large-tasksource-nli

Damien Sileo

DeBERTa-v3-large fine-tuned with multi-task learning on 600 tasks of the tasksource collection You can further fine-tune this model to use it for any classification or multiple-choice task. This checkpoint has strong zero-shot validation performance on many tasks (e.g. 77% on WNLI). The untuned model CLS embedding also has strong linear probing performance (90% on MNLI), due to the multitask training. This is the shared model with the MNLI classifier on top. Its encoder was trained on many datasets including bigbench, Anthropic rlhf, anli... alongside many NLI and classification tasks with a SequenceClassification heads while using only one shared encoder. Each task had a specific CLS…

Open weights apache-2.0 435M parameters 512 tokens transformers

Models in this series are designed for efficient zeroshot classification with the Hugging Face pipeline. These models can do classification without training data and run on both GPUs and CPUs. An overview of the latest zeroshot classifiers is available in my Zeroshot Classifier Collection. The main update of this zeroshot-v2.0 series of models is that several models are trained on fully commercially-friendly data for users with strict license requirements. These models can do one universal classification task: determine whether a hypothesis is "true" or "not true" given a text (entailment vs. notentailment). This task format is based on the Natural Language Inference task (NLI). The task is…

Open weights mit 435M parameters 512 tokens transformers