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

Beichen Zhang, Pan Zhang, Xiao-wen Dong, Yuhang Zang, Jiaqi Wang

arXiv:2403.15378 · 2026-07-27 공개 · arXiv · PDF

vision-language fine-tuning image-generation clip flickr30k coco positional-embedding long-text

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.

한국어 요약

한 줄 요약

Long-CLIP은 CLIP의 텍스트 길이 제한을 풀어 248 토큰까지 처리하며, 기존 성능을 유지하거나 개선하는 플러그 앤 플레이 방식의 확장 모델이다.

핵심 기여도

핵심 아이디어

CLIP은 단문 텍스트를 기반으로 학습되어, 77 토큰 길이의 텍스트 인코더가 실제 효과적으로 작동하는 토큰 수는 20 미만이라는 연구 결과를 바탕으로, Long-CLIP은 **장문 텍스트를 처리하면서 기존 단문 처리 능력을 유지**하는 것이 핵심 목표이다. 이는 단순히 토큰 길이를 늘리는 것 이상의 문제로, 기존 CLIP의 잠재 공간을 유지하면서도 새로운 정보를 학습해야 한다는 점에서 도전적이다.

이를 위해 Long-CLIP은 두 가지 핵심 전략을 도입한다:
1. **Knowledge-Preserved Stretching (KPS)**: 기존 20개의 잘 학습된 위치 임베딩을 유지하고, 나머지 57개는 보간하여 확장.
2. **Primary Component Matching (PCM)**: 이미지에서 미세한 세부 정보와 전체적인 주요 구성 요소를 동시에 정렬하여, 단문과 장문 텍스트 모두를 효과적으로 처리.

기술적 접근법

주요 결과

의의 및 한계

Long-CLIP은 CLIP의 단점을 보완하면서도 기존 성능을 유지하거나 개선함으로써, **장문 텍스트를 처리하는 텍스트-이미지 모델의 새로운 기준**을 제시한다. 특히, 생성 모델에서 플러그 앤 플레이 방식으로 바로 적용 가능하다는 점에서 실용적 가치가 크다.

그러나, Long-CLIP은 여전히 **최대 248 토큰**의 입력 길이 제한이 있으며, **상대적 위치 임베딩(RoPE)과 같은 무제한 길이 처리 기법**은 아직 적용되지 않았다. 또한, **장문 텍스트-이미지 쌍의 데이터가 희소**하기 때문에, 더 많은 데이터를 활용하면 성능이 향상될 가능성이 있다.

실용적 활용

Long-CLIP은 **이미지 생성**(Stable Diffusion 등), **장문 텍스트 기반 이미지 검색**, **세부 설명이 필요한 텍스트-이미지 매칭** 등 다양한 시각-언어 작업에 적용 가능하다. 특히, **사용자 입력이 상세한 설명을 포함하는 웹 검색, 콘텐츠 생성, 디자인 도구** 등에서 유용하게 활용될 수 있다.