Long-CLIP: Unlocking the Long-Text Capability of CLIP

Beichen Zhang, Pan Zhang, Xiao-wen Dong, Yuhang Zang, Jiaqi Wang
2/14/2026

No official code found. Best implementation: beichenzbc/Long-CLIP (903 stars, Apache-2.0, last commit 2024-08-13).

Abstract

Contrastive Language-Image Pre-training (CLIP) has been the cornerstone for zero-shot classification, text-image retrieval, and text-image generation by aligning image and text modalities. Despite its widespread adoption, a significant limitation of CLIP lies in the inadequate length of text input. The length of the text token is restricted to 77, and an empirical study shows the actual effective length is even less than 20. This prevents CLIP from handling detailed descriptions, limiting its applications for image retrieval and text-to-image generation with extensive prerequisites. To this end, we propose Long-CLIP as a plug-and-play alternative to CLIP that supports long-text input, retains or even surpasses its zero-shot generalizability, and aligns the CLIP latent space, making it readily replace CLIP without any further adaptation in downstream frameworks. Nevertheless, achieving this goal is far from straightforward, as simplistic fine-tuning can result in a significant degradation of CLIP's performance. Moreover, substituting the text encoder with a language model supporting longer contexts necessitates pretraining with vast amounts of data, incurring significant expenses. Accordingly, Long-CLIP introduces an efficient fine-tuning solution on CLIP with two novel strategies designed to maintain the original capabilities, including (1) a knowledge-preserved stretching of positional embedding and (2) a primary component matching of CLIP features. With leveraging just one million extra long text-image pairs, Long-CLIP has shown the superiority to CLIP for about 20% in long caption text-image retrieval and 6% in traditional text-image retrieval tasks, e.g., COCO and Flickr30k. Furthermore, Long-CLIP offers enhanced capabilities for generating images from detailed text descriptions by replacing CLIP in a plug-and-play manner.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

[ECCV 2024] official code for "Long-CLIP: Unlocking the Long-Text Capability of CLIP"

90347Shell, PythonMar 20, 20242 years agoApache-2.0

Similar Papers

Cite this paper

@article{zhang2026longclip,
  title  = {Long-CLIP: Unlocking the Long-Text Capability of CLIP},
  author = {Beichen Zhang and Pan Zhang and Xiao-wen Dong and Yuhang Zang and Jiaqi Wang},
  year   = {2026},
  eprint = {2403.15378},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2403.15378},
  journal = {ECCV 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2403.15378.svg)](https://codeofpaper.com/paper/2403.15378)

Discussion